Gem-graph 0.1.0
A modelling tool based on rewriting of geometric graphs.
|
fsm (Finite State Machine) management header More...
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <gtk-4.0/gtk/gtk.h>
Classes | |
struct | fsm_struct_journal_unit |
structure of a journal element More... | |
struct | fsm_struct_journal |
required to initialise a double-chained list More... | |
struct | fsm_struct_list_tool |
phantom documentation More... | |
struct | fsm_struct_list_data |
phantom documentation More... | |
struct | fsm_struct_list_disp |
phantom documentation More... | |
Macros | |
#define | JOURNAL_LOG_MAX_LENGTH 255 |
arbitrary | |
#define | n_rules 128 |
arbitrary | |
#define | n_objects 32 |
arbitrary too, | |
#define | n_situations 128 |
and so on... | |
Typedefs | |
typedef struct fsm_struct_journal_unit | fsm_struct_journal_unit |
structure of a journal element | |
typedef struct fsm_struct_list_tool | fsm_struct_list_tool |
phantom documentation | |
typedef struct fsm_struct_list_data | fsm_struct_list_data |
phantom documentation | |
typedef struct fsm_struct_list_disp | fsm_struct_list_disp |
phantom documentation | |
Enumerations | |
enum | fsm_enum_journal_severity { FATAL , ERROR , WARN , INFO , DEBUG , TRACE } |
Conforms to canonical log levels: FATAL, ERROR, WARN, INFO, DEBUG, TRACE. More... | |
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 } |
arbitrary values that can help the logging filter work more efficiently More... | |
enum | fsm_enum_exec_edit { EXEC , EDIT } |
phantom documentation | |
enum | fsm_enum_state_rules_data { SYNTH , STATE , RULES , DATA } |
phantom documentation | |
enum | fsm_enum_store_restore_reset { STORE , RESTORE , RESET } |
phantom documentation | |
enum | fsm_enum_measure_type { DATE_RULE_EXEC , RULE_EXEC_NB , OBJECT_NB , ELAPSED_TIME } |
phantom documentation | |
Functions | |
void | fsm_journal_publish (fsm_struct_journal jj) |
publish all the logs today just print in the console TODO > in a file | |
void | fsm_journal_init (fsm_struct_journal *jj) |
init the journal | |
void | fsm_journal_push_front (fsm_struct_journal *jj, const char *file_source, const char *function_source, const char *string_value) |
add an event | |
void | fsm_journal_clear (fsm_struct_journal *jj, const char *file_source, const char *function_source, const char *string_value) |
usefulness ? (systematic ^c) | |
long | fsm_journal_pop_back (fsm_struct_journal *jj, const char *file_source, const char *function_source, const char *string_value) |
remove an event | |
int | fsm_journal_length (fsm_struct_journal jj) |
get journal_length | |
void | fsm_journal_seek (fsm_struct_journal jj, long usec, const char *file_source, const char *function_source, const char *string_value) |
seek for an event | |
void | fsm_journal_publication_request () |
The fsm_journal_publication_request() is called only once, by main(), just after closing the app and before ending the program. | |
void | fsm_journal_event (int severity, int source, const char *file_source, const char *function_source, const char *string_value) |
It is mandatory for any event to call this function to be published in the journal. | |
void | fsm_init (char *message) |
fsm init is the first function called by main.c It initiates the journal and the four lists: 'measures', 'results', 'displayables results' and 'preferences'. | |
void | fsm_list_init_preferences () |
void | fsm_list_init_measures () |
void | fsm_list_init_results () |
phantom documentation | |
void | fsm_list_init_displayables () |
int | fsm_get_exec_edit () |
some client pages (in particular "state" and "rules") will be displayed and behave differently depending on whether the fsm is in edit or run state. | |
int | fsm_get_state_rules_data () |
The value of the static int choice_STATE_RULES_DATA can be one of the enum include/fsm enum fsm_enum_state_rules_data. | |
void | fsm_set_exec_edit (int value) |
setter for the static value: 'choice_STATE_RULES_DATA' (in this file) | |
void | fsm_set_state_rules_data (int value) |
setter for the static value: 'choice_STATE_RULES_DATA' (in this file) | |
void | fsm_set_store_restore_reset (int choice, int value) |
bool | fsm_get_preferences_state () |
getter for the static boolean: 'preferences_have_been_modified' | |
void | fsm_set_preferences_modified (bool value) |
setter for the static boolean: 'preferences_have_been_modified' | |
void | fsm_add_measure (char *measure_name) |
void | fsm_add_result (char *result_name) |
phantom documentation | |
void | fsm_add_displayable (char *displayable_name) |
void | fsm_reset_all_situations_values (int value) |
void | fsm_tools_list_insert (fsm_struct_list_tool **tl, int value) |
phantom documentation | |
int | fsm_tools_list_pop (fsm_struct_list_tool **tl) |
phantom documentation | |
int | fsm_tools_list_length (fsm_struct_list_tool *tl) |
phantom documentation | |
void | fsm_tools_list_clear (fsm_struct_list_tool **tl) |
phantom documentation | |
void | fsm_tools_list_view (fsm_struct_list_tool *tl) |
phantom documentation | |
void | fsm_tools_list_test () |
phantom documentation | |
void | fsm_rule_trig_measure (int rule_id, int object_id, int measure_id) |
void | fsm_add_data (fsm_struct_list_data d, int *p_data, int *p_target) |
phantom documentation | |
int | fsm_get_data (fsm_struct_list_data d, int from, int to) |
phantom documentation | |
void | fsm_remove_data (fsm_struct_list_data d, int *p_data) |
phantom documentation | |
fsm (Finite State Machine) management header
This file is part of Gem-graph.
typedef struct fsm_struct_journal_unit fsm_struct_journal_unit |
structure of a journal element
Conforms to canonical log levels: FATAL, ERROR, WARN, INFO, DEBUG, TRACE.
* * * - 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:
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
https://betterstack.com/community/guides/logging/logging-best-practices/ https://en.wikipedia.org/wiki/Syslog
arbitrary values that can help the logging filter work more efficiently
void fsm_add_data | ( | fsm_struct_list_data | d, |
int * | p_data, | ||
int * | p_target | ||
) |
phantom documentation
d | |
*p_data | |
*p_target |
void fsm_add_displayable | ( | char * | displayable_name | ) |
displayable_name |
void fsm_add_measure | ( | char * | measure_name | ) |
*measure_name |
int fsm_get_data | ( | fsm_struct_list_data | d, |
int | from, | ||
int | to | ||
) |
phantom documentation
d | |
from | |
to |
int fsm_get_exec_edit | ( | ) |
some client pages (in particular "state" and "rules") will be displayed and behave differently depending on whether the fsm is in edit or run state.
Any function which modifies the appearance or behavior of these pages must use this getter to access the choice_EXEC_EDIT value.
see include/fsm enum fsm_enum_exec_edit { EXEC, EDIT } The current int may be replaced by a boolean . TODO
bool fsm_get_preferences_state | ( | ) |
getter for the static boolean: 'preferences_have_been_modified'
int fsm_get_state_rules_data | ( | ) |
The value of the static int choice_STATE_RULES_DATA can be one of the enum include/fsm enum fsm_enum_state_rules_data.
To each value is associated a different page and different possible behaviors. Any function that modifies the client window must get this value.
see include/fsm enum fsm_enum_state_rules_data { SYNTH, STATE, RULES, DATA }
void fsm_init | ( | char * | initial_message_from_main | ) |
fsm init is the first function called by main.c It initiates the journal and the four lists: 'measures', 'results', 'displayables results' and 'preferences'.
The items selected in these lists define the current state of the fsm.
*initial_message_from_main |
void fsm_journal_clear | ( | fsm_struct_journal * | jj, |
const char * | file_source, | ||
const char * | function_source, | ||
const char * | string_value | ||
) |
usefulness ? (systematic ^c)
*jj | |
*file_source | |
*function_source | |
*string_value |
void fsm_journal_event | ( | int | severity, |
int | source, | ||
const char * | file_source, | ||
const char * | function_source, | ||
const char * | string_value | ||
) |
It is mandatory for any event to call this function to be published in the journal.
Before publication, a filter can be applied here (and only here) to select only some events of interest (during debugging, for example).
If there are too many events, a filter can be applied here to select a few interesting events for publication in the log.
This filter can operate on any the following five parameters: severity, source, *file_source, *function_source, *string_value.
Simple filters (on a single parameter) can be combined using the logical operators 'and' and 'or' and parentheses.
Use: $ grep -r "fsm_journal_event" to confirm the callergraph calls.
severity | <> |
source | <> |
*file_source | <> the name of the file that emits the event. |
*function_source | <> the function that emits the event. |
*string_value | <> any value that can qualify the event and provides useful information when reading the log. |
void fsm_journal_init | ( | fsm_struct_journal * | jj | ) |
init the journal
*jj |
int fsm_journal_length | ( | fsm_struct_journal | jj | ) |
get journal_length
*jj |
long fsm_journal_pop_back | ( | fsm_struct_journal * | jj, |
const char * | file_source, | ||
const char * | function_source, | ||
const char * | string_value | ||
) |
remove an event
*jj | |
*file_source | |
*function_source | |
*string_value |
void fsm_journal_publication_request | ( | ) |
The fsm_journal_publication_request() is called only once, by main(), just after closing the app and before ending the program.
This is to guarantee the chronological order of the events in the journal.
The log is modified for each event but events can be send asynchronously. This is why the journal is only published once, before the end of "main()", Its chronological order is therefore guaranteed.
src/journal.c/fsm_journal_publish() (called here) is the last function of the program to be executed.
The fsm_struct_journal (gg_logs) is a static instance in this file. Therefore, all the functions that read or write it are in this file. This is to avoid uncontrolled operations on it.
void fsm_journal_publish | ( | fsm_struct_journal | jj | ) |
publish all the logs today just print in the console TODO > in a file
*jj |
void fsm_journal_push_front | ( | fsm_struct_journal * | jj, |
const char * | file_source, | ||
const char * | function_source, | ||
const char * | string_value | ||
) |
add an event
*jj | |
*file_source | |
*function_source | |
*string_value |
void fsm_journal_seek | ( | fsm_struct_journal | jj, |
long | usec, | ||
const char * | file_source, | ||
const char * | function_source, | ||
const char * | string_value | ||
) |
seek for an event
*jj | |
usec | |
*file_source | |
*function_source | |
*string_value |
void fsm_list_init_displayables | ( | ) |
void fsm_list_init_measures | ( | ) |
void fsm_list_init_preferences | ( | ) |
void fsm_remove_data | ( | fsm_struct_list_data | d, |
int * | p_data | ||
) |
phantom documentation
d | |
*p_data |
void fsm_reset_all_situations_values | ( | int | value | ) |
value |
void fsm_rule_trig_measure | ( | int | rule_id, |
int | object_id, | ||
int | measure_id | ||
) |
rule_id | |
object_id | |
measure_id |
void fsm_set_exec_edit | ( | int | choice | ) |
setter for the static value: 'choice_STATE_RULES_DATA' (in this file)
see include/fsm enum fsm_enum_exec_edit { EXEC, EDIT }
choice | < a boolean value which can be "EXEC" or "EDIT" |
void fsm_set_preferences_modified | ( | bool | value | ) |
setter for the static boolean: 'preferences_have_been_modified'
value | = TRUE if preferences_have_been_modified. |
void fsm_set_state_rules_data | ( | int | choice | ) |
setter for the static value: 'choice_STATE_RULES_DATA' (in this file)
see include/fsm enum fsm_enum_state_rules_data { SYNTH, STATE, RULES, DATA } Today (2024-10) the initial page is set to 'SYNTH'.
choice |
void fsm_set_store_restore_reset | ( | int | choice, |
int | value | ||
) |
choice | |
value |