01234567890123456789012345678901234567890123456789012345678901234567890123456789
796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836 872873874875876877878879880881882883884885886887888889890891 892893894895896897898899900901902903904905906907908909910911 | <----SKIPPED LINES----> Simulations should use a timestamp contemporaneous with the flights, whereas live data should use the current timestamp. """ if not additional_attr: return 0 if additional_attr['simulation']: return json_desc_dict['now'] return time.time() def GenerateRemoteMessage( flight, json_desc_dict, configuration, additional_attr, display_mode): """Generates a value-tuple to be packed and sent to the arduino remote. Args: flight: dictionary describing the most recent flight. json_desc_dict: dictionary representing the current radio signal. configuration: dictionary representing the current state of the messageboard configuration. additional_attr: dictionary with miscellaneous attributes from messageboard. display_mode: integer specifying what display mode, so that the text display lines can be appropriately configured. Returns: Dictionary of values, where the dict keys and types are specified by RemoteMain.write_config. """ flight_last_seen = flight.get('now') # time flight was seen line1_decimal_mask = '00000000' line2_decimal_mask = '00000000' if display_mode == DISP_LAST_FLIGHT_NUMB_ORIG_DEST: # UAL1827 / SFO-LAX line1 = '' line2 = '' if flight: line1 = messageboard.DisplayFlightNumber(flight) origin = messageboard.DisplayOriginIata(flight)[:3] destination = messageboard.DisplayDestinationIata(flight)[:3] line2 = '%s-%s' % (origin, destination) <----SKIPPED LINES----> radio_range_flights = json_desc_dict.get('radio_range_flights', 0) plural = '' if radio_range_flights != 1: plural = 'S' line2 = '%d PLANE%s' % (radio_range_flights, plural) d = {} setting_screen_enabled = False if 'setting_screen_enabled' in configuration: setting_screen_enabled = True d['setting_screen_enabled'] = setting_screen_enabled d['setting_max_distance'] = configuration['setting_max_distance'] d['setting_max_altitude'] = configuration['setting_max_altitude'] d['setting_on_time'] = configuration['setting_on_time'] d['setting_off_time'] = configuration['setting_off_time'] d['setting_delay'] = configuration['setting_delay'] d['line1'] = line1.upper() d['line2'] = line2.upper() d['line1_dec_mask'] = int(line1_decimal_mask, 2) d['line2_dec_mask'] = int(line2_decimal_mask, 2) return d def ExecuteArduinoCommand( command, configuration, display_mode, low_battery, to_parent_q, link): """Executes the request as communicated in the command string. The remote may make one of the following requests: - Update a setting - (Re)display a recent flight - Display a histogram - Send information for a different display mode - Indicate that the battery is low Args: command: dictionary representing all data fields from remote. configuration: dictionary representing the current state of the messageboard configuration. display_mode: current display mode; only passed so that we may identify changes. <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836 872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912 | <----SKIPPED LINES----> Simulations should use a timestamp contemporaneous with the flights, whereas live data should use the current timestamp. """ if not additional_attr: return 0 if additional_attr['simulation']: return json_desc_dict['now'] return time.time() def GenerateRemoteMessage( flight, json_desc_dict, configuration, additional_attr, display_mode): """Generates a value-tuple to be packed and sent to the arduino remote. Args: flight: dictionary describing the most recent flight. json_desc_dict: dictionary representing the current radio signal. configuration: dictionary representing the current state of the messageboard configuration. additional_attr: dictionary with miscellaneous attributes from messageboard. display_mode: integer specifying the display mode, so that the text display lines can be appropriately configured. Returns: Dictionary of values, where the dict keys and types are specified by RemoteMain.write_config. """ flight_last_seen = flight.get('now') # time flight was seen line1_decimal_mask = '00000000' line2_decimal_mask = '00000000' if display_mode == DISP_LAST_FLIGHT_NUMB_ORIG_DEST: # UAL1827 / SFO-LAX line1 = '' line2 = '' if flight: line1 = messageboard.DisplayFlightNumber(flight) origin = messageboard.DisplayOriginIata(flight)[:3] destination = messageboard.DisplayDestinationIata(flight)[:3] line2 = '%s-%s' % (origin, destination) <----SKIPPED LINES----> radio_range_flights = json_desc_dict.get('radio_range_flights', 0) plural = '' if radio_range_flights != 1: plural = 'S' line2 = '%d PLANE%s' % (radio_range_flights, plural) d = {} setting_screen_enabled = False if 'setting_screen_enabled' in configuration: setting_screen_enabled = True d['setting_screen_enabled'] = setting_screen_enabled d['setting_max_distance'] = configuration['setting_max_distance'] d['setting_max_altitude'] = configuration['setting_max_altitude'] d['setting_on_time'] = configuration['setting_on_time'] d['setting_off_time'] = configuration['setting_off_time'] d['setting_delay'] = configuration['setting_delay'] d['line1'] = line1.upper() d['line2'] = line2.upper() d['line1_dec_mask'] = int(line1_decimal_mask, 2) d['line2_dec_mask'] = int(line2_decimal_mask, 2) d['display_mode'] = display_mode return d def ExecuteArduinoCommand( command, configuration, display_mode, low_battery, to_parent_q, link): """Executes the request as communicated in the command string. The remote may make one of the following requests: - Update a setting - (Re)display a recent flight - Display a histogram - Send information for a different display mode - Indicate that the battery is low Args: command: dictionary representing all data fields from remote. configuration: dictionary representing the current state of the messageboard configuration. display_mode: current display mode; only passed so that we may identify changes. <----SKIPPED LINES----> |