コード例 #1
0
inline void
DeviceListWidget::ManageCurrent()
{
  const unsigned current = GetList().GetCursorIndex();
  if (current >= NUMDEV)
    return;

  DeviceDescriptor &descriptor = (*devices)[current];
  if (!descriptor.IsManageable())
    return;

  if (descriptor.GetState() != PortState::READY) {
    ShowMessageBox(_("Device is not connected"), _("Manage"),
                   MB_OK | MB_ICONERROR);
    return;
  }

  if (!descriptor.Borrow()) {
    ShowMessageBox(_("Device is occupied"), _("Manage"), MB_OK | MB_ICONERROR);
    return;
  }

  Device *device = descriptor.GetDevice();
  if (device == NULL) {
    descriptor.Return();
    return;
  }

  if (descriptor.IsDriver(_T("CAI 302")))
    ManageCAI302Dialog(UIGlobals::GetMainWindow(), look, *device);
  else if (descriptor.IsDriver(_T("FLARM"))) {
    device_blackboard->mutex.Lock();
    const NMEAInfo &basic = device_blackboard->RealState(current);
    const FlarmVersion version = basic.flarm.version;
    device_blackboard->mutex.Unlock();

    ManageFlarmDialog(*device, version);
  } else if (descriptor.IsDriver(_T("LX"))) {
    device_blackboard->mutex.Lock();
    const NMEAInfo &basic = device_blackboard->RealState(current);
    const DeviceInfo info = basic.device;
    const DeviceInfo secondary_info = basic.secondary_device;
    device_blackboard->mutex.Unlock();

    LXDevice &lx_device = *(LXDevice *)device;
    if (lx_device.IsV7())
      ManageV7Dialog(lx_device, info, secondary_info);
    else if (lx_device.IsNano())
      ManageNanoDialog(lx_device, info);
    else if (lx_device.IsLX16xx())
      ManageLX16xxDialog(lx_device, info);
  } else if (descriptor.IsDriver(_T("Vega")))
    dlgConfigurationVarioShowModal(*device);
  else if (descriptor.IsDriver(_T("BlueFly")))
    dlgConfigurationBlueFlyVarioShowModal(*device);

  MessageOperationEnvironment env;
  descriptor.EnableNMEA(env);
  descriptor.Return();
}
コード例 #2
0
ファイル: ManageV7Dialog.cpp プロジェクト: StefanL74/XCSoar
void
ManageV7Widget::OnAction(int id)
{
  MessageOperationEnvironment env;

  switch (id) {
  case SETUP:
    {
      V7ConfigWidget widget(GetLook(), device);
      DefaultWidgetDialog(UIGlobals::GetMainWindow(), GetLook(),
                          _T("LXNAV V7"), widget);
    }
    break;

  case NANO:
    if (device.EnablePassThrough(env)) {
      ManageNanoDialog(device, secondary_info);
      device.EnableNMEA(env);
    }

    break;
  }
}