Compare commits

..

No commits in common. "89bde1d284b1462948e36e3315dfcb98df540438" and "fe047b5c2f6f5bce5ba2670df2ee5d3b3de52e3b" have entirely different histories.

6 changed files with 86 additions and 61 deletions

View File

@ -42,18 +42,15 @@ enum fsm_choice_EXEC_EDIT { EXEC, EDIT }; // xor
enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor
enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor
#define n_objects 32
#define n_situations 128
int fsm_get_exec_edit ();
int fsm_get_state_rules_data ();
int fsm_get_store_restore_reset ();
int fsm_get_objects_box_reset_value ();
int fsm_get_situations_box_reset_value ();
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_reset_all_situations_transparencies_at_value (int value);

View File

@ -33,11 +33,3 @@
#include <gtk-4.0/gtk/gtk.h>
void print_sth(char *msg);
struct preferences {
int id;
};
void pref_store_objects_transparencies_values ();
void pref_restore_previous_objects_transparencies_values ();
void pref_reset_objects_transparencies_values();

View File

@ -80,7 +80,7 @@ void on_toggle_state_rules_data (GtkWidget *btt_STATE_RULES_DATA, gpointer user_
/*************n_objects*****************************************************************/
/******************************************************************************/
/* D I A L O G W I N D O W */
/******************************************************************************/

View File

@ -31,6 +31,9 @@
#pragma once
#include <gtk-4.0/gtk/gtk.h>
#define n_objects 32
#define n_situations 128
/******************************************************************************/
/* W I N D O W S */
/******************************************************************************/

110
src/fsm.c
View File

@ -41,92 +41,136 @@ static int choice_EXEC_EDIT = EXEC;
static int choice_STATE_RULES_DATA = STATE;
static int choice_STORE_RESTORE_RESET = STORE;
int fsm_get_exec_edit () {return choice_EXEC_EDIT;}
int fsm_get_state_rules_data () {return choice_STATE_RULES_DATA;}
int fsm_get_store_restore_reset () {return choice_STORE_RESTORE_RESET;}
static int choice_OBJECTS_box_RESET_VALUE = -1;
static int choice_SITUATIONS_box_RESET_VALUE = -1;
/******************************************************************************/
/* T R A N S I T I O N S */
/******************************************************************************/
static void debug_printing (int choice, int value, int sub_automaton);
static void debug_printing (int value, int sub_automaton);
void fsm_set_exec_edit (int choice)
void fsm_set_exec_edit (int value)
{
if (choice_EXEC_EDIT != choice) {
debug_printing (choice, 0, 0); // EXEC_EDIT is sub_automaton 0
choice_EXEC_EDIT = choice;
if (choice_EXEC_EDIT != value) {
debug_printing (value, 0); // EXEC_EDIT is sub_automaton 0
choice_EXEC_EDIT = value;
}
}
void fsm_set_state_rules_data (int choice)
void fsm_set_state_rules_data (int value)
{
if (choice_STATE_RULES_DATA != choice) {
debug_printing (choice, 0, 1); // STATE_RULES_DATA is sub_automaton 1
choice_STATE_RULES_DATA = choice;
if (choice_STATE_RULES_DATA != value) {
debug_printing (value, 1); // STATE_RULES_DATA is sub_automaton 1
choice_STATE_RULES_DATA = value;
}
}
void fsm_set_store_restore_reset (int choice, int value)
void fsm_set_store_restore_reset (int target, int value)
{
choice_STORE_RESTORE_RESET = choice;
switch (choice) {
case (STORE) : printf("STORE current values in MEM ");
pref_store_objects_transparencies_values (); break;
case (RESTORE) : printf("RESTORE values from MEM "); break;
case (RESET) : printf("RESET current values from [value] "); break;
printf("fsm_set_store_restore_reset(%d,%3d) > ", target, value);
switch (target) {
case (STORE) : printf("STORE\n"); break;
case (RESTORE) : printf("RESTORE\n"); break;
case (RESET) : printf("RESET\n"); break;
default : printf("default in signal.switch_store_restore_reset()\n");
}
debug_printing (choice, value, 2); // STORE_RESTORE_RESET is sub_automaton 2
// debug_printing (target, 2); // STORE_RESTORE_RESET is sub_automaton 2
// choice_STORE_RESTORE_RESET = value;
}
void fsm_restore_all_objects_transparencies_from_mem (int value)
{
print_sth("Officially introducing : ' P R E F E R E N C E S' !");
debug_printing (value, 2); // OBJECTS_box_RESET_VALUES is sub_automaton 2
}
void fsm_store_all_objects_transparencies_current_values (int value)
{
debug_printing (value, 3); // OBJECTS_box_STORE_VALUES is sub_automaton 3
}
void fsm_reset_all_objects_transparencies_at_value (int value)
{
// if (choice_OBJECTS_box_RESET_VALUE != value) { << NON: Je veux pouvoir
// d'emblée tout remettre à zéro sans avoir eu à manipuler le curseur auparavant.
// Tant pis si cette fonction s'exécute parce qu'un reset inutile a été demandé.
debug_printing (value, 4); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
widget_reset_all_objects_transparencies_to_value (value);
}
// ---------------------- S I T U A T I O N S ---------------------------//
static int choice_SITUATIONS_box_RESET_VALUE = -1;
void fsm_reset_all_situations_transparencies_at_value (int value)
{
debug_printing (choice_SITUATIONS_box_RESET_VALUE, value, 3);
// SITUATIONS_box_RESTORE_VALUES is sub_automaton 3
debug_printing (value, 5); // SITUATIONS_box_RESTORE_VALUES is sub_automaton 4
choice_SITUATIONS_box_RESET_VALUE = value;
widget_reset_all_situations_transparencies_to_value (value);
}
void fsm_set_situations_box_reset_value (int value)
{
if (choice_SITUATIONS_box_RESET_VALUE != value) {
debug_printing (value, 5); // SITUATIONS_box_RESET_VALUE is sub_automaton 5
choice_SITUATIONS_box_RESET_VALUE = value;
}
}
int fsm_get_exec_edit () {return choice_EXEC_EDIT;}
int fsm_get_state_rules_data () {return choice_STATE_RULES_DATA;}
int fsm_get_objects_box_reset_value () {return choice_OBJECTS_box_RESET_VALUE;}
int fsm_get_situations_box_reset_value () {return choice_SITUATIONS_box_RESET_VALUE;}
/******************************************************************************/
/* D E B U G G E R S */
/***************************************************************************ù***/
/******************************************************************************/
static char *tab_0 [] = { "EXEC", "EDIT" };
static char *tab_1 [] = { "STATE", "RULES", "DATA" };
static char *tab_2 [] = { "STORE", "RESTORE", "RESET" };
static void debug_printing (int choice, int value, int sub_automaton)
static void debug_printing (int value, int sub_automaton)
{
switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and
// sub_automaton 1 is STATE_RULES_DATA
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_0 [value],
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]);
tab_1 [value]);
break;
case (2) : printf("fsm_set_store_restore_reset <> choice = %s\n",
case (2) : printf("fsm_set_store_restore_reset <> target = %s\n",
tab_2 [choice_STORE_RESTORE_RESET]);
break;
case (3) : printf("fsm_reset_all_situations_transparencies_at_value : %3d\n", value);
break;
default : printf("default in automaton.debug_printing()\n");
}

View File

@ -33,15 +33,4 @@
#include "../include/signal.h"
#include "../include/widget.h"
void print_sth(char *msg) {printf("%s\n", msg);}
struct preferences *pref;
void pref_store_objects_transparencies_values()
{
printf("pref_store_objects_transparencies_values n_objects = %d\n", n_objects);
}
void pref_restore_previous_objects_transparencies_values() {}
void pref_reset_objects_transparencies_values() {}
void print_sth(char *msg){printf("%s\n", msg);}