-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper_live.py
More file actions
36 lines (28 loc) · 1.29 KB
/
wrapper_live.py
File metadata and controls
36 lines (28 loc) · 1.29 KB
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
import signal
import sys
from main_system.components.BigWrapper import BigWrapper
from main_system.components.AltimeterReader import AltimeterReader
from main_system.components.GyroscopeReader import GyroscopeReader
from main_system.components.AccelReader import AccelReader
from main_system.components.TempReader import TempReader
# An asynchronous signal handler.
# If the user hits CTRL+C, dump the logs to disk and exit regardless of our position in the BigWrapper loops.
def handle_termination(signum, frame):
print('Handling SIGINT. Dumping logs.')
if (maincontroller != None):
maincontroller.force_write_logs()
sys.exit(0)
# All configs related to running the MainSoftwareSystem in its real launch configuration
# is contained in config.json.
# Note that BigWrapper reads its control and imaging configs from config.json in ./main_system/components/config.json
maincontroller = BigWrapper(AltimeterReader, GyroscopeReader, AccelReader, TempReader)
# Install the signal handler.
signal.signal(signal.SIGINT, handle_termination)
signal.signal(signal.SIGTERM, handle_termination)
try:
# Run the main loop.
maincontroller.run()
except Exception as e:
print(f'Exception caught: {e}.')
print('Initializing emergency imaging sequence.')
maincontroller.emergency_run()