50 #include <visp/vpConfig.h>
51 #include <visp/vpDebug.h>
54 #if defined VISP_HAVE_PARPORT
59 #include <visp/vpRingLight.h>
60 #include <visp/vpParseArgv.h>
61 #include <visp/vpTime.h>
64 #define GETOPTARGS "d:hn:ot:"
76 void usage(
const char *name,
const char *badparam,
int nsec,
double nmsec)
79 Send a pulse to activate the ring light or turn on the ring light \n\
82 By default, that means without parameters, send a pulse which duration\n\
83 is fixed by the harware. To control the duration of the pulse, use \n\
84 \"-t <pulse width in ms>\" option. To turn on the light permanently, \n\
85 use \"-o -n <on duration in second>]\"\n \
88 %s [-o] [-n <on duration in second>] [-t <pulse width in ms>] [-h]\n\
95 Turn the ring light on during %d s.\n\
96 If this option is not set, send a short pulse\n\
97 to activate the light.\n\
99 -t %%g : <pulse width in ms> %g\n\
100 Pulse width in milli-second.\n\
101 Send a pulse which duration is fixed by this parameter.\n\
102 Without this option, the pulse width is fixed by the \n\
105 -n %%d : <on duration in second> %d\n\
106 Time in second while the ring light is turned on.\n\
107 This option is to make into realtion with option \"-o\".\n\
110 Print the help.\n\n", nsec, nmsec, nsec);
113 fprintf(stderr,
"ERROR: \n" );
114 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
132 bool getOptions(
int argc,
const char **argv,
bool &on,
int &nsec,
double &nmsec)
140 case 'n': nsec = atoi(optarg);
break;
141 case 'o': on =
true;
break;
142 case 't': nmsec = atof(optarg);
break;
143 case 'h': usage(argv[0], NULL, nsec, nmsec);
return false;
break;
146 usage(argv[0], optarg, nsec, nmsec);
return false;
break;
150 if ((c == 1) || (c == -1)) {
152 usage(argv[0], NULL, nsec, nmsec);
153 std::cerr <<
"ERROR: " << std::endl;
154 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
167 main(
int argc,
const char **argv)
175 if (getOptions(argc, argv, on, nsec, nmsec) ==
false) {
182 if (std::fabs(nmsec) <= std::numeric_limits<double>::epsilon())
188 printf(
"Turn on ring light\n");
194 printf(
"Send a pulse to activate the ring light\n");
201 printf(
"Can't open the parallel port to access to the ring light device\n");
204 printf(
"Can't close the parallel port\n");
209 printf(
"An error occurs...\n");
217 vpTRACE(
"Sorry, for the moment, vpRingLight class works only on unix...");
int getCode(void)
send the object code
static int wait(double t0, double t)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Ring light management under unix.
Error that can be emited by the vpParallelPort class and its derivates.