arduino-2020-07-17-0839.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997











                            <----SKIPPED LINES---->




      new_flight = DifferentFlights(flight, last_flight)
      if new_flight:
        Log('Flight changed from %s to %s' % (
            messageboard.DisplayFlightNumber(last_flight),
            messageboard.DisplayFlightNumber(flight)
        ), ser=link)

        # Turn off laser so line isn't traced while it moves to new position
        message_dict = GenerateServoMessage(laser=LASER_OFF)
        message_tuple = DictToValueTuple(
            message_dict, write_keys, write_format_tuple)
        link.Write(message_tuple)

      last_flight = flight

    mode_switch_ack = False
    if time.time() >= next_read:
      bytes_read = []
      values_t = link.Read(bytes_read=bytes_read)
      values_d = dict(zip(read_keys, values_t))
      Log(str(values_t) + str(values_d))  #TODO
      next_read = time.time() + READ_DELAY_TIME_SERVO
      if bytes_read and VERBOSE:
        Log('Read by Servo: %s' % str(values_d))

      if values_d['mode_switch']:

        # makes a copy so as to not modify underlying config; we don't want
        # to modify underlying because otherwise the settings will bounce
        # around (values read from disk -> new values set by arduino -> old
        # values from disk -> new values from disk after Arduino update).
        configuration = dict(configuration)

        # LED only -> Laser only -> Both
        sequence = ('led_only', 'laser_only', 'both')
        old_name = configuration['servo_mode']
        old_id = sequence.index(old_name)
        new_id = (old_id + 1) % len(sequence)
        new_name = sequence[new_id]
        Log('Hemisphere mode updated from %s to %s' % (old_name, new_name))
        configuration['servo_mode'] = new_name
        settings_string = messageboard.BuildSettings(configuration)
        to_parent_q.put(('update_configuration', (settings_string, )))
        mode_switch_ack = True

    now = GetNow(json_desc_dict, additional_attr)




                            <----SKIPPED LINES---->





01234567890123456789012345678901234567890123456789012345678901234567890123456789









952953954955956957958959960961962963964965966967968969970971 972973974975976977978979980981982983984985986987988989990991992993994995996











                            <----SKIPPED LINES---->




      new_flight = DifferentFlights(flight, last_flight)
      if new_flight:
        Log('Flight changed from %s to %s' % (
            messageboard.DisplayFlightNumber(last_flight),
            messageboard.DisplayFlightNumber(flight)
        ), ser=link)

        # Turn off laser so line isn't traced while it moves to new position
        message_dict = GenerateServoMessage(laser=LASER_OFF)
        message_tuple = DictToValueTuple(
            message_dict, write_keys, write_format_tuple)
        link.Write(message_tuple)

      last_flight = flight

    mode_switch_ack = False
    if time.time() >= next_read:
      bytes_read = []
      values_t = link.Read(bytes_read=bytes_read)
      values_d = dict(zip(read_keys, values_t))

      next_read = time.time() + READ_DELAY_TIME_SERVO
      if bytes_read and VERBOSE:
        Log('Read by Servo: %s' % str(values_d))

      if bytes_read and values_d['mode_switch']:

        # makes a copy so as to not modify underlying config; we don't want
        # to modify underlying because otherwise the settings will bounce
        # around (values read from disk -> new values set by arduino -> old
        # values from disk -> new values from disk after Arduino update).
        configuration = dict(configuration)

        # LED only -> Laser only -> Both
        sequence = ('led_only', 'laser_only', 'both')
        old_name = configuration['servo_mode']
        old_id = sequence.index(old_name)
        new_id = (old_id + 1) % len(sequence)
        new_name = sequence[new_id]
        Log('Hemisphere mode updated from %s to %s' % (old_name, new_name))
        configuration['servo_mode'] = new_name
        settings_string = messageboard.BuildSettings(configuration)
        to_parent_q.put(('update_configuration', (settings_string, )))
        mode_switch_ack = True

    now = GetNow(json_desc_dict, additional_attr)




                            <----SKIPPED LINES---->