111 lines
2.6 KiB
C
111 lines
2.6 KiB
C
#include <gtk-4.0/gtk/gtk.h>
|
|
#include <assert.h>
|
|
#include "callback.h"
|
|
|
|
|
|
/******************************************************************************/
|
|
/* S T A T E S */
|
|
/******************************************************************************/
|
|
|
|
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
|
|
|
enum { // S T A T E S
|
|
INTER,
|
|
EXEC_STOP,
|
|
EXEC_RUN,
|
|
EDIT_STATE,
|
|
EDIT_RULE,
|
|
MEASURE,
|
|
OBSERVE,
|
|
ANALYSE,
|
|
HELP,
|
|
CONFIGURE
|
|
};
|
|
|
|
static int status = EXEC_STOP; // int get_status () {return status;}
|
|
|
|
enum { // T R A N S I T I O N S
|
|
EXEC_TO_RUN,
|
|
RUN_TO_EXEC,
|
|
EXEC_TO_INTER,
|
|
INTER_TO_EDIT,
|
|
EDIT_TO_INTER,
|
|
INTER_TO_EXEC,
|
|
};
|
|
/******************************************************************************/
|
|
/* T R A N S I T I O N S */
|
|
/******************************************************************************/
|
|
|
|
void SWITCH_TO (int asked) {
|
|
switch (asked) {
|
|
case (0) : // EXEC_TO_RUN
|
|
status = EXEC_RUN;
|
|
break;
|
|
case (1) : // RUN_TO_EXEC
|
|
status = EXEC_STOP;
|
|
break;
|
|
case (2) : // EXEC_TO_INTER
|
|
status = INTER;
|
|
break;
|
|
case (3) : // EDIT_TO_INTER
|
|
// Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon)
|
|
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
|
|
status = INTER;
|
|
break;
|
|
default : ;
|
|
}
|
|
|
|
//q gtk_window_present (GTK_WINDOW (main_window));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
void set_status (int prescribed) {
|
|
status = prescribed; if (0) printf ("status = %d\n", status);
|
|
|
|
switch (status) {
|
|
case (0) : // EXEC_STOP
|
|
status = EXEC_RUN;
|
|
break;
|
|
case (1) : // EXEC_RUN
|
|
// Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon)
|
|
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
|
|
status = EXEC_STOP;
|
|
break;
|
|
case (2) : // EXEC_STOP_EDIT_STOP
|
|
status = EXEC_RUN_EDIT_RULE;
|
|
break;
|
|
case (3) : // EXEC_RUN_EDIT_RULE
|
|
status = EXEC_STOP_EDIT_RULE;
|
|
break;
|
|
case (4) : // EXEC_STOP_EDIT_MEASURE
|
|
status = EXEC_RUN_EDIT_MEASURE;
|
|
break;
|
|
case (5) : // EXEC_RUN_EDIT_MEASURE
|
|
status = EXEC_STOP_EDIT_MEASURE;
|
|
break;
|
|
case (6) : // EDIT_STATE
|
|
break;
|
|
case (7) : // EDIT_RULE
|
|
break;
|
|
case (8) : // OBSERVE
|
|
break;
|
|
case (9) : // INTERPRET
|
|
break;
|
|
case (10) : // HELP
|
|
break;
|
|
case (11) : // CONFIGURE
|
|
break;
|
|
case (12) : // OTHER
|
|
break;
|
|
default : ;
|
|
}
|
|
} */
|