本文整理汇总了C++中DeviceName::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceName::toString方法的具体用法?C++ DeviceName::toString怎么用?C++ DeviceName::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceName
的用法示例。
在下文中一共展示了DeviceName::toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
/**
* \brief Construct a camera from a camera description
*
* \param name Name of the camera
* \return Camera with that name
*/
CameraPtr QhyCameraLocator::getCamera0(const DeviceName& name) {
QhyName qhyname(name);
if (!qhyname.isCamera(name)) {
std::string msg = stringprintf("%s is not a Camera name",
name.toString().c_str());
debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());
throw std::runtime_error(msg);
}
// scan the devices and get
std::vector<usb::DevicePtr> d = context.devices();
std::vector<usb::DevicePtr>::const_iterator i;
for (i = d.begin(); i != d.end(); i++) {
usb::DevicePtr dptr = *i;
int busnumber = dptr->getBusNumber();
int deviceaddress = dptr->getDeviceAddress();
if ((busnumber == qhyname.busnumber()) &&
(deviceaddress == qhyname.deviceaddress())) {
dptr->open();
return CameraPtr(new QhyCamera(dptr));
}
}
// failure to construct the camera
std::string msg = stringprintf("cannot create camera from '%s'",
name.toString().c_str());
throw std::runtime_error(msg);
}
示例2: GuidePortPtr
GuidePortPtr GpioLocator::getGuidePort0(const DeviceName& name) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "get the gpio guideport '%s'",
name.toString().c_str());
GpioGuideport *guideport = new GpioGuideport(name);
return GuidePortPtr(guideport);
}
示例3: 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");
}
示例4: DeviceName
DeviceName InstrumentComponent::remoteName() const {
// find out whether the name is local or uses the nice module
bool useNice = true;
// if this is already a local name, used unchanged
if (!useNice) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "using localized name %s",
_deviceurl.c_str());
return DeviceName(_deviceurl);
}
// this is a remote name, so construct a remote name
device::nice::DeviceNicer nicer(_servicename);
DeviceName result = nicer(_deviceurl);
debug(LOG_DEBUG, DEBUG_LOG, 0, "localized name: %s",
result.toString().c_str());
return result;
}
示例5: runtime_error
/**
* \brief Get a camera from an instrument
*/
CameraPtr Instrument::camera() {
if (!isLocal(DeviceName::Camera)) {
throw std::runtime_error("not a local camera");
}
debug(LOG_DEBUG, DEBUG_LOG, 0, "retrieve camera for instrument '%s'",
_name.c_str());
Repository repository;
Devices devices(repository);
InstrumentComponentPtr cameraptr = component(DeviceName::Camera);
switch (cameraptr->component_type()) {
case InstrumentComponent::direct:
case InstrumentComponent::mapped: {
DeviceName name = cameraptr->devicename();
debug(LOG_DEBUG, DEBUG_LOG, 0, "camera: %s", name.toString().c_str());
return devices.getCamera(name);
}
case InstrumentComponent::derived:
throw std::runtime_error("don't know how to derive camera");
}
throw std::runtime_error("unknown component type");
}
示例6: runtime_error
void DeviceDenicer::setup(const DeviceName& original) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "denice '%s'",
original.toString().c_str());
if (original.modulename() != "nice") {
throw std::runtime_error("cannot denice device names for "
"other modules");
}
if (original.size() < 2) {
throw std::runtime_error("bad nice device name: too short");
}
std::vector<std::string> components;
std::vector<std::string>::const_iterator i = original.begin();
i++; // skip the name nice
_service = *i;
i++; // skip the service name
copy(i, original.end(), std::back_inserter(components));
_devicename = std::shared_ptr<DeviceName>(new DeviceName(original.type(),
components));
debug(LOG_DEBUG, DEBUG_LOG, 0, "deniced service name: %s",
_devicename->toString().c_str());
}