diff --git a/include/fsm.h b/include/fsm.h index e8a699d..22416a0 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -48,7 +48,9 @@ enum fsm_measure_type {DATE_RULE_EXEC, RULE_EXEC_NB, OBJECT_NB, ELAPSED_TIME }; #define n_objects 32 // arbitrary too, #define n_situations 128 // and so on... -typedef struct measure_list {int value; struct measure_list *suiv;} measure_list ; +typedef struct tool_list {int value; struct tool_list *suiv;} tool_list ; +typedef struct flow_list {int value; struct flow_list *suiv;} flow_list ; +typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ; void fsm_init(); // def: fsm/dispatch; call: main; void fsm_preferences_init(); // def: fsm/prefer; call: fsm/dispatch; @@ -85,10 +87,10 @@ void fsm_debug_msg (int choice, int value, char *string, int sub_automaton); // fsm/result; // --------------------------------------------------------------- WIP -// def: measure/list call measure/list (following functions...) -void fsm_measures_sorted_list_insert (measure_list **sl, int value); -int fsm_measures_sorted_list_pop (measure_list **sl); -int fsm_measures_sorted_list_length (measure_list *sl); -void fsm_measures_sorted_list_clear (measure_list **sl); -void fsm_measures_sorted_list_view (measure_list *sl); -void fsm_measures_sorted_list_test(); // def: measure/manage; call measure/manage; +// def: measure/tool_list call measure/tool_list (about the following functions...) +void fsm_tools_sort_list_insert (tool_list **tl, int value); +int fsm_tools_sort_list_pop (tool_list **tl); +int fsm_tools_sort_list_length (tool_list *tl); +void fsm_tools_sort_list_clear (tool_list **tl); +void fsm_tools_sort_list_view (tool_list *tl); +void fsm_tools_sort_list_test(); // def: measure/manage; call measure/manage; diff --git a/src/fsm/measure/disp_list.c b/src/fsm/measure/disp_list.c new file mode 100644 index 0000000..fec2c1a --- /dev/null +++ b/src/fsm/measure/disp_list.c @@ -0,0 +1,44 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* State machine / Measures * +* * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * +* * +* 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 . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include +#include +#include +#include "../../../include/fsm.h" + + +/******************************************************************************/ +/* An editable list of displayed results is defined and maintained here */ +/* (see : fsm/measure/manage.c) */ +/* - - - */ +/* NB some data may be displayed simultaneously in different pages */ +/* ex : pages SYNTH & RESULTS */ +/******************************************************************************/ + + diff --git a/src/fsm/measure/flow_list.c b/src/fsm/measure/flow_list.c new file mode 100644 index 0000000..73b6a4f --- /dev/null +++ b/src/fsm/measure/flow_list.c @@ -0,0 +1,49 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* State machine / Measures * +* * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * +* * +* 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 . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include +#include +#include +#include "../../../include/fsm.h" + + +// data_list or flow_list +// ? +// when does a stream of numbers become data +// ? + +/******************************************************************************/ +/* An editable list of results is defined and maintained here */ +/* and some operations can be performed on them. */ +/* (see : fsm/measure/manage.c) */ +/* - - - */ +/* ex : filter, concat, inverse, scale, correlate, etc. */ +/******************************************************************************/ + + diff --git a/src/fsm/measure/manage.c b/src/fsm/measure/manage.c index 78cf52d..def9352 100644 --- a/src/fsm/measure/manage.c +++ b/src/fsm/measure/manage.c @@ -31,85 +31,43 @@ #include #include #include "../../../include/fsm.h" -#include "../../../include/util.h" /******************************************************************************/ -/* M E A S U R E M E N T S */ +/* F R O M M E A S U R E M E N T S T O P R E S E N T A T I O N S */ +/* */ +/* How should the sequence */ +/* from measurements to results presentation */ +/* be organized */ +/* ? */ +/* */ +/* (1) create/edit some mesurement tools and/or activate existing ones */ +/* (2) apply a mesurement tool to a situation to create a new data flow */ +/* and possibly carry out any operations on these results */ +/* (3) display (plot) the results and adjust the appearance of the tables */ +/* - - - */ +/* */ +/* As a result, three lists at least */ +/* must be created and maintained : */ +/* */ +/* (1) a mesurement tools list (see : fsm/measure/tool_list.c) */ +/* which should mention if the tool is 'active' or 'inactive' */ +/* NB each rule ou rues-tree edition may change some items of this list */ +/* */ +/* (2) a data flows list (see : fsm/measure/flow_list.c) */ +/* on which some operations should be performed : */ +/* ex : filter, concat, inverse, scale, correlate, etc. */ +/* NB each data flow should be maintained in a 'displayable form' */ +/* */ +/* (3) a displayed data list (see : fsm/measure/disp_list.c) */ +/* NB some data may be displayed simultaneously in different pages */ +/* ex : SYNTH & RESULTS */ +/* */ +/* NB these three lists should be stored in the XML model */ +/* and restored at the beginning of a new session */ /******************************************************************************/ -// An editable list of measurements is defined and maintained here. -// Each possible measurement can be activated or silenced. - -// The measures relate to -// - the number of occurrences of a rule or group of rules, -// - the number of objects or situations before/after the rule was applied, -// - the time (date) of the event, -// - the time elapsed between two events, -// - the occurrence of events C between events A and B -// - (non limitative, maybe) < pattern recognition tools ? - -// When a list of measurements is established, it is possible to evaluate -// if the results of a measurement are correlated with some other results. - -//------------------------------------------------------------------------------ - -// structure de données : chaque "item" comportera : - -// - identifiant (clé) (+/- pointeur vers : date de création, auteur,...) - -// - type de mesure -// les 6 items suivants peuvent documenter l'ensemble de toutes les valeurs -// à recueillir pour documenter tous les types de mesure possibles; -// tous ces items ne doivent pas être simultanément complétés -// mais, si un tableau etait utilisé, il y aurait peu de place perdue; - -// - pointeur vers le premier groupe de règles (une au moins) -// - pointeur vers un second groupe de règles (une au moins) -// - pointeur vers des objets ou situations (un au moins) -// - pointeur vers un ensemble d'évènements intercurrents -// - date de l'évènement -// - durée entre deux évènements - -// - mesure active ? + / - -// - pointeur vers une liste de mesures similaires -// - pointeur vers des données, des représentations de données ? void fsm_add_measure (char *measure_name) {fsm_debug_msg (2, 0, measure_name, 2);} -void fsm_measures_list_init() {fsm_measures_sorted_list_test();} - -void fsm_measures_sorted_list_test() -{ - measure_list *Mysl = NULL; - - puts("\ncréation d'une liste de 10 elements :"); - fsm_measures_sorted_list_insert (&Mysl,9); - fsm_measures_sorted_list_insert (&Mysl,-8); - fsm_measures_sorted_list_insert (&Mysl,3); - fsm_measures_sorted_list_insert (&Mysl,5); - fsm_measures_sorted_list_insert (&Mysl,-1); - fsm_measures_sorted_list_insert (&Mysl,4); - fsm_measures_sorted_list_insert (&Mysl,-6); - fsm_measures_sorted_list_insert (&Mysl,2); - fsm_measures_sorted_list_insert (&Mysl,0); - fsm_measures_sorted_list_insert (&Mysl,7); - fsm_measures_sorted_list_view (Mysl); - - puts("retrait des 3 premiers elements :"); - fsm_measures_sorted_list_pop (&Mysl); - fsm_measures_sorted_list_pop (&Mysl); - fsm_measures_sorted_list_pop (&Mysl); - fsm_measures_sorted_list_view (Mysl); - - puts("ajout des 3 elements (8, 1, 6) :"); - fsm_measures_sorted_list_insert (&Mysl,8); - fsm_measures_sorted_list_insert (&Mysl,1); - fsm_measures_sorted_list_insert (&Mysl,6); - fsm_measures_sorted_list_view (Mysl); - - fsm_measures_sorted_list_clear (&Mysl); - printf("clear()\n> nombre d'éléments restant = %d\n\n", - fsm_measures_sorted_list_length(Mysl)); -} - +void fsm_measures_list_init() {if (1) fsm_tools_sort_list_test();} diff --git a/src/fsm/measure/list.c b/src/fsm/measure/tool_list.c similarity index 72% rename from src/fsm/measure/list.c rename to src/fsm/measure/tool_list.c index 956ef87..bbe879f 100644 --- a/src/fsm/measure/list.c +++ b/src/fsm/measure/tool_list.c @@ -35,6 +35,7 @@ /******************************************************************************/ /* An editable list of measurements is defined and maintained here */ +/* (see : fsm/measure/manage.c) */ /* - - - */ /* Each possible measurement can be activated or silenced */ /* - - - */ @@ -44,40 +45,39 @@ /* - the time (date) of the event, */ /* - the time elapsed between two events, */ /* - the occurrence of events C between events A and B, */ -/* */ -/* When a list of measurements is established, it is possible to evaluate */ -/* if the results of a measurement are correlated with some other results. */ +/* NB This list is non limitative. ex : pattern recognition tools */ /******************************************************************************/ //------------------------------------------------------------------------------ - -// structure de données : chaque "item" comportera : - +// structure de données : chaque "item" doit comporter : +// // - identifiant (clé) (+/- pointeur vers : date de création, auteur,...) - +// // - type de mesure // les 6 items suivants peuvent documenter l'ensemble de toutes les valeurs // à recueillir pour documenter tous les types de mesure possibles; // tous ces items ne doivent pas être simultanément complétés // mais, si un tableau etait utilisé, il y aurait peu de place perdue; - +// // - pointeur vers le premier groupe de règles (une au moins) // - pointeur vers un second groupe de règles (une au moins) // - pointeur vers des objets ou situations (un au moins) // - pointeur vers un ensemble d'évènements intercurrents // - date de l'évènement // - durée entre deux évènements - +// // - mesure active ? + / - // - pointeur vers une liste de mesures similaires // - pointeur vers des données, des représentations de données ? +//------------------------------------------------------------------------------ -void fsm_measures_sorted_list_insert (measure_list **ml, int value) + +void fsm_tools_sort_list_insert (tool_list **ml, int value) { - measure_list *tmp = NULL; - measure_list *cml = *ml; - measure_list *elem = malloc (sizeof (measure_list)); + tool_list *tmp = NULL; + tool_list *cml = *ml; + tool_list *elem = malloc (sizeof (tool_list)); if (!elem) exit (EXIT_FAILURE); elem->value = value; while (cml && cml->value < value) @@ -90,10 +90,10 @@ void fsm_measures_sorted_list_insert (measure_list **ml, int value) else *ml = elem; } -int fsm_measures_sorted_list_pop (measure_list **ml) +int fsm_tools_sort_list_pop (tool_list **ml) { int value; - measure_list *tmp; + tool_list *tmp; if (! *ml) return -1; tmp = (*ml)->suiv; value = (*ml)->value; @@ -103,7 +103,7 @@ int fsm_measures_sorted_list_pop (measure_list **ml) return value; } -int fsm_measures_sorted_list_length (measure_list *ml) +int fsm_tools_sort_list_length (tool_list *ml) { int n = 0; while (ml) @@ -114,9 +114,9 @@ int fsm_measures_sorted_list_length (measure_list *ml) return n; } -void fsm_measures_sorted_list_clear (measure_list **ml) +void fsm_tools_sort_list_clear (tool_list **ml) { - measure_list *tmp; + tool_list *tmp; while (*ml) { tmp = (*ml)->suiv; @@ -125,10 +125,10 @@ void fsm_measures_sorted_list_clear (measure_list **ml) } } -void fsm_measures_sorted_list_view (measure_list *ml) +void fsm_tools_sort_list_view (tool_list *ml) { printf ("-------- view measures list (n = %d)\n", - fsm_measures_sorted_list_length (ml)); + fsm_tools_sort_list_length (ml)); while(ml) { printf("%d\n", ml->value); @@ -137,3 +137,63 @@ void fsm_measures_sorted_list_view (measure_list *ml) puts ("--------------"); } + + + + + + + + + + + + + + + + + + + + + + + + + +void fsm_tools_sort_list_test() +{ + tool_list *ex_tool = NULL; + + puts("\ncréation d'une liste de 10 elements :"); + fsm_tools_sort_list_insert (&ex_tool,9); + fsm_tools_sort_list_insert (&ex_tool,-8); + fsm_tools_sort_list_insert (&ex_tool,3); + fsm_tools_sort_list_insert (&ex_tool,5); + fsm_tools_sort_list_insert (&ex_tool,-1); + fsm_tools_sort_list_insert (&ex_tool,4); + fsm_tools_sort_list_insert (&ex_tool,-6); + fsm_tools_sort_list_insert (&ex_tool,2); + fsm_tools_sort_list_insert (&ex_tool,0); + fsm_tools_sort_list_insert (&ex_tool,7); + fsm_tools_sort_list_view (ex_tool); + + puts("retrait des 3 premiers elements :"); + fsm_tools_sort_list_pop (&ex_tool); + fsm_tools_sort_list_pop (&ex_tool); + fsm_tools_sort_list_pop (&ex_tool); + fsm_tools_sort_list_view (ex_tool); + + puts("ajout des 3 elements (8, 1, 6) :"); + fsm_tools_sort_list_insert (&ex_tool,8); + fsm_tools_sort_list_insert (&ex_tool,1); + fsm_tools_sort_list_insert (&ex_tool,6); + fsm_tools_sort_list_view (ex_tool); + + fsm_tools_sort_list_clear (&ex_tool); + printf("clear()\n> nombre d'éléments restant = %d\n\n", + fsm_tools_sort_list_length(ex_tool)); +} + + diff --git a/src/signal.c b/src/signal.c index f0bdcf6..df9125b 100644 --- a/src/signal.c +++ b/src/signal.c @@ -365,9 +365,9 @@ void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrol void on_clicked_topbar_right_measure (GtkWidget *btt, gpointer data) { - fsm_measures_sorted_list_test(); -// gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), -// GTK_WIDGET (widget_get_measure_page())); +// fsm_measures_sorted_list_do something (); + gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), + GTK_WIDGET (widget_get_measure_page())); } void on_start_new_measure (GtkWidget *btt, gpointer data)