01234567890123456789012345678901234567890123456789012345678901234567890123456789
883884885886887888889890891892893894895896897898899900901902 903904905906907908909910911912913914915916917918919920921922 11841185118611871188118911901191119211931194119511961197119811991200120112021203 1204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267 | <----SKIPPED LINES----> radio_range_str = KEY_NOT_PRESENT_STRING if radio_range is not None: radio_range_str = '%2dMI' % round(radio_range) line1 = 'RNG %s' % radio_range_str 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 <----SKIPPED LINES----> ('setting_delay', 'H'), ('last_plane', '?'), ('display_mode', 'H'), ('histogram_enabled', '?'), ('current_hist_type', 'H'), ('current_hist_history', 'H'), ('low_battery', '?')) write_config = ( ('setting_screen_enabled', '?'), # 1 bytes ('setting_max_distance', 'H'), # 2 bytes ('setting_max_altitude', 'L'), # 4 bytes ('setting_on_time', 'H'), # 2 bytes ('setting_off_time', 'H'), # 2 bytes ('setting_delay', 'H'), # 2 bytes ('line1', '9s'), # 9 bytes; 8 character plus terminator ('line2', '9s'), # 9 bytes; 8 character plus terminator ('line1_dec_mask', 'H'), # 2 bytes ('line2_dec_mask', 'H'), # 2 bytes ('display_mode', 'H'), # 2 bytes ) #pylint: enable = bad-whitespace read_keys, unused_read_format_tuple, read_format_string = SplitFormat(read_config) write_keys, write_format_tuple, write_format_string = SplitFormat(write_config) values_d = {} low_batt = False to_parent_q.put(('pin', (messageboard.GPIO_ERROR_BATTERY_CHARGE, low_batt))) link = Serial( *REMOTE_CONNECTION, read_timeout=7, error_pin=messageboard.GPIO_ERROR_ARDUINO_REMOTE_CONNECTION, to_parent_q=to_parent_q, read_format=read_format_string, write_format=write_format_string, name='Remote') link.Open() # Read in the saved display mode, if it exists display_mode = messageboard.ReadFile(REMOTE_DISPLAY_MODE, log_exception=False) if not display_mode: display_mode = DISP_LAST_FLIGHT_NUMB_ORIG_DEST else: display_mode = int(display_mode) flight, json_desc_dict, configuration, additional_attr = InitialMessageValues( to_arduino_q) next_read = 0 next_write = 0 last_configuration = configuration while not shutdown.value: if not to_arduino_q.empty(): to_arduino_message = to_arduino_q.get(block=False) flight, json_desc_dict, configuration, additional_attr = to_arduino_message if 'setting_screen_enabled' not in last_configuration and 'setting_screen_enabled' in configuration: Log('setting_screen_enabled changed from NOT PRESENT to ON') if 'setting_screen_enabled' in last_configuration and 'setting_screen_enabled' not in configuration: Log('setting_screen_enabled changed from ON to NOT PRESENT') last_configuration = configuration if 'test_remote' in configuration: messageboard.RemoveSetting(configuration, 'test_remote') configuration.pop('test_remote') # ensure that this is triggered only once def TestDisplayMode(m): SendRemoteMessage( flight, json_desc_dict, configuration, additional_attr, m, write_keys, write_format_tuple, link) time.sleep(1) TestDisplayMode(DISP_LAST_FLIGHT_NUMB_ORIG_DEST) TestDisplayMode(DISP_LAST_FLIGHT_AZIMUTH_ELEVATION) TestDisplayMode(DISP_FLIGHT_COUNT_LAST_SEEN) TestDisplayMode(DISP_RADIO_RANGE) if time.time() >= next_write: next_write = SendRemoteMessage( flight, json_desc_dict, configuration, additional_attr, display_mode, write_keys, write_format_tuple, link) <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923 118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232 1233123412351236 12371238123912401241124212431244124512461247124812491250125112521253125412551256 | <----SKIPPED LINES----> radio_range_str = KEY_NOT_PRESENT_STRING if radio_range is not None: radio_range_str = '%2dMI' % round(radio_range) line1 = 'RNG %s' % radio_range_str 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['last_flight_available'] = additional_attr['last_flight_available'] 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 <----SKIPPED LINES----> ('setting_delay', 'H'), ('last_plane', '?'), ('display_mode', 'H'), ('histogram_enabled', '?'), ('current_hist_type', 'H'), ('current_hist_history', 'H'), ('low_battery', '?')) write_config = ( ('setting_screen_enabled', '?'), # 1 bytes ('setting_max_distance', 'H'), # 2 bytes ('setting_max_altitude', 'L'), # 4 bytes ('setting_on_time', 'H'), # 2 bytes ('setting_off_time', 'H'), # 2 bytes ('setting_delay', 'H'), # 2 bytes ('line1', '9s'), # 9 bytes; 8 character plus terminator ('line2', '9s'), # 9 bytes; 8 character plus terminator ('line1_dec_mask', 'H'), # 2 bytes ('line2_dec_mask', 'H'), # 2 bytes ('display_mode', 'H'), # 2 bytes ('last_flight_available', '?'), # 1 byte ) #pylint: enable = bad-whitespace read_keys, unused_read_format_tuple, read_format_string = SplitFormat(read_config) write_keys, write_format_tuple, write_format_string = SplitFormat(write_config) values_d = {} low_batt = False to_parent_q.put(('pin', (messageboard.GPIO_ERROR_BATTERY_CHARGE, low_batt))) link = Serial( *REMOTE_CONNECTION, read_timeout=7, error_pin=messageboard.GPIO_ERROR_ARDUINO_REMOTE_CONNECTION, to_parent_q=to_parent_q, read_format=read_format_string, write_format=write_format_string, name='Remote') link.Open() # Read in the saved display mode, if it exists display_mode = messageboard.ReadFile(REMOTE_DISPLAY_MODE, log_exception=False) if not display_mode: display_mode = DISP_LAST_FLIGHT_NUMB_ORIG_DEST else: display_mode = int(display_mode) flight, json_desc_dict, configuration, additional_attr = InitialMessageValues( to_arduino_q) next_read = 0 next_write = 0 while not shutdown.value: if not to_arduino_q.empty(): to_arduino_message = to_arduino_q.get(block=False) flight, json_desc_dict, configuration, additional_attr = to_arduino_message if 'test_remote' in configuration: messageboard.RemoveSetting(configuration, 'test_remote') configuration.pop('test_remote') # ensure that this is triggered only once def TestDisplayMode(m): SendRemoteMessage( flight, json_desc_dict, configuration, additional_attr, m, write_keys, write_format_tuple, link) time.sleep(1) TestDisplayMode(DISP_LAST_FLIGHT_NUMB_ORIG_DEST) TestDisplayMode(DISP_LAST_FLIGHT_AZIMUTH_ELEVATION) TestDisplayMode(DISP_FLIGHT_COUNT_LAST_SEEN) TestDisplayMode(DISP_RADIO_RANGE) if time.time() >= next_write: next_write = SendRemoteMessage( flight, json_desc_dict, configuration, additional_attr, display_mode, write_keys, write_format_tuple, link) <----SKIPPED LINES----> |