summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNélio Laranjeiro2008-03-19 00:27:23 +0100
committerNélio Laranjeiro2008-03-19 00:27:23 +0100
commit1f9e5a0242b608ea941d6f8ea32fdc89c60224c1 (patch)
treee636167be96206e63fefa56aad37772a394bbcc5 /digital
parent164ac3a34cbac441e82b256c97cb8784ea9d482c (diff)
First dfagen for the getsamples fsm. This is only a first shoot, all the
transitions are not presents.
Diffstat (limited to 'digital')
-rw-r--r--digital/io/src/getsamples/Makefile23
-rw-r--r--digital/io/src/getsamples/getSamplesFsm.conf5
-rw-r--r--digital/io/src/getsamples/getSamplesFsm.fsm34
-rw-r--r--digital/io/src/getsamples/getsamples.c71
-rw-r--r--digital/io/src/getsamples/getsamples.dot11
-rw-r--r--digital/io/src/getsamples/getsamples.h77
-rw-r--r--digital/io/src/getsamples/getsamples_cb.h52
-rw-r--r--digital/io/src/getsamples/getsamples_cb_skel.c64
8 files changed, 337 insertions, 0 deletions
diff --git a/digital/io/src/getsamples/Makefile b/digital/io/src/getsamples/Makefile
new file mode 100644
index 00000000..41e7f96f
--- /dev/null
+++ b/digital/io/src/getsamples/Makefile
@@ -0,0 +1,23 @@
+CFLAGS = -O2 -Wall
+
+all: getsamples getsamples.png
+
+getsamples: getsamples.o getsamples_cb.o
+
+getsamples.c: getSamplesFsm.fsm getSamplesFsm.conf
+ python ../../../../tools/dfagen/dfagen.py -o c -d getSamplesFsm.fsm -c getSamplesFsm.conf -p getsamples
+
+getsamples.h getsamples_cb_skel.c getsamples_cb.h: getsamples.c
+
+getsamples.o: getsamples_cb.h getsamples.h
+getsamples_cb.o: getsamples_cb.h getsamples.h
+
+%.dot: %.fsm
+ python ../../../../tools/dfagen/dfagen.py -o dot -d $< -p $(@:%.dot=%)
+
+%.png: %.dot
+ dot -Tpng $< -o $@
+
+clean:
+ rm -f getsamples getsamples.o getsamples_cb.o getsamples.c getsamples.h getsamples_cb_skel.c getsamples_cb.h getsamples_cb.c
+ rm -f getsamples.dot getsamples.png
diff --git a/digital/io/src/getsamples/getSamplesFsm.conf b/digital/io/src/getsamples/getSamplesFsm.conf
new file mode 100644
index 00000000..bae8f698
--- /dev/null
+++ b/digital/io/src/getsamples/getSamplesFsm.conf
@@ -0,0 +1,5 @@
+[user]
+type = getsamples_t
+type-forward-decl = typedef struct getsamples_t getsamples_t;
+type-decl = struct getsamples_t { getsamples_state_t fsm; };
+field = fsm
diff --git a/digital/io/src/getsamples/getSamplesFsm.fsm b/digital/io/src/getsamples/getSamplesFsm.fsm
new file mode 100644
index 00000000..3ffc8377
--- /dev/null
+++ b/digital/io/src/getsamples/getSamplesFsm.fsm
@@ -0,0 +1,34 @@
+#FSM get samples
+get_samples
+
+States:
+ GO_TO_POSITION
+ PREPARE_ARM
+ FORWARD_CONTROL
+ PREPARE_CLASSIFIER
+ LOAD_SAMPLES
+
+Events:
+ move_finished
+ move_blocked
+ arm_prepared
+ ready_to_load
+ classifer_prepared
+ sample_loaded
+
+GO_TO_POSITION:
+ move_finished -> FORWARD_CONTROL
+ Go to the position desired, it is very near the position of the distributor in case it is a ice distributor or sample distributor.
+ move_blocked -> .
+
+FORWARD_CONTROL:
+ move_finished -> PREPARE_ARM
+ The position is reached the arm shall be seted to the position disired.
+
+PREPARE_ARM:
+ arm_prepared -> PREPARE_CLASSIFIER
+ Prepare the arm to load the samples.
+
+PREPARE_CLASSIFIER:
+ classifer_prepared -> LOAD_SAMPLES
+ Load some samples.
diff --git a/digital/io/src/getsamples/getsamples.c b/digital/io/src/getsamples/getsamples.c
new file mode 100644
index 00000000..6044d092
--- /dev/null
+++ b/digital/io/src/getsamples/getsamples.c
@@ -0,0 +1,71 @@
+/*
+ * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT!
+ *
+ * get_samples
+ *
+ *
+ */
+#include "getsamples_cb.h"
+#include <stddef.h>
+#include <assert.h>
+
+struct getsamples_t { getsamples_state_t fsm; };
+
+/* get_samples transition table. */
+static const getsamples_transition_t
+getsamples_transition_table[GETSAMPLES_STATE_NB][GETSAMPLES_EVENT_NB] = {
+ { getsamples__PREPARE_ARM__arm_prepared,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL },
+ { NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL },
+ { NULL,
+ getsamples__FORWARD_CONTROL__move_finished,
+ NULL,
+ NULL,
+ NULL,
+ NULL },
+ { NULL,
+ getsamples__GO_TO_POSITION__move_finished,
+ NULL,
+ getsamples__GO_TO_POSITION__move_blocked,
+ NULL,
+ NULL },
+ { NULL,
+ NULL,
+ NULL,
+ NULL,
+ getsamples__PREPARE_CLASSIFIER__classifer_prepared,
+ NULL },
+};
+
+/* Initialise get_samples automaton. */
+void
+getsamples_init (getsamples_t *user)
+{
+ user->fsm = GETSAMPLES_STATE_GO_TO_POSITION;
+}
+
+/* Handle events on get_samples automaton. */
+void
+getsamples_handle_event (getsamples_t *user, getsamples_event_t event)
+{
+ assert (user);
+ getsamples_state_t state = user->fsm;
+ assert (state < GETSAMPLES_STATE_NB);
+ assert (event < GETSAMPLES_EVENT_NB);
+ getsamples_transition_t tr = getsamples_transition_table[state][event];
+ assert (tr);
+ getsamples_branch_t br = tr (user);
+ assert (((br >> 16) & 0xff) == state);
+ assert (((br >> 8) & 0xff) == event);
+ user->fsm = br & 0xff;
+}
+
diff --git a/digital/io/src/getsamples/getsamples.dot b/digital/io/src/getsamples/getsamples.dot
new file mode 100644
index 00000000..34a724fe
--- /dev/null
+++ b/digital/io/src/getsamples/getsamples.dot
@@ -0,0 +1,11 @@
+digraph getsamples { PREPARE_ARM
+ PREPARE_ARM -> PREPARE_CLASSIFIER [ label = "arm_prepared" ];
+ LOAD_SAMPLES
+ FORWARD_CONTROL
+ FORWARD_CONTROL -> PREPARE_ARM [ label = "move_finished" ];
+ GO_TO_POSITION
+ GO_TO_POSITION -> GO_TO_POSITION [ label = "move_blocked" ];
+ GO_TO_POSITION -> FORWARD_CONTROL [ label = "move_finished" ];
+ PREPARE_CLASSIFIER
+ PREPARE_CLASSIFIER -> LOAD_SAMPLES [ label = "classifer_prepared" ];
+} \ No newline at end of file
diff --git a/digital/io/src/getsamples/getsamples.h b/digital/io/src/getsamples/getsamples.h
new file mode 100644
index 00000000..bdf5e0f7
--- /dev/null
+++ b/digital/io/src/getsamples/getsamples.h
@@ -0,0 +1,77 @@
+#ifndef getsamples_h
+#define getsamples_h
+/*
+ * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT!
+ *
+ * get_samples
+ *
+ *
+ */
+
+typedef struct getsamples_t getsamples_t;
+
+/* get_samples states. */
+enum getsamples_state_t
+{
+ GETSAMPLES_STATE_PREPARE_ARM,
+ GETSAMPLES_STATE_LOAD_SAMPLES,
+ GETSAMPLES_STATE_FORWARD_CONTROL,
+ GETSAMPLES_STATE_GO_TO_POSITION,
+ GETSAMPLES_STATE_PREPARE_CLASSIFIER,
+ GETSAMPLES_STATE_NB
+};
+typedef enum getsamples_state_t getsamples_state_t;
+
+/* get_samples events. */
+enum getsamples_event_t
+{
+ GETSAMPLES_EVENT_arm_prepared,
+ GETSAMPLES_EVENT_move_finished,
+ GETSAMPLES_EVENT_sample_loaded,
+ GETSAMPLES_EVENT_move_blocked,
+ GETSAMPLES_EVENT_classifer_prepared,
+ GETSAMPLES_EVENT_ready_to_load,
+ GETSAMPLES_EVENT_NB
+};
+typedef enum getsamples_event_t getsamples_event_t;
+
+/* This macro enables checks for branches used in the wrong state/event
+ * combination. */
+#define _BRANCH(state, event, to) \
+ ((GETSAMPLES_STATE_ ## state) << 16 \
+ | (GETSAMPLES_EVENT_ ## event) << 8 \
+ | (GETSAMPLES_STATE_ ## to))
+
+/* get_samples branches. */
+enum getsamples_branch_t
+{
+ GETSAMPLES_BRANCH__PREPARE_ARM__arm_prepared__ = _BRANCH (PREPARE_ARM, arm_prepared, PREPARE_CLASSIFIER),
+ GETSAMPLES_BRANCH__FORWARD_CONTROL__move_finished__ = _BRANCH (FORWARD_CONTROL, move_finished, PREPARE_ARM),
+ GETSAMPLES_BRANCH__GO_TO_POSITION__move_blocked__ = _BRANCH (GO_TO_POSITION, move_blocked, GO_TO_POSITION),
+ GETSAMPLES_BRANCH__GO_TO_POSITION__move_finished__ = _BRANCH (GO_TO_POSITION, move_finished, FORWARD_CONTROL),
+ GETSAMPLES_BRANCH__PREPARE_CLASSIFIER__classifer_prepared__ = _BRANCH (PREPARE_CLASSIFIER, classifer_prepared, LOAD_SAMPLES),
+};
+typedef enum getsamples_branch_t getsamples_branch_t;
+
+#undef _BRANCH
+
+/* get_samples transition type. */
+typedef getsamples_branch_t (*getsamples_transition_t) (getsamples_t *user);
+
+/* Initialise get_samples automaton. */
+void
+getsamples_init (getsamples_t *user);
+
+/* Handle events on get_samples automaton. */
+void
+getsamples_handle_event (getsamples_t *user, getsamples_event_t event);
+
+/* Value to return to follow the only branch. */
+#define getsamples_next(state, event) \
+ GETSAMPLES_BRANCH__ ## state ## __ ## event ## __
+
+/* Value to return to follow a given branch. */
+#define getsamples_next_branch(state, event, branch) \
+ GETSAMPLES_BRANCH__ ## state ## __ ## event ## __ ## branch
+
+#endif /* getsamples_h */
diff --git a/digital/io/src/getsamples/getsamples_cb.h b/digital/io/src/getsamples/getsamples_cb.h
new file mode 100644
index 00000000..e47b7abe
--- /dev/null
+++ b/digital/io/src/getsamples/getsamples_cb.h
@@ -0,0 +1,52 @@
+#ifndef getsamples_cb_h
+#define getsamples_cb_h
+/*
+ * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT!
+ *
+ * get_samples callbacks declaration.
+ *
+ *
+ */
+
+#include "getsamples.h"
+
+/*
+ * PREPARE_ARM =arm_prepared=>
+ * => PREPARE_CLASSIFIER
+ * Prepare the arm to load the samples.
+ */
+getsamples_branch_t
+getsamples__PREPARE_ARM__arm_prepared (getsamples_t *user);
+
+/*
+ * FORWARD_CONTROL =move_finished=>
+ * => PREPARE_ARM
+ * The position is reached the arm shall be seted to the position disired.
+ */
+getsamples_branch_t
+getsamples__FORWARD_CONTROL__move_finished (getsamples_t *user);
+
+/*
+ * GO_TO_POSITION =move_blocked=>
+ * => GO_TO_POSITION
+ */
+getsamples_branch_t
+getsamples__GO_TO_POSITION__move_blocked (getsamples_t *user);
+
+/*
+ * GO_TO_POSITION =move_finished=>
+ * => FORWARD_CONTROL
+ * Go to the position desired, it is very near the position of the distributor in case it is a ice distributor or sample distributor.
+ */
+getsamples_branch_t
+getsamples__GO_TO_POSITION__move_finished (getsamples_t *user);
+
+/*
+ * PREPARE_CLASSIFIER =classifer_prepared=>
+ * => LOAD_SAMPLES
+ * Load some samples.
+ */
+getsamples_branch_t
+getsamples__PREPARE_CLASSIFIER__classifer_prepared (getsamples_t *user);
+
+#endif /* getsamples_cb_h */
diff --git a/digital/io/src/getsamples/getsamples_cb_skel.c b/digital/io/src/getsamples/getsamples_cb_skel.c
new file mode 100644
index 00000000..997042b0
--- /dev/null
+++ b/digital/io/src/getsamples/getsamples_cb_skel.c
@@ -0,0 +1,64 @@
+/*
+ * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT!
+ *
+ * Skeleton for get_samples callbacks implementation.
+ *
+ *
+ */
+#include "getsamples_cb.h"
+
+/*
+ * PREPARE_ARM =arm_prepared=>
+ * => PREPARE_CLASSIFIER
+ * Prepare the arm to load the samples.
+ */
+getsamples_branch_t
+getsamples__PREPARE_ARM__arm_prepared (getsamples_t *user)
+{
+ return getsamples_next (PREPARE_ARM, arm_prepared);
+}
+
+/*
+ * FORWARD_CONTROL =move_finished=>
+ * => PREPARE_ARM
+ * The position is reached the arm shall be seted to the position disired.
+ */
+getsamples_branch_t
+getsamples__FORWARD_CONTROL__move_finished (getsamples_t *user)
+{
+ return getsamples_next (FORWARD_CONTROL, move_finished);
+}
+
+/*
+ * GO_TO_POSITION =move_blocked=>
+ * => GO_TO_POSITION
+ */
+getsamples_branch_t
+getsamples__GO_TO_POSITION__move_blocked (getsamples_t *user)
+{
+ return getsamples_next (GO_TO_POSITION, move_blocked);
+}
+
+/*
+ * GO_TO_POSITION =move_finished=>
+ * => FORWARD_CONTROL
+ * Go to the position desired, it is very near the position of the distributor in case it is a ice distributor or sample distributor.
+ */
+getsamples_branch_t
+getsamples__GO_TO_POSITION__move_finished (getsamples_t *user)
+{
+ return getsamples_next (GO_TO_POSITION, move_finished);
+}
+
+/*
+ * PREPARE_CLASSIFIER =classifer_prepared=>
+ * => LOAD_SAMPLES
+ * Load some samples.
+ */
+getsamples_branch_t
+getsamples__PREPARE_CLASSIFIER__classifer_prepared (getsamples_t *user)
+{
+ return getsamples_next (PREPARE_CLASSIFIER, classifer_prepared);
+}
+
+