From e07581bda7c35dad9f35f7d6d7c4ee34acdec6f0 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Mon, 18 May 2009 17:46:37 +0200 Subject: * digital/io/src: - update top FSM to be valid with the new init FSM. --- digital/io/src/main.c | 4 ++-- digital/io/src/top.fsm | 50 ++++++++++++++++++++++++++++++------------------- digital/io/src/top_cb.c | 42 +++++++++++++++++++++++++++++++---------- 3 files changed, 65 insertions(+), 31 deletions(-) (limited to 'digital') diff --git a/digital/io/src/main.c b/digital/io/src/main.c index 1ed93970..f7d168c5 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -169,9 +169,9 @@ main_event_to_fsm (void) FSM_HANDLE_TIMEOUT (&cylinder_fsm); /* If we have entering this function, last command of the asserv board has - * been aquited. - * FIXME: other FSM need it? */ + * been aquited. */ FSM_HANDLE_EVENT (&init_fsm, INIT_EVENT_asserv_last_cmd_ack); + FSM_HANDLE_EVENT (&init_fsm, TOP_EVENT_asserv_last_cmd_ack); asserv_status_e move_status = none, diff --git a/digital/io/src/top.fsm b/digital/io/src/top.fsm index f26468fc..3c3eaa7e 100644 --- a/digital/io/src/top.fsm +++ b/digital/io/src/top.fsm @@ -4,39 +4,51 @@ top States: IDLE - waiting for the beginning of the top FSM - WAIT_JACK_IN - waiting for the jack to be inserted into the bot - WAIT_JACK_OUT - waiting for the jack to be removed from the bot + waiting for the beginning of the top FSM. + WAIT_FIRST_JACK_IN + waiting for the jack to be inserted into the bot for the first time. + WAIT_FIRST_JACK_OUT + waiting for the jack to be removed from the bot for the first time. + WAIT_SECOND_JACK_IN + waiting for the jack to be inserted into the bot for the second time. + WAIT_SECOND_JACK_OUT + waiting for the jack to be removed into the bot for the second time. GET_PUCK_FROM_THE_GROUND - get some pucks from the ground + get some pucks from the ground. GET_PUCK_FROM_DISTRIBUTOR - get some pucks from the distributor + get some pucks from the distributor. Events: start - initialize the FSM + initialize the FSM. move_fsm_finished - when the move FSM returns + when the move FSM returns. jack_inserted_into_bot - the jack is inserted into the bot + the jack is inserted into the bot. jack_removed_from_bot - the jack is removed from the bot + the jack is removed from the bot. state_timeout - timeout in cycle count + timeout in cycle count. asserv_last_cmd_ack - last command sent to the asserv board has been acquitted + last command sent to the asserv board has been acquitted. IDLE: - start -> WAIT_JACK_IN + start -> WAIT_FIRST_JACK_IN nothing to do. -WAIT_JACK_IN: - jack_inserted_into_bot -> WAIT_JACK_OUT - configure the asserv board. +WAIT_FIRST_JACK_IN: + jack_inserted_into_bot -> WAIT_FIRST_JACK_OUT + nothing to do. + +WAIT_FIRST_JACK_OUT: + jack_removed_from_bot -> WAIT_SECOND_JACK_IN + nothing to do. + +WAIT_SECOND_JACK_IN: + jack_removed_from_bot -> WAIT_SECOND_JACK_OUT + nothing to do. -WAIT_JACK_OUT: +WAIT_SECOND_JACK_OUT: jack_removed_from_bot -> GET_PUCK_FROM_THE_GROUND - the match start, start the chronometer + the match start, try to get some puck from the ground. diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c index acad13a5..a10939d5 100644 --- a/digital/io/src/top_cb.c +++ b/digital/io/src/top_cb.c @@ -15,7 +15,7 @@ /* * IDLE =start=> - * => WAIT_JACK_IN + * => WAIT_FIRST_JACK_IN * nothing to do. */ fsm_branch_t @@ -25,27 +25,49 @@ top__IDLE__start (void) } /* - * WAIT_JACK_IN =jack_inserted_into_bot=> - * => WAIT_JACK_OUT - * configure the asserv board. + * WAIT_FIRST_JACK_IN =jack_inserted_into_bot=> + * => WAIT_FIRST_JACK_OUT + * nothing to do. + */ +fsm_branch_t +top__WAIT_FIRST_JACK_IN__jack_inserted_into_bot (void) +{ + return top_next (WAIT_FIRST_JACK_IN, jack_inserted_into_bot); +} + +/* + * WAIT_FIRST_JACK_OUT =jack_removed_from_bot=> + * => WAIT_SECOND_JACK_IN + * nothing to do. + */ +fsm_branch_t +top__WAIT_FIRST_JACK_OUT__jack_removed_from_bot (void) +{ + return top_next (WAIT_FIRST_JACK_OUT, jack_removed_from_bot); +} + +/* + * WAIT_SECOND_JACK_IN =jack_removed_from_bot=> + * => WAIT_SECOND_JACK_OUT + * nothing to do. */ fsm_branch_t -top__WAIT_JACK_IN__jack_inserted_into_bot (void) +top__WAIT_SECOND_JACK_IN__jack_removed_from_bot (void) { - return top_next (WAIT_JACK_IN, jack_inserted_into_bot); + return top_next (WAIT_SECOND_JACK_IN, jack_removed_from_bot); } /* - * WAIT_JACK_OUT =jack_removed_from_bot=> + * WAIT_SECOND_JACK_OUT =jack_removed_from_bot=> * => GET_PUCK_FROM_THE_GROUND - * the match start, start the chronometer + * the match start, try to get some puck from the ground. */ fsm_branch_t -top__WAIT_JACK_OUT__jack_removed_from_bot (void) +top__WAIT_SECOND_JACK_OUT__jack_removed_from_bot (void) { /* Start the chronometer */ chrono_init (); - return top_next (WAIT_JACK_OUT, jack_removed_from_bot); + return top_next (WAIT_SECOND_JACK_OUT, jack_removed_from_bot); } -- cgit v1.2.3