1515#include " igtlMessageBase.h"
1616
1717/* !
18- \class vtkPlusOpenIGTLinkDevice
18+ \class vtkPlusOpenIGTLinkDevice
1919 \brief Common base class for OpenIGTLink-based tracking and video devices
2020
2121 \ingroup PlusLibDataCollection
22- */
22+ */
2323class vtkPlusDataCollectionExport vtkPlusOpenIGTLinkDevice : public vtkPlusDevice
2424{
2525public:
26-
27- // static vtkPlusOpenIGTLinkDevice *New();
28- vtkTypeMacro (vtkPlusOpenIGTLinkDevice,vtkPlusDevice);
29- virtual void PrintSelf (ostream& os, vtkIndent indent);
26+ vtkTypeMacro ( vtkPlusOpenIGTLinkDevice, vtkPlusDevice );
27+ virtual void PrintSelf ( ostream& os, vtkIndent indent );
3028
3129 /* ! OpenIGTLink version. */
32- virtual std::string GetSdkVersion ();
30+ virtual std::string GetSdkVersion ();
3331
3432 /* ! Connect to device */
3533 virtual PlusStatus InternalConnect ();
@@ -41,38 +39,44 @@ class vtkPlusDataCollectionExport vtkPlusOpenIGTLinkDevice : public vtkPlusDevic
4139 virtual PlusStatus Probe ();
4240
4341 /* ! Read configuration from xml data */
44- virtual PlusStatus ReadConfiguration ( vtkXMLDataElement* config );
45-
42+ virtual PlusStatus ReadConfiguration ( vtkXMLDataElement* config );
43+
4644 /* ! Write configuration to xml data */
47- virtual PlusStatus WriteConfiguration (vtkXMLDataElement* config);
45+ virtual PlusStatus WriteConfiguration ( vtkXMLDataElement* config );
46+
47+ /* ! Set OpenIGTLink message type */
48+ vtkSetStringMacro ( MessageType );
49+ /* ! Get OpenIGTLink message type */
50+ vtkGetStringMacro ( MessageType );
4851
49- /* ! Set OpenIGTLink message type */
50- vtkSetStringMacro (MessageType);
51- /* ! Get OpenIGTLink message type */
52- vtkGetStringMacro (MessageType);
52+ /* ! Set image streams to be sent when message type is a type that sends an image */
53+ vtkSetMacro ( ImageStream, PlusTransformName );
5354
54- /* ! Set OpenIGTLink server address */
55- vtkSetStringMacro (ServerAddress);
56- /* ! Get OpenIGTLink server address */
57- vtkGetStringMacro (ServerAddress);
55+ /* ! Get image streams to be sent when message type is a type that sends an image */
56+ vtkGetMacro ( ImageStream, PlusTransformName );
5857
59- /* ! Set OpenIGTLink server port */
60- vtkSetMacro (ServerPort, int );
61- /* ! Get OpenIGTLink server port */
62- vtkGetMacro (ServerPort, int );
58+ /* ! Set OpenIGTLink server address */
59+ vtkSetStringMacro ( ServerAddress );
60+ /* ! Get OpenIGTLink server address */
61+ vtkGetStringMacro ( ServerAddress );
62+
63+ /* ! Set OpenIGTLink server port */
64+ vtkSetMacro ( ServerPort, int );
65+ /* ! Get OpenIGTLink server port */
66+ vtkGetMacro ( ServerPort, int );
6367
6468 /* ! Set OpenIGTLink socket timeout */
65- vtkSetMacro (ReceiveTimeoutSec, double );
69+ vtkSetMacro ( ReceiveTimeoutSec, double );
6670 /* ! Get OpenIGTLink socket timeout */
67- vtkGetMacro (ReceiveTimeoutSec, double );
71+ vtkGetMacro ( ReceiveTimeoutSec, double );
6872
69- /* ! Set IGTL CRC check flag (0: disabled, 1: enabled) */
70- vtkSetMacro (IgtlMessageCrcCheckEnabled, int );
71- /* ! Get IGTL CRC check flag (0: disabled, 1: enabled) */
72- vtkGetMacro (IgtlMessageCrcCheckEnabled, int );
73+ /* ! Set IGTL CRC check flag (0: disabled, 1: enabled) */
74+ vtkSetMacro ( IgtlMessageCrcCheckEnabled, int );
75+ /* ! Get IGTL CRC check flag (0: disabled, 1: enabled) */
76+ vtkGetMacro ( IgtlMessageCrcCheckEnabled, int );
7377
7478 /* ! Get the ReconnectOnNoData flag */
75- vtkGetMacro (ReconnectOnReceiveTimeout, bool );
79+ vtkGetMacro ( ReconnectOnReceiveTimeout, bool );
7680
7781protected:
7882 vtkPlusOpenIGTLinkDevice ();
@@ -81,53 +85,56 @@ class vtkPlusDataCollectionExport vtkPlusOpenIGTLinkDevice : public vtkPlusDevic
8185 /* ! Reconnect the client socket. Used when the connection is established or there is a socket error. */
8286 virtual PlusStatus ClientSocketReconnect ();
8387
84- /* ! Sends the requested mesage types when connection is established */
88+ /* ! Sends the requested message types when connection is established */
8589 virtual PlusStatus SendRequestedMessageTypes ();
86-
90+
8791 /* !
8892 This method is called when receiving a message is timed out.
8993 If ReconnectOnReceiveTimeout is enabled then this method attempts to reconnect to the server.
9094 */
9195 void OnReceiveTimeout ();
92-
96+
9397 /* !
9498 Calls ReceiveMessageHeader and logs the error and/or reconnect as needed.
9599 */
96- void ReceiveMessageHeaderWithErrorHandling (igtl::MessageHeader::Pointer & headerMsg);
97-
100+ void ReceiveMessageHeaderWithErrorHandling ( igtl::MessageHeader::Pointer& headerMsg );
101+
98102 /* !
99103 Receive an OpenITGLink message header.
100104 Returns PLUS_FAIL if there was a socket error.
101105 The headerMsg is NULL is no data is received.
102106 */
103- virtual PlusStatus ReceiveMessageHeader (igtl::MessageHeader::Pointer & headerMsg);
107+ virtual PlusStatus ReceiveMessageHeader ( igtl::MessageHeader::Pointer& headerMsg );
104108
105109 /* ! Set the ReconnectOnNoData flag */
106- vtkSetMacro (ReconnectOnReceiveTimeout, bool );
110+ vtkSetMacro ( ReconnectOnReceiveTimeout, bool );
107111
108- vtkSetMacro (UseReceivedTimestamps, bool );
112+ vtkSetMacro ( UseReceivedTimestamps, bool );
109113
110114 /* ! OpenIGTLink message type */
111- char * MessageType;
115+ char * MessageType;
116+
117+ /* ! Image stream to send when message type wants to send an image */
118+ PlusTransformName ImageStream;
112119
113- /* ! OpenIGTLink server address */
114- char * ServerAddress;
120+ /* ! OpenIGTLink server address */
121+ char * ServerAddress;
115122
116- /* ! OpenIGTLink server port */
117- int ServerPort;
123+ /* ! OpenIGTLink server port */
124+ int ServerPort;
118125
119126 double ReceiveTimeoutSec;
120127
121- /* ! Flag for IGTL CRC check (0: disabled, 1: enabled) */
122- int IgtlMessageCrcCheckEnabled;
128+ /* ! Flag for IGTL CRC check (0: disabled, 1: enabled) */
129+ int IgtlMessageCrcCheckEnabled;
123130
124- /* ! Number of retry attempts for message sending to and receiving from the server */
125- int NumberOfRetryAttempts;
131+ /* ! Number of retry attempts for message sending to and receiving from the server */
132+ int NumberOfRetryAttempts;
126133
127- /* ! Delay between retry attempts */
128- double DelayBetweenRetryAttemptsSec;
134+ /* ! Delay between retry attempts */
135+ double DelayBetweenRetryAttemptsSec;
129136
130- /* ! OpenIGTLink client socket */
137+ /* ! OpenIGTLink client socket */
131138 igtl::ClientSocket::Pointer ClientSocket;
132139
133140 /* ! Attempt a reconnection if no data is received */
@@ -138,11 +145,10 @@ class vtkPlusDataCollectionExport vtkPlusOpenIGTLinkDevice : public vtkPlusDevic
138145 If it is false then the time of reception is used as timestamp.
139146 */
140147 bool UseReceivedTimestamps;
141-
142- private:
143148
144- vtkPlusOpenIGTLinkDevice (const vtkPlusOpenIGTLinkDevice&); // Not implemented.
145- void operator =(const vtkPlusOpenIGTLinkDevice&); // Not implemented.
149+ private:
150+ vtkPlusOpenIGTLinkDevice ( const vtkPlusOpenIGTLinkDevice& ); // Not implemented.
151+ void operator =( const vtkPlusOpenIGTLinkDevice& ); // Not implemented.
146152};
147153
148154#endif
0 commit comments