示例#1
0
void
Profile::GetDeviceConfig(const ProfileMap &map, unsigned n,
                         DeviceConfig &config)
{
  char buffer[64];

  bool have_port_type = ReadPortType(map, n, config.port_type);

  MakeDeviceSettingName(buffer, "Port", n, "BluetoothMAC");
  map.Get(buffer, config.bluetooth_mac);

  MakeDeviceSettingName(buffer, "Port", n, "IOIOUartID");
  map.Get(buffer, config.ioio_uart_id);

  MakeDeviceSettingName(buffer, "Port", n, "IPAddress");
  if (!map.Get(buffer, config.ip_address))
    config.ip_address.clear();

  MakeDeviceSettingName(buffer, "Port", n, "TCPPort");
  if (!map.Get(buffer, config.tcp_port))
    config.tcp_port = 4353;

  config.path.clear();
  if ((!have_port_type ||
       config.port_type == DeviceConfig::PortType::SERIAL) &&
      !LoadPath(map, config, n) && LoadPortIndex(map, config, n))
    config.port_type = DeviceConfig::PortType::SERIAL;

  MakeDeviceSettingName(buffer, "Port", n, "BaudRate");
  if (!map.Get(buffer, config.baud_rate)) {
    /* XCSoar before 6.2 used to store a "speed index", not the real
       baud rate - try to import the old settings */

    static constexpr unsigned speed_index_table[] = {
      1200,
      2400,
      4800,
      9600,
      19200,
      38400,
      57600,
      115200
    };

    MakeDeviceSettingName(buffer, "Speed", n, "Index");
    unsigned speed_index;
    if (map.Get(buffer, speed_index) &&
        speed_index < ARRAY_SIZE(speed_index_table))
      config.baud_rate = speed_index_table[speed_index];
  }

  MakeDeviceSettingName(buffer, "Port", n, "BulkBaudRate");
  if (!map.Get(buffer, config.bulk_baud_rate))
    config.bulk_baud_rate = 0;

  strcpy(buffer, "DeviceA");
  buffer[strlen(buffer) - 1] += n;
  map.Get(buffer, config.driver_name);

  MakeDeviceSettingName(buffer, "Port", n, "Enabled");
  map.Get(buffer, config.enabled);

  MakeDeviceSettingName(buffer, "Port", n, "SyncFromDevice");
  map.Get(buffer, config.sync_from_device);

  MakeDeviceSettingName(buffer, "Port", n, "SyncToDevice");
  map.Get(buffer, config.sync_to_device);

  MakeDeviceSettingName(buffer, "Port", n, "K6Bt");
  map.Get(buffer, config.k6bt);

  MakeDeviceSettingName(buffer, "Port", n, "I2C_Bus");
  map.Get(buffer, config.i2c_bus);

  MakeDeviceSettingName(buffer, "Port", n, "I2C_Addr");
  map.Get(buffer, config.i2c_addr);

  MakeDeviceSettingName(buffer, "Port", n, "PressureUse");
  map.GetEnum(buffer, config.press_use);

  MakeDeviceSettingName(buffer, "Port", n, "SensorOffset");
  map.Get(buffer, config.sensor_offset);

  MakeDeviceSettingName(buffer, "Port", n, "SensorFactor");
  map.Get(buffer, config.sensor_factor);

  MakeDeviceSettingName(buffer, "Port", n, "UseSecondDevice");
  map.Get(buffer, config.use_second_device);

  MakeDeviceSettingName(buffer, "Port", n, "SecondDevice");
  map.Get(buffer, config.driver2_name);
}
示例#2
0
void
Profile::Load(const ProfileMap &map, FinishConstraints &constraints)
{
  map.GetEnum(ProfileKeys::FinishHeightRef, constraints.min_height_ref);
  map.Get(ProfileKeys::FinishMinHeight, constraints.min_height);
}
示例#3
0
void
Profile::Load(const ProfileMap &map, TaskStartMargins &settings)
{
  map.Get(ProfileKeys::StartMaxHeightMargin, settings.max_height_margin);
  map.Get(ProfileKeys::StartMaxSpeedMargin, settings.max_speed_margin);
}
示例#4
0
void
Profile::Load(const ProfileMap &map, GlideSettings &settings)
{
  map.Get(ProfileKeys::PredictWindDrift, settings.predict_wind_drift);
}
示例#5
0
void
Profile::Load(const ProfileMap &map, MapSettings &settings)
{
  map.Get(ProfileKeys::CircleZoom, settings.circle_zoom_enabled);
  map.Get(ProfileKeys::MaxAutoZoomDistance, settings.max_auto_zoom_distance);
  map.Get(ProfileKeys::DrawTopography, settings.topography_enabled);

  LoadTerrainRendererSettings(map, settings.terrain);

  map.GetEnum(ProfileKeys::AircraftSymbol, settings.aircraft_symbol);

  map.Get(ProfileKeys::DetourCostMarker, settings.detour_cost_markers_enabled);
  map.GetEnum(ProfileKeys::DisplayTrackBearing, settings.display_ground_track);
  map.Get(ProfileKeys::AutoZoom, settings.auto_zoom_enabled);

  map.GetEnum(ProfileKeys::WindArrowStyle, settings.wind_arrow_style);

  settings.waypoint.LoadFromProfile();

  Load(map, settings.airspace);

  map.Get(ProfileKeys::GliderScreenPosition, settings.glider_screen_position);

  bool orientation_found = false;

  unsigned Temp = (unsigned)MapOrientation::NORTH_UP;
  if (map.Get(ProfileKeys::OrientationCircling, Temp)) {
    orientation_found = true;

    if (IsValidMapOrientation(Temp))
      settings.circling_orientation = (MapOrientation)Temp;
  }

  Temp = (unsigned)MapOrientation::NORTH_UP;
  if (map.Get(ProfileKeys::OrientationCruise, Temp)) {
    orientation_found = true;

    if (IsValidMapOrientation(Temp))
      settings.cruise_orientation = (MapOrientation)Temp;
  }

  if (!orientation_found) {
    Temp = 1;
    map.Get(ProfileKeys::DisplayUpValue, Temp);
    switch (Temp) {
    case 0:
      settings.cruise_orientation = MapOrientation::TRACK_UP;
      settings.circling_orientation = MapOrientation::TRACK_UP;
      break;
    case 1:
      settings.cruise_orientation = MapOrientation::NORTH_UP;
      settings.circling_orientation = MapOrientation::NORTH_UP;
      break;
    case 2:
      settings.cruise_orientation = MapOrientation::TRACK_UP;
      settings.circling_orientation = MapOrientation::NORTH_UP;
      break;
    case 3:
      settings.cruise_orientation = MapOrientation::TRACK_UP;
      settings.circling_orientation = MapOrientation::TARGET_UP;
      break;
    case 4:
      settings.cruise_orientation = MapOrientation::NORTH_UP;
      settings.circling_orientation = MapOrientation::TRACK_UP;
      break;
    }
  }

  fixed tmp;
  if (map.Get(ProfileKeys::ClimbMapScale, tmp))
    settings.circling_scale = Clamp(tmp / 10000, fixed(0.0003), fixed(10));

  if (map.Get(ProfileKeys::CruiseMapScale, tmp))
    settings.cruise_scale = Clamp(tmp / 10000, fixed(0.0003), fixed(10));

  map.GetEnum(ProfileKeys::MapShiftBias, settings.map_shift_bias);
  map.Get(ProfileKeys::EnableFLARMMap, settings.show_flarm_on_map);

  map.Get(ProfileKeys::EnableThermalProfile, settings.show_thermal_profile);
  map.Get(ProfileKeys::EnableFinalGlideBarMC0,
          settings.final_glide_bar_mc0_enabled);
  map.GetEnum(ProfileKeys::FinalGlideBarDisplayMode,
              settings.final_glide_bar_display_mode);
  map.Get(ProfileKeys::ShowFAITriangleAreas,
          settings.show_fai_triangle_areas);
  ::Load(map, settings.fai_triangle_settings);

  map.Get(ProfileKeys::EnableVarioBar,
          settings.vario_bar_enabled);

  Load(map, settings.trail);
  Load(map, settings.item_list);
}
示例#6
0
void
Profile::Load(const ProfileMap &map, MapItemListSettings &settings)
{
  map.Get(ProfileKeys::EnableLocationMapItem, settings.add_location);
  map.Get(ProfileKeys::EnableArrivalAltitudeMapItem, settings.add_arrival_altitude);
}