bool RedundantDataPath::IsAValidConfiguration( U32 &errorString ){ // the connection # check if( (GetChildCount() > 2) || (GetChildCount() < 1 ) ){ errorString = CTS_SSAPI_CM_INVALID_CONN_COUNT_FOR_RDP; return false; } // must belong to the same host HostManager *pHM = (HostManager *)GetObjectManager( GetManager(), SSAPI_MANAGER_CLASS_TYPE_HOST_MANAGER ); if( !pHM->DoConnectionsBelongToSameHost( m_children ) ){ errorString = CTS_SSAPI_CM_CONN_MUST_BELONG_2_SAME_HOST; return false; } // must map to a single primary/fail-over IOP pair if( GetChildCount() == 2 ){ DeviceManager *pDM = (DeviceManager *)GetObjectManager(GetManager(), SSAPI_MANAGER_CLASS_TYPE_DEVICE_MANAGER ); ConnectionManager *pCM = (ConnectionManager *)GetManager(); DesignatorId id1 = GetChildIdAt( 0 ), id2 = GetChildIdAt( 1 ); id1 = ((ConnectionBase *)pCM->GetManagedObject( &id1 ))->GetGeminiPortId(); id2 = ((ConnectionBase *)pCM->GetManagedObject( &id2 ))->GetGeminiPortId(); if( !pDM->AreThesePortsOnPartneredNacs( id1, id2 ) ){ errorString = CTS_SSAPI_CM_CONN_MUST_BE_ON_PARTNER_NACS; return false; } } // we made it to here? Gee, it's good then!!! return true; }
/* * =================================================================== * Device Emulation * =================================================================== * XXX: Streams and Devices are largely non-overlapping from a RPC * point of view but they *do* intersect e.g. when a stream is trying to * find its associated device and info from that device such as src/dst * mac addresses. For this reason, both set of RPCs share the common * port level locking * =================================================================== */ void MyService::getDeviceGroupIdList( ::google::protobuf::RpcController* controller, const ::OstProto::PortId* request, ::OstProto::DeviceGroupIdList* response, ::google::protobuf::Closure* done) { DeviceManager *devMgr; int portId; qDebug("In %s", __PRETTY_FUNCTION__); portId = request->id(); if ((portId < 0) || (portId >= portInfo.size())) goto _invalid_port; devMgr = portInfo[portId]->deviceManager(); response->mutable_port_id()->set_id(portId); portLock[portId]->lockForRead(); for (int i = 0; i < devMgr->deviceGroupCount(); i++) { OstProto::DeviceGroupId *dgid; dgid = response->add_device_group_id(); dgid->CopyFrom(devMgr->deviceGroupAtIndex(i)->device_group_id()); } portLock[portId]->unlock(); done->Run(); return; _invalid_port: controller->SetFailed("Invalid Port Id"); done->Run(); }
int INDIMenu::processClient(QString hostname, QString portnumber) { DeviceManager *dev; INDIDriver *drivers = ksw->getINDIDriver(); dev = new DeviceManager(this, mgrCounter); if (dev->indiConnect(hostname, portnumber)) { mgr.append(dev); if (drivers) { connect(dev, SIGNAL(newDevice()), drivers, SLOT(updateMenuActions())); connect(dev, SIGNAL(newDevice()), this, SLOT(discoverDevice())); } } else { delete (dev); return (-1); } mgrCounter++; return (mgrCounter - 1); }
void IosDeviceManager::deviceConnected(const QString &uid, const QString &name) { DeviceManager *devManager = DeviceManager::instance(); Core::Id baseDevId(Constants::IOS_DEVICE_ID); Core::Id devType(Constants::IOS_DEVICE_TYPE); Core::Id devId = baseDevId.withSuffix(uid); IDevice::ConstPtr dev = devManager->find(devId); if (dev.isNull()) { IosDevice *newDev = new IosDevice(uid); if (!name.isNull()) newDev->setDisplayName(name); qCDebug(detectLog) << "adding ios device " << uid; devManager->addDevice(IDevice::ConstPtr(newDev)); } else if (dev->deviceState() != IDevice::DeviceConnected && dev->deviceState() != IDevice::DeviceReadyToUse) { qCDebug(detectLog) << "updating ios device " << uid; IosDevice *newDev = 0; if (dev->type() == devType) { const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); newDev = new IosDevice(*iosDev); } else { newDev = new IosDevice(uid); } devManager->addDevice(IDevice::ConstPtr(newDev)); } updateInfo(uid); }
void MyService::getDeviceNeighbors( ::google::protobuf::RpcController* controller, const ::OstProto::PortId* request, ::OstProto::PortNeighborList* response, ::google::protobuf::Closure* done) { DeviceManager *devMgr; int portId; qDebug("In %s", __PRETTY_FUNCTION__); portId = request->id(); if ((portId < 0) || (portId >= portInfo.size())) goto _invalid_port; devMgr = portInfo[portId]->deviceManager(); response->mutable_port_id()->set_id(portId); portLock[portId]->lockForRead(); devMgr->getDeviceNeighbors(response); portLock[portId]->unlock(); done->Run(); return; _invalid_port: controller->SetFailed("Invalid Port Id"); done->Run(); }
bool DeviceCheckBuildStep::init(QList<const BuildStep *> &earlierSteps) { Q_UNUSED(earlierSteps); IDevice::ConstPtr device = DeviceKitInformation::device(target()->kit()); if (!device) { Core::Id deviceTypeId = DeviceTypeKitInformation::deviceTypeId(target()->kit()); IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId); if (!factory || !factory->canCreate()) { emit addOutput(tr("No device configured."), BuildStep::ErrorMessageOutput); return false; } QMessageBox msgBox(QMessageBox::Question, tr("Set Up Device"), tr("There is no device set up for this kit. Do you want to add a device?"), QMessageBox::Yes|QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); if (msgBox.exec() == QMessageBox::No) { emit addOutput(tr("No device configured."), BuildStep::ErrorMessageOutput); return false; } IDevice::Ptr newDevice = factory->create(deviceTypeId); if (newDevice.isNull()) { emit addOutput(tr("No device configured."), BuildStep::ErrorMessageOutput); return false; } DeviceManager *dm = DeviceManager::instance(); dm->addDevice(newDevice); DeviceKitInformation::setDevice(target()->kit(), newDevice); } return true; }
SystemEngine::SystemEngine() { setProxy(); RemoteStorage::initialize(); DriverManager::initialize(); DeviceManager::initialize(); WatcherManager::initialize(); RemoteStorage *storage = RemoteStorage::instance(); DeviceManager *devManager = DeviceManager::instance(); if (storage) { _lastId = -1; if (devManager) { connect(devManager, SIGNAL(newMessageReceived(const IMessage*)), storage, SLOT(dispatchMessage(const IMessage*))); devManager->loadDevices(); } qDebug(">> Fetching pending messages from main server ..."); MessageList pendingMessages(storage->pendingMessages()); foreach (const IMessage *message, pendingMessages) { redirectMessage(message); } }
//-------------------------------------------------------------- Device* Animation::getDeviceCurrent() { DeviceManager* pDeviceManager = GLOBALS->mp_deviceManager; if (pDeviceManager) { return pDeviceManager->getDeviceCurrent(); } return 0; }
//-------------------------------------------------------------- Device* Animation::getDevice(string deviceId) { DeviceManager* pDeviceManager = GLOBALS->mp_deviceManager; if (pDeviceManager) { return pDeviceManager->getDeviceById(deviceId); } return 0; }
bool Device::unregisterDevice() { DeviceManager* manager = DeviceManager::getInstance(); if (manager->unregisterDevice(getId())) { this->setId(-1); return true; } else { return false; } }
QString IosRunConfiguration::disabledReason() const { if (m_parseInProgress) return tr("The .pro file \"%1\" is currently being parsed.") .arg(QFileInfo(m_profilePath).fileName()); if (!m_parseSuccess) return static_cast<QmakeProject *>(target()->project()) ->disabledReasonForRunConfiguration(m_profilePath); Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE) return tr("Kit has incorrect device type for running on iOS devices."); IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); QString validDevName; bool hasConncetedDev = false; if (devType == Constants::IOS_DEVICE_TYPE) { DeviceManager *dm = DeviceManager::instance(); for (int idev = 0; idev < dm->deviceCount(); ++idev) { IDevice::ConstPtr availDev = dm->deviceAt(idev); if (!availDev.isNull() && availDev->type() == Constants::IOS_DEVICE_TYPE) { if (availDev->deviceState() == IDevice::DeviceReadyToUse) { validDevName += QLatin1Char(' '); validDevName += availDev->displayName(); } else if (availDev->deviceState() == IDevice::DeviceConnected) { hasConncetedDev = true; } } } } if (dev.isNull()) { if (!validDevName.isEmpty()) return tr("No device chosen. Select %1.").arg(validDevName); // should not happen else if (hasConncetedDev) return tr("No device chosen. Enable developer mode on a device."); // should not happen else return tr("No device available."); } else { switch (dev->deviceState()) { case IDevice::DeviceReadyToUse: break; case IDevice::DeviceConnected: return tr("To use this device you need to enable developer mode on it."); case IDevice::DeviceDisconnected: case IDevice::DeviceStateUnknown: if (!validDevName.isEmpty()) return tr("%1 is not connected. Select %2?") .arg(dev->displayName(), validDevName); else if (hasConncetedDev) return tr("%1 is not connected. Enable developer mode on a device?") .arg(dev->displayName()); else return tr("%1 is not connected.").arg(dev->displayName()); } } return RunConfiguration::disabledReason(); }
int main(int argc, char *argv[]) { QApplication::setGraphicsSystem("raster"); QApplication a(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); QString privatePathQt(QApplication::applicationDirPath()); QString path(privatePathQt); path = QDir::toNativeSeparators(path); Server server; if (!server.listen(QHostAddress::Any, 6177)) { std::cerr << "Failed to bind to port" << std::endl; return 1; } QDeclarativeView view; view.engine()->setOfflineStoragePath(path); QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &a, SLOT(quit())); view.setSource(QUrl("qrc:/qml/main.qml")); view.show(); QString md5; QString dbname="DemoDB"; QByteArray ba; ba = QCryptographicHash::hash (dbname.toAscii(), QCryptographicHash::Md5); md5.append(ba.toHex()); md5.append(".sqlite"); path.append(QDir::separator()).append("Databases"); path.append(QDir::separator()).append(md5); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(path); if (!db.open()) { std::cerr << "Cannot open database" << std::endl; return 1; } OrderManager orderManager; view.rootContext()->setContextProperty("server", &server); view.rootContext()->setContextProperty("orderManager", &orderManager); Client client; QObject::connect(&orderManager, SIGNAL(send()), &client, SLOT(sendOrder())); QObject::connect(&server, SIGNAL(paied(quint32)), &orderManager, SLOT(payOrder(quint32))); DeviceManager deviceManager; QObject::connect(&deviceManager, SIGNAL(registerSignal()), &client, SLOT(sendRegistration())); view.rootContext()->setContextProperty("deviceManager", &deviceManager); deviceManager.registerDevice(); return a.exec(); }
int main(int argc, char **argv) { /*Load Plugins*/ DeviceManager *deviceManager = new DeviceManager("ReceiveTestApp"); deviceManager->pluginLoad("Plugins"); deviceManager->pluginSetCommParameter("Minuit", "pluginReceptionPort", "9998"); deviceManager->pluginSetCommParameter("OSC", "pluginReceptionPort", "9999"); deviceManager->pluginLaunch(); cout << endl; vector<string> plugins = deviceManager->pluginGetLoadedByName(); cout << "Current loaded plugins : " << endl; for (int i = 0; i < plugins.size(); i++) { cout << plugins.at(i) << endl; } cout << endl; /***************/ /*Add Devices(1 Minuit device)*/ std::map<std::string, std::string> *deviceParameters = new std::map<std::string, std::string>; deviceParameters->insert(std::pair<std::string, std::string>("ip", "127.0.0.1")); deviceParameters->insert(std::pair<std::string, std::string>("port", "7002")); deviceManager->deviceAdd("SendTestApp", "Minuit", deviceParameters); /*Display Device names*/ map<string, Device*> *devices = deviceManager->deviceGetCurrent(); cout << "Current devices : " << endl; map<string, Device*>::iterator it = devices->begin(); while(it != devices->end()){ cout << it->first << endl; it++; } cout << endl; /***************/ /*test receiveMessage*/ deviceManager->namespaceSetAddCallback(NULL, &receiveCallBack); cout << "Waiting message..." << endl; while (true) { usleep(1000); } /***************/ delete devices; delete deviceParameters; delete deviceManager; return EXIT_SUCCESS; }
void MyService::addDeviceGroup( ::google::protobuf::RpcController* controller, const ::OstProto::DeviceGroupIdList* request, ::OstProto::Ack* /*response*/, ::google::protobuf::Closure* done) { DeviceManager *devMgr; int portId; qDebug("In %s", __PRETTY_FUNCTION__); portId = request->port_id().id(); if ((portId < 0) || (portId >= portInfo.size())) goto _invalid_port; devMgr = portInfo[portId]->deviceManager(); if (portInfo[portId]->isTransmitOn()) goto _port_busy; portLock[portId]->lockForWrite(); for (int i = 0; i < request->device_group_id_size(); i++) { quint32 id = request->device_group_id(i).id(); const OstProto::DeviceGroup *dg = devMgr->deviceGroup(id); // If device group with same id as in request exists already ==> error! if (dg) continue; //! \todo (LOW): Partial status of RPC devMgr->addDeviceGroup(id); } portLock[portId]->unlock(); //! \todo (LOW): fill-in response "Ack"???? done->Run(); return; _port_busy: controller->SetFailed("Port Busy"); goto _exit; _invalid_port: controller->SetFailed("invalid portid"); _exit: done->Run(); }
int main() { DeviceManager devManager; devManager.scanDevices(); for(auto &dev: devManager){ dev->setPadReceiver(&padReceiver); dev->print(); } devManager.loop(); getchar(); return 0; }
//----------------------------------------------------------------------------- //! @brief TODO enter a description //! @remark //----------------------------------------------------------------------------- bool VertexBuffer::createBufferAndLayoutElements(const DeviceManager& deviceManager, size_t bufferSize, void* data, bool dynamic, const VertexDecalartionDesctriptor& vertexDeclartion, const ID3DBlob* vertexShaderCodeBlob) { D3D11_BUFFER_DESC bufferDescriptor; ZeroMemory(&bufferDescriptor, sizeof(D3D11_BUFFER_DESC)); bufferDescriptor.Usage = D3D11_USAGE_IMMUTABLE; bufferDescriptor.ByteWidth = (unsigned int)bufferSize; bufferDescriptor.BindFlags = D3D11_BIND_VERTEX_BUFFER; bufferDescriptor.CPUAccessFlags = 0; bufferDescriptor.MiscFlags = 0; D3D11_SUBRESOURCE_DATA initData; ZeroMemory(&initData, sizeof(D3D11_SUBRESOURCE_DATA)); initData.pSysMem = data; initData.SysMemPitch = 0; initData.SysMemSlicePitch = 0; HRESULT hr = deviceManager.getDevice()->CreateBuffer( &bufferDescriptor, &initData, &m_buffer ); if (FAILED(hr)) { MSG_TRACE_CHANNEL("VERTEXBUFFER", "Failed to create a D3D11 Buffer object with code: 0x%x", hr ); return false; } if (!createVertexInputLayout(deviceManager, const_cast<ID3DBlob*>(vertexShaderCodeBlob), vertexDeclartion.createInputElementLayout(m_vertexStride))) { MSG_TRACE_CHANNEL("VERTEXBUFFER", "Failed to create Vertex Input Layout" ); return false; } m_vertexCount = bufferSize / m_vertexStride; dynamic = false; return true; }
//------------------------------------------------------------------------- // @Create needed sampler states for the textures here //------------------------------------------------------------------------- bool TextureManager::createSamplerStates(const DeviceManager& deviceManager) { //Setup sampler state here D3D11_SAMPLER_DESC samplerStateDesc; samplerStateDesc.Filter = D3D11_FILTER_ANISOTROPIC; samplerStateDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; samplerStateDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; samplerStateDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; samplerStateDesc.MipLODBias = 0.0f; samplerStateDesc.MaxAnisotropy = 16; samplerStateDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; samplerStateDesc.BorderColor[0] = 0.0f; samplerStateDesc.BorderColor[1] = 0.0f; samplerStateDesc.BorderColor[2] = 0.0f; samplerStateDesc.BorderColor[3] = 0.0f; samplerStateDesc.MinLOD = -3.402823466e+38F; samplerStateDesc.MaxLOD = 3.402823466e+38F; ID3D11Device* device = deviceManager.getDevice(); HRESULT hr = device->CreateSamplerState(&samplerStateDesc, &m_samplerState); if (FAILED( hr ) ) { MSG_TRACE_CHANNEL("TEXTUREMANAGER", "Failed to create sampler state: 0x%x", hr ) return false; } return true; }
string HardwareDevice::display_name( const DeviceManager &device_manager) const { const auto hw_dev = hardware_device(); // If we can find another device with the same model/vendor then // we have at least two such devices and need to distinguish them. const auto &devices = device_manager.devices(); const bool multiple_dev = hw_dev && any_of( devices.begin(), devices.end(), [&](shared_ptr<devices::HardwareDevice> dev) { return dev->hardware_device()->vendor() == hw_dev->vendor() && dev->hardware_device()->model() == hw_dev->model() && dev->device_ != device_; }); vector<string> parts = {device_->vendor(), device_->model()}; if (multiple_dev) { parts.push_back(device_->version()); parts.push_back(device_->serial_number()); if ((device_->serial_number().length() == 0) && (device_->connection_id().length() > 0)) parts.push_back("(" + device_->connection_id() + ")"); } return join(parts, " "); }
bool INDIMenu::processServer() { INDIDriver *drivers = ksw->getINDIDriver(); DeviceManager *dev; if (drivers == NULL) return false; for (unsigned int i=0; i < drivers->devices.size(); i++) { // Devices ready to run but not yet managed if (drivers->devices[i]->state && drivers->devices[i]->managed == false && drivers->devices[i]->mode == IDevice::M_LOCAL) { dev = new DeviceManager(this, mgrCounter); if (dev->indiConnect("localhost", QString("%1").arg(drivers->devices[i]->indiPort))) { drivers->devices[i]->mgrID = mgrCounter; drivers->devices[i]->managed = true; mgr.append(dev); connect(dev, SIGNAL(newDevice()), drivers, SLOT(updateMenuActions())); connect(dev, SIGNAL(newDevice()), this, SLOT(discoverDevice())); mgrCounter++; } else { delete (dev); return false; } } // Devices running and they need to be shutdown else if (!drivers->devices[i]->state && drivers->devices[i]->managed == true && drivers->devices[i]->mode == IDevice::M_LOCAL) { drivers->devices[i]->managed = false; removeDeviceMgr(drivers->devices[i]->mgrID); return true; } } return true; }
bool MessageThread::loop() { XCamReturn ret = _manager->message_loop(); if (ret == XCAM_RETURN_NO_ERROR || ret == XCAM_RETURN_ERROR_TIMEOUT) return true; return false; }
void IosDeviceManager::updateAvailableDevices(const QStringList &devices) { foreach (const QString &uid, devices) deviceConnected(uid); DeviceManager *devManager = DeviceManager::instance(); for (int iDevice = 0; iDevice < devManager->deviceCount(); ++iDevice) { IDevice::ConstPtr dev = devManager->deviceAt(iDevice); Core::Id devType(Constants::IOS_DEVICE_TYPE); if (dev.isNull() || dev->type() != devType) continue; const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); if (devices.contains(iosDev->uniqueDeviceID())) continue; if (iosDev->deviceState() != IDevice::DeviceDisconnected) { qCDebug(detectLog) << "disconnecting device " << iosDev->uniqueDeviceID(); devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected); } } }
quint64 getNeighborMacAddress(int portId, int streamId, int frameIndex) { MyService *service = drone->rpcService(); DeviceManager *devMgr = NULL; quint64 mac; if (!service) return 0; if ((portId >= 0) && (portId < service->portInfo.size())) devMgr = service->portInfo[portId]->deviceManager(); if (!devMgr || !devMgr->deviceCount()) return 0; service->portLock[portId]->lockForWrite(); mac = service->portInfo[portId]->neighborMacAddress(streamId, frameIndex); service->portLock[portId]->unlock(); return mac; }
void IosDeviceManager::deviceDisconnected(const QString &uid) { qCDebug(detectLog) << "detected disconnection of ios device " << uid; DeviceManager *devManager = DeviceManager::instance(); Core::Id baseDevId(Constants::IOS_DEVICE_ID); Core::Id devType(Constants::IOS_DEVICE_TYPE); Core::Id devId = baseDevId.withSuffix(uid); IDevice::ConstPtr dev = devManager->find(devId); if (dev.isNull() || dev->type() != devType) { qCWarning(detectLog) << "ignoring disconnection of ios device " << uid; // should neve happen } else { const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); if (iosDev->m_extraInfo.isEmpty() || iosDev->m_extraInfo.value(QLatin1String("deviceName")) == QLatin1String("*unknown*")) { devManager->removeDevice(iosDev->id()); } else if (iosDev->deviceState() != IDevice::DeviceDisconnected) { qCDebug(detectLog) << "disconnecting device " << iosDev->uniqueDeviceID(); devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected); } } }
//----------------------------------------------------------------------------- //! @brief TODO enter a description //! @remark //----------------------------------------------------------------------------- bool VertexBuffer::createVertexInputLayout( const DeviceManager& deviceManager, ID3DBlob* vertexShaderCodeBlob, const std::vector<D3D11_INPUT_ELEMENT_DESC>& inputElements ) { HRESULT hr = deviceManager.getDevice()->CreateInputLayout(&inputElements[0], (unsigned int)inputElements.size(), vertexShaderCodeBlob->GetBufferPointer(), vertexShaderCodeBlob->GetBufferSize(), &m_inputLayout ); if (FAILED( hr ) ) { MSG_TRACE_CHANNEL("VERTEXBUFFER", "Failed to create the input layout: 0x%x", hr ) return false; } return true; }
int main(int argc, char **argv) { DeviceManager manager; Flash flash; if(argc != 3) { usage(argv[0]); return 0; } string action = argv[1]; if(action != "dump" && action != "flash") { cout << "Invalid action!" << endl; usage(argv[0]); return 0; } if(!UsbProgrammer::getProgrammer()->IsInitialized()) { cout << "Cannot connect to programmer!" << endl; return 1; } if(!manager.IsSupported()) { cout << "Device is NOT supported!" << endl; return 1; } if(action == "dump") { if(!flash.dump(argv[2])) { cout << "Dumping failed!" << endl; return 1; } } else if(action == "flash"){ cout << "Action currently not supported!" << endl; } manager.XapResetAndGo(); return 0; }
void MyService::modifyDeviceGroup( ::google::protobuf::RpcController* controller, const ::OstProto::DeviceGroupConfigList* request, ::OstProto::Ack* /*response*/, ::google::protobuf::Closure* done) { DeviceManager *devMgr; int portId; qDebug("In %s", __PRETTY_FUNCTION__); portId = request->port_id().id(); if ((portId < 0) || (portId >= portInfo.size())) goto _invalid_port; devMgr = portInfo[portId]->deviceManager(); if (portInfo[portId]->isTransmitOn()) goto _port_busy; portLock[portId]->lockForWrite(); for (int i = 0; i < request->device_group_size(); i++) devMgr->modifyDeviceGroup(&request->device_group(i)); portLock[portId]->unlock(); //! \todo(LOW): fill-in response "Ack"???? done->Run(); return; _port_busy: controller->SetFailed("Port Busy"); goto _exit; _invalid_port: controller->SetFailed("invalid portid"); _exit: done->Run(); }
void MyService::getDeviceGroupConfig( ::google::protobuf::RpcController* controller, const ::OstProto::DeviceGroupIdList* request, ::OstProto::DeviceGroupConfigList* response, ::google::protobuf::Closure* done) { DeviceManager *devMgr; int portId; qDebug("In %s", __PRETTY_FUNCTION__); portId = request->port_id().id(); if ((portId < 0) || (portId >= portInfo.size())) goto _invalid_port; devMgr = portInfo[portId]->deviceManager(); response->mutable_port_id()->set_id(portId); portLock[portId]->lockForRead(); for (int i = 0; i < request->device_group_id_size(); i++) { const OstProto::DeviceGroup *dg; dg = devMgr->deviceGroup(request->device_group_id(i).id()); if (!dg) continue; //! \todo(LOW): Partial status of RPC response->add_device_group()->CopyFrom(*dg); } portLock[portId]->unlock(); done->Run(); return; _invalid_port: controller->SetFailed("invalid portid"); done->Run(); }
int main( int argc, char *argv[] ) { struct sigaction sigact; int rval = 0; sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); using namespace USB; DeviceManager mgr; theMgr = &mgr; try { mgr.registerDevice( SpacePilotDevice::VendorID, SpacePilotDevice::ProductID, &SpacePilotDevice::factory ); mgr.start(); if ( argc > 1 ) { std::shared_ptr<Device> sppro = mgr.findDevice( SpacePilotDevice::VendorID, SpacePilotDevice::ProductID ); if ( sppro ) { SpacePilotDevice *dev = reinterpret_cast<SpacePilotDevice *>( sppro.get() ); dev->setLCD( std::string( argv[1] ) ); } } mgr.processEventLoop(); } catch ( usb_error &e ) { int err = e.getUSBError(); libusb_error ec = (libusb_error)( err ); std::cerr << "ERROR: " << libusb_error_name( err ) << " - " << libusb_strerror( ec ) << std::endl; rval = -1; } catch ( ... ) { rval = -1; } mgr.shutdown(); theMgr = nullptr; return rval; }
void IndexBuffer::createBuffer( const DeviceManager& deviceManager, unsigned int bufferSize, void* data, bool dynamic, unsigned int bindFlag ) { D3D11_BUFFER_DESC bufferDescriptor; ZeroMemory(&bufferDescriptor, sizeof(D3D11_BUFFER_DESC)); bufferDescriptor.Usage = D3D11_USAGE_IMMUTABLE; bufferDescriptor.ByteWidth = bufferSize; bufferDescriptor.BindFlags = bindFlag; bufferDescriptor.CPUAccessFlags = 0; bufferDescriptor.MiscFlags = 0; D3D11_SUBRESOURCE_DATA initData; ZeroMemory(&initData, sizeof(D3D11_SUBRESOURCE_DATA)); initData.pSysMem = data; initData.SysMemPitch = 0; initData.SysMemSlicePitch = 0; HRESULT hr = deviceManager.getDevice()->CreateBuffer( &bufferDescriptor, &initData, &m_buffer ); if (FAILED(hr)) { MSG_TRACE_CHANNEL("INDEXBUFFER", "Failed to create a D3D11 Buffer object with code: 0x%x", hr ); } dynamic = false; }
//----------------------------------------------------------------------------- int main( int argc, char* argv[]) //----------------------------------------------------------------------------- { const char* pDevSerial = "BF*"; cout << "\n ++ Start PowerDownTest sample: " << __DATE__ << "/" << __TIME__ << endl; if( argc > 1 ) { pDevSerial = argv[1]; } unsigned int uiDevCount = 0; DeviceManager DevMgr; if( ( uiDevCount = DevMgr.deviceCount() ) == 0 ) { cout << "*** Error: No MATRIX VISION device found! Unable to continue!" << endl; return 0; } cout << "Have found " << uiDevCount << " devices on this platform!" << endl; for( unsigned i=0; i<uiDevCount; i++ ) { Device* pDevTmp = DevMgr.getDevice( i ); cout << " " << i << " Serial: " << pDevTmp->serial.read() << endl; } cout << "Initialising the device: "<< pDevSerial << ". This might take some time..." << endl; // create an interface to the first MATRIX VISION device with the serila number pDevSerial Device* pDev = DevMgr.getDeviceBySerial( pDevSerial ); try { pDev->open(); } catch( ImpactAcquireException& e ) { // this e.g. might happen if the same device is already opened in another process... cout << "*** Error: An error occurred while opening the device(error code: " << e.getErrorCode() << ")." << endl; return 0; } FunctionInterface fi( pDev ); // only 8Bit/pixel destination image are supported by the \c writeFile() function ImageDestination imgDst( pDev ); imgDst.pixelFormat.write( idpfMono8 ); // get mvBF system settings SystemBlueFOX sbf( pDev ); bool bPowerDown = false; do { cout << "Ready to snap. Press 'p'<return> to power down, 'q'<return> to quit or <return> to snap an image.." << endl; char ch = getchar(); if( ch == 'p' ) { // for mvBlueFOX only: test power down / up cout << "Power off!" << endl; sbf.powerMode.write( dpmOff ); bPowerDown = true; // read and discard the <return> getchar(); } else if( ch == 'q' ) { // break out of loop to finish application // read and discard the <return> getchar(); break; } else { // snap if( bPowerDown ) { // first we need to power up again CTime timer1; sbf.powerMode.write( dpmOn ); bPowerDown = false; cout << "Power On!" << ". Power On took " << timer1.elapsed() << "s., " << endl; } CTime timer; // send a request to the default request queue of the device and wait for the result. fi.imageRequestSingle(); const int iMaxWaitTime_ms = 5000; // wait for results from the default capture queue int iRequestNr = fi.imageRequestWaitFor( iMaxWaitTime_ms ); cout << "Request Nr.: " << iRequestNr << ". Snap took " << timer.elapsed() << "s., " << endl; // check if the image has been captured without any problems if( !fi.isRequestNrValid( iRequestNr ) ) { // this can not happen in this sample, but may happen if you wait for a request without // sending one to the driver before cout << "*** Error: No request has been sent to the driver." << endl; // unlock the buffer to let the driver know that you no longer need this buffer fi.imageRequestUnlock( iRequestNr ); // free resources fi.imageRequestReset( 0, 0 ); pDev->close(); return 0; } const Request* psRequest = fi.getRequest(iRequestNr); if( !fi.isRequestOK( psRequest ) ) { cout << "*** " << psRequest->requestResult << endl; // unlock the buffer to let the driver know that you no longer need this buffer fi.imageRequestUnlock( iRequestNr ); // free resources fi.imageRequestReset( 0, 0 ); pDev->close(); return 0; } // Everything went well. Save the result const char* pImageName = "SingCapt.pgm"; cout << "Will save the file as: " << pImageName << endl; if( writeFile( (const unsigned char*)psRequest->imageData.read(), psRequest->imageWidth.read(), psRequest->imageHeight.read(), psRequest->imageLinePitch.read(), psRequest->imagePixelPitch.read(), pImageName ) < 0 ) cout << "*** Error: File: "<< pImageName << " could not be saved!!" << endl; // unlock the buffer to let the driver know that you no longer need this buffer fi.imageRequestUnlock( iRequestNr ); } // snap } while( true ); // free resources fi.imageRequestReset( 0, 0 ); pDev->close(); return 0; }