207 lines
10 KiB
C
207 lines
10 KiB
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* Gem-graph client *
|
|
* Finite state machine header *
|
|
* *
|
|
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
|
|
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
|
|
* *
|
|
* 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 publishedby 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 <http://www.gnu.org/licenses/>. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
#pragma once
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <gtk-4.0/gtk/gtk.h>
|
|
|
|
/******************************************************************************/
|
|
/* J O U R N A L */
|
|
/******************************************************************************/
|
|
|
|
/* * * * * - J O U R N A L M E T A R U L E S - * * * *
|
|
*
|
|
* ref: sudo cat /var/log/messages
|
|
*
|
|
* structure d'un log:
|
|
* - date
|
|
* - rang (n° d'ordre)
|
|
* - fichier
|
|
* - fonction
|
|
* - valeur, paramètre, descriptif, contexte,...
|
|
* (tout ce qui peut contribuer à améliorer la compréhension du journal)
|
|
*
|
|
* - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
*
|
|
* Un seul fsm_journal_event() par fonction
|
|
* ? sauf si cette fonction génère plusieurs autres fonctions d'intérêt ?
|
|
*
|
|
* S'il y a deux fsm_journal_event() (begin / end) dans une fonction,
|
|
* ils doivent avoir la même étiquette (les mêmes valeurs) : SEVERITY & SOURCE
|
|
*
|
|
* * * * * - J O U R N A L M E T A R U L E S - * * * */
|
|
|
|
|
|
enum fsm_enum_journal_severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW};
|
|
|
|
enum fsm_enum_journal_source {
|
|
SOURCE, TARGET, JOURNAL, FSM, PREFER,
|
|
MAIN, APP, WIDGETS, SIGNAL,
|
|
MAIN_WINDOW, DIALOG_WINDOW, MODAL_WINDOW, TEXT_WINDOW, AUTO_NOTIFICATION,
|
|
TOPBAR, TOPBAR_LEFT, TOPBAR_RIGHT, TOPBAR_CENTER,
|
|
SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE,
|
|
SenumYNTH_GLAREA, SYNTH_ALL_RESULTS,
|
|
SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS,
|
|
STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA,
|
|
RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA,
|
|
RULE_ALGEBRA, RULE_CONDITION, RULE_ASSIGN, RULE_ID,
|
|
RULES_TREE, RULES_COMPARE, RULES_USE,
|
|
MEASURES_TOOLS, MEASURES__ACTIVITY, MEASURES__DISPLAY,
|
|
RESULTS, TIME_DEP_RESULTS, TIME_INDEP_RESULTS,
|
|
WIDGET, BUTTON, SCROLL, GLAREA, TEXT, LABEL, TREE, SLIDER, EXPANDER, ENTRY,
|
|
SWITCH_STATE_RULES_DATA,
|
|
SLIDER_X, SLIDER_Y, SLIDER_Z,
|
|
SLIDER_A, SLIDER_B, SLIDER_C,
|
|
};
|
|
|
|
#define JOURNAL_LOG_MAX_LENGTH 255
|
|
|
|
typedef struct fsm_struct_journal_unit
|
|
{
|
|
long yy_dd_mm;
|
|
long usec;
|
|
const char *file_source;
|
|
const char *function_source;
|
|
const char *string_value;
|
|
struct fsm_struct_journal_unit *prev;
|
|
struct fsm_struct_journal_unit *next;
|
|
}
|
|
fsm_struct_journal_unit; // journal unit structure
|
|
|
|
typedef struct {
|
|
fsm_struct_journal_unit *first;
|
|
fsm_struct_journal_unit *last;
|
|
}
|
|
fsm_struct_journal; // journal unit access
|
|
|
|
void fsm_journal_publish (fsm_struct_journal jj); // def: src/journal call: fsm/dispatch
|
|
void fsm_journal_init (fsm_struct_journal *jj); // def: src/journal call: fsm/dispatch
|
|
void fsm_journal_push_front (fsm_struct_journal *jj, // def: src/journal call: fsm/dispatch
|
|
const char *file_source,
|
|
const char *function_source,
|
|
const char *string_value);
|
|
void fsm_journal_clear (fsm_struct_journal *jj, // def: src/journal call: none
|
|
const char *file_source,
|
|
const char *function_source,
|
|
const char *string_value);
|
|
long fsm_journal_pop_back (fsm_struct_journal *jj, // def: src/journal call: none
|
|
const char *file_source,
|
|
const char *function_source,
|
|
const char *string_value);
|
|
int fsm_journal_length (fsm_struct_journal jj); // def: src/journal call: none
|
|
void fsm_journal_seek (fsm_struct_journal jj, // def: src/journal call: none
|
|
long usec,
|
|
const char *file_source,
|
|
const char *function_source,
|
|
const char *string_value);
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
//
|
|
|
|
void fsm_journal_publication_request(); // def: fsm/dispatch call: main;
|
|
void fsm_journal_event (int severity,
|
|
int source,
|
|
const char *file_source,
|
|
const char *function_source,
|
|
const char *string_value);
|
|
// def: fsm/dispatch call: widget/dispatch;
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
/******************************************************************************/
|
|
/* S T A T E M A C H I N E */
|
|
/******************************************************************************/
|
|
// called by widgets through signal functions
|
|
|
|
enum fsm_enum_exec_edit { EXEC, EDIT };
|
|
enum fsm_enum_state_rules_data { SYNTH, STATE, RULES, DATA };
|
|
enum fsm_enum_store_restore_reset { STORE, RESTORE, RESET };
|
|
|
|
enum fsm_enum_measure_type {DATE_RULE_EXEC, RULE_EXEC_NB, OBJECT_NB, ELAPSED_TIME };
|
|
|
|
#define n_rules 128 // arbitrary
|
|
#define n_objects 32 // arbitrary too,
|
|
#define n_situations 128 // and so on...
|
|
|
|
typedef struct fsm_struct_list_tool {int value; struct fsm_struct_list_tool *suiv;} fsm_struct_list_tool ;
|
|
typedef struct fsm_struct_list_data {int value; struct fsm_struct_list_data *suiv;} fsm_struct_list_data ;
|
|
typedef struct fsm_struct_list_disp {int value; struct fsm_struct_list_disp *suiv;} fsm_struct_list_disp ;
|
|
|
|
|
|
|
|
void fsm_init (char *message); // def: fsm/dispatch; call: main;
|
|
void fsm_list_init_preferences(); // def: fsm/preferences/manager; call: fsm/dispatch;
|
|
void fsm_list_init_measures(); // def: fsm/measure/manager; call: fsm/dispatch;
|
|
void fsm_list_init_results(); // def: fsm/results/manager; call: fsm/dispatch;
|
|
void fsm_list_init_displayables(); // def: fsm/preferences/manager; call: fsm/dispatch;
|
|
|
|
int fsm_get_exec_edit(); // def: fsm/disfpatch; call: signal;
|
|
// widget/state/dispatch;
|
|
// widget/rules/selected/dispatch;
|
|
int fsm_get_state_rules_data(); // def: fsm/dispatch; call: signal;
|
|
|
|
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;
|
|
|
|
void fsm_set_store_restore_reset (int choice, int value);// def: prefer; call: signal;
|
|
|
|
bool fsm_get_preferences_state(); // def: fsm/dispatch; call: - - -
|
|
void fsm_set_preferences_modified (bool value); // def: fsm/dispatch;
|
|
// call: signal; fsm/prefer;
|
|
|
|
void fsm_add_measure (char *measure_name); // def: fsm/measure/manager;
|
|
// call: widget/measure/dispatch;
|
|
void fsm_add_result (char *result_name); // def: fsm/results/manager; call: - - -
|
|
void fsm_add_displayable (char *displayable_name);// def: fsm/preferences/manager; call: fsm/preferences/manager;
|
|
|
|
void fsm_reset_all_situations_values (int value); // def: fsm/preferences/manager; call: signal;
|
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
// def: measure/tool_list call: measure/tool_list (about the following functions...)
|
|
void fsm_list_tools_insert (fsm_struct_list_tool **tl, int value);
|
|
int fsm_list_tools_pop (fsm_struct_list_tool **tl);
|
|
int fsm_list_tools_length (fsm_struct_list_tool *tl);
|
|
void fsm_list_tools_clear (fsm_struct_list_tool **tl);
|
|
void fsm_list_tools_view (fsm_struct_list_tool *tl);
|
|
void fsm_list_tools_test(); // def: measures/manager; call: measures/manager;
|
|
|
|
// def: fsm/measure/manage/; call: rule exec
|
|
void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id);
|
|
|
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
void fsm_add_data (fsm_struct_list_data d, int *p_data, int *p_target);
|
|
int fsm_get_data (fsm_struct_list_data d, int from, int to);
|
|
void fsm_remove_data (fsm_struct_list_data d, int *p_data);
|
|
|
|
|
|
// --------------------------------------------------------------- WIP ------
|
|
/*void fsm_disp_add_chart (fsm_struct_list_disp d, int *p_chart);
|
|
int fsm_disp_get_chart (fsm_struct_list_disp d, int from, int to);
|
|
void fsm_disp_remove_chart (fsm_struct_list_disp d, int *p_chart);*/
|
|
|