当前位置: 首页>>代码示例>>C++>>正文


C++ DeviceName::toString方法代码示例

本文整理汇总了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);
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:34,代码来源:QhyLocator.cpp

示例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);
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:8,代码来源:GpioLocator.cpp

示例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");
}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:42,代码来源:OthelloLocator.cpp

示例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;
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:18,代码来源:InstrumentComponent.cpp

示例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");
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:24,代码来源:Instrument.cpp

示例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());
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:21,代码来源:DeviceDenicer.cpp


注:本文中的DeviceName::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。