PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
PlusCmsBrachyStepper.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2  Program: Plus
3  Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4  See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #ifndef _CMSBRACHYSTEPPER_H_
8 #define _CMSBRACHYSTEPPER_H_
9 
10 #include "PlusConfigure.h"
11 #include "vtkPlusDataCollectionExport.h"
12 
13 #include "PlusBrachyStepper.h"
14 #include <vector>
15 #include <string>
16 
17 class SerialLine;
18 
32 class vtkPlusDataCollectionExport PlusCmsBrachyStepper : public PlusBrachyStepper
33 {
34 public:
35  typedef const char* STEPPERCOMMAND;
36  typedef const char* STEPPERRESPCODE;
37 
39  PlusCmsBrachyStepper(unsigned long COMPort=1, unsigned long BaudRate=19200);
41  virtual ~PlusCmsBrachyStepper();
42 
44  virtual PlusStatus Connect();
45 
47  virtual PlusStatus Disconnect();
48 
50  virtual PlusStatus GetEncoderValues(double &PPosition,
51  double &GPosition, double &RPosition, unsigned long &PositionRequestNumber);
52 
54  virtual PlusStatus GetDeviceModelInfo( std::string& version, std::string& model, std::string& serial );
55 
57  virtual PlusStatus ResetStepper();
58 
60  virtual PlusStatus InitializeStepper(std::string &CalibMsg);
61 
63  virtual PlusStatus SetBaudRate(unsigned long BaudRate);
64 
66  virtual PlusStatus SetCOMPort(unsigned long COMPort);
67 
69  virtual PlusStatus IsStepperAlive();
70 
71 public:
72 
74  PlusStatus GetStatusInfo(unsigned int &Status);
75 
77  PlusStatus GetProbeReferenceData(double &count, double &dist, double &scale);
78 
80  PlusStatus GetGridReferenceData(double &count, double &dist, double &scale);
81 
83  PlusStatus GetRotationReferenceData(double &count, double &dist, double &scale);
84 
86  PlusStatus GetCalibrationState(int &PState, int &GState, int &RState);
87 
89  PlusStatus GetRotateState(int &State);
90 
92  bool IsStepperCalibrated();
93 
95  PlusStatus GetMotorizationScaleFactor(int &scaleFactor);
96 
98  bool IsStepperMotorized();
99 
101  PlusStatus MoveProbeToPosition(double PositionInMm, int &ReturnCode);
102 
103 protected:
105  PlusStatus GetVersionInfo(int &iVerHi, int &iVerLo, int &iModelNum, int &iSerialNum);
106 
108  PlusStatus TurnMotorOn();
109 
111  PlusStatus TurnMotorOff();
112 
114  PlusStatus StepperButtonEnable();
115 
117  PlusStatus StepperButtonDisable();
118 
120  PlusStatus StepperRotateCalibrationEnable();
121 
123  PlusStatus StepperRotateCalibrationDisable();
124 
126  void SetScalingParameters();
127 
129  void ClearBuffer();
130 
131 protected:
133  static unsigned int AsciiToBin(unsigned int i, unsigned int j);
134 
136  static void BinToAscii(unsigned int n, unsigned char *c1, unsigned char *c2);
137 
139  void SendStepperCommand(STEPPERCOMMAND command, STEPPERRESPCODE Response, std::vector<BYTE> &vRawMessage);
140 
142  void SendPositionRequestCommand(STEPPERCOMMAND command, std::vector<BYTE> &vRawMessage);
143 
145  void StepperInstruction(STEPPERCOMMAND command);
146 
148  void ReadStepperAnswer(std::vector<BYTE> &stepperAnswer);
149 
151  bool IsStepperACKRecieved(std::vector<BYTE> &ackMessage, STEPPERCOMMAND command);
152 
154  void GetStepperMessage(STEPPERCOMMAND command, const char* Response, std::vector<BYTE> &DecodedMessage);
155 
157  void GetPositionMessage(std::vector<BYTE> &StepperMessage, std::vector<BYTE> &DecodedMessage);
158 
160  void CreateAckMessage( BYTE opcode, std::string *sMessage);
161 
163  void SendAckMessage(std::vector<BYTE> StepperMessage);
164 
166  void DecodeStepperMessage(std::vector<BYTE> StepperMessage, std::vector<BYTE> &DecodedMessage);
167 
169  PlusStatus GetReferenceData(STEPPERCOMMAND command, STEPPERRESPCODE respcode, double &count, double &dist, double &scale);
170 
171 private:
172 
174  SerialLine* m_StepperCOMPort;
175 
177  double m_ProbeScale;
178 
180  double m_GridScale;
181 
183  double m_RotationScale;
184 
186  bool m_IsCalibrated;
187 
191  int m_RepeatedPositionErrorCount;
192 
194  CRITICAL_SECTION m_CriticalSection;
195 
196 };
197 
198 #endif
virtual PlusStatus SetBaudRate(unsigned long BaudRate)=0
igsioStatus PlusStatus
Definition: PlusCommon.h:40
for i
Class for reading and writing data through the serial (RS-232) port.
virtual PlusStatus IsStepperAlive()=0
virtual PlusStatus SetCOMPort(unsigned long COMPort)=0
virtual PlusStatus ResetStepper()=0
Phidget_ChannelClass uint32_t * count
Definition: phidget22.h:1321
virtual PlusStatus Disconnect()=0
virtual PlusStatus GetDeviceModelInfo(std::string &version, std::string &model, std::string &serial)=0
virtual PlusStatus InitializeStepper(std::string &CalibMsg)=0
virtual PlusStatus Connect()=0
unsigned char BYTE
Definition: ATC3DGm.h:449
virtual PlusStatus GetEncoderValues(double &PPosition, double &GPosition, double &RPosition, unsigned long &PositionRequestNumber)=0