01234567890123456789012345678901234567890123456789012345678901234567890123456789
55445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584 57475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775 |
<----SKIPPED LINES---->
last_heartbeat_time = HeartbeatRestart()
init_timing = [time.time()] # time 0
# This flag slows down simulation time around a flight, great for debugging the arduinos
simulation_slowdown = bool('-f' in sys.argv)
# Redirect any errors to a log file instead of the screen, and add a datestamp
if not SIMULATION:
sys.stderr = open(STDERR_FILE, 'a')
Log('', STDERR_FILE)
init_timing.append(time.time()) # time 1
Log('Starting up process %d' % os.getpid())
already_running_ids = FindRunningParents()
if already_running_ids:
for pid in already_running_ids:
Log('Sending termination signal to %d' % pid)
os.kill(pid, signal.SIGTERM)
init_timing.append(time.time()) # time 2
SetPinMode()
configuration = ReadAndParseSettings(CONFIG_FILE)
startup_time = time.time()
json_desc_dict = {}
init_timing.append(time.time()) # time 3
flights = UnpickleObjectFromFile(PICKLE_FLIGHTS, True, max_days=MAX_INSIGHT_HORIZON_DAYS)
# Clear the loaded flight of any cached data, identified by keys with a specific
# suffix, since code fixes may change the values for some of those cached elements
for flight in flights:
for key in list(flight.keys()):
if key.endswith(CACHED_ELEMENT_PREFIX):
flight.pop(key)
init_timing.append(time.time()) # time 4
# If we're displaying just a single insight message, we want it to be something
# unique, to the extent possible; this dict holds a count of the diff types of messages
# displayed so far
<----SKIPPED LINES---->
reboot = CheckRebootNeeded(startup_time, message_queue, json_desc_dict, configuration)
CheckTemperature()
if not SIMULATION:
time.sleep(max(0, next_loop_time - time.time()))
next_loop_time = time.time() + LOOP_DELAY_SECONDS
else:
SIMULATION_COUNTER += 1
if simulation_slowdown:
SimulationSlowdownNearFlight(flights, persistent_nearby_aircraft)
if SIMULATION:
SimulationEnd(message_queue, flights)
PerformGracefulShutdown((to_remote_q, to_servo_q, to_main_q), shutdown, reboot)
if __name__ == "__main__":
#interrupt, as in ctrl-c
signal.signal(signal.SIGINT, InterruptShutdownFromSignal) #TODO
#terminate, when another instance found or via kill
signal.signal(signal.SIGTERM, InterruptShutdownFromSignal) #TODO
if '-i' in sys.argv:
BootstrapInsightList()
else:
main()
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
55445545554655475548554955505551555255535554555555565557555855595560556155625563 55645565556655675568556955705571557255735574557555765577557855795580558155825583 57465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774 |
<----SKIPPED LINES---->
last_heartbeat_time = HeartbeatRestart()
init_timing = [time.time()] # time 0
# This flag slows down simulation time around a flight, great for debugging the arduinos
simulation_slowdown = bool('-f' in sys.argv)
# Redirect any errors to a log file instead of the screen, and add a datestamp
if not SIMULATION:
sys.stderr = open(STDERR_FILE, 'a')
Log('', STDERR_FILE)
init_timing.append(time.time()) # time 1
Log('Starting up process %d' % os.getpid())
already_running_ids = FindRunningParents()
if already_running_ids:
for pid in already_running_ids:
Log('Sending termination signal to %d' % pid)
os.kill(pid, signal.SIGTERM)
init_timing.append(time.time()) # time 2
SetPinMode()
configuration = ReadAndParseSettings(CONFIG_FILE)
startup_time = time.time()
json_desc_dict = {}
init_timing.append(time.time()) # time 3
flights = UnpickleObjectFromFile(PICKLE_FLIGHTS, True, max_days=MAX_INSIGHT_HORIZON_DAYS)
# Clear the loaded flight of any cached data, identified by keys with a specific
# suffix, since code fixes may change the values for some of those cached elements
for flight in flights:
for key in list(flight.keys()):
if key.endswith(CACHED_ELEMENT_PREFIX):
flight.pop(key)
init_timing.append(time.time()) # time 4
# If we're displaying just a single insight message, we want it to be something
# unique, to the extent possible; this dict holds a count of the diff types of messages
# displayed so far
<----SKIPPED LINES---->
reboot = CheckRebootNeeded(startup_time, message_queue, json_desc_dict, configuration)
CheckTemperature()
if not SIMULATION:
time.sleep(max(0, next_loop_time - time.time()))
next_loop_time = time.time() + LOOP_DELAY_SECONDS
else:
SIMULATION_COUNTER += 1
if simulation_slowdown:
SimulationSlowdownNearFlight(flights, persistent_nearby_aircraft)
if SIMULATION:
SimulationEnd(message_queue, flights)
PerformGracefulShutdown((to_remote_q, to_servo_q, to_main_q), shutdown, reboot)
if __name__ == "__main__":
#interrupt, as in ctrl-c
#signal.signal(signal.SIGINT, InterruptShutdownFromSignal) #TODO
#terminate, when another instance found or via kill
#signal.signal(signal.SIGTERM, InterruptShutdownFromSignal) #TODO
if '-i' in sys.argv:
BootstrapInsightList()
else:
main()
|