QString IGTLinkConversion::decode(igtl::StringMessage::Pointer msg)
{
    QString devicename(msg->GetDeviceName());
    QString message(msg->GetString());
    QString retval = devicename + ": " + message;
    return retval;
}
int	main(int argc, char *argv[]) {

	int	c;
	int	longindex;
	while (EOF != (c = getopt_long(argc, argv, "dhs:", longopts, &longindex)))
		switch (c) {
		case 'd':
			debuglevel = LOG_DEBUG;
			debugthreads = 1;
			debugtimeprecision = 3;
			break;
		case 'h':
			usage(argv[0]);
			return EXIT_SUCCESS;
		case 's':
			scale = atof(optarg);
			if (scale <= 0) {
				throw std::runtime_error("scale must be positive");
			}
			break;
		default:
			throw std::runtime_error("unknown option");
		}

	// next argument must be the device name
	if (argc <= optind) {
		throw std::runtime_error("no device specified");
	}
	DeviceName	devicename(argv[optind++]);

	// retrieve the guider port
	astro::module::Repository	repository;
        astro::module::Devices	devices(repository);

	astro::camera::GuidePortPtr	guideport
		= devices.getGuidePort(devicename);

	// get the program number
	int	prognumber = 0;
	if (argc > optind) {
		prognumber = std::stoi(argv[optind++]) - 1;
	}
	debug(LOG_DEBUG, DEBUG_LOG, 0, "run program %d on %s", prognumber,
		devicename.toString().c_str());

	// run the different programs
	if ((prognumber > 4) || (prognumber < 0)) {
		throw std::runtime_error("unknown program number");
	}
	globaltimer.start();
	display_header();
	programtable[prognumber](guideport);

	return EXIT_SUCCESS;
}