01234567890123456789012345678901234567890123456789012345678901234567890123456789
53455346534753485349535053515352535353545355535653575358535953605361536253635364 53655366536753685369537053715372537353745375537653775378537953805381538253835384 |
<----SKIPPED LINES---->
def EnqueueArduinos(flights, json_desc_dict, configuration, to_servo_q, to_remote_q):
"""Send latest data to arduinos via their shared-memory queues"""
last_flight = {}
if flights:
last_flight = flights[-1]
if SIMULATION:
now = json_desc_dict['now']
else:
now = time.time()
additional_attributes = {}
today = EpochDisplayTime(now, '%x')
flight_count_today = len([1 for f in flights if DisplayTime(f, '%x') == today])
additional_attributes['flight_count_today'] = flight_count_today
additional_attributes['simulation'] = SIMULATION
message = (last_flight, json_desc_dict, configuration, additional_attributes)
try:
if 'enable_servos' in configuration:
to_servo_q.put(message, block=False)
if 'enable_remote' in configuration:
to_remote_q.put(message, block=False)
except queue.Full:
msg = 'Message queues to Arduinos full - trigger shutdown'
Log(msg)
global SHUTDOWN_SIGNAL
SHUTDOWN_SIGNAL = msg
def ProcessArduinoCommmands(q, flights, configuration, message_queue, next_message_time):
"""Executes the commands enqueued by the arduinos.
The commands on the queue q are of the form (command, args), where command is an
identifier indicating the type of instruction, and the args is a possibly empty tuple
with the attributes to follow thru.
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
53455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385 |
<----SKIPPED LINES---->
def EnqueueArduinos(flights, json_desc_dict, configuration, to_servo_q, to_remote_q):
"""Send latest data to arduinos via their shared-memory queues"""
last_flight = {}
if flights:
last_flight = flights[-1]
if SIMULATION:
now = json_desc_dict['now']
else:
now = time.time()
additional_attributes = {}
today = EpochDisplayTime(now, '%x')
flight_count_today = len([1 for f in flights if DisplayTime(f, '%x') == today])
additional_attributes['flight_count_today'] = flight_count_today
additional_attributes['simulation'] = SIMULATION
additional_attributes['ts'] = time.time() # TODO - remove this after debugging
message = (last_flight, json_desc_dict, configuration, additional_attributes)
try:
if 'enable_servos' in configuration:
to_servo_q.put(message, block=False)
if 'enable_remote' in configuration:
to_remote_q.put(message, block=False)
except queue.Full:
msg = 'Message queues to Arduinos full - trigger shutdown'
Log(msg)
global SHUTDOWN_SIGNAL
SHUTDOWN_SIGNAL = msg
def ProcessArduinoCommmands(q, flights, configuration, message_queue, next_message_time):
"""Executes the commands enqueued by the arduinos.
The commands on the queue q are of the form (command, args), where command is an
identifier indicating the type of instruction, and the args is a possibly empty tuple
with the attributes to follow thru.
<----SKIPPED LINES---->
|