summaryrefslogtreecommitdiff
path: root/tools/dfagen/examples
diff options
context:
space:
mode:
authorNicolas Schodet2009-05-08 23:07:25 +0200
committerNicolas Schodet2009-05-08 23:07:25 +0200
commitb566e4bcd0c7cb3c90ad941b37db223134090ded (patch)
tree7d3f24a25860e17e7fa9cd017ad2d8bd8c0bd227 /tools/dfagen/examples
parent6b3d5061623a35c96e66e25fc14af6a9323f81b0 (diff)
* tools/dfagen:
- added state attributes. - added support for more than one initial state. - added table of transitions with only one default branch. - added state and event template parameter. - added --output-dir. - make template directory relative to config file. - more options checking. - added transition attributes and callback definition. - conserve input file order in output. - added --dump and more option checking. - fixed missing newline.
Diffstat (limited to 'tools/dfagen/examples')
-rw-r--r--tools/dfagen/examples/ex1_cb.c.patch2
-rw-r--r--tools/dfagen/examples/ex2.fsm8
-rw-r--r--tools/dfagen/examples/ex2_cb.c.patch50
-rw-r--r--tools/dfagen/examples/tpl/template_defs.h9
-rw-r--r--tools/dfagen/examples/tpl/template_table.h16
5 files changed, 51 insertions, 34 deletions
diff --git a/tools/dfagen/examples/ex1_cb.c.patch b/tools/dfagen/examples/ex1_cb.c.patch
index bc4cc924..48941dc5 100644
--- a/tools/dfagen/examples/ex1_cb.c.patch
+++ b/tools/dfagen/examples/ex1_cb.c.patch
@@ -7,7 +7,7 @@
+#include <stdio.h>
+
+struct door_t { ex1_state_t fsm; };
-+
++
/*
* OPEN =close=>
* => CLOSED
diff --git a/tools/dfagen/examples/ex2.fsm b/tools/dfagen/examples/ex2.fsm
index e290c05c..8142ad88 100644
--- a/tools/dfagen/examples/ex2.fsm
+++ b/tools/dfagen/examples/ex2.fsm
@@ -3,9 +3,9 @@ Example 2
A barman robot.
States:
- IDLE
+ IDLE [in=hello out=goodbye]
waiting for a command
- DROPPING_ICE
+ DROPPING_ICE [in=hi]
FILLING_GLASS
Events:
@@ -15,13 +15,13 @@ Events:
replace bottle
IDLE:
- command: with ice -> DROPPING_ICE
+ command: with ice -> DROPPING_ICE [ex2_idle_command]
open the ice door
command: without ice -> FILLING_GLASS
start filling
command: empty bottle -> .
display "empty bottle, please replace it"
- replace bottle -> .
+ replace bottle -> . [ex2_idle_replace]
reset glass counter
DROPPING_ICE:
diff --git a/tools/dfagen/examples/ex2_cb.c.patch b/tools/dfagen/examples/ex2_cb.c.patch
index f1402431..09f03791 100644
--- a/tools/dfagen/examples/ex2_cb.c.patch
+++ b/tools/dfagen/examples/ex2_cb.c.patch
@@ -1,5 +1,5 @@
---- ex2_cb_skel.c 2008-01-06 18:02:50.000000000 +0100
-+++ ex2_cb.c 2008-01-06 18:02:50.000000000 +0100
+--- ex2_cb_skel.c 2008-06-10 17:47:09.000000000 +0200
++++ ex2_cb.c 2008-06-10 17:47:09.000000000 +0200
@@ -6,6 +6,9 @@
* A barman robot.
*/
@@ -9,31 +9,14 @@
+#include <stdio.h>
/*
- * FILLING_GLASS =command=>
-@@ -37,6 +40,7 @@
+ * IDLE =command=>
+@@ -19,9 +22,25 @@
ex2_branch_t
- ex2__FILLING_GLASS__glass_filled (robot_t *user)
- {
-+ puts ("stop filling");
- return ex2_next (FILLING_GLASS, glass_filled);
- }
-
-@@ -48,6 +52,8 @@
- ex2_branch_t
- ex2__IDLE__replace_bottle (robot_t *user)
- {
-+ puts ("reset glass counter");
-+ user->bottle = 3;
- return ex2_next (IDLE, replace_bottle);
- }
-
-@@ -63,9 +69,25 @@
- ex2_branch_t
- ex2__IDLE__command (robot_t *user)
+ ex2_idle_command (robot_t *user)
{
-- return ex2_next_branch (IDLE, command, empty_bottle);
-- return ex2_next_branch (IDLE, command, without_ice);
- return ex2_next_branch (IDLE, command, with_ice);
+- return ex2_next_branch (IDLE, command, without_ice);
+- return ex2_next_branch (IDLE, command, empty_bottle);
+ if (user->bottle)
+ {
+ user->bottle--;
@@ -56,7 +39,16 @@
}
/*
-@@ -99,6 +121,8 @@
+@@ -32,6 +51,8 @@
+ ex2_branch_t
+ ex2_idle_replace (robot_t *user)
+ {
++ puts ("reset glass counter");
++ user->bottle = 3;
+ return ex2_next (IDLE, replace_bottle);
+ }
+
+@@ -44,6 +65,8 @@
ex2_branch_t
ex2__DROPPING_ICE__ice_dropped (robot_t *user)
{
@@ -65,3 +57,11 @@
return ex2_next (DROPPING_ICE, ice_dropped);
}
+@@ -77,6 +100,7 @@
+ ex2_branch_t
+ ex2__FILLING_GLASS__glass_filled (robot_t *user)
+ {
++ puts ("stop filling");
+ return ex2_next (FILLING_GLASS, glass_filled);
+ }
+
diff --git a/tools/dfagen/examples/tpl/template_defs.h b/tools/dfagen/examples/tpl/template_defs.h
index 54fabba4..e4e29fd3 100644
--- a/tools/dfagen/examples/tpl/template_defs.h
+++ b/tools/dfagen/examples/tpl/template_defs.h
@@ -15,11 +15,11 @@ enum %(prefix)s_state_t
typedef enum %(prefix)s_state_t %(prefix)s_state_t;
/* %(name)s events. */
-enum %(prefix)s_event_t
+enum %(prefix)s_event_type_t
{
-%(events)s %(PREFIX)s_EVENT_NB
+%(events,%(PREFIX)s_EVENT_TYPE_%(event)s)s %(PREFIX)s_EVENT_TYPE_NB
};
-typedef enum %(prefix)s_event_t %(prefix)s_event_t;
+typedef enum %(prefix)s_event_type_t %(prefix)s_event_type_t;
/* Only care about next state. */
#define _BRANCH(state, event, to) (%(PREFIX)s_STATE_ ## to)
@@ -43,4 +43,7 @@ typedef %(prefix)s_branch_t (*%(prefix)s_transition_t) (void);
#define %(prefix)s_next_branch(state, event, branch) \
%(PREFIX)s_BRANCH__ ## state ## __ ## event ## __ ## branch
+/* Number of initial events. */
+#define %(PREFIX)s_INITIALS_NB %(initials_nb)s
+
#endif /* %(prefix)s_defs_h */
diff --git a/tools/dfagen/examples/tpl/template_table.h b/tools/dfagen/examples/tpl/template_table.h
index 817197fa..39f07bdb 100644
--- a/tools/dfagen/examples/tpl/template_table.h
+++ b/tools/dfagen/examples/tpl/template_table.h
@@ -7,6 +7,20 @@
/* %(name)s transition table. */
static const %(prefix)s_transition_t
-%(prefix)s_transition_table[%(PREFIX)s_STATE_NB][%(PREFIX)s_EVENT_NB] = {
+%(prefix)s_transition_table[%(PREFIX)s_STATE_NB][%(PREFIX)s_EVENT_TYPE_NB] = {
%(transition_table)s};
+/* %(name)s only branch table. */
+static const %(prefix)s_state_t
+%(prefix)s_only_table[%(PREFIX)s_STATE_NB][%(PREFIX)s_EVENT_TYPE_NB] = {
+%(only_branch_table)s};
+
+/* %(name)s initial states. */
+static const %(prefix)s_state_t
+%(prefix)s_initials_table[] = {
+%(initials)s};
+
+/* %(name)s state attributes. */
+static const %(prefix)s_state_t
+%(prefix)s_attr_table[] = {
+%(states,"%(state)s (%(@)s) (%(@in)s) (%(@out|no_out)s)")s};