summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/main.c
diff options
context:
space:
mode:
authorJérémy Dufour2009-05-18 22:29:25 +0200
committerJérémy Dufour2009-05-18 22:29:25 +0200
commitf416af1eeed92e9508744544e39983af82479965 (patch)
treedd9f3ff7639cb2e6dfdd64947e10335aaf11ef4a /digital/io/src/main.c
parent4cdc74b87719195c82d6e2b2026edf5887c6b0e3 (diff)
* digital/io/src:
- fix event sent to the wrong FSM, - start top FSM, - rewrite event generated by move FSM when its finished, - init FSM generates an event when the match start, - init FSM starts the chrono when the match start, - top FSM now uses the event generated by the init FSM to know when the match start and not the jack states.
Diffstat (limited to 'digital/io/src/main.c')
-rw-r--r--digital/io/src/main.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/digital/io/src/main.c b/digital/io/src/main.c
index 6b8643eb..e4455844 100644
--- a/digital/io/src/main.c
+++ b/digital/io/src/main.c
@@ -54,6 +54,7 @@
#include "elevator.h"
#include "filterbridge.h"
#include "cylinder.h"
+#include "init.h"
#include "io.h"
@@ -172,7 +173,7 @@ main_event_to_fsm (void)
/* If we have entering this function, last command of the asserv board has
* been aquited. */
FSM_HANDLE_EVENT (&init_fsm, INIT_EVENT_asserv_last_cmd_ack);
- FSM_HANDLE_EVENT (&init_fsm, TOP_EVENT_asserv_last_cmd_ack);
+ FSM_HANDLE_EVENT (&top_fsm, TOP_EVENT_asserv_last_cmd_ack);
asserv_status_e
move_status = none,
@@ -241,8 +242,6 @@ main_event_to_fsm (void)
/* Jack */
if(switch_get_jack())
{
- FSM_HANDLE_EVENT (&top_fsm,
- TOP_EVENT_jack_removed_from_bot);
FSM_HANDLE_EVENT (&init_fsm,
INIT_EVENT_jack_removed_from_bot);
}
@@ -250,8 +249,6 @@ main_event_to_fsm (void)
{
FSM_HANDLE_EVENT (&init_fsm,
INIT_EVENT_jack_inserted_into_bot);
- FSM_HANDLE_EVENT (&top_fsm,
- TOP_EVENT_jack_inserted_into_bot);
FSM_HANDLE_EVENT (&elevator_fsm,
ELEVATOR_EVENT_jack_inserted_into_bot);
FSM_HANDLE_EVENT (&cylinder_fsm,
@@ -260,6 +257,14 @@ main_event_to_fsm (void)
CYLINDER_EVENT_jack_inserted_into_bot);
}
+ if (init_match_is_started)
+ {
+ FSM_HANDLE_EVENT (&top_fsm, TOP_EVENT_init_match_is_started);
+
+ /* This must be done in the last part of this block. */
+ init_match_is_started = 0;
+ }
+
/* Event generated at the end of the sub FSM to post to the top FSM */
if (main_post_event_for_top_fsm != 0xFF)
{
@@ -348,6 +353,7 @@ main_init (void)
/* Start all FSM (except move and top FSM) */
/* FIXME: who sould start top? init?. */
fsm_handle_event (&init_fsm, INIT_EVENT_start);
+ fsm_handle_event (&top_fsm, TOP_EVENT_start);
fsm_handle_event (&filterbridge_fsm, FILTERBRIDGE_EVENT_start);
fsm_handle_event (&elevator_fsm, ELEVATOR_EVENT_start);
fsm_handle_event (&cylinder_fsm, CYLINDER_EVENT_start);