Esempio n. 1
0
void
Profile::SetAirspaceMode(ProfileMap &map,
                         unsigned i, bool display, bool warning)
{
  char name[64];

  MakeAirspaceSettingName(name, "AirspaceDisplay", i);
  map.Set(name, display);

  MakeAirspaceSettingName(name, "AirspaceWarning", i);
  map.Set(name, warning);
}
Esempio n. 2
0
void
Profile::SetAirspaceBrush(ProfileMap &map, unsigned i, int brush_index)
{
  char name[64];
  MakeAirspaceSettingName(name, "Brush", i);
  map.Set(name, brush_index);
}
Esempio n. 3
0
void
Profile::SetAirspaceBorderWidth(ProfileMap &map,
                                unsigned i, unsigned border_width)
{
  char name[64];
  MakeAirspaceSettingName(name, "AirspaceBorderWidth", i);
  map.Set(name, border_width);
}
Esempio n. 4
0
static void
WritePortType(ProfileMap &map, unsigned n, DeviceConfig::PortType type)
{
  const char *value = PortTypeToString(type);
  if (value == NULL)
    return;

  char name[64];
  MakeDeviceSettingName(name, "Port", n, "Type");
  map.Set(name, value);
}
Esempio n. 5
0
void
Profile::Save(ProfileMap &map, const FlarmColorDatabase &db)
{
  std::string ids[4];

  for (const auto &i : db) {
    assert(i.first.IsDefined());
    assert((int)i.second < (int)FlarmColor::COUNT);

    if (i.second == FlarmColor::NONE)
      continue;

    unsigned color_index = (int)i.second - 1;

    char id_buffer[16];
    ids[color_index] += i.first.Format(id_buffer);
    ids[color_index] += ',';
  }

  map.Set("FriendsGreen", ids[0].c_str());
  map.Set("FriendsBlue", ids[1].c_str());
  map.Set("FriendsYellow", ids[2].c_str());
  map.Set("FriendsMagenta", ids[3].c_str());
}
Esempio n. 6
0
bool
SetProfilePasswordDialog(ProfileMap &map)
{
  StringBuffer<TCHAR, 80> new_password;
  new_password.clear();
  if (!TextEntryDialog(new_password, _("Enter a new password")))
    return false;

  if (new_password.empty())
    map.erase(ProfileKeys::Password);
  else
    map.Set(ProfileKeys::Password, new_password);

  return true;
}
Esempio n. 7
0
bool
Profile::LoadFile(ProfileMap &map, const TCHAR *path, Error &error)
{
  FileLineReaderA reader(path, error);
  if (reader.error())
    return false;

  KeyValueFileReader kvreader(reader);
  KeyValuePair pair;
  while (kvreader.Read(pair))
    /* ignore the "Vega*" values; the Vega driver used to abuse the
       profile to pass messages between the driver and the user
       interface */
    if (!StringIsEqual(pair.key, "Vega", 4))
      map.Set(pair.key, pair.value);

  return true;
}
Esempio n. 8
0
void
Profile::SetDeviceConfig(ProfileMap &map,
                         unsigned n, const DeviceConfig &config)
{
  char buffer[64];

  WritePortType(map, n, config.port_type);

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

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

  MakeDeviceSettingName(buffer, "Port", n, "Path");
  map.Set(buffer, config.path);

  MakeDeviceSettingName(buffer, "Port", n, "BaudRate");
  map.Set(buffer, config.baud_rate);

  MakeDeviceSettingName(buffer, "Port", n, "BulkBaudRate");
  map.Set(buffer, config.bulk_baud_rate);

  MakeDeviceSettingName(buffer, "Port", n, "IPAddress");
  map.Set(buffer, config.ip_address);

  MakeDeviceSettingName(buffer, "Port", n, "TCPPort");
  map.Set(buffer, config.tcp_port);

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

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

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

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

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

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

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

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

  MakeDeviceSettingName(buffer, "Port", n, "SensorOffset");
  auto offset = DeviceConfig::UsesCalibration(config.port_type) ? config.sensor_offset : fixed(0);
  // Has new calibration data been delivered ?
  if (CommonInterface::Basic().sensor_calibration_available)
    offset = CommonInterface::Basic().sensor_calibration_offset;
  map.Set(buffer, offset);

  MakeDeviceSettingName(buffer, "Port", n, "SensorFactor");
  auto factor = DeviceConfig::UsesCalibration(config.port_type) ? config.sensor_factor : fixed(0);
  // Has new calibration data been delivered ?
  if (CommonInterface::Basic().sensor_calibration_available)
    factor = CommonInterface::Basic().sensor_calibration_factor;
  map.Set(buffer, factor);

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

  MakeDeviceSettingName(buffer, "Port", n, "SecondDevice");
  map.Set(buffer, config.driver2_name);
}