47 #include <visp3/core/vpConfig.h> 48 #include <visp3/core/vpDebug.h> 49 #if defined VISP_HAVE_PARPORT 54 #include <visp3/core/vpTime.h> 55 #include <visp3/io/vpParseArgv.h> 56 #include <visp3/robot/vpRingLight.h> 59 #define GETOPTARGS "d:hn:ot:" 71 void usage(
const char *name,
const char *badparam,
int nsec,
double nmsec)
74 Send a pulse to activate the ring light or turn on the ring light \n\ 77 By default, that means without parameters, send a pulse which duration\n\ 78 is fixed by the harware. To control the duration of the pulse, use \n\ 79 \"-t <pulse width in ms>\" option. To turn on the light permanently, \n\ 80 use \"-o -n <on duration in second>]\"\n \ 83 %s [-o] [-n <on duration in second>] [-t <pulse width in ms>] [-h]\n\ 90 Turn the ring light on during %d s.\n\ 91 If this option is not set, send a short pulse\n\ 92 to activate the light.\n\ 94 -t %%g : <pulse width in ms> %g\n\ 95 Pulse width in milli-second.\n\ 96 Send a pulse which duration is fixed by this parameter.\n\ 97 Without this option, the pulse width is fixed by the \n\ 100 -n %%d : <on duration in second> %d\n\ 101 Time in second while the ring light is turned on.\n\ 102 This option is to make into realtion with option \"-o\".\n\ 105 Print the help.\n\n", nsec, nmsec, nsec);
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], NULL, nsec, nmsec);
149 usage(argv[0], optarg, nsec, nmsec);
155 if ((c == 1) || (c == -1)) {
157 usage(argv[0], NULL, 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");
197 printf(
"Send a pulse to activate the ring light\n");
203 printf(
"Can't open the parallel port to access to the ring light " 207 printf(
"Can't close the parallel port\n");
211 printf(
"An error occurs...\n");
218 std::cout <<
"vpRingLight class works only on unix on a the Inria Afma6 platform..." << std::endl;
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.