46 #include <visp3/core/vpConfig.h> 47 #include <visp3/core/vpDebug.h> 50 #if defined VISP_HAVE_PARPORT 55 #include <visp3/robot/vpRingLight.h> 56 #include <visp3/io/vpParseArgv.h> 57 #include <visp3/core/vpTime.h> 60 #define GETOPTARGS "d:hn:ot:" 72 void usage(
const char *name,
const char *badparam,
int nsec,
double nmsec)
75 Send a pulse to activate the ring light or turn on the ring light \n\ 78 By default, that means without parameters, send a pulse which duration\n\ 79 is fixed by the harware. To control the duration of the pulse, use \n\ 80 \"-t <pulse width in ms>\" option. To turn on the light permanently, \n\ 81 use \"-o -n <on duration in second>]\"\n \ 84 %s [-o] [-n <on duration in second>] [-t <pulse width in ms>] [-h]\n\ 91 Turn the ring light on during %d s.\n\ 92 If this option is not set, send a short pulse\n\ 93 to activate the light.\n\ 95 -t %%g : <pulse width in ms> %g\n\ 96 Pulse width in milli-second.\n\ 97 Send a pulse which duration is fixed by this parameter.\n\ 98 Without this option, the pulse width is fixed by the \n\ 101 -n %%d : <on duration in second> %d\n\ 102 Time in second while the ring light is turned on.\n\ 103 This option is to make into realtion with option \"-o\".\n\ 106 Print the help.\n\n", nsec, nmsec, nsec);
109 fprintf(stderr,
"ERROR: \n" );
110 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
128 bool getOptions(
int argc,
const char **argv,
bool &on,
int &nsec,
double &nmsec)
136 case 'n': nsec = atoi(optarg);
break;
137 case 'o': on =
true;
break;
138 case 't': nmsec = atof(optarg);
break;
139 case 'h': usage(argv[0], NULL, nsec, nmsec);
return false;
break;
142 usage(argv[0], optarg, nsec, nmsec);
return false;
break;
146 if ((c == 1) || (c == -1)) {
148 usage(argv[0], NULL, nsec, nmsec);
149 std::cerr <<
"ERROR: " << std::endl;
150 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
163 main(
int argc,
const char **argv)
171 if (getOptions(argc, argv, on, nsec, nmsec) ==
false) {
178 if (std::fabs(nmsec) <= std::numeric_limits<double>::epsilon())
184 printf(
"Turn on ring light\n");
190 printf(
"Send a pulse to activate the ring light\n");
197 printf(
"Can't open the parallel port to access to the ring light device\n");
200 printf(
"Can't close the parallel port\n");
205 printf(
"An error occurs...\n");
213 vpTRACE(
"Sorry, for the moment, vpRingLight class works only on unix...");
VISP_EXPORT int wait(double t0, double t)
int getCode(void)
Send the object code.
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.