summaryrefslogtreecommitdiff
path: root/digital/io/src/cylinder.fsm
blob: bb63d96c3b18add41f72b3f8009f37771063e0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Cylinder FSM
# Control the puck's entrance
cylinder

States:
 IDLE
  waiting for init
 WAIT_FOR_JACK_IN
  waiting for jack
 RESET_POS
  reset the cylinder position
 INIT_POS
  initializing cylinder to a good position (open)
 WAIT_A_PUCK
  waiting a puck enter in cylinder
 WAIT_BRIDGE_READY
  waiting fb is ready to accept new puck
 TURN_PLUS_1_AND_OFO
  turn 1+of_offset position after when we see a new puck
 TURN_PLUS_1_AND_MINUS_OFO
  turn 1-of_offset position after to be ready to get a new puck
 WAIT_BOT_NOT_FULL
  wait the bot to drop pucks
 WAIT_CLEAR_ORDER
  wait the clear order (unset close_order flags)
 TURN_PLUS_1_OPEN
  open cylinder after close (bot full/close_order)
 TURN_PLUS_1_FLUSH
  open cylinder to prepare cyliner flush
 WAIT_BRIDGE_READY_FLUSH
  we wait fb is ready during the flush
 TURN_PLUS_3_FLUSH
  drop 1 puck to the fb
 TURN_PLUS_1_CLOSE
  close the cylinder
 WAIT_BRIDGE_READY_DISTRIB
  waiting for the bridge
 TURN_PLUS_1_AND_OFO_DISTRIB
  get a puck on distrib
 TURN_PLUS_1_AND_MINUS_OFO_DISTRIB
  we neutralize the offset before return in normal mode
 TURN_PLUS_1_AND_MINUS_OFO_DISTRIB_LOOP
  blah
 PROBE_OF
  we probe the OF


Events:
 start
  start event
 jack_inserted_into_bot
  the init signal
 new_puck
  there is a puck in position 1
 move_done
  cylinder move finished
 bridge_ready
  the fb is ready to get new pucks
 close_order
  we receive the order to close the cylinder
 no_close_order
  we can reopen the cylinder
 bot_not_full
  the bot dont have 4 pucks
 flush_order
  we receive a flush order
 distrib_fucked
  we are really in the distributor
 of_puck
  we see a puck to the of
 of_no_puck
  we don't see a puck in of
 state_timeout
  useless here

IDLE:
 start -> WAIT_FOR_JACK_IN
  we wait the jack before moving anything

WAIT_FOR_JACK_IN:
 jack_inserted_into_bot -> RESET_POS
  we init the cylinder position

RESET_POS:
 move_done -> INIT_POS
  move the cylinder to open it

INIT_POS:
 move_done -> WAIT_A_PUCK
  the cylinder is ready to get pucks

WAIT_A_PUCK:
 new_puck -> WAIT_BRIDGE_READY
  look if the bridge is ready before move
 close_order -> TURN_PLUS_1_CLOSE
  we close cylinder as requested
 flush_order -> WAIT_BRIDGE_READY_FLUSH
  flush all pucks to the bridge
 distrib_fucked -> WAIT_BRIDGE_READY_DISTRIB
  we verify bridge

WAIT_BRIDGE_READY_DISTRIB:
 bridge_ready -> TURN_PLUS_1_AND_OFO_DISTRIB
  we turn to check the of

TURN_PLUS_1_AND_OFO_DISTRIB:
 move_done -> PROBE_OF
  We probe the puck

PROBE_OF:
 of_puck: bot_full -> WAIT_BOT_NOT_FULL
  return to normal mode with a bot full of puck
 of_puck: bot_not_full -> TURN_PLUS_1_AND_MINUS_OFO_DISTRIB_LOOP
  we get a puck and we are hungry yet, go eat an another puck
 of_no_puck -> TURN_PLUS_1_AND_MINUS_OFO_DISTRIB
  Distributor empty, go elsewhere

TURN_PLUS_1_AND_MINUS_OFO_DISTRIB_LOOP:
 move_done -> WAIT_BRIDGE_READY_DISTRIB
  ready to get another puck

WAIT_BRIDGE_READY:
 bridge_ready -> TURN_PLUS_1_AND_OFO
  open the cylinder with the puck or not.

TURN_PLUS_1_AND_OFO:
 move_done: bot_not_full -> TURN_PLUS_1_AND_MINUS_OFO
  open the cylinder to wait a new puck
 move_done: bot_full -> WAIT_BOT_NOT_FULL
  bot full, waiting for pucks teleportation

TURN_PLUS_1_AND_MINUS_OFO_DISTRIB:
 move_done -> WAIT_A_PUCK
  bridge empty, return to normal mode

TURN_PLUS_1_AND_MINUS_OFO:
 move_done -> WAIT_A_PUCK
  ready for other pucks

WAIT_BOT_NOT_FULL:
 bot_not_full -> WAIT_CLEAR_ORDER
  the bot is not full, we go testing the other close condition
 flush_order -> TURN_PLUS_1_FLUSH
  flush order received, go open the cylinder

WAIT_CLEAR_ORDER:
 no_close_order -> TURN_PLUS_1_OPEN
  no close order, we reopen cylinder to get other pucks
 flush_order -> TURN_PLUS_1_FLUSH
  flush order received, go open the cylinder

TURN_PLUS_1_OPEN:
 move_done -> WAIT_A_PUCK
  cylinder ready to get other pucks

TURN_PLUS_1_FLUSH:
 move_done -> WAIT_BRIDGE_READY_FLUSH
  we wait the bridge before moving

WAIT_BRIDGE_READY_FLUSH:
 bridge_ready -> TURN_PLUS_3_FLUSH
  bridge is ready, flush gordon

TURN_PLUS_3_FLUSH:
 move_done -> WAIT_BOT_NOT_FULL
  cylinder flushed, we test the 2 close conditions before reopen cylinder

TURN_PLUS_1_CLOSE:
 move_done -> WAIT_BOT_NOT_FULL
  close order executed, test the 2 close conditions before reopen cylinder