当前位置: 首页>>代码示例>>C++>>正文


C++ DeviceDescriptor类代码示例

本文整理汇总了C++中DeviceDescriptor的典型用法代码示例。如果您正苦于以下问题:C++ DeviceDescriptor类的具体用法?C++ DeviceDescriptor怎么用?C++ DeviceDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DeviceDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Set

    void Set(const DeviceConfig &config, const DeviceDescriptor &device,
             const NMEAInfo &basic) {
      /* if a DeviceDescriptor is "unconfigured" but its DeviceConfig
         contains a valid configuration, then it got disabled by
         DeviceConfigOverlaps(), i.e. it's duplicate */
      duplicate = !config.IsDisabled() && !device.IsConfigured();

      switch (device.GetState()) {
      case PortState::READY:
        open = true;
        error = false;
        break;

      case PortState::FAILED:
        open = false;
        error = true;
        break;

      case PortState::LIMBO:
        open = false;
        error = false;
        break;
      }

      alive = basic.alive;
      location = basic.location_available;
      gps = basic.gps.fix_quality_available;
      baro = basic.baro_altitude_available ||
        basic.pressure_altitude_available ||
        basic.static_pressure_available;
      airspeed = basic.airspeed_available;
      vario = basic.total_energy_vario_available;
      traffic = basic.flarm.IsDetected();
      debug = device.IsDumpEnabled();
    }
开发者ID:ThomasXBMC,项目名称:XCSoar,代码行数:35,代码来源:DeviceListDialog.cpp

示例2: DeviceDeclare

static bool
DeviceDeclare(DeviceDescriptor &dev, const Declaration &declaration,
              const Waypoint *home)
{
  if (dev.IsOccupied())
    return false;

  if (ShowMessageBox(_("Declare task?"), dev.GetDisplayName(),
                  MB_YESNO | MB_ICONQUESTION) != IDYES)
    return false;

  if (!dev.Borrow())
    return false;

  const TCHAR *caption = dev.GetDisplayName();
  if (caption == NULL)
    caption = _("Declare task");

  bool success = DoDeviceDeclare(dev, declaration, home);
  dev.Return();

  if (!success) {
    ShowMessageBox(_("Error occured,\nTask NOT declared!"),
                caption, MB_OK | MB_ICONERROR);
    return false;
  }

  ShowMessageBox(_("Task declared!"),
              caption, MB_OK | MB_ICONINFORMATION);
  return true;
}
开发者ID:damianob,项目名称:xcsoar,代码行数:31,代码来源:ExternalLogger.cpp

示例3: assert

    void MPICommunicatorImpl::Initialize(const std::vector<NDArrayViewPtr>& values)
    {
        assert(CPUDEVICE < 0); // just in case somebody decides to change CPUDEVICE macro.
        DeviceDescriptor lastGpuDevice = DeviceDescriptor::CPUDevice();
        m_gpuDataTransferers.resize(values.size());
        m_intermediateCPUBuffers.resize(values.size());
        for (auto i = 0; i < values.size(); ++i)
        {
            auto view = values[i];
            auto device = view->Device();

            // Make sure none of the values are sparse - we currently do not support aggregation of sparse matrices
            if (view->GetStorageFormat() != StorageFormat::Dense)
                RuntimeError("Aggregation for sparse matrices is currently not supported!");

            // TODO: device.Type should be called Kind.
            if (device.Type() != DeviceKind::GPU)
            {
                m_intermediateCPUBuffers[i] = Buffer();
                m_gpuDataTransferers[i] = nullptr;
            }
            else
            {
                if (lastGpuDevice.Type() == DeviceKind::CPU)
                    lastGpuDevice = device;
                else if (device.Id() != lastGpuDevice.Id()) // For the time being, assume all devices have the same id.
                    LogicError("Not all values are on the same GPU device id");

                auto requiredSize = GetBufferSize(view);
                m_gpuDataTransferers[i] = std::make_shared<GPUDataTransferer>(device.Id(), true);
                if (m_intermediateCPUBuffers[i].totalSize < requiredSize)
                    m_intermediateCPUBuffers[i] = AllocateIntermediateBuffer(device.Id(), requiredSize);
            }
        }
    }
开发者ID:rlugojr,项目名称:CNTK,代码行数:35,代码来源:DistributedCommunicator.cpp

示例4: devInitOne

static bool
devInitOne(DeviceDescriptor &device, const DeviceConfig &config,
           DeviceDescriptor *&nmeaout)
{
  if (config.port_type == DeviceConfig::INTERNAL) {
#ifdef ANDROID
    if (is_simulator())
      return true;

    device.internal_gps = InternalGPS::create(Java::GetEnv(), native_view,
                                              device.GetIndex());
    return device.internal_gps != NULL;
#else
    return false;
#endif
  }

  const struct DeviceRegister *Driver = devGetDriver(config.driver_name);
  if (Driver == NULL)
    return false;

  Port *Com = OpenPort(config, device);
  if (Com == NULL)
    return false;

  if (!device.Open(Com, Driver)) {
    delete Com;
    return false;
  }

  if (nmeaout == NULL && (Driver->Flags & (1l << dfNmeaOut)))
    nmeaout = &device;

  return true;
}
开发者ID:Mrdini,项目名称:XCSoar,代码行数:35,代码来源:device.cpp

示例5: TestCheckpointing

void TestCheckpointing(const DeviceDescriptor& device)
{
    auto featureStreamName = L"features";
    auto labelsStreamName = L"labels";

    size_t inputDim = 784;
    size_t numOutputClasses = 10;
    auto features1 = InputVariable({ inputDim }, false /*isSparse*/, DataType::Float, featureStreamName);
    auto labels1 = InputVariable({ numOutputClasses }, DataType::Float, labelsStreamName);
    auto net1_1 = BuildFFClassifierNet(features1, numOutputClasses, device, 1);
    FunctionPtr net1_2;

    if (device.Type() == DeviceKind::GPU)
    {
        // TODO: instead of cloning here, reset curand generator to make sure that parameters are initialized to the same state.
        for (auto& p : net1_1->Parameters()) 
        {
            // make sure all parameters are initialized
            assert(p.Value() != nullptr);
        }
        net1_2 = net1_1->Clone();
    }
    else 
    {
        net1_2 = BuildFFClassifierNet(features1, numOutputClasses, device, 1);
    }

    auto minibatchSource1 = TextFormatMinibatchSource(L"Train-28x28_cntk_text.txt", { { featureStreamName, inputDim }, { labelsStreamName, numOutputClasses } },  1000, false);

    TestTrainingWithCheckpointing(net1_1, net1_2, labels1, minibatchSource1, device);

    inputDim = 2000;
    numOutputClasses = 5;
    auto features2 = InputVariable({ inputDim }, true /*isSparse*/, DataType::Float, featureStreamName);
    auto labels2 = InputVariable({ numOutputClasses }, DataType::Float, labelsStreamName, { Axis::DefaultBatchAxis() });
    auto net2_1 = BuildLSTMClassifierNet(features2, numOutputClasses, device, 1);
    FunctionPtr net2_2;

    if (device.Type() == DeviceKind::GPU)
    {
        // TODO: instead of cloning here, reset curand generator to make sure that parameters are initialized to the same state.
        for (auto& p : net2_1->Parameters()) 
        {
            // make sure all parameters are initialized
            assert(p.Value() != nullptr);
        }
        net2_2 = net2_1->Clone();
    }
    else 
    {
        net2_2 = BuildLSTMClassifierNet(features2, numOutputClasses, device, 1);
    }

    auto minibatchSource2 = TextFormatMinibatchSource(L"Train.ctf", { { featureStreamName, inputDim, true, L"x" }, {  labelsStreamName, numOutputClasses, false, L"y" } }, 1000, false);

    TestTrainingWithCheckpointing(net2_1, net2_2, labels2, minibatchSource2, device);
}
开发者ID:shadrack4292,项目名称:CNTK,代码行数:57,代码来源:SerializationTests.cpp

示例6: devTick

void
devTick(const NMEA_INFO &basic, const DERIVED_INFO &calculated)
{
  int i;

  for (i = 0; i < NUMDEV; i++) {
    DeviceDescriptor *d = &DeviceList[i];
    d->OnSysTicker(basic, calculated);
  }
}
开发者ID:Mrdini,项目名称:XCSoar,代码行数:10,代码来源:All.cpp

示例7: devTick

void
devTick(const DerivedInfo &calculated)
{
  int i;

  for (i = 0; i < NUMDEV; i++) {
    DeviceDescriptor *d = &DeviceList[i];
    d->OnSysTicker(calculated);
  }
}
开发者ID:macsux,项目名称:XCSoar,代码行数:10,代码来源:All.cpp

示例8: devInitOne

static void
devInitOne(DeviceDescriptor &device, const DeviceConfig &config)
{
  device.SetConfig(config);

  /* this OperationEnvironment instance must be persistent, because
     DeviceDescriptor::Open() is asynchronous */
  static PopupOperationEnvironment env;

  device.ResetFailureCounter();
  device.Open(env);
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:12,代码来源:device.cpp

示例9: DeviceDescriptor

bool UsbDmxPlugin::AddDeviceDescriptor(int fd) {
  vector<DeviceDescriptor*>::const_iterator iter = m_descriptors.begin();
  for (; iter != m_descriptors.end(); ++iter) {
    if ((*iter)->ReadDescriptor() == fd)
      return true;
  }
  DeviceDescriptor *socket = new DeviceDescriptor(fd);
  socket->SetOnData(NewCallback(this, &UsbDmxPlugin::SocketReady));
  m_plugin_adaptor->AddReadDescriptor(socket);
  m_descriptors.push_back(socket);
  return true;
}
开发者ID:Jazeido,项目名称:ola,代码行数:12,代码来源:UsbDmxPlugin.cpp

示例10: findIndexWithPhysicalDevice

 void Manager::devicePlugged( DeviceDescriptor * physicalDevice )
 {
     bool matchedExisting = false;
     
     Index * existing = findIndexWithPhysicalDevice(physicalDevice);
     if( existing ) return;
     
     //look for matching deviceless index
     for( tIndices::iterator i = mIndices.begin(); i != mIndices.end() ; i++ )
     {
         Index * index = * i;
         if( !index->getPhysicalDevice() )
         {
             DeviceDescriptor * dd = index->recallDevice();
             if( dd && dd->fuzzyCompareType( physicalDevice ) )
             {
                 index->setPhysicalDevice( physicalDevice );
                 index->forgetDevice();
                 matchedExisting = true;
                 
                  BOOST_LOG_TRIVIAL(trace) << "Reconnected physical device (" << physicalDevice->getVendorProductCombo() << ") to Player [" << index->getPlayer() << "] with existing index \"" << index->getName() << "\"" << std::endl;
             }
         }
     }
     
     if( !matchedExisting )
     {
         //build look for matching index delcaration and create an index
         for( ast::hidCollapseList::iterator d = indexDefinitions.begin();
             d != indexDefinitions.end() ;
             d++ )
         {
             //build a comparable device descriptor ot compare with the ones
             //generated by the operating system specific code
             DeviceDescriptor declaredDevice = boost::apply_visitor( makeDescriptor() , d->device );
             
             if( declaredDevice.fuzzyCompareType( physicalDevice ) > DeviceDescriptor::MATCH_THRESHOLD )
             {
                 //build an index for this device
                 //element mapping occurrs at an OS-aware level
                 //so let the implementaiton of createIndex and createElements handle that
                 Index * newIndex = new Index( this, d->entries , d->index );
                 newIndex->setPhysicalDevice( physicalDevice );
                 mIndices.push_back( newIndex );
                 
                 putInNextAvailablePlayerSlot( newIndex );
                 return;
             }
         }
     }
 }
开发者ID:quiasmo,项目名称:HIDCollapse,代码行数:51,代码来源:Manager.cpp

示例11: BOOST_LOG_TRIVIAL

 void Manager::buildIndices()
 {
     /*
     BOOST_LOG_TRIVIAL(trace) << "Initially available physical devices: " << std::endl;
     if( mPhysicalDevices.size() == 0 )
          BOOST_LOG_TRIVIAL(trace) << "\t No physical devices." << std::endl;
     
     for( tPhysicalDevices::iterator i= mPhysicalDevices.begin() ;
         i!= mPhysicalDevices.end() ;
         i++ )
     {
         DeviceDescriptor * dd = *i;
          BOOST_LOG_TRIVIAL(trace) << "\t" << dd->getVendorProductCombo() << std::endl;
     }
     */
     
     for( ast::hidCollapseList::iterator d = indexDefinitions.begin();
         d != indexDefinitions.end() ;
         d++ )
     {
         //build a comparable device descriptor ot compare with the ones
         //generated by the operating system specific code
         DeviceDescriptor declaredDevice = boost::apply_visitor( makeDescriptor() , d->device );
         
         for( tPhysicalDevices::iterator i= mPhysicalDevices.begin() ;
             i!= mPhysicalDevices.end() ;
             i++ )
         {
             DeviceDescriptor * physicalDevice = *i;
             
             Index * existing = findIndexWithPhysicalDevice( physicalDevice );
             
             if( !existing )
             {
                 if( declaredDevice.fuzzyCompareType( physicalDevice ) > DeviceDescriptor::MATCH_THRESHOLD )
                 {
                     //build an index for this device
                     //element mapping occurrs at an OS-aware level
                     //so let the implementaiton of createIndex and createElements handle that
                     Index * newIndex = new Index( this, d->entries , d->index );
                     newIndex->setPhysicalDevice( physicalDevice );
                     mIndices.push_back( newIndex );
                     
                     putInNextAvailablePlayerSlot(newIndex);
                 }
             }
         }
     }
 }
开发者ID:quiasmo,项目名称:HIDCollapse,代码行数:49,代码来源:Manager.cpp

示例12: strError

tPtr<DeviceHandleImpl> DriverMIDI::connect(const DeviceDescriptor& device_)
{
  M_LOG("[DriverMIDI] connecting to " << device_.name() << ":" << device_.vendorId() << ":"
                                      << device_.productId());
  try
  {
    return tPtr<DeviceHandleImpl>(new DeviceHandleMIDI(device_));
  }
  catch (RtMidiError& error)
  {
	std::string strError(error.getMessage());
    M_LOG("[DriverMIDI] RtMidiError: " << strError);
    return nullptr;
  }
}
开发者ID:shaduzlabs,项目名称:cabl,代码行数:15,代码来源:DriverMIDI.cpp

示例13: Set

    void Set(const DeviceDescriptor &device, const NMEAInfo &basic) {
      switch (device.GetState()) {
      case PortState::READY:
        open = true;
        error = false;
        break;

      case PortState::FAILED:
        open = false;
        error = true;
        break;

      case PortState::LIMBO:
        open = false;
        error = false;
        break;
      }

      alive = basic.alive;
      location = basic.location_available;
      gps = basic.gps.fix_quality_available;
      baro = basic.baro_altitude_available ||
        basic.pressure_altitude_available ||
        basic.static_pressure_available;
      airspeed = basic.airspeed_available;
      vario = basic.total_energy_vario_available;
      traffic = basic.flarm.IsDetected();
    }
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:28,代码来源:DeviceListDialog.cpp

示例14: Init

/// <summary> 
/// Инициализирует канал связи с указанным устройством.
/// До вызова этой функции никакие настроики порта или операции ввода-вывода проводиться не могут.
/// </summary>
/// <param name="d"> Описатель устройства. Экземпляр класса, позволяющего идентефицировать устройство, к которому надо подключиться.
/// Как получить список доступных устройств, см: <see cref="DeviceDescriptor::GetDevicesList()">Класс перечисления совместимых устройств</see></param> 
/// <returns> Результат попытки открытия канала</returns>
bool COM_CommCh::Init(DeviceDescriptor d)
{
	this->setDeviceName(d.GetCOMname());

    std::cout<<"Device COM name = "<<this->deviceName().toStdString()<<std::endl;
		
    if (this->AbstractSerial::open(this->ReadWrite | AbstractSerial::Unbuffered))
    {
		// при небуферизованном режиме, необходимо выставить не нулевое время таймаутов !!!
		// ИНАЧЕ НИЧЕГО ЧИТАТЬСЯ НЕ БУДЕТ!!! 
		const int CharIntervalTimeout__ = 10;
		const int TotalReadConstantTimeout__ = 10;
		this->setCharIntervalTimeout(CharIntervalTimeout__); 
		this->setTotalReadConstantTimeout(TotalReadConstantTimeout__);

        std::cout<<"Device opened."<<std::endl;

		// устанавливаем состояние
		opened = true;
		return true;
	}
    else
	{
        std::cout<<"Failed to open Device"<<std::endl;
		// устанавливаем состояние
		opened = false;
		return false;
	}
};
开发者ID:physt111,项目名称:Base,代码行数:36,代码来源:Basic_CommunicationChannel.cpp

示例15: ShowPortMonitor

void
ShowPortMonitor(SingleWindow &parent, const DialogLook &dialog_look,
                const TerminalLook &terminal_look,
                DeviceDescriptor &device)
{
  /* create the dialog */

  WindowStyle dialog_style;
  dialog_style.Hide();
  dialog_style.ControlParent();

  TCHAR buffer[64];
  StaticString<128> caption;
  caption.Format(_T("%s: %s"), _("Port monitor"),
                 device.GetConfig().GetPortName(buffer, ARRAY_SIZE(buffer)));

  WndForm dialog(dialog_look);
  dialog.Create(parent, caption, dialog_style);

  ContainerWindow &client_area = dialog.GetClientAreaWindow();

  PortMonitorGlue glue(device, terminal_look);

  ButtonPanel buttons(client_area, dialog_look);
  buttons.Add(_("Close"), dialog, mrOK);
  glue.CreateButtons(buttons);
  glue.CreateTerminal(client_area, buttons.UpdateLayout());

  /* run it */

  dialog.ShowModal();
}
开发者ID:MindMil,项目名称:XCSoar,代码行数:32,代码来源:PortMonitor.cpp


注:本文中的DeviceDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。