summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/guybrush/bottom_clamp.c
diff options
context:
space:
mode:
authorJulien Balleyguier2012-05-13 17:11:30 +0200
committerNicolas Schodet2012-05-14 00:34:57 +0200
commitcffa0218d0511a4e7a540cad9e09d52f52d27e7a (patch)
tree1285a7a30d48c99875ea6e870d77f2d224587b71 /digital/io-hub/src/guybrush/bottom_clamp.c
parenta5be49c7eae38c2e1af9b801a3211870d62ffa69 (diff)
digital/io-hub/src/guybrush: clean area modifications
Diffstat (limited to 'digital/io-hub/src/guybrush/bottom_clamp.c')
-rw-r--r--digital/io-hub/src/guybrush/bottom_clamp.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/digital/io-hub/src/guybrush/bottom_clamp.c b/digital/io-hub/src/guybrush/bottom_clamp.c
index 9936b5bb..0b951138 100644
--- a/digital/io-hub/src/guybrush/bottom_clamp.c
+++ b/digital/io-hub/src/guybrush/bottom_clamp.c
@@ -69,7 +69,10 @@ FSM_STATES (
/* Waiting external events. */
CLAMP_IDLE,
-
+ /*---------------------------Cleaning area sequence---------------------*/
+ CLAMP_READY_TO_CLEAN,
+ CLAMP_CATCH_COIN,
+ CLAMP_READY_TO_LOAD,
/*---------------------------Taking coin sequence-----------------------*/
/*Taking a coin. */
CLAMP_TAKE_COIN,
@@ -138,6 +141,12 @@ FSM_EVENTS (
upper_set_up,
/*upper set is totally close*/
upper_set_down,
+ /*Clean the area*/
+ clean_start,
+ /*Clos the bottom clamp*/
+ clean_catch,
+ /* Load the coin*/
+ clean_load,
/* Tree detected, get ready to empty it. */
tree_detected,
/* stop the tree-emptying cycle*/
@@ -301,7 +310,7 @@ FSM_TRANS (CLAMP_GOING_IDLE, lower_clamp_rotation_success, CLAMP_WAIT_BEFORE_IDL
}
/*---------------------------------------------------------*/
-/* parts of the FSM that Takes coin */
+/* IDLE!! */
/*---------------------------------------------------------*/
FSM_TRANS_TIMEOUT (CLAMP_WAIT_BEFORE_IDLE, TIMEOUT_IDLE, CLAMP_IDLE)
{
@@ -309,7 +318,45 @@ FSM_TRANS_TIMEOUT (CLAMP_WAIT_BEFORE_IDLE, TIMEOUT_IDLE, CLAMP_IDLE)
fsm_queue_post_event (FSM_EVENT (AI, clamps_ready));
return FSM_NEXT_TIMEOUT (CLAMP_WAIT_BEFORE_IDLE);
}
+/*---------------------------------------------------------*/
+/* parts of the FSM that Clean areas */
+/*---------------------------------------------------------*/
+FSM_TRANS (CLAMP_IDLE, clean_start,CLAMP_READY_TO_CLEAN)
+{
+ return FSM_NEXT(CLAMP_IDLE,clean_start);
+}
+FSM_TRANS (CLAMP_READY_TO_CLEAN, clean_catch,CLAMP_CATCH_COIN)
+{
+ /*If the clamp 1 has the CD.*/
+ if (ctx.clamp_1_down)
+ {
+ /*Close it.*/
+ IO_SET (OUTPUT_LOWER_CLAMP_1_CLOSE);
+ }
+ /*If the clamp 2 is closed. */
+ else
+ {
+ IO_SET (OUTPUT_LOWER_CLAMP_2_CLOSE);
+ }
+ return FSM_NEXT(CLAMP_READY_TO_CLEAN,clean_catch);
+}
+FSM_TRANS_TIMEOUT (CLAMP_CATCH_COIN, TIMEOUT_CLOSE_CLAMPS*2,CLAMP_READY_TO_LOAD)
+{
+ fsm_queue_post_event (FSM_EVENT (AI, clamps_ready));
+ return FSM_NEXT_TIMEOUT(CLAMP_CATCH_COIN);
+}
+
+FSM_TRANS (CLAMP_READY_TO_LOAD, clean_load,CLAMP_TAKE_COIN)
+{
+ return FSM_NEXT(CLAMP_READY_TO_LOAD,clean_load);
+}
+
+
+
+/*---------------------------------------------------------*/
+/* parts of the FSM that Takes coin */
+/*---------------------------------------------------------*/
FSM_TRANS (CLAMP_IDLE, coin_detected,
normal_clamp,CLAMP_TAKE_COIN,
calm_clamp,CLAMP_IDLE)