コード例 #1
0
	DeviceVector ATIGPUDevice::createDevices(unsigned int flags)
	{
		DeviceVector devices;

		if(deviceCount() == 0) return devices;

		try {
			// Multiple devices is not supported yet
			devices.push_back(new ATIGPUDevice());
		} catch (hydrazine::Exception he) {
			// Swallow the exception and return empty device vector
			report(he.what());
		}

		return devices;
	}
コード例 #2
0
 void addDevice(Freenect2DeviceImpl *device)
 {
   devices_.push_back(device);
 }
コード例 #3
0
ファイル: dalidevicecontainer.cpp プロジェクト: viiimmx/vdcd
ErrorPtr DaliDeviceContainer::handleMethod(VdcApiRequestPtr aRequest, const string &aMethod, ApiValuePtr aParams)
{
  ErrorPtr respErr;
  if (aMethod=="x-p44-groupDevices") {
    // create a composite device out of existing single-channel ones
    ApiValuePtr components;
    long long collectionID = -1;
    DeviceVector groupedDevices;
    respErr = checkParam(aParams, "members", components);
    if (Error::isOK(respErr)) {
      if (components->isType(apivalue_object)) {
        components->resetKeyIteration();
        string dimmerType;
        ApiValuePtr o;
        while (components->nextKeyValue(dimmerType, o)) {
          DsUid memberUID;
          memberUID.setAsBinary(o->binaryValue());
          bool deviceFound = false;
          // search for this device
          for (DeviceVector::iterator pos = devices.begin(); pos!=devices.end(); ++pos) {
            // only non-grouped DALI devices can be grouped
            DaliDevicePtr dev = boost::dynamic_pointer_cast<DaliDevice>(*pos);
            if (dev && dev->getDsUid() == memberUID) {
              deviceFound = true;
              // found this device, create DB entry for it
              db.executef(
                "INSERT OR REPLACE INTO compositeDevices (dimmerUID, dimmerType, collectionID) VALUES ('%s','%s',%lld)",
                memberUID.getString().c_str(),
                dimmerType.c_str(),
                collectionID
              );
              if (collectionID<0) {
                // use rowid of just inserted item as collectionID
                collectionID = db.last_insert_rowid();
                // - update already inserted first record
                db.executef(
                  "UPDATE compositeDevices SET collectionID=%lld WHERE ROWID=%lld",
                  collectionID,
                  collectionID
                );
              }
              // remember
              groupedDevices.push_back(dev);
              // done
              break;
            }
          }
          if (!deviceFound) {
            respErr = ErrorPtr(new WebError(404, "some devices of the group could not be found"));
            break;
          }
        }
        if (Error::isOK(respErr) && groupedDevices.size()>0) {
          // all components inserted into DB
          // - remove grouped single devices
          for (DeviceVector::iterator pos = groupedDevices.begin(); pos!=groupedDevices.end(); ++pos) {
            (*pos)->hasVanished(false); // vanish, but keep settings
          }
          // - re-collect devices to find grouped composite now, but only in a second starting from main loop, not from here
          CompletedCB cb = boost::bind(&DaliDeviceContainer::groupCollected, this, aRequest);
          MainLoop::currentMainLoop().executeOnce(boost::bind(&DaliDeviceContainer::collectDevices, this, cb, false, false), 1*Second);
        }
      }
    }
  }
  else {
    respErr = inherited::handleMethod(aRequest, aMethod, aParams);
  }
  return respErr;
}