Cleaning static debug_printing() in fsm.c using static char *tab[] = { STATE, RULES, DATA }

This commit is contained in:
Jean Sirmai 2024-07-19 12:00:46 +02:00
parent 8e0ef0fdbd
commit 6142fac0d4
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 16 additions and 33 deletions

View File

@ -80,50 +80,33 @@ void fsm_set_SITUATIONS_box_RESET_VALUE (int value)
}
}
/******************************************************************************/
/* G E T T E R S & D E B U G G E R S */
/******************************************************************************/
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;}
static char *fsm_get_str_EXEC_EDIT (int value)
{
switch (value) {
case (EXEC) : return "EXEC";
case (EDIT) : return "EDIT";
default : printf("default in automaton.fsm_get_EXEC_EDIT ()\n"); return NULL;
}
}
static char *fsm_get_str_STATE_RULES_DATA (int value)
{
switch (value) {
case (STATE) : return "STATE";
case (RULES) : return "RULES";
case (DATA) : return "DATA";
default : printf("default in automaton.fsm_get_STATE_RULES_DATA ()\n"); return NULL;
}
}
/******************************************************************************/
/* D E B U G G E R S */
/******************************************************************************/
static char *tab[] = { "STATE", "RULES", "DATA" };
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",
fsm_get_str_EXEC_EDIT (choice_EXEC_EDIT),
fsm_get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
fsm_get_str_EXEC_EDIT (value),
fsm_get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA));
tab [choice_EXEC_EDIT],
tab [choice_STATE_RULES_DATA],
tab [value],
tab [choice_STATE_RULES_DATA]);
break;
case (1) : printf("switch %5s x %5s > %5s x %5s\n",
fsm_get_str_EXEC_EDIT (choice_EXEC_EDIT),
fsm_get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
fsm_get_str_EXEC_EDIT (choice_EXEC_EDIT),
fsm_get_str_STATE_RULES_DATA (value));
tab [choice_EXEC_EDIT],
tab [choice_STATE_RULES_DATA],
tab [choice_EXEC_EDIT],
tab [value]);
break;
case (2) : printf("automat.fsm_set_OBJECTS_box_RESET_VALUE : %2d > %2d\n",
fsm_get_OBJECTS_box_RESET_VALUE(), value);

View File

@ -101,8 +101,8 @@
* Exemple, muni des deux 'sous-automates' :
* > { EXEC, EDIT }; // xor
* > { STATE, RULES, DATA }; // xor
* la 'state machine' peut se trouver dans 2 x 3 = 6 états.
* (voir automat.h lignes 39-40)
* la 'finite state machine' peut se trouver dans 2 x 3 = 6 états.
* (voir fsm.h lignes 40-41)
*
*
* Les grandes fonctions du client seront lancées par cette state machine :