SimLocator::SimLocator() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "create SimLocator");

	_camera = CameraPtr(new SimCamera(*this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "camera: %s",
		_camera->name().toString().c_str());

	_ccd = CcdPtr(new SimCcd(_camera->getCcdInfo(0), *this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "ccd: %s",
		_ccd->name().toString().c_str());

	_guiderport = GuiderPortPtr(new SimGuiderPort(*this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "guiderport: %s",
		_guiderport->name().toString().c_str());

	_filterwheel = FilterWheelPtr(new SimFilterWheel(*this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "filterwheel: %s",
		_filterwheel->name().toString().c_str());

	_cooler = CoolerPtr(new SimCooler(*this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "cooler: %s",
		_cooler->name().toString().c_str());

	_focuser = FocuserPtr(new SimFocuser(*this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "focuser: %s",
		_focuser->name().toString().c_str());

	_mount = astro::device::MountPtr(new SimMount(*this));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "mount: %s",
		_mount->name().toString().c_str());

	debug(LOG_DEBUG, DEBUG_LOG, 0, "SimLocator created");
}
CcdPtr	SimCamera::getCcd0(size_t id) {
	if (id > 0) {
		debug(LOG_ERR, DEBUG_LOG, 0, "no ccd %d available", id);
		throw std::runtime_error("only ccd0 available");
	}
	return CcdPtr(new SimCcd(ccdinfo[0], *this));
}
/**
 * \brief Get the simulated CCD
 *
 * The simulator camera only implements a single ccd.
 */
CcdPtr	SimCamera::getCcd0(size_t ccdid) {
	if (0 != ccdid) {
		throw NotFound("only ccd 0 exists");
	}
	CcdInfo	info = getCcdInfo(0);
	return CcdPtr(new SimCcd(info, _locator));
}
CcdPtr	Mock1Camera::getCcd0(size_t id) {
	if (id > 1) {
		throw std::runtime_error("bad ccd id");
	}
	return CcdPtr(new Mock1Ccd(ccdinfo[id], this->id, id));
}
CcdPtr	NiceCamera::getCcd0(size_t id) {
    snowstar::CcdPrx	ccd = _camera->getCcd(id);
    std::string	servicename = name()[1];
    astro::device::nice::DeviceNicer	nicer(servicename);
    return CcdPtr(new NiceCcd(ccd, nicer(ccd->getName())));
}
/**
 * \brief Get the CCD from the camera
 */
CcdPtr	QsiCamera::getCcd0(size_t id) {
	if (id > 0) {
		throw std::invalid_argument("only CCD 0 defined");
	}
	return CcdPtr(new QsiCcd(ccdinfo[0], *this));
}
CcdPtr	SimCamera::getCcd0(size_t id) {
	if (id > 0) {
		throw std::runtime_error("only ccd0 available");
	}
	return CcdPtr(new SimCcd(ccdinfo[0], *this));
}