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:"
59 #ifdef ENABLE_VISP_NAMESPACE
73 void usage(
const char *name,
const char *badparam,
int nsec,
double nmsec)
76 Send a pulse to activate the ring light or turn on the ring light \n\
79 By default, that means without parameters, send a pulse which duration\n\
80 is fixed by the harware. To control the duration of the pulse, use \n\
81 \"-t <pulse width in ms>\" option. To turn on the light permanently, \n\
82 use \"-o -n <on duration in second>]\"\n\
85 %s [-o] [-n <on duration in second>] [-t <pulse width in ms>] [-h]\n\
93 Turn the ring light on during %d s.\n\
94 If this option is not set, send a short pulse\n\
95 to activate the light.\n\
97 -t %%g : <pulse width in ms> %g\n\
98 Pulse width in milli-second.\n\
99 Send a pulse which duration is fixed by this parameter.\n\
100 Without this option, the pulse width is fixed by the \n\
103 -n %%d : <on duration in second> %d\n\
104 Time in second while the ring light is turned on.\n\
105 This option is to make into realtion with option \"-o\".\n\
108 Print the help.\n\n",
112 fprintf(stderr,
"ERROR: \n");
113 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
130 bool getOptions(
int argc,
const char **argv,
bool &on,
int &nsec,
double &nmsec)
145 nmsec = atof(optarg);
148 usage(argv[0],
nullptr, nsec, nmsec);
153 usage(argv[0], optarg, nsec, nmsec);
159 if ((c == 1) || (c == -1)) {
161 usage(argv[0],
nullptr, nsec, nmsec);
162 std::cerr <<
"ERROR: " << std::endl;
163 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
175 int main(
int argc,
const char **argv)
183 if (getOptions(argc, argv, on, nsec, nmsec) ==
false) {
190 if (std::fabs(nmsec) <= std::numeric_limits<double>::epsilon())
196 printf(
"Turn on ring light\n");
202 printf(
"Send a pulse to activate the ring light\n");
209 printf(
"Can't open the parallel port to access to the ring light "
213 printf(
"Can't close the parallel port\n");
218 printf(
"An error occurs...\n");
225 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)
VISP_EXPORT int wait(double t0, double t)