45 #include <visp3/core/vpConfig.h>
46 #include <visp3/core/vpDebug.h>
47 #if defined VISP_HAVE_PARPORT
52 #include <visp3/core/vpTime.h>
53 #include <visp3/io/vpParseArgv.h>
54 #include <visp3/robot/vpRingLight.h>
57 #define GETOPTARGS "d:hn:ot:"
69 void usage(
const char *name,
const char *badparam,
int nsec,
double nmsec)
72 Send a pulse to activate the ring light or turn on the ring light \n\
75 By default, that means without parameters, send a pulse which duration\n\
76 is fixed by the harware. To control the duration of the pulse, use \n\
77 \"-t <pulse width in ms>\" option. To turn on the light permanently, \n\
78 use \"-o -n <on duration in second>]\"\n\
81 %s [-o] [-n <on duration in second>] [-t <pulse width in ms>] [-h]\n\
89 Turn the ring light on during %d s.\n\
90 If this option is not set, send a short pulse\n\
91 to activate the light.\n\
93 -t %%g : <pulse width in ms> %g\n\
94 Pulse width in milli-second.\n\
95 Send a pulse which duration is fixed by this parameter.\n\
96 Without this option, the pulse width is fixed by the \n\
99 -n %%d : <on duration in second> %d\n\
100 Time in second while the ring light is turned on.\n\
101 This option is to make into realtion with option \"-o\".\n\
104 Print the help.\n\n",
108 fprintf(stderr,
"ERROR: \n");
109 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
126 bool getOptions(
int argc,
const char **argv,
bool &on,
int &nsec,
double &nmsec)
141 nmsec = atof(optarg);
144 usage(argv[0],
nullptr, nsec, nmsec);
149 usage(argv[0], optarg, nsec, nmsec);
155 if ((c == 1) || (c == -1)) {
157 usage(argv[0],
nullptr, nsec, nmsec);
158 std::cerr <<
"ERROR: " << std::endl;
159 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
171 int main(
int argc,
const char **argv)
179 if (getOptions(argc, argv, on, nsec, nmsec) ==
false) {
186 if (std::fabs(nmsec) <= std::numeric_limits<double>::epsilon())
192 printf(
"Turn on ring light\n");
198 printf(
"Send a pulse to activate the ring light\n");
205 printf(
"Can't open the parallel port to access to the ring light "
209 printf(
"Can't close the parallel port\n");
214 printf(
"An error occurs...\n");
221 std::cout <<
"vpRingLight class works only on unix on a the Inria Afma6 platform..." << std::endl;
Error that can be emitted by the vpParallelPort class and its derivates.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Ring light management under unix.
VISP_EXPORT int wait(double t0, double t)