43 bool IsLightOn (
int index)
override;
44 bool IsScanning ()
const override {
return _isScanning; }
51 const char*
GetVersion ()
const override {
return _version.c_str(); }
55 int GetFoci ()
const override {
return _foci; }
56 int GetDelay ()
const override {
return _delay; }
57 int GetPulse ()
const override {
return _pulse; }
58 int GetPhase ()
const override {
return _phase; }
60 void GetScanArea (
int* xStart,
int* xStop,
int* yStart,
int* yStop)
const override;
61 void GetMirror (
int* major,
int* minor)
const override;
62 bool GetSwapXY ()
const override {
return _swapXY; }
64 const char* GetPortName ()
override;
66 const char* GetLastCommandSent ()
const override;
67 const char* GetLastResponse ()
const override;
85 bool SetAScans (
int value)
override;
86 bool SetBScans (
int value)
override;
87 bool SetFoci (
int value)
override;
88 bool SetDelay (
int value)
override;
89 bool SetPulse (
int value)
override;
90 bool SetPhase (
int value)
override;
93 bool SetXRampMinPos(
int value)
override;
94 bool SetXRampMaxPos(
int value)
override;
95 bool SetYRampMinPos(
int value)
override;
96 bool SetYRampMaxPos(
int value)
override;
99 bool SetArmPosition (
int position)
override;
100 bool SetScanArea (
int xStart,
int xStop,
int yStart,
int yStop)
override;
101 bool SetScanArea (
int xStart,
int xStop,
int yStart,
int yStop,
int numPasses)
override;
102 bool SetMirror (
int major,
int minor)
override;
103 bool SetSwapXY (
bool value)
override { _swapXY = value;
return true; }
114 bool OpenPort (
const char* portName,
int baudRate,
int numStopBits,
115 int timeout,
bool monitorConnection)
override;
117 bool OpenPort (
int baudRate,
int numStopBits,
int timeout,
bool monitorConnection)
override;
119 bool OpenPort ()
override;
121 void ReadControllerVersion(
bool &result);
124 bool ClosePort ()
override;
126 bool SendCommand (
const char* command,
char* response,
int maxResponseSize)
override;
127 bool SendCommand (
const char* command)
override;
132 bool TurnLightOn (
int num)
override;
133 bool TurnLightOff (
int num)
override;
134 bool TurnLightsOff ()
override;
137 bool StartScan ()
override;
139 bool StopScan ()
override;
142 bool ParkArm ()
override;
145 bool SendMotorsHome ()
override;
148 int GetActiveOpticalPort ()
override;
149 bool SetActiveOpticalPort (
int port)
override;
150 bool ToggleOpticalSwitch ()
override;
153 bool IsShutterOpen (
int ID,
bool* open)
override;
154 bool OpenShutter (
int ID)
override;
155 bool CloseShutter (
int ID)
override;
161 virtual void SetSerialPortLostCallback (NotifyErrorCallback notifyError)
override;
162 virtual void SetSerialPortLostCallback2 (
SendNoParams serialPortLost,
void* context)
override;
164 void CheckPingResponse ();
167 const int PathMotorSpeedMax = 2900;
168 const int QuarterHalfWaveSpeedMax = 10000;
169 const int PathMotorAccelMax = 10000;
170 const int QuarterHalfWaveAccelMax = 10000;
172 bool SendStringToWasatchPort (std::string rawCommand);
173 bool SendStringToCameraPort (std::string rawCommand);
174 bool SendCommandToPort (std::string command);
175 bool SendShutterCommand (std::string& inCommand);
177 void ReadResponse (std::string &finalCommand);
179 bool CheckWasatchCommandValid(std::string& inCommand, std::string& outCommand);
180 bool CheckCameraCommandValid (std::string& inCommand, std::string& outCommand);
182 bool ChangePortMonitoring (
bool isOn);
183 bool ReestablishConnection ();
184 void FormatVersionString ();
186 bool FormAScansCmd (vector<std::string>& words,
string& outCommand);
187 bool FormBScansCmd (vector<std::string>& words,
string& outCommand);
189 bool FormDelayCmd (vector<std::string>& words,
string& outCommand);
190 bool FormPulseCmd (vector<std::string>& words,
string& outCommand);
191 bool FormPhaseCmd (vector<std::string>& words,
string& outCommand);
192 bool FormFociCmd (vector<std::string>& words,
string& outCommand);
193 bool FormFocusCmd (vector<std::string>& words,
string& outCommand);
194 bool FormScanCmd (vector<std::string>& words,
string& outCommand);
195 bool FormMirrorCmd (vector<std::string>& words,
string& outCommand);
196 bool FormVerboseCmd (vector<std::string>& words,
string& outCommand);
197 bool FormPauseTimeoutCmd (vector<std::string>& words,
string& outCommand);
198 bool FormSetOpticalPortCmd(vector<std::string>& words,
string& outCommand);
200 bool FormMghCmd (vector<std::string>& words,
string& outCommand);
201 bool FormMstopCmd (vector<std::string>& words,
string& outCommand);
202 bool FormMgrCmd (vector<std::string>& words,
string& outCommand);
203 bool FormMg2Cmd (vector<std::string>& words,
string& outCommand);
204 bool FormMihCmd (vector<std::string>& words,
string& outCommand);
205 bool FormMasetCmd (vector<std::string>& words,
string& outCommand);
206 bool FormMssetCmd (vector<std::string>& words,
string& outCommand);
207 bool FormCameraCommand(vector<std::string>& words,
string& outCommand);
209 bool RunSetShutterCmd(vector<std::string>& words);
210 bool RunGetShutterCmd(vector<std::string>& words,
bool& open);
212 int CheckMotorPosLimits (vector<std::string>& words);
213 int CheckRelativeMotorPosLimits(vector<std::string>& words);
214 int CheckMotorAccelLimits (vector<std::string>& words);
215 int CheckMotorSpeedLimits (vector<std::string>& words);
216 void RecordMotorPos (std::vector<std::string> & words,
int pos);
217 void RecordRelativeMotorPos (std::vector<std::string> & words,
int relativePos);
219 bool FormPrampCmd (vector<std::string>& words,
string& outCommand);
220 bool FormXYRampCmd (vector<std::string>& words,
string& outCommand);
221 bool FormXRampCmd (vector<std::string>& words,
string& outCommand);
222 bool FormYRampCmd (vector<std::string>& words,
string& outCommand);
224 bool FormOut1Cmd (vector<std::string>& words,
string& outCommand);
225 bool FormOut2Cmd (vector<std::string>& words,
string& outCommand);
227 bool FormTRetCmd (vector<std::string>& words,
string& outCommand);
228 bool FormTriggerCmd (vector<std::string>& words,
string& outCommand);
229 bool FormTrigDelayModeCmd(vector<std::string>& words,
string& outCommand);
230 bool FormTrigDelayCmd (vector<std::string>& words,
string& outCommand);
231 bool FormADivCmd (vector<std::string>& words,
string& outCommand);
232 bool FormAHoldCmd (vector<std::string>& words,
string& outCommand);
233 bool FormBHoldCmd (vector<std::string>& words,
string& outCommand);
234 bool FormRRampCmd (vector<std::string>& words,
string& outCommand);
235 bool FormRotCrossCmd (vector<std::string>& words,
string& outCommand);
238 const int MinRadialScanRadius = 10;
239 static const int MaxShutterDevices = 4;
242 std::atomic<IWPOCTController::ErrorCode> _lastError;
244 std::atomic<IWPOCTController::CurrentStates> _currentStatus;
247 std::string _portName;
248 std::string _version;
249 std::string _finalCommand;
251 std::string _commandResponse;
253 std::string _pingCommandResponse;
254 std::vector<std::string> _commandsToIssue;
255 std::mutex _serialPortMutex;
260 bool _openPortIfNeeded;
261 bool _isInitializing;
264 std::atomic<bool> _swapXY;
265 std::atomic<bool> _isScanning;
266 std::atomic<bool> _readResponse;
272 bool _monitorConnection;
306 int _shutterSerialNum;
307 int _shutterOpenClose;
311 int _quarterMotorPos;
315 int _pathMotorPosMax;
316 int _quarterHalfWavePosMax;
320 void* _serialPortLostNotifyContext;
322 NotifyErrorCallback _notifyErrorCallback;
326 void InitShutters ();
330 void SendCommandsToGalvo ();
331 void AddCommand (std::string command);
332 bool WordIsMotorRef (
string& input);
333 bool WordStandsForAll (
string& input);
334 void SetStatusFlags (
string& command);
335 bool SendCommand (
string& command);
337 int SetWithinMinMax (
string& input,
int minValue,
int maxValue);
338 int SetWithinMinMax (
int input,
int minValue,
int maxValue);
339 int SetWithinPathMotorMinMax (
string& input,
int minValue,
int maxValue);
340 int SetWithinQuarterMotorMinMax (
string& input,
int minValue,
int maxValue);
341 int SetWithinHalfMotorMinMax (
string& input,
int minValue,
int maxValue);
342 int SetRRampRadius (
string& radius,
int centerX,
int centerY);
344 int SetXRampStart (
int value);
345 int SetXRampStop (
int value);
346 int SetYRampStart (
int value);
347 int SetYRampStop (
int value);
349 bool ParseBool (
string& input);
350 int ParseInteger (
string& input);
351 double ParseDouble (
string& input);
354 void DeleteShutterDevices();
356 void OutputDebugMsg (
const char* str)
360 OutputDebugStringA( str );
Interface of the IWPOCTController struct.
void(* SendNoParams)(void *)
Typedefs for callbacks.
Definition: IWPOCTController.h:9
Interface of the CSerial class.
Used for callbacks, in particular for the SimpleTimer class.
Definition: CallbackInfo.h:10
Class that controls a Picard Industries USB shutter device.
Definition: ShutterDevice.h:14
Definition: SimpleTimer.h:27
Class that converts a scanned image from one format to another.
Definition: WPScanController.h:29
int GetYRampStartPos() const override
Get the y ramp start position.
Definition: WPScanController.h:77
int GetArmPosition() const override
Get the reference arm position.
Definition: WPScanController.h:59
bool GetSwapXY() const override
Gets the value of the SwapXY flag.
Definition: WPScanController.h:62
int GetXRampStopPos() const override
Get the x ramp stop position.
Definition: WPScanController.h:76
bool GetMonitorPort() const override
Gets the flag that determines if serial port is constantly being monitored for a connection.
Definition: WPScanController.h:49
bool SetReadResponse(bool value) override
Sets the flag that determines if the response from the serial port is read after a command is issued.
Definition: WPScanController.h:104
int GetQuarterHalfWavePosMax() const override
Gets the max possible value of the quarter and half wave motors’ position.
Definition: WPScanController.h:82
bool SetQuarterHalfWavePosMax(int value) override
Sets the max possible value of the quarter and half wave motor position.
Definition: WPScanController.h:108
int GetXRampMinPos() const override
Get the x ramp min position.
Definition: WPScanController.h:70
bool SetSwapXY(bool value) override
Sets the SwapXY flag.
Definition: WPScanController.h:103
int GetXRampStartPos() const override
Get the x ramp start position.
Definition: WPScanController.h:75
int GetXRampMaxPos() const override
Get the x ramp max position.
Definition: WPScanController.h:71
virtual IWPOCTController::ErrorCode GetLastError() const override
Gets the result of the most current operation.
Definition: WPScanController.h:158
int GetBScans() const override
Gets the number of B-scans output by the controller.
Definition: WPScanController.h:54
bool SetPathMotorPosMax(int value) override
Sets the max possible value of the path motor.
Definition: WPScanController.h:107
int GetFoci() const override
Get the foci value.
Definition: WPScanController.h:55
int GetNumStopBits() const override
Gets the number of stop bits used to communicate with the controller.
Definition: WPScanController.h:47
const char * GetVersion() const override
Get the firmware version of the controller.
Definition: WPScanController.h:51
virtual IWPOCTController::CurrentStates GetCurrentStatus() const override
Gets the current status of the controller.
Definition: WPScanController.h:159
bool IsScanning() const override
Returns the scanning state.
Definition: WPScanController.h:44
int GetPulse() const override
Gets the size of the timing pulse in milliseconds that is used to trigger an A-scan.
Definition: WPScanController.h:57
int GetPathMotorPosMax() const override
Gets the max possible value of the path motor.
Definition: WPScanController.h:81
int GetYRampMaxPos() const override
Get the y ramp max position.
Definition: WPScanController.h:73
bool GetReadResponse() const override
Gets the flag that determines if the response is read from the serial port after each command is sent...
Definition: WPScanController.h:50
int GetPhase() const override
Get the phase delay.
Definition: WPScanController.h:58
bool IsPortOpen() const override
Returns whether the port is open or closed.
Definition: WPScanController.h:41
int GetDelay() const override
Gets the delay in milliseconds between the end of one pulse and the start of another.
Definition: WPScanController.h:56
int GetBaudRate() const override
Gets the baud rate used to communicate with the controller.
Definition: WPScanController.h:46
int GetYRampMinPos() const override
Get the y ramp min position.
Definition: WPScanController.h:72
int GetPortTimeout() const override
Gets the timeout period of the serial port in milliseconds.
Definition: WPScanController.h:48
int GetAScans() const override
Gets the number of A-scans per B-scan output by the controller.
Definition: WPScanController.h:53
int GetYRampStopPos() const override
Get the y ramp stop position.
Definition: WPScanController.h:78
The WPOCT Controller is packaged as a toolkit and provides a set of application programming interface...
Definition: IWPOCTController.h:75
ErrorCode
The following are error codes that are used within the controller.
Definition: IWPOCTController.h:86
CurrentStates
The following are status codes that are used within the controller.
Definition: IWPOCTController.h:104