7 #include "PlusConfigure.h" 8 #include "vtksys/CommandLineArguments.hxx" 14 int main (
int argc,
char* argv[])
16 bool printHelp(
false);
17 bool resetStepper(
false);
18 std::string stepperType(
"Burdette Medical Systems Digital Stepper");
20 int inputNumberOfTrials(20);
21 int samplingTimeMs(50);
23 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
25 vtksys::CommandLineArguments args;
26 args.Initialize(argc, argv);
28 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
29 args.AddArgument(
"--reset", vtksys::CommandLineArguments::NO_ARGUMENT, &resetStepper,
"Reset the stepper (need's to calibrate it).");
30 args.AddArgument(
"--com-port", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputComPort,
"Com port number (Default: 2)." );
31 args.AddArgument(
"--number-of-trials", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputNumberOfTrials,
"Number of trials (Default: 20)." );
32 args.AddArgument(
"--sampling-time", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &samplingTimeMs,
"Sampling time in milliseconds (Default: 20)." );
33 args.AddArgument(
"--brachy-stepper-type", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &stepperType,
"Set brachy stepper type (Default: Burdette Medical Systems Digital Stepper; Burdette Medical Systems Digital Stepper, Burdette Medical Systems Digital Motorized Stepper, CMS Accuseed DS300.)");
34 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
38 std::cerr <<
"Problem parsing arguments" << std::endl;
39 std::cout <<
"\n\nCmsBrachyStepperTest help:" << args.GetHelp() << std::endl;
47 std::cout <<
"\n\nCmsBrachyStepperTest help:" << args.GetHelp() << std::endl;
52 for (
int reconnect = 0; reconnect < 5; reconnect++ )
54 LOG_INFO(
"Starting test " << reconnect + 1 );
58 if ( STRCASECMP(
"Burdette Medical Systems Digital Stepper", stepperType.c_str()) == 0 )
62 else if ( STRCASECMP(
"Burdette Medical Systems Digital Motorized Stepper", stepperType.c_str()) == 0 )
66 else if ( STRCASECMP(
"CMS Accuseed DS300", stepperType.c_str()) == 0 )
73 LOG_ERROR(
"Couldn't connect to tracker!");
78 if ( resetStepper && reconnect == 0)
80 LOG_INFO(
"Resetting stepper...");
84 LOG_ERROR(
"Wrong answer received!");
90 LOG_INFO(
"Checking stepper's calibration state...");
93 std::cout << std::endl <<
"The stepper needs to be initialized!" << std::endl << std::endl;
97 std::cout << CalibMsg <<
" ";
102 LOG_INFO(
"Getting stepper's calibration state...");
103 int pState(0), gState(0), rState(0);
106 LOG_INFO(
"Probe state = " << pState <<
" Grid state = " << gState <<
" Rotation state = " << rState );
110 LOG_ERROR(
"Wrong answer received!");
114 LOG_INFO(
"Getting stepper's rotate state...");
118 LOG_INFO(
"Rotate state = " << State);
122 LOG_ERROR(
"Wrong answer received!");
126 LOG_INFO(
"Getting motorized stepper's tick count...");
127 int MotorizationScaleFactor=-1;
129 if (MotorizationScaleFactor > 0)
131 LOG_INFO(
"Tick count = " << MotorizationScaleFactor);
135 LOG_INFO(
"Stepper is not motorized");
142 LOG_ERROR(
"Wrong answer received!");
146 LOG_INFO(
"Getting stepper's status info...");
147 unsigned int Status=-1;
150 LOG_INFO(
"Status: " << std::hex << Status << std::dec);
154 LOG_ERROR(
"Wrong answer received!");
159 LOG_INFO(
"Getting stepper's device info...");
166 LOG_INFO(
"Version = " << version <<
"\tModel = " << model <<
"\tSerial = " << serial );
170 LOG_ERROR(
"Wrong answer received!");
174 LOG_INFO(
"Getting stepper's probe reference data...");
175 double count = 0;
double dist = 0;
double scale = 0;
178 LOG_INFO(
"Count = " <<
count <<
"\tDist = " << dist <<
"\tScale = " << scale <<
" mm" );
182 LOG_ERROR(
"Wrong answer received!");
186 LOG_INFO(
"Getting stepper's grid reference data...");
189 LOG_INFO(
"Count = " <<
count <<
"\tDist = " << dist <<
"\tScale = " << scale <<
" mm");
193 LOG_ERROR(
"Wrong answer received!");
197 LOG_INFO(
"Getting stepper's rotation reference data...");
200 LOG_INFO(
"Count = " <<
count <<
"\tDist = " << dist <<
"\tScale = " << scale <<
" deg" );
204 LOG_ERROR(
"Wrong answer received!");
210 LOG_INFO(
"Testing motorized stepper..");
211 for (
int i = 1;
i <= 10;
i++ )
217 LOG_ERROR(
"Unable to move probe to position: " << -5*
i <<
"mm");
221 LOG_INFO(
"Probe moved to position: " << -5*
i <<
"mm");
223 vtkIGSIOAccurateTimer::GetInstance()->Delay(1);
227 for (
int i = 9;
i >= 0;
i-- )
233 LOG_ERROR(
"Unable to move probe to position: " << -5*
i <<
"mm");
237 LOG_INFO(
"Probe moved to position: " << -5*
i <<
"mm");
239 vtkIGSIOAccurateTimer::GetInstance()->Delay(1);
245 LOG_INFO(
"Getting stepper's probe position...");
246 for (
int i = 0;
i<inputNumberOfTrials;
i++)
248 double pposition=0, gposition=0, rposition=0;
249 unsigned long positionRequestNumber(0);
250 if (myStepper->
GetEncoderValues(pposition, gposition, rposition, positionRequestNumber))
252 LOG_INFO(
"Probe = " << pposition <<
" mm\tGrid = " << gposition <<
" mm\tRotate = " << rposition <<
" deg\tRequestNumber = " << positionRequestNumber);
256 LOG_ERROR(
"Wrong answer received!");
260 vtkIGSIOAccurateTimer::Delay(0.001*samplingTimeMs);
263 LOG_INFO(
"Stopping stepper...\n");
267 LOG_INFO(
"Exit successfully...");
virtual PlusStatus InitializeStepper(std::string &CalibMsg)
PlusStatus GetMotorizationScaleFactor(int &scaleFactor)
virtual PlusStatus Connect()
bool IsStepperCalibrated()
int main(int argc, char *argv[])
PlusStatus GetCalibrationState(int &PState, int &GState, int &RState)
PlusStatus GetGridReferenceData(double &count, double &dist, double &scale)
virtual PlusStatus GetDeviceModelInfo(std::string &version, std::string &model, std::string &serial)
PlusStatus GetStatusInfo(unsigned int &Status)
PlusStatus GetProbeReferenceData(double &count, double &dist, double &scale)
virtual PlusStatus ResetStepper()
PlusStatus GetRotationReferenceData(double &count, double &dist, double &scale)
virtual PlusStatus GetEncoderValues(double &PPosition, double &GPosition, double &RPosition, unsigned long &PositionRequestNumber)
PlusStatus MoveProbeToPosition(double PositionInMm, int &ReturnCode)
Phidget_ChannelClass uint32_t * count
static vtkIGSIOLogger * Instance()
PlusStatus GetRotateState(int &State)
bool IsStepperMotorized()
virtual PlusStatus Disconnect()
void SetBrachyStepperType(BRACHY_STEPPER_TYPE type)