2021-06-21 14:26:09 +02:00
|
|
|
//=-------------------------------------------------------------------------=//
|
|
|
|
// Model definitions //
|
|
|
|
// //
|
2021-10-13 09:44:00 +02:00
|
|
|
// Copyright © 2021 Libre en Communs (contact@a-lec.org) //
|
|
|
|
// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) //
|
2021-06-21 14:26:09 +02:00
|
|
|
// //
|
|
|
|
// This file is part of gem-graph. //
|
|
|
|
// //
|
|
|
|
// This program is free software: you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU Affero General Public License as //
|
|
|
|
// published by the Free Software Foundation, either version 3 of the //
|
|
|
|
// License, or (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU Affero General Public License for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU Affero General Public License //
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
|
|
|
//=-------------------------------------------------------------------------=//
|
|
|
|
|
2021-09-15 18:25:35 +02:00
|
|
|
#pragma once
|
2021-06-21 14:26:09 +02:00
|
|
|
#ifndef BASE_H
|
|
|
|
#include "../include/base.h"
|
|
|
|
#endif
|
|
|
|
|
2021-09-18 01:00:48 +02:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <signal.h>
|
2024-03-10 21:19:12 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2024-03-13 19:10:10 +01:00
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/xmlschemas.h>
|
2021-09-18 01:00:48 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
2021-09-18 01:00:48 +02:00
|
|
|
#define MODEL_STRING_SIZE 64
|
2021-09-17 16:14:04 +02:00
|
|
|
#define MAX_MODEL_NUMBER 1
|
|
|
|
|
|
|
|
#define ARROW_NUMBER 6
|
|
|
|
#define SITE_NUMBER 2
|
|
|
|
#define MAX_CYCLES 10
|
|
|
|
#define MAX_THREAD 0
|
|
|
|
#define XMAX 39
|
|
|
|
#define YMAX 0
|
|
|
|
#define ZMAX 0
|
|
|
|
#define SPACE_SIZE (XMAX+1) * (YMAX+1) * (ZMAX+1)
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Model init function (and model discovery) //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// void model_system_init (parameters_t *parameters);
|
2021-06-23 09:13:46 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Model stopping function //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// void model_system_shutdown (void);
|
2021-06-23 09:13:46 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Load a model ready to execute //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// int model_load (int id);
|
2021-06-23 09:13:46 +02:00
|
|
|
|
2024-03-15 22:10:10 +01:00
|
|
|
bool model_init(const char *content, size_t length, const char *basename);
|
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Unload a model //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// int model_unload (int id);
|
2021-06-23 14:16:45 +02:00
|
|
|
|
2024-03-15 22:10:10 +01:00
|
|
|
bool model_shutdown(void);
|
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Add a model to the known model list //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// void model_add_to_known (model_t **newModel);
|
2021-06-23 17:07:43 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Print informations about all models (known and loaded) to the client //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// void print_models (char *buf);
|
2021-07-07 19:46:23 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Launch a model execution //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// int model_run (int id);
|
2021-06-23 17:07:43 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Stop a model execution //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// int model_stop (int id);
|
2021-06-23 17:07:43 +02:00
|
|
|
|
2021-09-02 16:54:42 +02:00
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Stop and unload all loaded or running model //
|
|
|
|
// -------------------------------------------------------------------------- //
|
2024-03-13 19:10:10 +01:00
|
|
|
// void model_shutdown (void);
|
2024-03-15 22:10:10 +01:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
// Parsing primitives //
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
|
|
|
|
char model_get_dim(void);
|
|
|
|
|
|
|
|
long model_get_dim_value(const char *axis);
|
|
|
|
|
|
|
|
char model_get_multiplicity(void);
|
|
|
|
|
|
|
|
bool model_get_next_state(char *new_state_id);
|
|
|
|
|
|
|
|
bool model_get_next_arrow(struct arrow_t *new_arrow,
|
|
|
|
const char *state_id,
|
|
|
|
char dimension);
|