From 270b408d28b5089f80c713525e34b8b5c0993cd0 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 30 Aug 2024 15:14:01 +0200 Subject: [PATCH] https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_pour_gnuplot (@fsm/measure/data_list.c) --- a_main.plt | 8 ++ include/fsm.h | 26 +++--- include/heaviside.h | 8 ++ include/xdef.h | 52 ++++++++++++ include/xfx_x.h | 32 ++++++++ include/xfxy_x.h | 70 ++++++++++++++++ include/xfxyz_x.h | 51 ++++++++++++ include/xplt.h | 70 ++++++++++++++++ include/xspv.h | 60 ++++++++++++++ list.txt | 11 +++ src/fsm/dispatch.c | 44 +++++----- src/fsm/journal.c | 3 +- src/fsm/measure/data_list.c | 84 +++++++++++++++++++ src/fsm/measure/disp_list.c | 33 ++++---- src/fsm/measure/flow_list.c | 49 ----------- src/fsm/measure/manage.c | 41 +++++----- src/fsm/measure/tool_list.c | 112 +++++++++----------------- src/fsm/prefer.c | 6 +- src/util/tests.c | 9 ++- src/widget/rules/tree_tools/compare.c | 13 +-- src/widget/topbar/left.c | 14 ++-- 21 files changed, 588 insertions(+), 208 deletions(-) create mode 100644 a_main.plt create mode 100644 include/heaviside.h create mode 100644 include/xdef.h create mode 100644 include/xfx_x.h create mode 100644 include/xfxy_x.h create mode 100644 include/xfxyz_x.h create mode 100644 include/xplt.h create mode 100644 include/xspv.h create mode 100644 list.txt create mode 100644 src/fsm/measure/data_list.c delete mode 100644 src/fsm/measure/flow_list.c diff --git a/a_main.plt b/a_main.plt new file mode 100644 index 0000000..f15987f --- /dev/null +++ b/a_main.plt @@ -0,0 +1,8 @@ +# Fichier de commande pour gnuplot +# En ligne de commande : load "a_main.plt" +# + set zeroaxis + plot cos(x),\ + sin(x) + + reset \ No newline at end of file diff --git a/include/fsm.h b/include/fsm.h index 890b3e4..492da69 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -49,8 +49,9 @@ enum fsm_measure_type {DATE_RULE_EXEC, RULE_EXEC_NB, OBJECT_NB, ELAPSED_TIME }; #define n_situations 128 // and so on... 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 data_list {int value; struct data_list *suiv;} data_list ; typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ; +typedef struct journal {int value; struct journal *prev;} journal; void fsm_init(); // def: fsm/dispatch; call: main; void fsm_preferences_init(); // def: fsm/prefer; call: fsm/dispatch; @@ -88,23 +89,28 @@ void fsm_msg (int choice, int value, char *string, int sub_automaton); // --------------------------------------------------------------- WIP ------ // 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; +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; // def: fsm/measure/manage/; call: rule exec void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id); // --------------------------------------------------------------- WIP ------ -typedef struct journal {int value; struct journal *prev;} journal; // structure d'un élément - int fsm_journal_push (journal **jj, int v_value); int fsm_journal_pop (journal **jj); void fsm_journal_clear (journal **jj); int fsm_journal_length (journal *jj); void fsm_journal_view (journal *jj); -void fsm_journal_seek (journal *jj, int v_value); +void fsm_journal_seek (journal *jj, int vv); + + +// --------------------------------------------------------------- WIP ------ +void fsm_data_new_insert (data_list d, int *p_data); +void fsm_data_new_concat (data_list d, int *p_data, int *p_target); +void *fsm_data_get(); // (data_list d, int from, int to); +void fsm_data_erase (data_list d, int from, int to); diff --git a/include/heaviside.h b/include/heaviside.h new file mode 100644 index 0000000..e49f74a --- /dev/null +++ b/include/heaviside.h @@ -0,0 +1,8 @@ +/* ------------------------------------ */ +double H( +double x) +{ + if(x>0.)return(1.); + else return(0.); +} +/* ------------------------------------ */ diff --git a/include/xdef.h b/include/xdef.h new file mode 100644 index 0000000..3ae00c1 --- /dev/null +++ b/include/xdef.h @@ -0,0 +1,52 @@ +/* --------------------------------------------------------------- */ +/* gnuplot : xdef.h */ +/* https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_h_:_xdef */ +/* --------------------------------------------------------------- */ + +#ifndef PI +#define PI 3.14159265359 +#endif + +/* ------------------------------------ */ +void clrscrn(void) +{ + printf("\n\n\n\n\n\n\n\n\n\n\n" + "\n\n\n\n\n\n\n\n\n\n\n" + "\n\n\n\n\n\n\n\n\n\n\n"); +} +/* ------------------------------------ */ +void Pause(void) +{ +int i=300; +int j; + + while(--i){j=600000;while(--j);} +} +/* ------------------------------------ */ +/* First file name : */ +/* */ +/* char fname[]= "a_paaa"; */ +/* ------------------------------------ */ +char *NewName( +char *name +) +{ + if(name[5]<'z') + + ++name[5]; + + else if(name[4]<'z') + { + name[5]='a'; + ++name[4]; + } + else if(name[3]<'z') + { + name[5]='a'; + name[4]='a'; + ++name[3]; + } + + return(name); +} + diff --git a/include/xfx_x.h b/include/xfx_x.h new file mode 100644 index 0000000..92becb4 --- /dev/null +++ b/include/xfx_x.h @@ -0,0 +1,32 @@ +/* ------------------------------------------------------------------ */ +/* gnuplot : xfx_x.h */ +/* https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_h_:_xfx_x */ +/* ------------------------------------------------------------------ */ + +/* ------------------------------------ + f'(a) = f(a+h) - f(a-h) + ------------- + 2h + ---------------------------------- */ +double fx_x( +double (*P_f)(double x), +double a, +double h +) +{ + return( ( ((*P_f)(a+h))-((*P_f)(a-h)) ) / (2.*h) ); +} +/* ------------------------------------ + f''(a) = f(a+h) - 2 f(a) + f(a-h) + ---------------------- + h**2 + ---------------------------------- */ +double fx_xx( +double (*P_f)(double x), +double a, +double h +) +{ + return( (((*P_f)(a+h))-2*((*P_f)(a))+((*P_f)(a-h))) / (h*h) ); +} + diff --git a/include/xfxy_x.h b/include/xfxy_x.h new file mode 100644 index 0000000..c16e08e --- /dev/null +++ b/include/xfxy_x.h @@ -0,0 +1,70 @@ +/* ------------------------------------------------------------------ */ +/* gnuplot : xfxy_x.h */ +/* https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_h_:_xfxy_x */ +/* ------------------------------------------------------------------ */ + +#include "xspv.h" + +double fxy_x( +double (*P_f)(double x, double y), +double h, +point2d p +) +{ +double tplsh; +double tmnsh; + + tplsh = ((*P_f)(p.x+h,p.y)); + tmnsh = ((*P_f)(p.x-h,p.y)); + + return(( tplsh-tmnsh)/(2.*h) ); +} +/* ------------------------------------ */ +double fxy_y( +double (*P_f)(double x, double y), +double h, +point2d p +) +{ +double tplsh; +double tmnsh; + + tplsh = ((*P_f)(p.x,p.y+h)); + tmnsh = ((*P_f)(p.x,p.y-h)); + + return(( tplsh-tmnsh)/(2.*h) ); +} +/* ------------------------------------ */ +double fxy_xx( +double (*P_f)(double x, double y), +double h, +point2d p +) +{ +double t; +double tplsh; +double tmnsh; + + t = ((*P_f)(p.x , p.y)); + tplsh = ((*P_f)(p.x+h, p.y)); + tmnsh = ((*P_f)(p.x-h, p.y)); + + return( (tplsh-2*t+tmnsh)/(h*h) ); +} +/* ------------------------------------ */ +double fxy_yy( +double (*P_f)(double x, double y), +double h, +point2d p +) +{ +double t; +double tplsh; +double tmnsh; + + t = ((*P_f)(p.x, p.y )); + tplsh = ((*P_f)(p.x, p.y+h)); + tmnsh = ((*P_f)(p.x, p.y-h)); + + return( (tplsh-2*t+tmnsh)/(h*h) ); +} diff --git a/include/xfxyz_x.h b/include/xfxyz_x.h new file mode 100644 index 0000000..ee737bc --- /dev/null +++ b/include/xfxyz_x.h @@ -0,0 +1,51 @@ +/* ------------------------------------------------------------------ */ +/* gnuplot : xfxyz_x.h */ +/* https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_h_:_xfxyz_x */ +/* ------------------------------------------------------------------ */ + +#include "xspv.h" + +double fxyz_x( +double (*P_f)(double x, double y, double z), +double h, +point3d p +) +{ +double tplsh; +double tmnsh; + + tplsh = ((*P_f)(p.x+h,p.y,p.z)); + tmnsh = ((*P_f)(p.x-h,p.y,p.z)); + + return(( tplsh-tmnsh)/(2.*h) ); +} +/* ------------------------------------ */ +double fxyz_y( +double (*P_f)(double x, double y, double z), +double h, +point3d p +) +{ +double tplsh; +double tmnsh; + + tplsh = ((*P_f)(p.x,p.y+h,p.z)); + tmnsh = ((*P_f)(p.x,p.y-h,p.z)); + + return(( tplsh-tmnsh)/(2.*h) ); +} +/* ------------------------------------ */ +double fxyz_z( +double (*P_f)(double x, double y, double z), +double h, +point3d p +) +{ +double tplsh; +double tmnsh; + + tplsh = ((*P_f)(p.x,p.y,p.z+h)); + tmnsh = ((*P_f)(p.x,p.y,p.z-h)); + + return(( tplsh-tmnsh)/(2.*h) ); +} diff --git a/include/xplt.h b/include/xplt.h new file mode 100644 index 0000000..0f322c2 --- /dev/null +++ b/include/xplt.h @@ -0,0 +1,70 @@ +/* --------------------------------------------------------------- */ +/* gnuplot : xplt.h */ +/* https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_h_:_xplt */ +/* --------------------------------------------------------------- */ + +typedef struct +{ + double xmini; double xmaxi; + double ymini; double ymaxi; + +}W_Ctrl, *PW_Ctrl; +/* ------------------------------------ */ +W_Ctrl i_WGnuplot( + double xmini, double xmaxi, + double ymini, double ymaxi +) +{ +W_Ctrl w = {xmini,xmaxi,ymini,ymaxi}; + +return (w);} +/* ------------------------------------ */ +typedef struct +{ + double xmini; double xmaxi; + double ymini; double ymaxi; + double zmini; double zmaxi; + +}Ws_Ctrl, *PWs_Ctrl; +/* ------------------------------------ */ +Ws_Ctrl i_WsGnuplot( + double xmini, double xmaxi, + double ymini, double ymaxi, + double zmini, double zmaxi +) +{ +Ws_Ctrl w = {xmini,xmaxi,ymini,ymaxi,zmini,zmaxi}; + +return (w);} +/* ------------------------------------ */ +typedef struct +{ + double rot_x; double rot_z; + double scale; double scale_z; + +}View_Ctrl, *PView_Ctrl; +/* ------------------------------------ */ +View_Ctrl i_VGnuplot( + double rot_x, double rot_z, + double scale, double scale_z +) +{ +View_Ctrl V = {rot_x,rot_z,scale_z,scale_z}; + +return (V);} +/* ------------------------------------ */ +typedef struct +{ + double mini; double maxi; + double step; + +}t_Ctrl, *Pt_Ctrl; +/* ------------------------------------ */ +t_Ctrl i_time( + double mini, double maxi, + double step +) +{ +t_Ctrl t = {mini,maxi,step}; + +return (t);} diff --git a/include/xspv.h b/include/xspv.h new file mode 100644 index 0000000..ae88360 --- /dev/null +++ b/include/xspv.h @@ -0,0 +1,60 @@ +/* --------------------------------------------------------------- */ +/* gnuplot : xspv.h */ +/* https://fr.wikibooks.org/wiki/Mathc_gnuplot/Fichiers_h_:_xspv */ +/* --------------------------------------------------------------- */ + +typedef struct +{ + double x; double y; + +}point2d, *Ppoint2d; +/* ------------------------------------ */ +point2d i_point2d( + double x, double y +) +{ +point2d p = {x,y}; + +return (p);} +/* ------------------------------------ */ +typedef struct +{ + double x; double y; double z; + +}point3d, *Ppoint3d; +/* ------------------------------------ */ +point3d i_point3d( +double x, double y, double z +) +{ +point3d p = {x,y,z}; + +return (p);} +/* ------------------------------------ */ +typedef struct +{ + double i; double j; + +}vector2d, *Pvector2d; +/* ------------------------------------ */ +vector2d i_vector2d( + double i, double j +) +{ +vector2d v = {i,j}; + +return (v);} +/* ------------------------------------ */ +typedef struct +{ + double i; double j; double k; + +}vector3d, *Pvector3d; +/* ------------------------------------ */ +vector3d i_vector3d( + double i, double j, double k +) +{ +vector3d v = {i,j,k}; + +return (v);} diff --git a/list.txt b/list.txt new file mode 100644 index 0000000..0da200a --- /dev/null +++ b/list.txt @@ -0,0 +1,11 @@ + -5.000 0.959 + -4.000 0.757 + -3.000 -0.141 + -2.000 -0.909 + -1.000 -0.841 + 0.000 0.000 + 1.000 0.841 + 2.000 0.909 + 3.000 0.141 + 4.000 -0.757 + 5.000 -0.959 diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index 28eaa5f..685aedb 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -1,34 +1,32 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Gem-graph client * +* Gem-graph client * +* Finite State Machine (src/fsm/measure/dispatch.c) * * * -* State machine * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * * * -* Copyright © 2024 Libre en Communs * -* Copyright © 2024 Adrien Bourmault * -* Copyright © 2024 Jean Sirmai * -* * -* This file is part of Gem-graph. * +* 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. * +* 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. * +* 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 . * +* along with this program. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include - #include "../../include/fsm.h" @@ -123,20 +121,22 @@ void fsm_msg (int choice, int value, char *string, int sub_automaton) switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and // sub_automaton 1 is STATE_RULES_DATA // sub_automaton 2 is MEASURE - case (0) : printf ("fsm/dispatch.message | switch %5s x %5s > %5s x %5s\n", + case (0) : printf ("fsm/dispatch.message |\ + switch %5s x %5s > %5s x %5s\n", tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA], tab_0 [choice], tab_1 [choice_STATE_RULES_DATA]); break; - case (1) : printf ("fsm/dispatch.message | switch %5s x %5s > %5s x %5s\n", + case (1) : printf ("fsm/dispatch.message |\ + switch %5s x %5s > %5s x %5s\n", tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA], tab_0 [choice_EXEC_EDIT], tab_1 [choice]); break; - case (2) : printf ("fsm/dispatch.message | %s\n", string); + case (2) : printf ("fsm/dispatch.message | %s\n", string); break; - case (3) : printf ("fsm/dispatch.message | %2d\n", choice); + case (3) : printf ("fsm/dispatch.message | %2d\n", choice); break; diff --git a/src/fsm/journal.c b/src/fsm/journal.c index a0890fb..e337ac3 100644 --- a/src/fsm/journal.c +++ b/src/fsm/journal.c @@ -61,7 +61,6 @@ int fsm_journal_pop (journal **jj) return vv; // retourne la value retirée du journal. } - void fsm_journal_clear (journal **jj) { journal *tmp; @@ -95,7 +94,7 @@ void fsm_journal_view (journal *jj) puts ("------"); } -void fsm_journal_seek (journal *jj, int value) +void fsm_journal_seek (journal *jj, int vv) { } diff --git a/src/fsm/measure/data_list.c b/src/fsm/measure/data_list.c new file mode 100644 index 0000000..04c02a7 --- /dev/null +++ b/src/fsm/measure/data_list.c @@ -0,0 +1,84 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* 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 "../../../include/fsm.h" + + + +/******************************************************************************/ +/* An editable list of results is defined and maintained here. */ +/* Some operations can be performed on them. */ +/* (see : fsm/measure/manage.c) */ +/* - - - */ +/* ex : filter, concat, inverse, scale, correlate, etc. */ +/******************************************************************************/ + +void fsm_data_new_insert (data_list d, int *p_data) {} +void fsm_data_new_concat (data_list d, int *p_data, int *p_target) {} +void fsm_data_erase (data_list d, int from, int to) {} + +char heq[] = "sin(x)"; +char geq[] = "cos(x)"; + +void *fsm_data_get () // (data_list d, int from, int to) +{ + int v[10]; + for (int i = 0; i < 10; i++) {v[i] = rand() % 10; printf("%d ", v[i]);} + printf("\n"); + + FILE *fp; + double a; + fp = fopen("list.txt","w"); + for(a = -5.0; a <= 5.0; a++) fprintf(fp, " %6.3f %6.3f\n", a, sin(a)); + fclose(fp); + printf("file list.txt opened\npress 'return' to continue."); + getchar(); + + fp = fopen("a_main.plt","w"); + + fprintf(fp,"# Fichier de commande pour gnuplot \n" + "# En ligne de commande : load \"a_main.plt\"\n" + "#\n" + " set zeroaxis\n" + " plot %s,\\\n" + " %s \n\n" + " reset", geq, heq); + fclose(fp); + + printf("\n\nload \"a_main.plt\" with gnuplot." + "\n\npress return to continue. "); + getchar(); + + + return v; +} + diff --git a/src/fsm/measure/disp_list.c b/src/fsm/measure/disp_list.c index fec2c1a..0a7dc8f 100644 --- a/src/fsm/measure/disp_list.c +++ b/src/fsm/measure/disp_list.c @@ -1,29 +1,28 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Gem-graph client * +* Gem-graph client * +* State machine / Measures * * * -* State machine / Measures * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * * * -* Copyright © 2024 Libre en Communs * -* Copyright © 2024 Adrien Bourmault * -* Copyright © 2024 Jean Sirmai * -* * -* This file is part of Gem-graph. * +* 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. * +* 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. * +* 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 . * +* along with this program. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/src/fsm/measure/flow_list.c b/src/fsm/measure/flow_list.c deleted file mode 100644 index 73b6a4f..0000000 --- a/src/fsm/measure/flow_list.c +++ /dev/null @@ -1,49 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* 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 f3c6119..6aef9b2 100644 --- a/src/fsm/measure/manage.c +++ b/src/fsm/measure/manage.c @@ -1,29 +1,28 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Gem-graph client * +* Gem-graph client * +* State machine / Measures * * * -* State machine / Measures * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * * * -* Copyright © 2024 Libre en Communs * -* Copyright © 2024 Adrien Bourmault * -* Copyright © 2024 Jean Sirmai * -* * -* This file is part of Gem-graph. * +* 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. * +* 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. * +* 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 . * +* along with this program. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -79,9 +78,11 @@ /******************************************************************************/ + +// use gnuplot ? gtkwave ? TODO check + + void fsm_add_measure (char *measure_name) {fsm_msg (2, 0, measure_name, 2);} - -void fsm_measures_list_init() {if (0) fsm_tools_sort_list_test();} - +void fsm_measures_list_init() {if (0) fsm_tools_list_test(); fsm_data_get();} void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id) {} diff --git a/src/fsm/measure/tool_list.c b/src/fsm/measure/tool_list.c index bbe879f..fd62142 100644 --- a/src/fsm/measure/tool_list.c +++ b/src/fsm/measure/tool_list.c @@ -1,29 +1,28 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Gem-graph client * +* Gem-graph client * +* Finite State Machine (src/fsm/measure/tool_list.c) * * * -* State machine / Measures * +* Copyright © 2024 Libre en Communs * +* Copyright © 2024 Adrien Bourmault * +* Copyright © 2024 Jean Sirmai * * * -* Copyright © 2024 Libre en Communs * -* Copyright © 2024 Adrien Bourmault * -* Copyright © 2024 Jean Sirmai * -* * -* This file is part of Gem-graph. * +* 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. * +* 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. * +* 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 . * +* along with this program. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -73,7 +72,7 @@ //------------------------------------------------------------------------------ -void fsm_tools_sort_list_insert (tool_list **ml, int value) +void fsm_tools_list_insert (tool_list **ml, int value) { tool_list *tmp = NULL; tool_list *cml = *ml; @@ -90,7 +89,7 @@ void fsm_tools_sort_list_insert (tool_list **ml, int value) else *ml = elem; } -int fsm_tools_sort_list_pop (tool_list **ml) +int fsm_tools_list_pop (tool_list **ml) { int value; tool_list *tmp; @@ -103,7 +102,7 @@ int fsm_tools_sort_list_pop (tool_list **ml) return value; } -int fsm_tools_sort_list_length (tool_list *ml) +int fsm_tools_list_length (tool_list *ml) { int n = 0; while (ml) @@ -114,7 +113,7 @@ int fsm_tools_sort_list_length (tool_list *ml) return n; } -void fsm_tools_sort_list_clear (tool_list **ml) +void fsm_tools_list_clear (tool_list **ml) { tool_list *tmp; while (*ml) @@ -125,10 +124,10 @@ void fsm_tools_sort_list_clear (tool_list **ml) } } -void fsm_tools_sort_list_view (tool_list *ml) +void fsm_tools_list_view (tool_list *ml) { printf ("-------- view measures list (n = %d)\n", - fsm_tools_sort_list_length (ml)); + fsm_tools_list_length (ml)); while(ml) { printf("%d\n", ml->value); @@ -138,62 +137,31 @@ void fsm_tools_sort_list_view (tool_list *ml) } - - - - - - - - - - - - - - - - - - - - - - - - -void fsm_tools_sort_list_test() +void fsm_tools_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("\nfsm/measure/ fsm_tools_list_test() > création d'une liste de 6 elements :"); + fsm_tools_list_insert (&ex_tool,-3); + fsm_tools_list_insert (&ex_tool,5); + fsm_tools_list_insert (&ex_tool,-1); + fsm_tools_list_insert (&ex_tool,4); + fsm_tools_list_insert (&ex_tool,2); + fsm_tools_list_insert (&ex_tool,0); + fsm_tools_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("retrait des 2 premiers elements :"); + fsm_tools_list_pop (&ex_tool); + fsm_tools_list_pop (&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); + puts("ajout des 2 elements (3, 1) :"); + fsm_tools_list_insert (&ex_tool,3); + fsm_tools_list_insert (&ex_tool,1); + fsm_tools_list_view (ex_tool); - fsm_tools_sort_list_clear (&ex_tool); + fsm_tools_list_clear (&ex_tool); printf("clear()\n> nombre d'éléments restant = %d\n\n", - fsm_tools_sort_list_length(ex_tool)); + fsm_tools_list_length(ex_tool)); } diff --git a/src/fsm/prefer.c b/src/fsm/prefer.c index 870f119..8abffcd 100644 --- a/src/fsm/prefer.c +++ b/src/fsm/prefer.c @@ -132,5 +132,7 @@ void fsm_add_displayable (char *displayable_name) /* P R E F E R E N C E S */ /******************************************************************************/ -void fsm_preferences_init () {fsm_displayable_list_init ();} -void fsm_displayable_list_init () { printf("src/fsm/prefer.c fsm_displayable_list_init()\n");} +void fsm_preferences_init () {printf("src/fsm/prefer.c\ + | src/fsm/prefer.c fsm_preferences_init()\n");} +void fsm_displayable_list_init () {printf("src/fsm/prefer.c\ + | src/fsm/prefer.c fsm_displayable_list_init()\n");} diff --git a/src/util/tests.c b/src/util/tests.c index e660b0b..93ab276 100644 --- a/src/util/tests.c +++ b/src/util/tests.c @@ -93,7 +93,7 @@ void util_sorted_list_test() { slist *Mysl = NULL; - puts("\ncréation d'une liste de 10 elements :"); + puts("\nfsm/util util_sorted_list_test() > création d'une liste de 10 elements :"); util_sorted_list_insert (&Mysl,9); util_sorted_list_insert (&Mysl,-8); util_sorted_list_insert (&Mysl,3); @@ -118,6 +118,13 @@ void util_sorted_list_test() util_sorted_list_insert (&Mysl,6); util_sorted_list_view (Mysl); + puts("retrait des 5 derniers elements :"); + util_sorted_list_pop (&Mysl); + util_sorted_list_pop (&Mysl); + util_sorted_list_pop (&Mysl); + util_sorted_list_pop (&Mysl); + util_sorted_list_pop (&Mysl); + util_sorted_list_clear (&Mysl); printf("clear()\n> nombre d'éléments restant = %d\n\n", util_sorted_list_length(Mysl)); diff --git a/src/widget/rules/tree_tools/compare.c b/src/widget/rules/tree_tools/compare.c index 4671479..2a9afa2 100644 --- a/src/widget/rules/tree_tools/compare.c +++ b/src/widget/rules/tree_tools/compare.c @@ -32,6 +32,7 @@ #include "../../../../include/signal.h" #define MAX_SIZE 255 +#define CHECK_STACK 0 // ----------------------------------------------------------------------------- // Below is ^c^v from RMS C manual (p 77) 24 * 256 * 256 * 2 = 3 145 728 @@ -77,7 +78,7 @@ static void push (Stack *stack, GtkWidget *value) { if (isFull(stack)) { printf("Stack Overflow\n"); return; } stack->arr[++stack->top] = value; - printf("%d ", stack->top); + if (CHECK_STACK) printf("%d ", stack->top); } static GtkWidget *pop (Stack *stack) @@ -85,8 +86,8 @@ static GtkWidget *pop (Stack *stack) if (isEmpty(stack)) { printf("Stack Underflow\n"); return NULL; } GtkWidget *popped = stack->arr[stack->top]; stack->top--; - printf("Popped %p from the stack %2d ", popped, stack->top); - if ((stack->top + 1) % 3 == 0) printf("\n"); + if (CHECK_STACK) printf("Popped %p from the stack %2d ", popped, stack->top); + if (CHECK_STACK) if ((stack->top + 1) % 3 == 0) printf("\n"); return popped; } @@ -171,7 +172,7 @@ void *widget_get_an_impression_of_what_a_rules_comparator_could_be(){ push(&stack_b, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/folic acid.png"))); - printf(" ---------\ + if (CHECK_STACK) printf(" ---------\ widget/rules/tree_tools/compare.c widget_get_an_impression_of_...()\n");//%d\n", *stack_b->arr[0]); // peek(&stack_b); @@ -235,7 +236,7 @@ static GtkWidget *do_rtfd (Stack stack) // TODO static void *push_images_onto_stack (Stack stack) { clock_t start, end; - printf("compare.c push_images_onto_stack() start >> "); + if (CHECK_STACK) printf("widget/rules/tree_tools/compare.c push_images_onto_stack() start >> "); start = clock(); /* push(&stack, GTK_WIDGET (gtk_picture_new_for_filename @@ -285,6 +286,6 @@ static void *push_images_onto_stack (Stack stack) */ end = clock(); long double t = (long double)(end - start) / CLOCKS_PER_SEC; - printf(" << %9Lg sec\n", t); + if (CHECK_STACK) printf(" << %9Lg sec\n", t); return 0; } diff --git a/src/widget/topbar/left.c b/src/widget/topbar/left.c index 4b67287..bff4d08 100644 --- a/src/widget/topbar/left.c +++ b/src/widget/topbar/left.c @@ -84,8 +84,7 @@ void window_design_topbar_left (GtkWidget *header_bar) - - +#define YOU_WANT_TO_START_ON_ANOTHER_PAGE 0 /******************************************************************************/ /* use the next lineS to select the page that will be presented first */ /* it triggers <=> signal.on_toggle_state_rule_data (a btt_NAME) */ @@ -93,11 +92,12 @@ void window_design_topbar_left (GtkWidget *header_bar) /* the last one is the winner (and the winner takes it all !...) */ /* THE LAST ONE IS THE WINNER (AND THE WINNER TAKES IT ALL !...) */ /******************************************************************************/ - - gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_rules()), TRUE); - gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_state()), TRUE); - gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_data()), TRUE); - gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_synth()), TRUE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_synth()), TRUE); + if (YOU_WANT_TO_START_ON_ANOTHER_PAGE) { // select one + gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_rules()), TRUE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_state()), TRUE); + gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_data()), TRUE); + } }