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


C++ DeviceName类代码示例

本文整理汇总了C++中DeviceName的典型用法代码示例。如果您正苦于以下问题:C++ DeviceName类的具体用法?C++ DeviceName怎么用?C++ DeviceName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DeviceName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DeviceName

/**
 * \brief Name of the device
 *
 * For derived components, this only returns the device name of the
 * parent device, it is the client's responsibilty to retrieve the
 * correct subdevice of the parent device.
 */
DeviceName	InstrumentComponentDerived::devicename() {
	DeviceName	name = _instrument.devicename(_derivedfrom);
	if (type() != DeviceName::Ccd) {
		name.type(type());
		return name;
	} else {
		return DeviceName(name, type(), stringprintf("%d", unit()));
	}
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:16,代码来源:Instrument.cpp

示例3: equal

bool	DeviceName::operator==(const DeviceName& other) const {
	if (type() != other.type()) {
		return false;
	}
	if (size() != other.size()) {
		return false;
	}
	return std::equal(begin(), end(), other.begin());
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:9,代码来源:DeviceName.cpp

示例4: lexicographical_compare

bool	DeviceName::operator<(const DeviceName& other) const {
	if (type() < other.type()) {
		return true;
	}
	if (type() == other.type()) {
		return lexicographical_compare(begin(), end(),
						other.begin(), other.end());
	}
	return false;
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:10,代码来源:DeviceName.cpp

示例5: begin

DeviceName	DeviceName::parent(const DeviceName::device_type& devicetype) const {
	DeviceName	result;
	const_iterator	i = begin();
	size_type	j = 1;
	while (j++ < size()) {
		result.push_back(*i);
		i++;
	}
	result.type(devicetype);
	return result;
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:11,代码来源:DeviceName.cpp

示例6: debug

/**
 * \brief add the names of all cooler to a name vector
 *
 * \param names		list of names to which cooler names should be added
 */
void	AsiCameraLocator::addCoolerNames(std::vector<std::string>& names) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "retrieving Cooler names");
	int	n = ASIGetNumOfConnectedCameras();
	for (int index = 0; index < n; index++) {
		std::vector<std::string>	it = imgtypes(index);
		std::vector<std::string>::const_iterator	i;
		for (i = it.begin(); i != it.end(); i++) {
			DeviceName	ccdname = asiCcdName(index, *i);
			names.push_back(ccdname.child(DeviceName::Cooler,
				"cooler"));
		}
	}
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:18,代码来源:AsiLocator.cpp

示例7: debug

/**
 * \brief Get a CCD device for a camera
 */
CcdPtr	QhyCameraLocator::getCcd0(const DeviceName& name) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "get QHY ccd named: %s",
		name.toString().c_str());
	QhyName	qhyname(name);
	if (!qhyname.isCcd(name)) {
		std::string	msg = stringprintf("%s is not a CCD name",
			name.toString().c_str());
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());
		throw std::runtime_error(msg);
	}

	DeviceName	cameraname = qhyname.cameraname();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "looking for CCD of camera %s",
		cameraname.toString().c_str());
	CameraPtr	camera = this->getCamera(cameraname);
	return camera->getCcd(0);
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:20,代码来源:QhyLocator.cpp

示例8: 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

示例9: qhyname

/**
 * \brief Get a guider port by name
 */
GuidePortPtr	QhyCameraLocator::getGuidePort0(const DeviceName& name) {
	QhyName	qhyname(name);
	if (!qhyname.isGuideport(name)) {
		std::string	msg = stringprintf("%s is not a Guideport name",
			name.toString().c_str());
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());
		throw std::runtime_error(msg);
	}
	DeviceName	cameraname = qhyname.cameraname();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "looking for guider port of camera %s",
		cameraname.toString().c_str());
	CameraPtr	camera = this->getCamera(cameraname);
	if (!camera->hasGuidePort()) {
		debug(LOG_ERR, DEBUG_LOG, 0, "camera has no guider port");
		throw NotFound("camera does not have a guider port");
	}
	return GuidePortPtr();
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:21,代码来源:QhyLocator.cpp

示例10: debug

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

示例11: debug

/**
 * \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

示例12: 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

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

示例14: debug

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

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


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