WIP: prêt pour un deuxième essai d'automate...
This commit is contained in:
parent
3d7167361a
commit
246c2f2cac
82
automaton.c
82
automaton.c
|
@ -1,56 +1,41 @@
|
|||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include <assert.h>
|
||||
#include "callback.h"
|
||||
#include "automaton.h"
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* S T A T E S */
|
||||
/******************************************************************************/
|
||||
|
||||
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
||||
/* (exec / edit)
|
||||
* X
|
||||
* (state / rules / data)
|
||||
* X
|
||||
* (measure / analyse / interpret)
|
||||
* X
|
||||
* (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 = INTER; // int get_status () {return status;}
|
||||
|
||||
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;
|
||||
case (INTER) : // BEGIN_TO_EXEC_STOP
|
||||
status = STATE; printf ("SWITCH_TO INTER\n");
|
||||
break;
|
||||
case (1) : // RUN_TO_EXEC
|
||||
status = EXEC_STOP;
|
||||
case (STATE) : // EXEC_STOP_TO_RUN
|
||||
status = RULES; printf ("SWITCH_TO STATE\n");
|
||||
break;
|
||||
case (2) : // EXEC_TO_INTER
|
||||
status = INTER;
|
||||
case (RULES) : // EXEC_RUN_TO_STOP
|
||||
status = DATA; printf ("SWITCH_TO RULES\n");
|
||||
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;
|
||||
case (DATA) : // EXEC_TO_INTER
|
||||
status = INTER; printf ("SWITCH_TO DATA\n");
|
||||
break;
|
||||
default : ;
|
||||
}
|
||||
|
@ -67,15 +52,42 @@ void SWITCH_TO (int asked) {
|
|||
|
||||
|
||||
/*
|
||||
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
|
||||
};
|
||||
|
||||
static int status = EXEC_STOP; // int get_status () {return status;}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
void set_status (int prescribed) {
|
||||
status = prescribed; if (0) printf ("status = %d\n", status);
|
||||
|
||||
switch (status) {
|
||||
case (0) : // EXEC_STOP
|
||||
case (0) : // EXEC_STOP DATA_ANALYSIS
|
||||
status = EXEC_RUN;
|
||||
break;
|
||||
case (1) : // EXEC_RUN
|
||||
// Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon)
|
||||
// Ici, il faudra prévenir l'utilisateur par une pop-up window : (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;
|
||||
|
|
|
@ -4,3 +4,6 @@
|
|||
void set_status (int prescribed);
|
||||
int get_status ();
|
||||
|
||||
enum choice { INTER, STATE, RULES, DATA };
|
||||
|
||||
void SWITCH_TO (int asked);
|
||||
|
|
|
@ -199,11 +199,13 @@ void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointe
|
|||
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
|
||||
printf ("callback.c (line 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
|
||||
SWITCH_TO (INTER);
|
||||
}
|
||||
|
||||
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
||||
gtk_window_close (GTK_WINDOW (data));
|
||||
printf ("callback.c (line 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
|
||||
SWITCH_TO (RULES);
|
||||
}
|
||||
|
||||
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) {
|
||||
|
|
Loading…
Reference in New Issue