本文整理汇总了C++中DeviceName::unitname方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceName::unitname方法的具体用法?C++ DeviceName::unitname怎么用?C++ DeviceName::unitname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceName
的用法示例。
在下文中一共展示了DeviceName::unitname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GuiderPortPtr
/**
* \brief Get a guider port by name
*/
GuiderPortPtr OthelloLocator::getGuiderPort0(const DeviceName& name) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "looking for device %s",
name.toString().c_str());
// extract the serial number from the name
std::string serial = name.unitname();
debug(LOG_DEBUG, DEBUG_LOG, 0, "looking for device unit %s",
serial.c_str());
// find the device with this serial number
std::vector<astro::usb::DevicePtr> d = context.devices();
std::vector<astro::usb::DevicePtr>::const_iterator i;
for (i = d.begin(); i != d.end(); i++) {
astro::usb::DevicePtr dptr = (*i);
uint16_t vendor = dptr->descriptor()->idVendor();
if (vendor != OTHELLO_VENDOR_ID) {
break;
}
debug(LOG_DEBUG, DEBUG_LOG, 0, "device vendor: %04x", vendor);
bool needsclosing = true;
if (dptr->isOpen()) {
needsclosing = false;
} else {
dptr->open();
}
std::string devserial = dptr->descriptor()->iSerialNumber();
debug(LOG_DEBUG, DEBUG_LOG, 0, "device serial: %s",
devserial.c_str());
if (devserial == serial) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "matching guider port");
return GuiderPortPtr(new OthelloGuiderPort(dptr));
}
if (needsclosing) {
dptr->close();
}
}
debug(LOG_ERR, DEBUG_LOG, 0, "coult no find device %s",
name.toString().c_str());
throw std::runtime_error("device not found");
}
示例2: CameraPtr
/**
* \brief Construct a camera from a camera description
*
* \param name Name of the camera
* \return Camera with that name
*/
CameraPtr SxCameraLocator::getCamera0(const DeviceName& name) {
std::string sname = name.unitname();
debug(LOG_DEBUG, DEBUG_LOG, 0, "analyzing '%s'", sname.c_str());
// parse the name string
int busnumber = 0, deviceaddress = 0;
sxparse(sname, busnumber, deviceaddress);
debug(LOG_DEBUG, DEBUG_LOG, 0,
"looking for busnumber=%d, deviceaddress=%d",
busnumber, deviceaddress);
// find the device with this bus number and address
std::vector<DevicePtr> d = context.devices();
std::vector<DevicePtr>::const_iterator i;
for (i = d.begin(); i != d.end(); i++) {
DevicePtr dptr = (*i);
if ((dptr->getBusNumber() == busnumber) &&
(dptr->getDeviceAddress() == deviceaddress)) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "found matching device");
dptr->open();
return CameraPtr(new SxCamera(dptr));
}
}
throw SxError("cannot create a camera from a name");
}
示例3: AdaptiveOpticsPtr
/**
* \brief Get an AO object
*/
AdaptiveOpticsPtr SxCameraLocator::getAdaptiveOptics0(const DeviceName& name) {
std::string sname = URL::decode(name.unitname());
debug(LOG_DEBUG, DEBUG_LOG, 0, "AO unit device name: %s", sname.c_str());
return AdaptiveOpticsPtr(new SxAO(sname));
}