From 866e8d9be52ef7b44829f89457011fe9987ca2af Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Mon, 14 Apr 2008 12:02:35 +0200 Subject: * digital/io/src - integrate some events into the main for the getsamples FSM ; - correct example. --- digital/io/src/fsm.h | 4 ++-- digital/io/src/main.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/digital/io/src/fsm.h b/digital/io/src/fsm.h index ced9fadb..33c9a108 100644 --- a/digital/io/src/fsm.h +++ b/digital/io/src/fsm.h @@ -35,8 +35,8 @@ * * if (asserv_move_cmd_status () == success) * { - * fsm_handle_event (fsm_top, TOP_EVENT_position_reached); - * fsm_handle_event (fsm_getsamples, GETSAMPLES_EVENT_position_reached); + * fsm_handle_event (&top_fsm, TOP_EVENT_position_reached); + * fsm_handle_event (&getsamples_fsm, GETSAMPLES_EVENT_position_reached); * } * * Any unhandled event will be ignored. diff --git a/digital/io/src/main.c b/digital/io/src/main.c index 20eace93..d03714c4 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -39,6 +39,7 @@ #include "asserv.h" /* Functions to control the asserv board */ #include "eeprom.h" /* Parameters loaded/stored in the EEPROM */ #include "trap.h" /* Trap module (trap_* functions) */ +#include "fsm.h" /* fsm_* */ #include "io.h" @@ -100,6 +101,38 @@ main_loop (void) if (asserv_last_cmd_ack () == 0) /* Called function to manage retransmission */ asserv_retransmit (); + else + { + /* Check commands move status */ + if (asserv_move_cmd_status () == success) + { + /* Pass it to all the FSM that need it */ + fsm_handle_event (&getsamples_fsm, + GETSAMPLES_EVENT_bot_move_succeed); + } + else + { + /* Move failed */ + fsm_handle_event (&getsamples_fsm, + GETSAMPLES_EVENT_bot_move_failed); + } + /* Check commands arm status */ + if (asserv_arm_cmd_status () == success) + { + /* Pass it to all the FSM that need it */ + fsm_handle_event (&getsamples_fsm, + GETSAMPLES_EVENT_arm_move_succeed); + } + /* TODO: Check if the sensor placed at the noted position has seen + * an arm passed and forward this event to the getsamples FSM */ +// if (arm_in_front_of_reached_position) +// { +// /* Reset the sensor back to see a new transit of the arm */ +// fsm_handle_event (&getsamples_fsm, +// GETSAMPLES_EVENT_arm_pass_noted_position); +// } + /* Check other sensors */ + } } } -- cgit v1.2.3