2024-09-10 12:58:18 +02:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Gem-graph client *
|
|
|
|
* Finite state machine header *
|
2024-07-08 22:05:15 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
|
|
|
|
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
|
2024-07-08 22:05:15 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* This file is part of Gem-graph. *
|
2024-07-08 22:05:15 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU Affero General Public License *
|
|
|
|
* as publishedby the Free Software Foundation, *
|
|
|
|
* either version 3 of the License, or (at your option) any later version. *
|
2024-07-08 22:05:15 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* 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. *
|
2024-07-08 22:05:15 +02:00
|
|
|
* *
|
2024-09-10 12:58:18 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
2024-07-08 22:05:15 +02:00
|
|
|
|
|
|
|
|
2024-07-18 23:51:04 +02:00
|
|
|
#pragma once
|
2024-07-25 05:55:15 +02:00
|
|
|
#include <stdbool.h>
|
2024-08-19 22:53:47 +02:00
|
|
|
#include <stddef.h>
|
2024-08-20 09:50:20 +02:00
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
2024-07-08 22:05:15 +02:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* S T A T E M A C H I N E */
|
|
|
|
/******************************************************************************/
|
2024-07-22 18:02:14 +02:00
|
|
|
// called by widgets through signal functions
|
2024-07-08 22:05:15 +02:00
|
|
|
|
2024-08-26 22:11:51 +02:00
|
|
|
enum fsm_select_EXEC_EDIT { EXEC, EDIT };
|
|
|
|
enum fsm_select_STATE_RULES_DATA { SYNTH, STATE, RULES, DATA };
|
|
|
|
enum fsm_select_STORE_RESTORE_RESET { STORE, RESTORE, RESET };
|
2024-07-08 22:05:15 +02:00
|
|
|
|
2024-08-26 22:11:51 +02:00
|
|
|
enum fsm_measure_type {DATE_RULE_EXEC, RULE_EXEC_NB, OBJECT_NB, ELAPSED_TIME };
|
|
|
|
|
2024-07-29 15:15:08 +02:00
|
|
|
#define n_rules 128 // arbitrary
|
2024-07-29 05:46:10 +02:00
|
|
|
#define n_objects 32 // arbitrary too,
|
|
|
|
#define n_situations 128 // and so on...
|
2024-07-24 23:07:14 +02:00
|
|
|
|
2024-08-28 16:52:16 +02:00
|
|
|
typedef struct tool_list {int value; struct tool_list *suiv;} tool_list ;
|
2024-08-30 15:14:01 +02:00
|
|
|
typedef struct data_list {int value; struct data_list *suiv;} data_list ;
|
2024-08-28 16:52:16 +02:00
|
|
|
typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ;
|
2024-09-10 22:37:31 +02:00
|
|
|
|
2024-09-11 09:05:10 +02:00
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
|
|
void fsm_get_time();
|
2024-09-10 22:37:31 +02:00
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
|
|
typedef struct unit {int event; struct unit *prev; struct unit *next;} unit;
|
|
|
|
typedef struct {unit *first; unit *last;} journal; // structure d'accès au journal
|
|
|
|
|
2024-09-11 08:13:00 +02:00
|
|
|
void fsm_journal_init (journal *jj); // initialise
|
|
|
|
void fsm_journal_clear (journal *jj); // vide tout le journal
|
|
|
|
int fsm_journal_push_back (journal *jj, int event); // ajoute un évènement en fin de journal
|
|
|
|
int fsm_journal_push_front (journal *jj, int event); // ajoute un évènement en début de journal
|
|
|
|
int fsm_journal_pop_back (journal *jj); // retire un évènement en fin de journal
|
|
|
|
int fsm_journal_pop_front (journal *jj); // retire un évènement en début de journal
|
|
|
|
int fsm_journal_length (journal jj); // nombre d'évènements dans le journal
|
|
|
|
void fsm_journal_seek (journal jj, int event); // recherche un évènement dans le journal
|
|
|
|
void fsm_journal_view (journal jj); // affiche tout le journal
|
2024-09-10 22:37:31 +02:00
|
|
|
void fsm_journal_test();
|
|
|
|
// --------------------------------------------------------------- WIP ------
|
2024-08-31 16:07:19 +02:00
|
|
|
// ref: sudo cat /var/log/messages
|
2024-09-10 22:37:31 +02:00
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
|
|
|
|
|
|
|
2024-08-28 06:19:06 +02:00
|
|
|
|
2024-09-02 18:50:47 +02:00
|
|
|
void fsm_init(); // def: fsm/dispatch; call: main;
|
|
|
|
void fsm_engine_init(); // def: fsm/engine/engine; call main
|
2024-08-23 23:30:39 +02:00
|
|
|
void fsm_preferences_init(); // def: fsm/prefer; call: fsm/dispatch;
|
2024-08-28 06:19:06 +02:00
|
|
|
void fsm_measures_list_init(); // def: fsm/measure/manage.c; call: fsm/dispatch;
|
2024-08-21 23:19:27 +02:00
|
|
|
void fsm_results_list_init(); // def: fsm/results; call: fsm/dispatch;
|
|
|
|
void fsm_displayable_list_init(); // def: fsm/prefer; call: fsm/dispatch;
|
2024-07-24 23:07:14 +02:00
|
|
|
|
2024-08-21 23:19:27 +02:00
|
|
|
int fsm_get_exec_edit(); // def: fsm/dispatch; call: signal;
|
|
|
|
// widget/state/dispatch;
|
|
|
|
// widget/rules/selected/dispatch;
|
|
|
|
int fsm_get_state_rules_data(); // def: fsm/dispatch; call: signal;
|
2024-07-24 23:07:14 +02:00
|
|
|
|
2024-08-21 23:19:27 +02:00
|
|
|
void fsm_set_exec_edit (int value);// def: fsm/dispatch; call: signal;
|
|
|
|
void fsm_set_state_rules_data (int value); // def: fsm/dispatch; call: signal;
|
2024-07-19 00:17:19 +02:00
|
|
|
|
2024-08-21 23:19:27 +02:00
|
|
|
void fsm_store_restore_reset (int choice, int value);// def: prefer; call: signal;
|
2024-07-20 19:04:08 +02:00
|
|
|
|
2024-08-21 23:19:27 +02:00
|
|
|
bool fsm_get_preferences_state(); // def: fsm/dispatch; call: - - -
|
|
|
|
void fsm_set_preferences_state (bool value); // def: fsm/dispatch; call: signal;
|
|
|
|
// fsm/prefer;
|
2024-07-27 12:34:32 +02:00
|
|
|
|
2024-08-27 15:07:16 +02:00
|
|
|
void fsm_add_measure (char *measure_name); // def: fsm/measure/manage.c;
|
|
|
|
// call: widget/measure/dispatch;
|
2024-08-21 23:19:27 +02:00
|
|
|
void fsm_add_result (char *result_name); // def: fsm/result; call: - - -
|
|
|
|
void fsm_add_displayable (char *displayable_name);// def: fsm/prefer; call: fsm/prefer;
|
2024-08-20 09:32:20 +02:00
|
|
|
|
|
|
|
void fsm_reset_all_situations_transparencies_at_value (int value); // provisoire...
|
2024-08-21 23:19:27 +02:00
|
|
|
// def: fsm/prefer; call: signal;
|
2024-08-20 09:32:20 +02:00
|
|
|
|
|
|
|
|
2024-08-29 08:21:22 +02:00
|
|
|
void fsm_msg (int choice, int value, char *string, int sub_automaton);
|
2024-08-21 23:19:27 +02:00
|
|
|
// def: fsm/dispatch; call: fsm/dispatch;
|
|
|
|
// fsm/measure;
|
|
|
|
// fsm/result;
|
2024-08-23 23:30:39 +02:00
|
|
|
|
2024-08-29 08:21:22 +02:00
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
|
|
// def: measure/tool_list call: measure/tool_list (about the following functions...)
|
2024-08-30 15:14:01 +02:00
|
|
|
void fsm_tools_list_insert (tool_list **tl, int value);
|
|
|
|
int fsm_tools_list_pop (tool_list **tl);
|
|
|
|
int fsm_tools_list_length (tool_list *tl);
|
|
|
|
void fsm_tools_list_clear (tool_list **tl);
|
|
|
|
void fsm_tools_list_view (tool_list *tl);
|
|
|
|
void fsm_tools_list_test(); // def: measure/manage; call: measure/manage;
|
2024-08-29 08:21:22 +02:00
|
|
|
|
|
|
|
// def: fsm/measure/manage/; call: rule exec
|
|
|
|
void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id);
|
|
|
|
|
|
|
|
|
2024-08-30 15:14:01 +02:00
|
|
|
// --------------------------------------------------------------- WIP ------
|
2024-08-31 09:12:59 +02:00
|
|
|
void fsm_add_data (data_list d, int *p_data, int *p_target);
|
|
|
|
int fsm_get_data (data_list d, int from, int to);
|
|
|
|
void fsm_remove_data (data_list d, int *p_data);
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
|
|
void fsm_disp_add_chart (disp_list d, int *p_chart);
|
|
|
|
int fsm_disp_get_chart (disp_list d, int from, int to);
|
|
|
|
void fsm_disp_remove_chart (disp_list d, int *p_chart);
|
|
|
|
|