01234567890123456789012345678901234567890123456789012345678901234567890123456789
6674667566766677667866796680668166826683668466856686668766886689669066916692669366946695 66966697669866996700670167026703670467056706670767086709671067116712671367146715 73587359736073617362736373647365736673677368736973707371737273737374737573767377 737873797380738173827383738473857386738773887389739073917392739373947395739673977398 |
<----SKIPPED LINES---->
next_message_time: epoch at which next message should be displayed
configuration: dictionary of configuration attributes.
screens: List of past screens displayed to splitflap screen.
Returns:
Next_message_time, potentially updated if a message has been displayed,
or unchanged if no message was displayed.
"""
if message_queue and (time.time() >= next_message_time or SIMULATION):
status = ''
if SIMULATION: # drain the queue because the messages come so fast
messages_to_display = list(message_queue)
# passed by reference, so clear it out since we drained it to the display
del message_queue[:]
else: # display only one message, being mindful of the display timing
messages_to_display = [message_queue.pop(0)]
for message in messages_to_display:
# we cannot just unpack the tuple because messages of type
# FLAG_MSG_FLIGHT are 3-tuples (with the third element being the flight
# dictionary) whereas other message types are 2-tuples
message_type = message[0]
message_text = message[1]
# There may be one or several insight messages that were added to the
# message queue along with the flight at a time when the screen was
# enabled, but by the time it comes to display them, the screen is now
# disabled. These should not be displayed. Note that this check only
# needs to be done for insight messages because other message types
# are user initiated and so presumably should be displayed irrespective
# of when the user triggered it to be displayed.
if message_type == FLAG_MSG_INSIGHT and not MessageMeetsDisplayCriteria(
configuration):
status = 'Message purged as no longer meets display criteria'
Log('Message %s purged' % message_text)
else:
if isinstance(message_text, str):
message_text = textwrap.wrap(
message_text,
width=SPLITFLAP_CHARS_PER_LINE)
<----SKIPPED LINES---->
# and delete any queued insight messages about other flights that have
# not yet displayed, since a newer flight has taken precedence
message_queue = DeleteMessageTypes(message_queue, (FLAG_MSG_INSIGHT,))
# Though we also manage the message queue outside this conditional
# as well, because it can take a half second to generate the flight
# insights, this allows this message to start displaying on the
# board immediately, so it's up there when it's most relevant
next_message_time = ManageMessageQueue(
message_queue, next_message_time, configuration, screen_history)
insight_messages = CreateFlightInsights(
flights,
configuration.get('insights'),
insight_message_distribution)
if configuration.get('next_flight', 'off') == 'on':
next_flight_text = FlightInsightNextFlight(flights, configuration)
if next_flight_text:
insight_messages.insert(0, next_flight_text)
insight_messages = [(FLAG_MSG_INSIGHT, m) for m in insight_messages]
time_insight_message_inserted = time.time()
for insight_message in insight_messages:
message_queue.insert(0, insight_message)
else: # flight didn't meet display criteria
flight['insight_types'] = []
PickleObjectToFile(
flight, PICKLE_FLIGHTS, True, timestamp=flight['now'])
# We record flight number, flight_meets_display_criteria,
# reason_flight_fails_criteria, flight_aware_error_message, and
# time stamps of when we confirmed new flight; when we generated
# message; when we generated insight messages (if any), to a
# to a pickle file so that we may construct a flight-centric
# status report
#
# Specifically, we record a 3-tuple:
# - flight number
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
6674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716 735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400 |
<----SKIPPED LINES---->
next_message_time: epoch at which next message should be displayed
configuration: dictionary of configuration attributes.
screens: List of past screens displayed to splitflap screen.
Returns:
Next_message_time, potentially updated if a message has been displayed,
or unchanged if no message was displayed.
"""
if message_queue and (time.time() >= next_message_time or SIMULATION):
status = ''
if SIMULATION: # drain the queue because the messages come so fast
messages_to_display = list(message_queue)
# passed by reference, so clear it out since we drained it to the display
del message_queue[:]
else: # display only one message, being mindful of the display timing
messages_to_display = [message_queue.pop(0)]
for message in messages_to_display:
# we cannot just unpack the tuple because messages of type
# FLAG_MSG_FLIGHT & FLAG_MSG_INSIGHT are 3-tuples (with the third
# element being the flight dictionary) whereas other message types
# are 2-tuples
message_type = message[0]
message_text = message[1]
# There may be one or several insight messages that were added to the
# message queue along with the flight at a time when the screen was
# enabled, but by the time it comes to display them, the screen is now
# disabled. These should not be displayed. Note that this check only
# needs to be done for insight messages because other message types
# are user initiated and so presumably should be displayed irrespective
# of when the user triggered it to be displayed.
if message_type == FLAG_MSG_INSIGHT and not MessageMeetsDisplayCriteria(
configuration):
status = 'Message purged as no longer meets display criteria'
Log('Message %s purged' % message_text)
else:
if isinstance(message_text, str):
message_text = textwrap.wrap(
message_text,
width=SPLITFLAP_CHARS_PER_LINE)
<----SKIPPED LINES---->
# and delete any queued insight messages about other flights that have
# not yet displayed, since a newer flight has taken precedence
message_queue = DeleteMessageTypes(message_queue, (FLAG_MSG_INSIGHT,))
# Though we also manage the message queue outside this conditional
# as well, because it can take a half second to generate the flight
# insights, this allows this message to start displaying on the
# board immediately, so it's up there when it's most relevant
next_message_time = ManageMessageQueue(
message_queue, next_message_time, configuration, screen_history)
insight_messages = CreateFlightInsights(
flights,
configuration.get('insights'),
insight_message_distribution)
if configuration.get('next_flight', 'off') == 'on':
next_flight_text = FlightInsightNextFlight(flights, configuration)
if next_flight_text:
insight_messages.insert(0, next_flight_text)
insight_messages = [
(FLAG_MSG_INSIGHT, m, flight) for m in insight_messages]
time_insight_message_inserted = time.time()
for insight_message in insight_messages:
message_queue.insert(0, insight_message)
else: # flight didn't meet display criteria
flight['insight_types'] = []
PickleObjectToFile(
flight, PICKLE_FLIGHTS, True, timestamp=flight['now'])
# We record flight number, flight_meets_display_criteria,
# reason_flight_fails_criteria, flight_aware_error_message, and
# time stamps of when we confirmed new flight; when we generated
# message; when we generated insight messages (if any), to a
# to a pickle file so that we may construct a flight-centric
# status report
#
# Specifically, we record a 3-tuple:
# - flight number
<----SKIPPED LINES---->
|