PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusGenericSerialDevice.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 __vtkPlusGenericSerialDevice_h
8 #define __vtkPlusGenericSerialDevice_h
9 
10 #include "vtkPlusDataCollectionExport.h"
11 
12 #include "vtkPlusDevice.h"
13 
14 class SerialLine;
15 
25 class vtkPlusDataCollectionExport vtkPlusGenericSerialDevice : public vtkPlusDevice
26 {
27 public:
28 
31  void PrintSelf(ostream& os, vtkIndent indent);
32 
33  static const char* SERIAL_COMMAND_GET_RTS;
34  static const char* SERIAL_COMMAND_SET_RTS;
35  static const char* SERIAL_COMMAND_GET_CTS;
36 
39 
42 
49 
51  virtual PlusStatus ReadConfiguration(vtkXMLDataElement* config);
52 
54  virtual PlusStatus WriteConfiguration(vtkXMLDataElement* config);
55 
56  virtual bool IsTracker() const { return false; }
57 
58  vtkSetMacro(SerialPort, unsigned long);
59  vtkSetMacro(BaudRate, unsigned long);
60  vtkSetMacro(MaximumReplyDelaySec, double);
61  vtkSetMacro(MaximumReplyDurationSec, double);
62 
64  void SetLineEnding(const char* lineEndingHex);
65  vtkGetMacro(LineEnding, std::string);
66 
69  {
70  REQUIRE_LINE_ENDING = 0, // only proper LineEnding termination will result in success
71  REQUIRE_NOT_EMPTY = 1, // if respnse is not empty, results in success even on timeout
72  ANY = 2 // always results in success, but waits for a timeout or LineEnding termination
73  };
74 
84  virtual PlusStatus SendText(const std::string& textToSend, std::string* textReceived = NULL) VTK_OVERRIDE { return this->SendText(textToSend, textReceived, REQUIRE_LINE_ENDING); };
85  virtual PlusStatus SendText(const std::string& textToSend, std::string* textReceived, ReplyTermination acceptReply);
86 
93  virtual PlusStatus ReceiveResponse(std::string& textReceived, ReplyTermination acceptReply = REQUIRE_LINE_ENDING);
94 
95  virtual PlusStatus NotifyConfigured();
96 
98  PlusStatus SetDTR(bool onOff);
99 
101  vtkGetMacro(DTR, bool);
102 
104  PlusStatus SetRTS(bool onOff);
105 
107  vtkGetMacro(RTS, bool);
108 
110  PlusStatus GetDSR(bool& onOff);
111 
113  PlusStatus GetCTS(bool& onOff);
114 
115 protected:
118 
120  virtual bool WaitForResponse();
121 
122 private:
124  void operator=(const vtkPlusGenericSerialDevice&);
125 
126 protected:
129 
131  unsigned long SerialPort;
132 
134  unsigned long BaudRate;
135 
137  bool DTR;
138 
140  bool RTS;
141 
143  std::string LineEnding;
144 
146  std::string LineEndingBin;
147 
150 
153 
156 
158  vtkSmartPointer<vtkIGSIORecursiveCriticalSection> Mutex;
159 };
160 
161 #endif
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
static const char * SERIAL_COMMAND_GET_CTS
virtual PlusStatus InternalConnect()
igsioStatus PlusStatus
Definition: PlusCommon.h:40
Class for reading and writing data through the serial (RS-232) port.
#define VTK_OVERRIDE
Definition: PlusCommon.h:49
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *)
static const char * SERIAL_COMMAND_GET_RTS
vtkSmartPointer< vtkIGSIORecursiveCriticalSection > Mutex
virtual PlusStatus NotifyConfigured()
static const char * SERIAL_COMMAND_SET_RTS
virtual PlusStatus SendText(const std::string &textToSend, std::string *textReceived=NULL) VTK_OVERRIDE
virtual PlusStatus InternalDisconnect()
Generic interface for communicating with a serial device.
virtual PlusStatus SendText(const std::string &textToSend, std::string *textReceived=NULL)
virtual PlusStatus InternalUpdate()
static vtkPlusDevice * New()
Interface to a 3D positioning tool, video source, or generalized data stream.