summaryrefslogtreecommitdiff
path: root/digital/io/src/elevator.fsm
blob: c57bedb865b7816f108302df422f423151444af6 (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
# Elevator FSM
# Control the elevator's position and doors.
elevator

States:
 IDLE
  waiting for the beginning of the round
 WAIT_JACK_IN
  waiting for the jack
 INIT
  init the elevator
 GO_TO_POS_X
  go to a position to be ready to get a new puck
 WAIT_A_PUCK
  waiting for a new puck (hurry up filter bridge!)
 WAIT_POS_ORDER
  waiting for position order (depending where we want to drop our column)
 GO_TO_POS_Y
  go to a position + 1cm to be ready to release pucks
 WAIT_FOR_RELEASE_ORDER
  ready to open doors at your command
 LAND_ELEVATOR
  land elevator to the ground
 MINI_CLOSE
  try to unblock pucks
 OPEN_DOORS
  releasing pucks
 WAIT_FOR_CLOSE_ORDER
  ready to close doors at your command
 CLOSE_DOORS
  closing the elevator's doors

Events:
 start
  io power on!
 jack_inserted_into_bot
  jack into the bot
 init_done
  init done
 in_position
  elevator is in position
 new_puck
  we received a new puck from FB (filter bridge, not facebook)
 time_up
  complex event (!time_ok . fb_empty)
 order_received
  we received a new order
 doors_opened
  doors are opened
 door_move_finished
  doors move is done
 state_timeout

IDLE:
 start -> WAIT_JACK_IN
  waiting for jack

WAIT_JACK_IN:
 jack_inserted_into_bot -> INIT
  make initializations

INIT:
 init_done -> GO_TO_POS_X
  match begin, we're going to be ready to get a new puck

GO_TO_POS_X:
 in_position -> WAIT_A_PUCK
  in position and ready to get a new puck

WAIT_A_PUCK:
 new_puck: ok_for_other_pucks -> GO_TO_POS_X
  incrementing nb_puck var
  update elevator position to get a new puck
 new_puck: not_ok_for_other_pucks -> WAIT_POS_ORDER
  incrementing nb_puck var
  no more time to wait a new puck
 time_up -> WAIT_POS_ORDER
  no more time to wait a new puck

WAIT_POS_ORDER:
 order_received -> GO_TO_POS_Y
  go to position Y

GO_TO_POS_Y:
 in_position -> WAIT_FOR_RELEASE_ORDER
  ready to release pucks at altitude Y

WAIT_FOR_RELEASE_ORDER:
 order_received -> LAND_ELEVATOR
  make the elevator touch the target zone

LAND_ELEVATOR:
 in_position -> OPEN_DOORS
  release pucks to the target position (I hope)

OPEN_DOORS:
 doors_opened -> WAIT_FOR_CLOSE_ORDER
  wait for close order
 door_move_finished -> MINI_CLOSE
  try to unblock doors

MINI_CLOSE:
 door_move_finished -> OPEN_DOORS
  try to release pucks again

WAIT_FOR_CLOSE_ORDER:
 order_received -> CLOSE_DOORS
  closing doors

CLOSE_DOORS:
 door_move_finished -> GO_TO_POS_X
  pucks are released and elevator is ready to make a new column