2024-06-02 22:49:16 +02:00
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
|
|
|
#include <assert.h>
|
2024-06-03 05:46:01 +02:00
|
|
|
#include "callback.h"
|
2024-06-13 00:08:10 +02:00
|
|
|
#include "automaton.h"
|
2024-06-02 22:49:16 +02:00
|
|
|
|
|
|
|
|
2024-06-04 06:25:47 +02:00
|
|
|
/******************************************************************************/
|
2024-06-09 11:23:42 +02:00
|
|
|
/* S T A T E S */
|
2024-06-04 06:25:47 +02:00
|
|
|
/******************************************************************************/
|
2024-06-03 05:46:01 +02:00
|
|
|
|
2024-06-16 00:06:49 +02:00
|
|
|
/* (exec / edit) < MODE
|
2024-06-15 23:29:17 +02:00
|
|
|
* X
|
2024-06-16 06:38:14 +02:00
|
|
|
* (state / rules / data) < VIEW
|
2024-06-15 23:29:17 +02:00
|
|
|
* X
|
|
|
|
* (measure / analyse / interpret)
|
|
|
|
* X
|
|
|
|
* (read / write)
|
2024-06-13 00:08:10 +02:00
|
|
|
*/
|
2024-06-03 05:46:01 +02:00
|
|
|
|
2024-06-16 00:06:49 +02:00
|
|
|
static int mode = RUN;
|
|
|
|
void set_mode (int prescribed) {mode = prescribed;}
|
|
|
|
int get_mode () {return mode;}
|
|
|
|
|
2024-06-16 06:38:14 +02:00
|
|
|
static int view = INTER; // int get_view () {return view;}
|
|
|
|
void set_view (int prescribed) {view = prescribed;}
|
|
|
|
int get_view () {return view;}
|
2024-06-16 00:06:49 +02:00
|
|
|
|
2024-06-04 06:25:47 +02:00
|
|
|
|
|
|
|
/******************************************************************************/
|
2024-06-09 11:23:42 +02:00
|
|
|
/* T R A N S I T I O N S */
|
2024-06-04 06:25:47 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
|
2024-06-11 00:11:50 +02:00
|
|
|
void SWITCH_TO (int asked) {
|
2024-06-09 15:55:36 +02:00
|
|
|
switch (asked) {
|
2024-06-15 23:29:17 +02:00
|
|
|
case (INTER) :
|
2024-06-16 06:38:14 +02:00
|
|
|
view = INTER; printf ("SWITCH_TO INTER\n");
|
2024-06-09 15:55:36 +02:00
|
|
|
break;
|
2024-06-15 23:29:17 +02:00
|
|
|
case (STATE) : // BEGIN_TO_EXEC_STOP
|
2024-06-16 06:38:14 +02:00
|
|
|
view = STATE; printf ("SWITCH_TO STATE\n");
|
2024-06-11 00:11:50 +02:00
|
|
|
break;
|
2024-06-15 23:29:17 +02:00
|
|
|
case (RULES) : // EXEC_STOP_TO_RUN
|
2024-06-16 06:38:14 +02:00
|
|
|
view = RULES; printf ("SWITCH_TO RULES\n");
|
2024-06-11 00:11:50 +02:00
|
|
|
break;
|
2024-06-15 23:29:17 +02:00
|
|
|
case (DATA) : // EXEC_RUN_TO_STOP
|
2024-06-16 06:38:14 +02:00
|
|
|
view = DATA; printf ("SWITCH_TO DATA\n");
|
2024-06-09 15:55:36 +02:00
|
|
|
break;
|
|
|
|
default : ;
|
|
|
|
}
|
2024-06-11 00:11:50 +02:00
|
|
|
|
|
|
|
//q gtk_window_present (GTK_WINDOW (main_window));
|
2024-06-09 15:55:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2024-06-13 00:08:10 +02:00
|
|
|
enum { // S T A T E S
|
|
|
|
INTER,
|
|
|
|
EXEC_STOP,
|
|
|
|
EXEC_RUN,
|
|
|
|
EDIT_STATE,
|
|
|
|
EDIT_RULES_TREE,
|
|
|
|
EDIT_RULE,
|
|
|
|
EDIT_MEASURE,
|
|
|
|
OBSERVE,
|
|
|
|
ANALYSE,
|
|
|
|
HELP,
|
|
|
|
CONFIGURE
|
|
|
|
};
|
|
|
|
|
2024-06-16 06:38:14 +02:00
|
|
|
static int view = EXEC_STOP; // int get_view () {return view;}
|
2024-06-13 00:08:10 +02:00
|
|
|
|
|
|
|
enum { // T R A N S I T I O N S
|
|
|
|
BEGIN_TO_EXEC_STOP
|
|
|
|
EXEC_STOP_TO_RUN,
|
|
|
|
EXEC_RUN_TO_STOP,
|
|
|
|
EXEC_TO_INTER,
|
|
|
|
INTER_TO_EDIT,
|
|
|
|
EDIT_TO_INTER,
|
|
|
|
INTER_TO_EXEC,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-06-16 06:38:14 +02:00
|
|
|
void set_view (int prescribed) {
|
|
|
|
view = prescribed; if (0) printf ("view = %d\n", view);
|
2024-06-03 05:46:01 +02:00
|
|
|
|
2024-06-16 06:38:14 +02:00
|
|
|
switch (view) {
|
2024-06-13 00:08:10 +02:00
|
|
|
case (0) : // EXEC_STOP DATA_ANALYSIS
|
2024-06-16 06:38:14 +02:00
|
|
|
view = EXEC_RUN;
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (1) : // EXEC_RUN
|
2024-06-13 00:08:10 +02:00
|
|
|
// Ici, il faudra prévenir l'utilisateur par une pop-up window : (sauvegarde automatique sinon)
|
2024-06-09 15:55:36 +02:00
|
|
|
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
|
2024-06-16 06:38:14 +02:00
|
|
|
view = EXEC_STOP;
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (2) : // EXEC_STOP_EDIT_STOP
|
2024-06-16 06:38:14 +02:00
|
|
|
view = EXEC_RUN_EDIT_RULE;
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (3) : // EXEC_RUN_EDIT_RULE
|
2024-06-16 06:38:14 +02:00
|
|
|
view = EXEC_STOP_EDIT_RULE;
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (4) : // EXEC_STOP_EDIT_MEASURE
|
2024-06-16 06:38:14 +02:00
|
|
|
view = EXEC_RUN_EDIT_MEASURE;
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (5) : // EXEC_RUN_EDIT_MEASURE
|
2024-06-16 06:38:14 +02:00
|
|
|
view = EXEC_STOP_EDIT_MEASURE;
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (6) : // EDIT_STATE
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (7) : // EDIT_RULE
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (8) : // OBSERVE
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (9) : // INTERPRET
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (10) : // HELP
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (11) : // CONFIGURE
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
2024-06-09 15:55:36 +02:00
|
|
|
case (12) : // OTHER
|
2024-06-09 13:27:15 +02:00
|
|
|
break;
|
|
|
|
default : ;
|
|
|
|
}
|
2024-06-09 15:55:36 +02:00
|
|
|
} */
|