comments (fsm.f) & https://learntutorials.net/fr/c/topic/560/listes-liees < ^c^v > fsm/measure.c
This commit is contained in:
parent
3d71b6e9c1
commit
2da17cc549
|
@ -47,35 +47,35 @@ enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor
|
|||
#define n_objects 32 // arbitrary too,
|
||||
#define n_situations 128 // and so on...
|
||||
|
||||
bool fsm_init ();
|
||||
bool fsm_init(); // def: fsm/dispatch; call: main;
|
||||
void fsm_measures_list_init(); // def: fsm/measure; call: fsm/dispatch;
|
||||
void fsm_results_list_init(); // def: fsm/results; call: fsm/dispatch;
|
||||
void fsm_preferences_init(); // def: fsm/prefer; call: fsm/dispatch;
|
||||
void fsm_displayable_list_init(); // def: fsm/prefer; call: fsm/dispatch;
|
||||
|
||||
void fsm_measures_list_init ();
|
||||
void fsm_results_list_init ();
|
||||
void fsm_displayable_list_init ();
|
||||
int fsm_get_exec_edit(); // def: fsm/dispatch; call: signal;
|
||||
// widget/state/dispatch;
|
||||
// widget/rules/selected/dispatch;
|
||||
int fsm_get_state_rules_data(); // def: fsm/dispatch; call: signal;
|
||||
|
||||
int fsm_get_exec_edit ();
|
||||
int fsm_get_state_rules_data ();
|
||||
int fsm_get_store_restore_reset ();
|
||||
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_exec_edit (int value);
|
||||
void fsm_set_state_rules_data (int value);
|
||||
void fsm_set_store_restore_reset (int target, int value);
|
||||
void fsm_store_restore_reset (int choice, int value);// def: prefer; call: signal;
|
||||
|
||||
bool fsm_get_preferences_state(); // def: fsm/dispatch; call: - - -
|
||||
void fsm_set_preferences_state (bool value); // def: fsm/dispatch; call: signal;
|
||||
// fsm/prefer;
|
||||
|
||||
bool fsm_get_preferences_state ();
|
||||
void fsm_set_preferences_state (bool value);
|
||||
|
||||
void *fsm_add_measure (char *measure_name);
|
||||
void *fsm_add_result (char *result_name);
|
||||
|
||||
void fsm_debug (int choice, int value, char *string, int sub_automaton);
|
||||
|
||||
void fsm_store_restore_reset (int choice, int value);
|
||||
const char *fsm_get_button_icon_name (int n);
|
||||
void fsm_add_measure (char *measure_name); // def: fsm/measure; call: widget/measure/dispatch;
|
||||
void fsm_add_result (char *result_name); // def: fsm/result; call: - - -
|
||||
void fsm_add_displayable (char *displayable_name);// def: fsm/prefer; call: fsm/prefer;
|
||||
|
||||
void fsm_reset_all_situations_transparencies_at_value (int value); // provisoire...
|
||||
// def: fsm/prefer; call: signal;
|
||||
|
||||
void *fsm_add_displayable (char *displayable_name);
|
||||
|
||||
void fsm_preferences_init ();
|
||||
|
||||
void fsm_debug (int choice, int value, char *string, int sub_automaton);
|
||||
// def: fsm/dispatch; call: fsm/dispatch;
|
||||
// fsm/measure;
|
||||
// fsm/result;
|
||||
|
|
|
@ -122,20 +122,27 @@ void fsm_debug (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("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("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 <> %s\n", string); break;
|
||||
case (3) : printf("FSM debug <> choice = %2d\n", choice); break;
|
||||
|
||||
case (2) : printf("fsm <> %s\n", string);
|
||||
break;
|
||||
|
||||
case (3) : printf("fsm debug <> %2d\n", choice);
|
||||
break;
|
||||
|
||||
|
||||
default : printf("default in fsm/dispatch.fsm_debug()\n");
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../../include/fsm.h"
|
||||
|
||||
|
@ -67,7 +68,7 @@
|
|||
// - the time (date) of the event,
|
||||
// - the time elapsed between two events,
|
||||
// - the occurrence of events C between events A and B
|
||||
// - (non limitative, may be)
|
||||
// - (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.
|
||||
|
@ -95,33 +96,123 @@
|
|||
// - pointeur vers des données, des représentations de données ?
|
||||
|
||||
|
||||
void *fsm_add_measure (char *measure_name) {fsm_debug (2, 0, measure_name, 2); return NULL;}
|
||||
|
||||
//static void *list_measures;
|
||||
typedef struct s_List List;
|
||||
struct s_List
|
||||
{
|
||||
List *next; /* pointeur sur le reste de la liste */
|
||||
// void *data; /* pointeur sur une donnée générique */
|
||||
};
|
||||
|
||||
List *list = NULL;
|
||||
|
||||
List *list_create (void *data)
|
||||
{
|
||||
List *list = malloc(sizeof(list)); /* allocation (en vert sur le diagramme)
|
||||
* et affectation à la variable list (en bleu) */
|
||||
if (list) /* si l'allocation a réussi */
|
||||
{
|
||||
// list->data = data; /* affectation du champ data (en rouge) */
|
||||
list->next = NULL; /* affectation du champ next à la liste vide */
|
||||
}
|
||||
return list; /* retour de la liste
|
||||
* (correctement allouée et affectée ou NULL) */
|
||||
}
|
||||
void fsm_add_measure (char *measure_name) {fsm_debug (2, 0, measure_name, 2);}
|
||||
|
||||
void fsm_measures_list_init ()
|
||||
{
|
||||
fsm_debug (0,0, "fsm_measures_list_init()", 2); // sub_automaton 2
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// https://learntutorials.net/fr/c/topic/560/listes-liees < ^c^v vvv
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct doubly_node
|
||||
{
|
||||
struct doubly_node * prev;
|
||||
struct doubly_node * next;
|
||||
};
|
||||
|
||||
void doubly_node_bind (struct doubly_node * prev, struct doubly_node * next)
|
||||
{
|
||||
prev->next = next;
|
||||
next->prev = prev;
|
||||
}
|
||||
|
||||
void doubly_node_make_empty_circularly_list (struct doubly_node * head)
|
||||
{
|
||||
doubly_node_bind (head, head);
|
||||
}
|
||||
|
||||
void doubly_node_insert_between
|
||||
(struct doubly_node * prev, struct doubly_node * next, struct doubly_node * insertion)
|
||||
{
|
||||
doubly_node_bind (prev, insertion);
|
||||
doubly_node_bind (insertion, next);
|
||||
}
|
||||
|
||||
void doubly_node_insert_before
|
||||
(struct doubly_node * tail, struct doubly_node * insertion)
|
||||
{
|
||||
doubly_node_insert_between (tail->prev, tail, insertion);
|
||||
}
|
||||
|
||||
void doubly_node_insert_after
|
||||
(struct doubly_node * head, struct doubly_node * insertion)
|
||||
{
|
||||
doubly_node_insert_between (head, head->next, insertion);
|
||||
}
|
||||
|
||||
struct Node {
|
||||
int data;
|
||||
struct Node *next;
|
||||
};
|
||||
|
||||
|
||||
void insert_node (struct Node **head, int nodeValue);
|
||||
void print_list (struct Node *head);
|
||||
|
||||
int any () {
|
||||
struct Node* headNode;
|
||||
headNode = NULL; /* Initialize our first node pointer to be NULL. */
|
||||
size_t listSize, i;
|
||||
do {
|
||||
printf("How many numbers would you like to input?\n");
|
||||
} while(1 != scanf("%zu", &listSize));
|
||||
|
||||
for (i = 0; i < listSize; i++) {
|
||||
int numToAdd;
|
||||
do {
|
||||
printf("Enter a number:\n");
|
||||
} while (1 != scanf("%d", &numToAdd));
|
||||
|
||||
insert_node (&headNode, numToAdd);
|
||||
printf("Current list after your inserted node: \n");
|
||||
print_list(headNode);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_list (struct Node *head) {
|
||||
struct Node* currentNode = head;
|
||||
|
||||
/* Iterate through each link. */
|
||||
while (currentNode != NULL) {
|
||||
printf("Value: %d\n", currentNode->data);
|
||||
currentNode = currentNode -> next;
|
||||
}
|
||||
}
|
||||
|
||||
void insert_node (struct Node **head, int nodeValue) {
|
||||
struct Node *currentNode = malloc(sizeof *currentNode);
|
||||
currentNode->data = nodeValue;
|
||||
currentNode->next = (*head);
|
||||
|
||||
*head = currentNode;
|
||||
}
|
||||
|
|
|
@ -50,13 +50,15 @@
|
|||
// Les "symbolics" (les noms) des icônes devraient être déclarées une seule fois (ici))
|
||||
// de façon à ce qu'une seule variable soit utilisée pour les deux fonctions.
|
||||
|
||||
/* use this ?
|
||||
static const char *icon_name [3] = {
|
||||
"document-revert-rtl-symbolic",
|
||||
"edit-undo-symbolic",
|
||||
"view-refresh-symbolic"
|
||||
};
|
||||
// transtypage vers un pointeur depuis un entier de taille différente vvv TODO
|
||||
|
||||
const char *fsm_get_button_icon_name (int n) {return (const char*) icon_name [n];}
|
||||
*/
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -119,13 +121,16 @@ void fsm_reset_all_situations_transparencies_at_value (int value)
|
|||
|
||||
static void *list_displayables;
|
||||
|
||||
void *fsm_add_displayable (char *displayable_name)
|
||||
void fsm_add_displayable (char *displayable_name)
|
||||
{
|
||||
printf("fsm_add_displayable %p <<< %s (see prefer.c)\n", list_displayables, displayable_name);
|
||||
return NULL;
|
||||
printf("fsm_add_displayable %p <<< %s (see prefer.c)\n",
|
||||
list_displayables, 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("fsm prefer <> fsm_displayable_list_init() < in the fsm ? < TODO\n");}
|
||||
void fsm_displayable_list_init () { printf("src/fsm/prefer.c fsm_displayable_list_init()\n");}
|
||||
|
|
|
@ -67,10 +67,9 @@
|
|||
|
||||
static void *list_results;
|
||||
|
||||
void *fsm_add_result (char *result_name)
|
||||
void fsm_add_result (char *result_name)
|
||||
{
|
||||
printf("fsm_add_result %p <<< %s (see fsm.c)\n", list_results, result_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void fsm_results_list_init ()
|
||||
|
|
|
@ -153,10 +153,10 @@ int main (int argc, char **argv)
|
|||
|
||||
app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
|
||||
|
||||
fsm_init (); // fsm = finite state machine (see src/fsm/dispatch)
|
||||
fsm_init (); // fsm = finite state machine (see : src/fsm/dispatch.c)
|
||||
|
||||
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
|
||||
// on_windows_activation <> is in src/widget/dispatch
|
||||
// on_windows_activation <> see : src/widget/dispatch
|
||||
|
||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* # # ### ##### ###### ######## ######## */
|
||||
/* ## ## ### ##### ###### ######## ######## */
|
||||
/* # # # # ## ## ## # # */
|
||||
/* # # # # ## ## # # */
|
||||
/* # # # # ## ## #### # */
|
||||
/* # # # # # # # # # */
|
||||
/* # # # # # # # # # # */
|
||||
/* # # # # # # ## ## #### # # */
|
||||
/* ## ## # # ## ## ## # # */
|
||||
/* ## ## ### ###### ####### ######## # */
|
||||
|
@ -65,7 +65,7 @@ void on_windows_activation (GtkApplication *app)
|
|||
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
|
||||
text_window = GTK_WINDOW (gtk_application_window_new (app));
|
||||
|
||||
widget_design_main_window (main_window);
|
||||
widget_design_main_window (main_window); // def: widget/topbar/dispatch
|
||||
widget_design_dialog_window (main_window, dialog_window);
|
||||
widget_design_text_window (main_window, text_window);
|
||||
}
|
||||
|
|
|
@ -46,16 +46,6 @@ void widget_design_main_window (GtkWindow *main_window)
|
|||
window_design_topbar_left (topbar);
|
||||
window_design_topbar_right (topbar);
|
||||
|
||||
// use the next lineS to select the page that will be presented first
|
||||
// it triggers <=> signal.on_toggle_state_rule_data (a btt_NAME)
|
||||
|
||||
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_synth()), TRUE);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_data()), TRUE);
|
||||
|
||||
// THE LAST ONE IS THE WINNER (AND THE WINNER TAKES IT ALL !...)
|
||||
|
||||
gtk_window_present (GTK_WINDOW (main_window));
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,23 @@ void window_design_topbar_left (GtkWidget *header_bar)
|
|||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_RULES));
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_DATA));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* use the next lineS to select the page that will be presented first */
|
||||
/* it triggers <=> signal.on_toggle_state_rule_data (a btt_NAME) */
|
||||
/* and remember: */
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue