7 #include "PlusConfigure.h" 8 #include "vtksys/CommandLineArguments.hxx" 14 int main (
int argc,
char* argv[])
16 bool printHelp(
false);
17 bool resetStepper(
false);
19 int inputNumberOfTrials(20);
20 int samplingTimeMs(50);
22 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
24 vtksys::CommandLineArguments args;
25 args.Initialize(argc, argv);
27 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
28 args.AddArgument(
"--reset", vtksys::CommandLineArguments::NO_ARGUMENT, &resetStepper,
"Reset the stepper.");
29 args.AddArgument(
"--com-port", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputComPort,
"Com port number (Default: 2)." );
30 args.AddArgument(
"--number-of-trials", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputNumberOfTrials,
"Number of trials (Default: 20)." );
31 args.AddArgument(
"--sampling-time", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &samplingTimeMs,
"Sampling time in milliseconds (Default: 20)." );
32 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
36 std::cerr <<
"Problem parsing arguments" << std::endl;
37 std::cout <<
"\n\nCivcoBrachyStepperTest help:" << args.GetHelp() << std::endl;
45 std::cout <<
"\n\nCivcoBrachyStepperTest help:" << args.GetHelp() << std::endl;
50 for (
int reconnect = 0; reconnect < 5; reconnect++ )
52 LOG_INFO(
"Starting test " << reconnect + 1 );
58 LOG_ERROR(
"Couldn't connect to tracker!");
63 if ( resetStepper && reconnect == 0)
65 LOG_INFO(
"Resetting stepper...");
69 LOG_ERROR(
"Wrong answer received!");
74 LOG_INFO(
"Getting stepper's device info...");
81 LOG_INFO(
"Version = " << version <<
"\tModel = " << model <<
"\tSerial = " << serial );
85 LOG_ERROR(
"Wrong answer received!");
90 LOG_INFO(
"Getting stepper's encoder values...");
91 for (
int i = 0;
i<inputNumberOfTrials;
i++)
93 double pposition=0, gposition=0, rposition=0;
94 unsigned long positionRequestNumber(0);
95 if (myStepper->
GetEncoderValues(pposition, gposition, rposition, positionRequestNumber))
97 LOG_INFO(
"Probe = " << pposition <<
" mm\tGrid = " << gposition <<
" mm\tRotate = " << rposition <<
" deg\tRequestNumber = " << positionRequestNumber);
101 LOG_ERROR(
"Wrong answer received!");
105 vtkIGSIOAccurateTimer::Delay(0.001*samplingTimeMs);
108 LOG_INFO(
"Stopping stepper...\n");
112 LOG_INFO(
"Exit successfully...");
virtual PlusStatus ResetStepper()
virtual PlusStatus Disconnect()
virtual PlusStatus GetEncoderValues(double &PPosition, double &GPosition, double &RPosition, unsigned long &PositionRequestNumber)
virtual PlusStatus GetDeviceModelInfo(std::string &version, std::string &model, std::string &serial)
int main(int argc, char *argv[])
virtual PlusStatus Connect()
static vtkIGSIOLogger * Instance()