-
Notifications
You must be signed in to change notification settings - Fork 0
/
HX_FSM_code.py
63 lines (59 loc) · 2.48 KB
/
HX_FSM_code.py
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
bms_values = 0.0
PT1_value = 0.0
PT2_value = 0.0
PT3_value = 0.0
GUI_message = 0.0
brakes_signalled = 0.0
power_check = 0.0
while(True):
#LOADING----------------------------------------------------------------
if (current_state == 1):
state1_message = "Brakes are not actuated \n Contactor turned off"
print("Brakes are not actuated \n Contactor turned off")
state1(state1_message)
if(PT1_value == 1):
print("PT 1 Checked!")
else:
print("PT 1 Failed!")
if(PT2_value == 1):
print("PT 2 Checked!")
else:
print("PT 2 Failed!")
if(BMS_value < 3.4):
print("Error in BMS values!")
#disconnect battery from motors
else:
print("Log all cell values")
#GUI Indicates that we want to run the pod then:
if (GUI_message == 2):
current_state = 2
await sio.emit("heard_message", 'heard!', to=sid_save_value)
else:
print("GUI has not indicated start still!")
#STARTING----------------------------------------------------------------
if(current_state == 2):
#SIGNAL THE BRAKES
#SEND DATA to GUI
await sio.emit("PT1_value", PT1_value, to=sid_save_value)
await sio.emit("PT2_value", PT2_value, to=sid_save_value)
await sio.emit("BMS_value", BMS_value, to=sid_save_value)
if(brakes_signalled == 1):
print("t\The brakes have been signalled successfully")
else:
print("The brakes were not signalled successfully")
#RUNNING--------------------------------------------------------------------
if(current_state == 3):
await sio.emit("PT1_value", PT1_value, to=sid_save_value)
await sio.emit("PT2_value", PT2_value, to=sid_save_value)
await sio.emit("BMS_value", BMS_value, to=sid_save_value)
if (GUI_message == 4):
print("GUI requested STOP")
current_state = 4
if(power_check == 1):
print("Power check successful! ")
else:
print("Power check failed")
current_state = 4
#STOPPING-------------------------------------------------------------------------
if(current_state == 4):
#STOP