本文整理汇总了C++中DeviceManager::addDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceManager::addDevice方法的具体用法?C++ DeviceManager::addDevice怎么用?C++ DeviceManager::addDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceManager
的用法示例。
在下文中一共展示了DeviceManager::addDevice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deviceConnected
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);
}
示例2: init
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;
}
示例3: deviceInfo
void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
const Ios::IosToolHandler::Dict &info)
{
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);
bool skipUpdate = false;
IosDevice *newDev = 0;
if (!dev.isNull() && dev->type() == devType) {
const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data());
if (iosDev->m_extraInfo == info) {
skipUpdate = true;
newDev = const_cast<IosDevice *>(iosDev);
} else {
newDev = new IosDevice(*iosDev);
}
} else {
newDev = new IosDevice(uid);
}
if (!skipUpdate) {
QString devNameKey = QLatin1String("deviceName");
if (info.contains(devNameKey))
newDev->setDisplayName(info.value(devNameKey));
newDev->m_extraInfo = info;
qCDebug(detectLog) << "updated info of ios device " << uid;
dev = IDevice::ConstPtr(newDev);
devManager->addDevice(dev);
}
QLatin1String devStatusKey = QLatin1String("developerStatus");
if (info.contains(devStatusKey)) {
QString devStatus = info.value(devStatusKey);
if (devStatus == QLatin1String("Development")) {
devManager->setDeviceState(newDev->id(), IDevice::DeviceReadyToUse);
m_userModeDeviceIds.removeOne(uid);
} else {
devManager->setDeviceState(newDev->id(), IDevice::DeviceConnected);
bool shouldIgnore = newDev->m_ignoreDevice;
newDev->m_ignoreDevice = true;
if (devStatus == QLatin1String("*off*")) {
if (!shouldIgnore && !IosConfigurations::ignoreAllDevices()) {
QMessageBox mBox;
mBox.setText(tr("An iOS device in user mode has been detected."));
mBox.setInformativeText(tr("Do you want to see how to set it up for development?"));
mBox.setStandardButtons(QMessageBox::NoAll | QMessageBox::No | QMessageBox::Yes);
mBox.setDefaultButton(QMessageBox::Yes);
int ret = mBox.exec();
switch (ret) {
case QMessageBox::Yes:
Core::HelpManager::handleHelpRequest(
QLatin1String("qthelp://org.qt-project.qtcreator/doc/creator-developing-ios.html"));
break;
case QMessageBox::No:
break;
case QMessageBox::NoAll:
IosConfigurations::setIgnoreAllDevices(true);
break;
default:
break;
}
}
}
if (!m_userModeDeviceIds.contains(uid))
m_userModeDeviceIds.append(uid);
m_userModeDevicesTimer.start();
}
}
}
示例4: update
//--------------------------------------------------------------
void oscReceiver::update()
{
DeviceManager* pDeviceManager = Globals::instance()->mp_deviceManager;
if (hasWaitingMessages())
{
while(getNextMessage(&m_oscMessage))
{
int indexArg = 0;
if (m_oscMessage.getAddress() == OSC_ADDRESS_SET_DEVICE_PROP)
{
Device* pDevice = pDeviceManager->getDeviceById( m_oscMessage.getArgAsString(indexArg++) );
if (pDevice)
{
// Property
string propName = m_oscMessage.getArgAsString(indexArg++);
if (propName == "volMax")
{
pDevice->setSoundInputVolumeMaxOSC( m_oscMessage.getArgAsFloat(indexArg) );
}
else
if (propName == "volHistorySize")
{
pDevice->setSoundInputVolHistorySizeOSC( m_oscMessage.getArgAsInt32(indexArg) );
}
else
if (propName == "volHistoryTh")
{
pDevice->setSoundInputVolHistoryThOSC( m_oscMessage.getArgAsFloat(indexArg) );
}
else
if (propName == "enableStandbyMode")
{
pDevice->setEnableStandbyModeOSC( m_oscMessage.getArgAsInt32(indexArg)==1 ? true : false );
}
else
if (propName == "timeStandby")
{
//printf("timeStandby = %.3f - ", m_oscMessage.getArgAsFloat(indexArg));
pDevice->setTimeStandbyOSC( m_oscMessage.getArgAsFloat(indexArg) );
}
else
if (propName == "sampleVolStandby")
{
pDevice->setSampleVolumeStandbyOSC( m_oscMessage.getArgAsFloat(indexArg) );
}
else
if (propName == "nbLEDsStandby")
{
// pDevice->setNbLEDsStandbyOSC( m_oscMessage.getArgAsInt32(indexArg) );
}
else
if (propName == "speedStandby")
{
// pDevice->setSpeedStandbyOSC( m_oscMessage.getArgAsFloat(indexArg) );
}
}
}
else
if (m_oscMessage.getAddress() == OSC_ADDRESS_SEND_PACKETS)
{
if (pDeviceManager)
{
string deviceId = m_oscMessage.getArgAsString(indexArg++);
Device* pDevice = pDeviceManager->getDeviceById( deviceId );
// Not found, create the device now
if (pDevice == 0)
{
// TODO : type ? -> factory
if (Globals::instance()->mp_app->isSimulation == false)
{
int nbLEDs = m_oscMessage.getNumArgs() - indexArg; // WARNING with this
printf("> New Device found ! id=%s, nbLEDs=%d\n", deviceId.c_str(), nbLEDs);
DeviceEcho* pDeviceEcho = new DeviceEcho(deviceId, nbLEDs, 4.0f/float(nbLEDs-1));
pDeviceEcho->setupSenderOSC(m_oscMessage.getRemoteIp(), 1235);
pDeviceEcho->loadXML("Config/devices/");
// Add device to list
pDeviceManager->addDevice(pDeviceEcho);
// TEMP / TODO : attach to surface main
if (Globals::instance()->mp_app->mp_surfaceMain)
Globals::instance()->mp_app->mp_surfaceMain->addDevice(pDeviceEcho);
// Create a node in visualisation scene
Globals::instance()->mp_app->createDeviceNodeInScene(pDeviceEcho);
// Update interface
//Globals::instance()->mp_app->guiMarkUpdateLayout();
Globals::instance()->mp_app->guiUpdateListDevices();
Globals::instance()->mp_app->selectDevice(pDeviceEcho->m_id);
//.........这里部分代码省略.........