void TestSubscription(CpStack& aCpStack) { gSubscriptionCount = 0; // reset this here in case we're run multiple times via TestShell Debug::SetLevel(Debug::kNone); Environment& env = aCpStack.Env(); DeviceList* deviceList = new DeviceList(env); FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &DeviceList::Added); FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &DeviceList::Removed); const Brn domainName("upnp.org"); const Brn serviceType("ConnectionManager"); #if 1 const TUint ver = 1; CpDeviceListUpnpServiceType* list = new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed); #else const Brn uuid("896659847466-a4badbeaacbc-737837"); CpDeviceListUpnpUuid* list = new CpDeviceListUpnpUuid(aCpStack, uuid, added, removed); #endif Blocker* blocker = new Blocker(env); blocker->Wait(env.InitParams().MsearchTimeSecs()); delete blocker; deviceList->Stop(); TUint startTime = Os::TimeInMs(env.OsCtx()); deviceList->Poll(); const TUint count = deviceList->Count(); Print("\n%u subscriptions on %u devices (avg %u) in %u seconds\n", gSubscriptionCount, count, (count==0? 0 : gSubscriptionCount/count), (Os::TimeInMs(env.OsCtx())-startTime+500)/1000); delete list; delete deviceList; }
DeviceList DeviceInfo::xvAdaptors() { qDebug("DeviceInfo::xvAdaptors"); DeviceList l; QRegExp rx_device("^.*Adaptor #([0-9]+): \"(.*)\""); QProcess p; p.setProcessChannelMode(QProcess::MergedChannels); p.setEnvironment(QProcess::systemEnvironment() << "LC_ALL=C"); p.start("xvinfo"); if (p.waitForFinished()) { QByteArray line; while (p.canReadLine()) { line = p.readLine(); qDebug("DeviceInfo::xvAdaptors: '%s'", line.constData()); if (rx_device.indexIn(line) > -1) { QString id = rx_device.cap(1); QString desc = rx_device.cap(2); qDebug("DeviceInfo::xvAdaptors: found adaptor: '%s' '%s'", id.toUtf8().constData(), desc.toUtf8().constData()); l.append(DeviceData(id, desc)); } } } else { qDebug("DeviceInfo::xvAdaptors: could not start xvinfo, error %d", p.error()); } return l; }
extern "C" void OhNetTestRunner(OhNetHandleInitParams aInitParams) { OhNetInitParamsSetMsearchTime(aInitParams, 1); OhNetInitParamsSetUseLoopbackNetworkAdapter(aInitParams); OhNetInitParamsSetDvUpnpServerPort(aInitParams, 0); OhNetLibraryInitialise(aInitParams); Print("TestDvDeviceC - starting\n"); OhNetHandleNetworkAdapterList subnetList = OhNetSubnetListCreate(); OhNetHandleNetworkAdapter nif = OhNetSubnetAt(subnetList, 0); TIpAddress subnet = OhNetNetworkAdapterSubnet(nif); OhNetSubnetListDestroy(subnetList); (void)OhNetLibraryStartCombined(subnet); // Debug::SetLevel(Debug::kService); Semaphore* sem = new Semaphore("SEM1", 0); DeviceBasicC* device = new DeviceBasicC(DeviceBasicC::eProtocolUpnp); DeviceList* deviceList = new DeviceList(*sem); HandleCpDeviceList dlh = CpDeviceListCreateUpnpServiceType("openhome.org", "TestBasic", 1, added, deviceList, removed, deviceList); sem->Wait(30*1000); // allow up to 30 seconds to find our one device deviceList->TestActions(); deviceList->TestSubscriptions(); CpDeviceListDestroy(dlh); delete sem; delete deviceList; delete device; Print("TestDvDeviceC - completed\n"); OhNetLibraryClose(); }
DeviceList DeviceInfo::alsaDevices() { qDebug("DeviceInfo::alsaDevices"); DeviceList l; QRegExp rx_device("^card\\s([0-9]+).*\\[(.*)\\],\\sdevice\\s([0-9]+):"); QProcess p; p.setProcessChannelMode(QProcess::MergedChannels); p.setEnvironment(QStringList() << "LC_ALL=C"); p.start("aplay", QStringList() << "-l"); if (p.waitForFinished()) { QByteArray line; while (p.canReadLine()) { line = p.readLine(); qDebug("DeviceInfo::alsaDevices: '%s'", line.constData()); if (rx_device.indexIn(line) > -1) { QString id = rx_device.cap(1); id.append("."); id.append(rx_device.cap(3)); QString desc = rx_device.cap(2); qDebug("DeviceInfo::alsaDevices: found device: '%s' '%s'", id.toUtf8().constData(), desc.toUtf8().constData()); l.append(DeviceData(id, desc)); } } } else { qDebug("DeviceInfo::alsaDevices: could not start aplay, error %d", p.error()); } return l; }
DeviceList DeviceInfo::retrieveDevices(DeviceType type) { qDebug("DeviceInfo::retrieveDevices: %d", type); DeviceList l; QRegExp rx_device("^(\\d+): (.*)"); if (QFile::exists("dxlist.exe")) { QProcess p; p.setProcessChannelMode( QProcess::MergedChannels ); QStringList arg; if (type == Sound) arg << "-s"; else arg << "-d"; p.start("dxlist", arg); if (p.waitForFinished()) { QByteArray line; while (p.canReadLine()) { line = p.readLine().trimmed(); qDebug("DeviceInfo::retrieveDevices: '%s'", line.constData()); if ( rx_device.indexIn(line) > -1 ) { int id = rx_device.cap(1).toInt(); QString desc = rx_device.cap(2); qDebug("DeviceInfo::retrieveDevices: found device: '%d' '%s'", id, desc.toUtf8().constData()); l.append( DeviceData(id, desc) ); } } } } return l; }
// Starts audio input void KinectApp::startAudio() { // Initialize audio device if ( !mInput ) { mInput = AudioInput::create(); } // Find Kinect audio int32_t deviceId = -1; int32_t audioDeviceIndex = 0; DeviceList devices = mInput->getDeviceList(); for ( DeviceList::const_iterator deviceIt = devices.cbegin(); deviceIt != devices.cend(); ++deviceIt, audioDeviceIndex ) { if ( boost::contains( boost::to_lower_copy( deviceIt->second ), "kinect" ) ) { deviceId = deviceIt->first; audioDeviceIndex++; } } // Start receiving audio mInput->setDevice( deviceId ); mCallbackId = mInput->addCallback<KinectApp>( & KinectApp::onData, this ); mInput->start(); }
void ManageMetronomeDialog::slotPreviewPitch(int pitch) { RG_DEBUG << "ManageMetronomeDialog::slotPreviewPitch"; DeviceList *devices = m_doc->getStudio().getDevices(); DeviceListConstIterator it; int count = 0; Device *dev = 0; for (it = devices->begin(); it != devices->end(); it++) { dev = *it; if (!isSuitable(dev)) continue; if (count == m_metronomeDevice->currentIndex()) break; count++; } if (!dev || !isSuitable(dev)) return; const MidiMetronome *metronome = getMetronome(dev); if (metronome == 0) return; InstrumentList list = dev->getPresentationInstruments(); Instrument *inst = list[m_metronomeInstrument->currentIndex()]; StudioControl::playPreviewNote(inst, pitch, MidiMaxValue, RealTime(0, 10000000)); }
RobotInterface::DeviceList RobotInterface::XMLReader::Private::readDevicesTag(TiXmlElement *devicesElem) { const std::string &valueStr = devicesElem->ValueStr(); if (valueStr.compare("devices") != 0) { SYNTAX_ERROR(devicesElem->Row()) << "Expected \"devices\". Found" << valueStr; } std::string filename; if (devicesElem->QueryStringAttribute("file", &filename) == TIXML_SUCCESS) { // yDebug() << "Found devices file [" << filename << "]"; #ifdef WIN32 std::replace(filename.begin(), filename.end(), '/', '\\'); filename = path + "\\" + filename; #else // WIN32 filename = path + "/" + filename; #endif //WIN32 return readDevicesFile(filename); } std::string robotName; if (devicesElem->QueryStringAttribute("robot", &robotName) != TIXML_SUCCESS) { SYNTAX_WARNING(devicesElem->Row()) << "\"devices\" element should contain the \"robot\" attribute"; } if (robotName != robot.name()) { SYNTAX_WARNING(devicesElem->Row()) << "Trying to import a file for the wrong robot. Found" << robotName << "instead of" << robot.name(); } unsigned int build; #if TINYXML_UNSIGNED_INT_BUG if (devicesElem->QueryUnsignedAttribute("build", &build()) != TIXML_SUCCESS) { // No build attribute. Assuming build="0" SYNTAX_WARNING(devicesElem->Row()) << "\"devices\" element should contain the \"build\" attribute [unsigned int]. Assuming 0"; } #else int tmp; if (devicesElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) { // No build attribute. Assuming build="0" SYNTAX_WARNING(devicesElem->Row()) << "\"devices\" element should contain the \"build\" attribute [unsigned int]. Assuming 0"; tmp = 0; } build = (unsigned)tmp; #endif if (build != robot.build()) { SYNTAX_WARNING(devicesElem->Row()) << "Import a file for a different robot build. Found" << build << "instead of" << robot.build(); } DeviceList devices; for (TiXmlElement* childElem = devicesElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) { DeviceList childDevices = readDevices(childElem); for (DeviceList::const_iterator it = childDevices.begin(); it != childDevices.end(); ++it) { devices.push_back(*it); } } return devices; }
//---------------------------------------------------------------------------------// DeviceList WiiMoteFactoryCreator::freeDeviceList() { DeviceList list; for( std::deque<int>::iterator i = mFreeWiis.begin(); i != mFreeWiis.end(); ++i ) { list.insert(std::make_pair(OISJoyStick, mVendorName)); } return list; }
//---------------------------------------------------------------------------- DeviceList PhoneInputManager::GetFreeDeviceList() { DeviceList ret; if (false == mIsMuliTouchUsed) ret.insert(std::make_pair(IT_TOUCH, mInputSystemName)); return ret; }
void ControlPoint::print() { DeviceList *devList = getDeviceList(); int devCnt = devList->size(); cout << "Device Num = " << devCnt << endl; for (int n = 0; n < devCnt; n++) { Device *dev = devList->getDevice(n); cout << "[" << n << "] " << dev->getFriendlyName() << ", " << dev->getLeaseTime() << ", " << dev->getElapsedTime() << endl; } }
void LeapHands::onDeviceChange(const Controller& controller) { std::cout << "Device Changed" << std::endl; const DeviceList devices = controller.devices(); for (int i = 0; i < devices.count(); ++i) { std::cout << "id: " << devices[i].toString() << std::endl; std::cout << " isStreaming: " << (devices[i].isStreaming() ? "true" : "false") << std::endl; } }
void ControlPoint::renewSubscriberService(long timeout) { lock(); DeviceList *devList = getDeviceList(); int devCnt = devList->size(); for (int n = 0; n < devCnt; n++) { Device *dev = devList->getDevice(n); renewSubscriberService(dev, timeout); } unlock(); }
void PrintDevice(Device *dev, int indent) { PrintDeviceInfo(dev, indent); DeviceList *childDevList = dev->getDeviceList(); int nChildDevs = childDevList->size(); for (int n=0; n<nChildDevs; n++) { Device *childDev = childDevList->getDevice(n); PrintDevice(childDev, indent); } }
//--------------------------------------------------------------------------------// DeviceList MacHIDManager::freeDeviceList() { DeviceList ret; HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end(); for(; it != end; ++it) { if((*it)->inUse == false) ret.insert(std::make_pair((*it)->type, (*it)->combinedKey)); } return ret; }
void Studio:: resyncDeviceConnections(void) { // Sync all the device connections DeviceList *devices = getDevices(); for (uint i = 0; i < devices->size(); ++i) { DeviceId id = (*devices)[i]->getId(); QString connection = RosegardenSequencer::getInstance()->getConnection(id); (*devices)[i]->setConnection(qstrtostr(connection)); } }
void TestCtrlPoint::print() { DeviceList *rootDevList = getDeviceList(); int nRootDevs = rootDevList->size(); cout << "Device Num = " << nRootDevs << endl; for (int n=0; n<nRootDevs; n++) { Device *dev = rootDevList->getDevice(n); const char *devName = dev->getFriendlyName(); cout << "[" << n << "] = " << devName << endl; PrintDevice(dev, 1); } }
//----------------------------------------------------------------------------// DeviceList InputManager::listFreeDevices() { DeviceList list; FactoryList::iterator i = mFactories.begin(), e = mFactories.end(); for( ; i != e; ++i ) { DeviceList temp = (*i)->freeDeviceList(); list.insert(temp.begin(), temp.end()); } return list; }
//--------------------------------------------------------------------------------// DeviceList MacInputManager::freeDeviceList() { DeviceList ret; if( keyboardUsed == false ) ret.insert(std::make_pair(OISKeyboard, mInputSystemName)); if( mouseUsed == false ) ret.insert(std::make_pair(OISMouse, mInputSystemName)); return ret; }
//---------------------------------------------------------------------------- DeviceList Win32InputManager::GetFreeDeviceList() { DeviceList list; if (!mIsKeyboardUsed) list.insert(std::make_pair(IT_KEYBOARD, mInputSystemName)); if (!mIsMouseUsed) list.insert(std::make_pair(IT_MOUSE, mInputSystemName)); return list; }
Device *ControlPoint::getDevice(const std::string &name) { DeviceList *devList = getDeviceList(); int nDevs = devList->size(); for (int n = 0; n < nDevs; n++) { Device *dev = devList->getDevice(n); if (dev->isDevice(name) == true) return dev; Device *cdev = dev->getDevice(name); if (cdev != NULL) return cdev; } return NULL; }
//----------------------------------------------------------------------------// DeviceList LinuxInputManager::freeDeviceList() { DeviceList ret; if( keyboardUsed == false ) ret.insert(std::make_pair(OISKeyboard, mInputSystemName)); if( mouseUsed == false ) ret.insert(std::make_pair(OISMouse, mInputSystemName)); for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i) ret.insert(std::make_pair(OISJoyStick, i->vendor)); return ret; }
RobotInterface::Robot& RobotInterface::XMLReader::Private::readRobotTag(TiXmlElement *robotElem) { if (robotElem->ValueStr().compare("robot") != 0) { SYNTAX_ERROR(robotElem->Row()) << "Root element should be \"robot\". Found" << robotElem->ValueStr(); } if (robotElem->QueryStringAttribute("name", &robot.name()) != TIXML_SUCCESS) { SYNTAX_ERROR(robotElem->Row()) << "\"robot\" element should contain the \"name\" attribute"; } #if TINYXML_UNSIGNED_INT_BUG if (robotElem->QueryUnsignedAttribute("build", &robot.build()) != TIXML_SUCCESS) { // No build attribute. Assuming build="0" SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0"; } #else int tmp; if (robotElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) { // No build attribute. Assuming build="0" SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0"; tmp = 0; } robot.build() = (unsigned)tmp; #endif if (robotElem->QueryStringAttribute("portprefix", &robot.portprefix()) != TIXML_SUCCESS) { SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"portprefix\" attribute. Using \"name\" attribute"; robot.portprefix() = robot.name(); } // yDebug() << "Found robot [" << robot.name() << "] build [" << robot.build() << "] portprefix [" << robot.portprefix() << "]"; for (TiXmlElement* childElem = robotElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) { if (childElem->ValueStr().compare("device") == 0 || childElem->ValueStr().compare("devices") == 0) { DeviceList childDevices = readDevices(childElem); for (DeviceList::const_iterator it = childDevices.begin(); it != childDevices.end(); ++it) { robot.devices().push_back(*it); } } else { ParamList childParams = readParams(childElem); for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) { robot.params().push_back(*it); } } } return robot; }
void device_node::Dump(int32 level) { put_level(level); kprintf("(%" B_PRId32 ") @%p \"%s\" (ref %" B_PRId32 ", init %" B_PRId32 ", module %p, data %p)\n", level, this, ModuleName(), fRefCount, fInitialized, DriverModule(), DriverData()); AttributeList::Iterator attribute = Attributes().GetIterator(); while (attribute.HasNext()) { dump_attribute(attribute.Next(), level); } DeviceList::Iterator deviceIterator = fDevices.GetIterator(); while (deviceIterator.HasNext()) { Device* device = deviceIterator.Next(); put_level(level); kprintf("device: %s, %p\n", device->ModuleName(), device->Data()); } NodeList::ConstIterator iterator = Children().GetIterator(); while (iterator.HasNext()) { iterator.Next()->Dump(level + 1); } }
DeviceList AndroidInputManager::freeDeviceList() { DeviceList ret; //if( bAccelerometerUsed == false ) ret.insert(std::make_pair(OISKeyboard, mInputSystemName)); //if( bMultiTouchUsed == false ) ret.insert(std::make_pair(OISMultiTouch, mInputSystemName)); if (mAccelerometer){ ret.insert(std::make_pair(OISJoyStick, mInputSystemName)); } return ret; }
bool ImportDeviceDialog::importFromRG(QString fileName) { bool skipAutoload = true, clearCommandHistory = false; RosegardenDocument fileDoc(RosegardenMainWindow::self(), 0, skipAutoload, clearCommandHistory); if (!fileDoc.openDocument(fileName, false)) { return false; } for (int i = 0; i < (int)m_devices.size(); ++i) delete m_devices[i]; m_devices.clear(); DeviceList *list = fileDoc.getStudio().getDevices(); if (list->size() == 0) { return true; // true because we successfully read the document } for (DeviceListIterator it = list->begin(); it != list->end(); ++it) { MidiDevice *device = dynamic_cast<MidiDevice*>(*it); if (device) { std::vector<MidiBank> banks = device->getBanks(); // DMM - check for controllers too, because some users have // created .rgd files that contain only controllers // see bug #1183522 // std::vector<ControlParameter> controllers = device->getControlParameters(); // We've got a bank on a Device fom this file // (or a device that contains controllers or key mappings) // if (banks.size() || controllers.size() || device->getKeyMappings().size()) { m_devices.push_back(new MidiDevice(*device)); } } } return true; }
void VCXYPadProperties::slotAdd(QListView *list) { DeviceList* dl = new DeviceList(this); dl->init(); if (list == m_listX) { dl->setCaption("Add a channel to the list of horizontal axes"); } else { dl->setCaption("Add a channel to the list of vertical axes"); } if (dl->exec() == QDialog::Accepted) { t_device_id did = dl->selectedDeviceID(); t_channel ch = dl->selectedChannel(); if (did != KNoID && ch != KChannelInvalid) { createChannelEntry(list, did, ch, KChannelValueMin, KChannelValueMax, false); } } delete dl; }
void CAVMediaPlayer::DumpInfo() { DeviceList *devList = this->getDeviceList(); int devCnt = devList->size(); int mediaServerCnt = 0; for (int n=0; n<devCnt; n++) { Device *dev = devList->getDevice(n); if (dev->isDeviceType(MediaServer::DEVICE_TYPE) == false) continue; FTLTRACEA("[%d],Name=%s,LeaseTime=%d,ElpaseTime=%d", n, dev->getFriendlyName(), dev->getLeaseTime() , dev->getElapsedTime()); //PrintContentDirectory(mplayer, dev); mediaServerCnt++; } if (mediaServerCnt == 0) { FTLTRACE(TEXT("MediaServer is not found\n")); } }
void ControlPoint::unsubscribe(Device *device) { int n; ServiceList *serviceList = device->getServiceList(); int serviceCnt = serviceList->size(); for (n = 0; n < serviceCnt; n++) { Service *service = serviceList->getService(n); if (service->hasSID() == true) unsubscribe(service); } DeviceList *childDevList = device->getDeviceList(); int childDevCnt = childDevList->size(); for (n = 0; n < childDevCnt; n++) { Device *cdev = childDevList->getDevice(n); unsubscribe(cdev); } }
void BasicSensorSimulationHelper::initialize(Body* body, double timeStep, const Vector3& gravityAcceleration) { isActive_ = false; DeviceList<> devices = body->devices(); if(!devices.empty()){ forceSensors_.extractFrom(devices); rateGyroSensors_.extractFrom(devices); accelerationSensors_.extractFrom(devices); if(!forceSensors_.empty() || !rateGyroSensors_.empty() || !accelerationSensors_.empty()){ impl->initialize(body, timeStep, gravityAcceleration); isActive_ = true; } } }