include/fsm.h File Reference include/fsm.h FSM (Finite State Machine) header. #include <stdbool.h>#include <stddef.h>#include <string.h>#include <gtk-4.0/gtk/gtk.h>Include dependency graph for fsm.h: This graph shows which files directly or indirectly include this file: Classes struct fsm_log_struct_unit structure of a log element struct fsm_log_struct required to initialise a double-chained list struct fsm_struct_list_tool phantom documentation struct fsm_struct_list_data phantom documentation struct fsm_struct_list_disp phantom documentation Macros #define 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_log_struct_unit fsm_log_struct_unit structure of a log 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_log_severity { FATAL , ERROR , WARN , INFO , DEBUG , TRACE } Conforms to canonical log levels: FATAL, ERROR, WARN, INFO, DEBUG, TRACE. enum fsm_enum_log_source { SOURCE , TARGET , LOG , FSM , PREFER , MAIN , APP , WIDGETS , SIGNAL , WINDOW , DIALOG_WINDOW , MODAL_WINDOW , TEXT_WINDOW , AUTO_NOTIFICATION , TOPBAR , TOPBAR_LEFT , TOPBAR_CENTER , TOPBAR_RIGHT , PAGE , SYNTH_PAGE , STATE_PAGE , RULES_PAGE , MEASURES_PAGE , RESULTS_PAGE , SYNTH_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 , ON_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 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_publish_log (fsm_log_struct jj) publish all the logs today just print in the console TODO > in a file void fsm_init_log (fsm_log_struct *jj) init the journal void fsm_add_log_event (fsm_log_struct *jj, const char *file_source, const char *function_source, const char *string_value) add an event void fsm_clear_log (fsm_log_struct *jj, const char *file_source, const char *function_source, const char *string_value) usefulness ? (systematic ^c) long fsm_pop_back_log (fsm_log_struct *jj, const char *file_source, const char *function_source, const char *string_value) remove an event int fsm_get_log_length (fsm_log_struct jj) get journal_length void fsm_seek_log (fsm_log_struct jj, long usec, const char *file_source, const char *function_source, const char *string_value) seek for an event void fsm_log_publication_request () This request is called only once, by main(), just after closing the app and before ending the program. void fsm_add_log (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 () 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) 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) int fsm_tools_list_pop (fsm_struct_list_tool **tl) int fsm_tools_list_length (fsm_struct_list_tool *tl) void fsm_tools_list_clear (fsm_struct_list_tool **tl) void fsm_tools_list_view (fsm_struct_list_tool *tl) void fsm_tools_list_test () 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
Detailed Description FSM (Finite State Machine) header. This file is part of Gem-graph.
Typedef Documentation
fsm_log_struct_unit fsm_log_struct_unitfsm.h fsm.hfsm_log_struct_unit typedef struct fsm_log_struct_unit fsm_log_struct_unit structure of a log element See also fsm_add_log() fsm_add_log_event()
Enumeration Type Documentation
fsm_enum_log_severity fsm_enum_log_severityfsm.h fsm.hfsm_enum_log_severity enum fsm_enum_log_severity 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 log structure: date rank file function value, parameter, description, context,... (any value that can qualify the event and provides useful information when reading the log) Un seul fsm_add_log() par fonction ? sauf si cette fonction génère plusieurs autres fonctions d'intérêt ? S'il y a deux fsm_add_log() (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 See also fsm_add_log())
Enumerator FATALfsm.h fsm.hFATAL FATAL (or CRITICAL) an unrecoverable failure that prevents the whole application from doing any further useful work ERRORfsm.h fsm.hERROR ERROR a condition that hinders the execution of a specific operation within an application and is unrecoverable WARNfsm.h fsm.hWARN WARN something unexpected has occurred, but the application can continue to function normally for the time being INFOfsm.h fsm.hINFO INFO (or MESSAGE) a significant event occurs while the system is operating normally DEBUGfsm.h fsm.hDEBUG DEBUG a description of system states in sufficient detail to give developers clues as to the cause of an error TRACEfsm.h fsm.hTRACE TRACE provides a systematic overview of code execution but comes at a cost in terms of performance
fsm_enum_log_source fsm_enum_log_sourcefsm.h fsm.hfsm_enum_log_source enum fsm_enum_log_source arbitrary values that can help the logging filter work more efficiently See also fsm_add_log()) Enumerator SOURCEfsm.h fsm.hSOURCE SOURCE must each element of this enumeration be commented (enhanced) ? TARGETfsm.h fsm.hTARGET TARGET let's observe first how the enumeration structures and evolves on usage WINDOWfsm.h fsm.hWINDOW WINDOW MAIN_WINDOW || DIALOG_WINDOW || MODAL_WINDOW || TEXT_WINDOW TOPBARfsm.h fsm.hTOPBAR TOPBAR LEFT || CENTER || RIGHT. PAGEfsm.h fsm.hPAGE PAGE SYNTH_PAGE || STATE_PAGE || RULES_PAGE || MEASURES_PAGE || RESULTS_PAGE RULES_PAGE == USER TREE versus SELECTED (vertical separation)
Function Documentation
fsm_add_data() fsm_add_datafsm.h fsm.hfsm_add_data void fsm_add_data (fsm_struct_list_data d, int * p_data, int * p_target) phantom documentation Parameters d *p_data *p_target
fsm_add_displayable() fsm_add_displayablefsm.h fsm.hfsm_add_displayable void fsm_add_displayable (char * displayable_name) Date Author See also Parameters displayable_name
Here is the call graph for this function:
fsm_add_log() fsm_add_logfsm.h fsm.hfsm_add_log void fsm_add_log (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. See also below (params) Simple filters (on a single parameter) can be combined using the logical operators 'and' and 'or' and parentheses. Use: $ grep -r "fsm_add_log" to confirm the callergraph calls. Since 2024-08 See also src/journal.c/fsm_journal_push_front() src/main/main() src/widget/topbar/modal.c src/widget/topbar/right.c src/widget/topbar/dialog.c src/widget/topbar/left.c src/widget/topbar/dispatch.c * 3 src/widget/one_rule/dispatch.c src/widget/one_rule/algebra/conditions.c * 2 src/widget/measure/dispatch.c src/widget/dispatch.c * 3 src/widget/all_rules/dispatch.c src/fsm/preferences/manager.c * 8 src/fsm/measures/manager.c * 2 src/fsm/measures/tools_list.c * 4 src/fsm/dispatch.c * 10 src/fsm/results/manager.c src/util/tree.c src/signal.c * 38 Parameters severity <>
See also enum fsm_enum_journal_severity in include/fsm.h 'severity' is a pre-defined value that must be associated to each event. It ranges from zero to six : CRITICAL ERROR WARNING INFO INFO DEBUG TRACE 0 1 2 3 4 5 6 Parameters source <>
See also enum fsm_enum_journal_source in include/fsm.h 'source' is a pre-defined value that can be associated to each event. It is not mandatory. It can be set to 'NULL'. Parameters *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.
Here is the call graph for this function: Here is the caller graph for this function:
fsm_add_log_event() fsm_add_log_eventfsm.h fsm.hfsm_add_log_event void fsm_add_log_event (fsm_log_struct * jj, const char * file_source, const char * function_source, const char * string_value) add an event Since 2024-09 Parameters *jj *file_source *function_source *string_value
Here is the caller graph for this function:
fsm_add_measure() fsm_add_measurefsm.h fsm.hfsm_add_measure void fsm_add_measure (char * measure_name) Since 2024-09 See also src/widget/measure/dispatch/widget_measure_event_occurences_nb() src/widget/measure/dispatch/widget_measure_event_occurences_dates() src/widget/measure/dispatch/widget_measure_event_occurences_situations() src/widget/measure/dispatch/widget_measure_time_elapsed_between_two_events() src/widget/measure/dispatch/widget_measure_third_event_occurences_in_between() src/fsm/dispatch/fsm_add_log() Parameters *measure_name
Here is the call graph for this function: Here is the caller graph for this function:
fsm_add_result() fsm_add_resultfsm.h fsm.hfsm_add_result void fsm_add_result (char * result_name) See also util_concat() fsm_init() Here is the call graph for this function: Here is the caller graph for this function:
fsm_clear_log() fsm_clear_logfsm.h fsm.hfsm_clear_log void fsm_clear_log (fsm_log_struct * jj, const char * file_source, const char * function_source, const char * string_value) usefulness ? (systematic ^c) Since 2024-09 Parameters *jj *file_source *function_source *string_value
fsm_get_data() fsm_get_datafsm.h fsm.hfsm_get_data int fsm_get_data (fsm_struct_list_data d, int from, int to) phantom documentation Parameters d from to
fsm_get_exec_edit() fsm_get_exec_editfsm.h fsm.hfsm_get_exec_edit 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 Since 2024-06 See also src/widget/one_rule/dispatch src/widget/state/dispatch * 2 src/signal choice_EXEC_EDIT and include/fsm/enum fsm_enum_exec_edit {} Returns choice_EXEC_EDIT Here is the caller graph for this function:
fsm_get_log_length() fsm_get_log_lengthfsm.h fsm.hfsm_get_log_length int fsm_get_log_length (fsm_log_struct jj) get journal_length Since 2024-09 Parameters *jj
Returns journal length
fsm_get_preferences_state() fsm_get_preferences_statefsm.h fsm.hfsm_get_preferences_state bool fsm_get_preferences_state ( ) getter for the static boolean: 'preferences_have_been_modified' Since 2024-08 See also TODO A function must obtain this boolean when it stores the current state of the fsm (including preferences) before closing the current session. Returns preferences_have_been_modified
fsm_get_state_rules_data() fsm_get_state_rules_datafsm.h fsm.hfsm_get_state_rules_data 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 } Since 2024-06 See also src/widget/topbar/left src/signal Returns choice_STATE_RULES_DATA Here is the caller graph for this function:
fsm_init() fsm_initfsm.h fsm.hfsm_init void fsm_init (char * initial_INFO_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. Since 2024-08 See also src/main/main() src/journal/fsm_init_log() src/fsm/dispatch/fsm_add_log() src/fsm/measures/manager/fsm_list_init_measures() src/fsm/results/manager/fsm_list_init_results() src/fsm/preferences/manager/fsm_list_init_displayables() src/fsm/preferences/manager/fsm_list_init_preferences() Parameters *initial_INFO_from_main
Here is the call graph for this function: Here is the caller graph for this function:
fsm_init_log() fsm_init_logfsm.h fsm.hfsm_init_log void fsm_init_log (fsm_log_struct * jj) init the journal Since 2024-09 Parameters *jj
Here is the caller graph for this function:
fsm_list_init_displayables() fsm_list_init_displayablesfsm.h fsm.hfsm_list_init_displayables void fsm_list_init_displayables ( ) Date Author See also Here is the call graph for this function: Here is the caller graph for this function:
fsm_list_init_measures() fsm_list_init_measuresfsm.h fsm.hfsm_list_init_measures void fsm_list_init_measures ( ) Since 2024-09 See also src/fsm/dispatch/fsm_init() Here is the call graph for this function: Here is the caller graph for this function:
fsm_list_init_preferences() fsm_list_init_preferencesfsm.h fsm.hfsm_list_init_preferences void fsm_list_init_preferences ( ) Date Author See also Here is the call graph for this function: Here is the caller graph for this function:
fsm_list_init_results() fsm_list_init_resultsfsm.h fsm.hfsm_list_init_results void fsm_list_init_results ( ) See also fsm_init() fsm_add_result() fsm_add_log() Here is the call graph for this function: Here is the caller graph for this function:
fsm_log_publication_request() fsm_log_publication_requestfsm.h fsm.hfsm_log_publication_request void fsm_log_publication_request ( ) This 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. 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_publish_log() (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. Since 2024-08 See also main() fsm_publish_log() Here is the call graph for this function: Here is the caller graph for this function:
fsm_pop_back_log() fsm_pop_back_logfsm.h fsm.hfsm_pop_back_log long fsm_pop_back_log (fsm_log_struct * jj, const char * file_source, const char * function_source, const char * string_value) remove an event Since 2024-09 Parameters *jj *file_source *function_source *string_value
fsm_publish_log() fsm_publish_logfsm.h fsm.hfsm_publish_log void fsm_publish_log (fsm_log_struct jj) publish all the logs today just print in the console TODO > in a file Since 2024-09 Parameters *jj
Here is the caller graph for this function:
fsm_remove_data() fsm_remove_datafsm.h fsm.hfsm_remove_data void fsm_remove_data (fsm_struct_list_data d, int * p_data) phantom documentation Parameters d *p_data
fsm_reset_all_situations_values() fsm_reset_all_situations_valuesfsm.h fsm.hfsm_reset_all_situations_values void fsm_reset_all_situations_values (int value) Date Author See also Parameters value
Here is the call graph for this function: Here is the caller graph for this function:
fsm_rule_trig_measure() fsm_rule_trig_measurefsm.h fsm.hfsm_rule_trig_measure void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id) Since 2024-09 Parameters rule_id object_id measure_id
fsm_seek_log() fsm_seek_logfsm.h fsm.hfsm_seek_log void fsm_seek_log (fsm_log_struct jj, long usec, const char * file_source, const char * function_source, const char * string_value) seek for an event Since 2024-09 Parameters *jj usec *file_source *function_source *string_value
fsm_set_exec_edit() fsm_set_exec_editfsm.h fsm.hfsm_set_exec_edit 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 } Since 2024-08 See also src/signal * 2 Parameters choice < a boolean value which can be "EXEC" or "EDIT"
Here is the call graph for this function: Here is the caller graph for this function:
fsm_set_preferences_modified() fsm_set_preferences_modifiedfsm.h fsm.hfsm_set_preferences_modified void fsm_set_preferences_modified (bool value) setter for the static boolean: 'preferences_have_been_modified' Since 2024-08 See also TODO To be used by any function that modifies the current user preferences fsm_add_log() Parameters value = TRUE if preferences_have_been_modified.
Here is the call graph for this function: Here is the caller graph for this function:
fsm_set_state_rules_data() fsm_set_state_rules_datafsm.h fsm.hfsm_set_state_rules_data 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'. See also line 292 choice_STATE_RULES_DATA = SYNTH; NB This choice can be temporarily modified for debugging purpose: end of the function: fsm/dispatch.c window_design_topbar_left() Since 2024-08 See also src/signal * 4 Parameters choice
Here is the call graph for this function: Here is the caller graph for this function:
fsm_set_store_restore_reset() fsm_set_store_restore_resetfsm.h fsm.hfsm_set_store_restore_reset void fsm_set_store_restore_reset (int choice, int value) Date Author See also Parameters choice value
Here is the call graph for this function: Here is the caller graph for this function:
fsm_tools_list_clear() fsm_tools_list_clearfsm.h fsm.hfsm_tools_list_clear void fsm_tools_list_clear (fsm_struct_list_tool ** ml) Parameters **ml
See also fsm_tools_list_test()
Here is the caller graph for this function:
fsm_tools_list_insert() fsm_tools_list_insertfsm.h fsm.hfsm_tools_list_insert void fsm_tools_list_insert (fsm_struct_list_tool ** ml, int value) Parameters **ml value
See also fsm_tools_list_test()
Here is the caller graph for this function:
fsm_tools_list_length() fsm_tools_list_lengthfsm.h fsm.hfsm_tools_list_length int fsm_tools_list_length (fsm_struct_list_tool * ml) Parameters **ml
See also fsm_tools_list_test()
Here is the caller graph for this function:
fsm_tools_list_pop() fsm_tools_list_popfsm.h fsm.hfsm_tools_list_pop int fsm_tools_list_pop (fsm_struct_list_tool ** ml) Parameters **ml
See also fsm_tools_list_test()
Here is the caller graph for this function:
fsm_tools_list_test() fsm_tools_list_testfsm.h fsm.hfsm_tools_list_test void fsm_tools_list_test ( ) See also fsm_list_init_measures()() fsm_add_log() fsm_tools_list_insert() fsm_tools_list_pop() fsm_tools_list_view() fsm_tools_list_clear() Here is the call graph for this function: Here is the caller graph for this function:
fsm_tools_list_view() fsm_tools_list_viewfsm.h fsm.hfsm_tools_list_view void fsm_tools_list_view (fsm_struct_list_tool * ml) Parameters **ml
See also fsm_tools_list_test()
Here is the call graph for this function: Here is the caller graph for this function: