-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (56 loc) · 2.33 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
74
from system_lib import *
def main():
system = System()
while True:
if system.reset_button.is_pushed():
system.reset()
# Check if tray is empty
if system.is_mask_tray_empty():
system.report_empty()
# And skip all the following processes and directly wait for the reset
system.HALT()
# When the HALT is over, go back to the beginning of the loop
continue
# Detect masks in stack and display
system.display_stack_level()
# Detect whether the mask is being transmitted (this mask should not be transmitting,
# if it is, an error will be reported
if system.is_mask_in_transit():
system.report_fault()
# And skip all the following processes and directly wait for the reset
system.HALT()
# When the HALT is over, go back to the beginning of the loop
continue
else:
system.turn_on_led(LED_READY)
# The mask machine is started, waiting for the customer to issue a mask request
system.wait_request()
# Here, it means that a customer has come to the door
system.dispensing_mask()
# TODO because the motor dispensing_mask takes time.
# Maybe add a time.sleep(), but not necessarily useful
# Check if the mask has been removed from the stack correctly
if not system.is_mask_in_waiting_position():
system.report_fault()
system.HALT()
continue
# Hand out the mask and wait until
system.release_mask_partially_and_wait()
if system.is_mask_still_waiting_collection():
system.release_mask_totally()
# TODO
# maybe time.sleep()
# Check again whether the masks are all pushed out, if not, report an error
if system.is_mask_still_waiting_collection():
system.report_fault()
system.HALT()
continue
# Close the door, and send data to the GUI
system.close_door()
system.stack_count -= 1
system.send_current_stack_count()
system.reset_report_led()
# TODO
# maybe time.sleep()
if __name__ == "__main__":
main()