13 #ifndef mitkIGTLDevice_h
14 #define mitkIGTLDevice_h
22 #include "itkObject.h"
25 #include "igtlSocket.h"
26 #include "igtlMessageBase.h"
27 #include "igtlTransformMessage.h"
30 #include "MitkOpenIGTLinkExports.h"
35 #if !defined(MITK_WINDOWS_NO_UNDEF) && defined(SendMessage)
62 class MITKOPENIGTLINK_EXPORT
IGTLDevice :
public itk::Object
83 virtual bool OpenConnection() = 0;
91 virtual bool CloseConnection();
98 virtual bool StopCommunication();
105 bool StartCommunication();
116 void RunCommunication(
void (
IGTLDevice::*ComFunction)(
void), std::mutex& mutex);
127 void SendMessage(mitk::IGTLMessage::Pointer msg);
132 IGTLDeviceState GetState()
const;
138 igtl::MessageBase::Pointer GetNextCommand();
144 igtl::ImageMessage::Pointer GetNextImage2dMessage();
146 igtl::ImageMessage::Pointer GetNextImage3dMessage();
148 igtl::TransformMessage::Pointer GetNextTransformMessage();
150 igtl::TrackingDataMessage::Pointer GetNextTrackingDataMessage();
152 igtl::StringMessage::Pointer GetNextStringMessage();
154 igtl::MessageBase::Pointer GetNextMiscMessage();
159 itkSetMacro(PortNumber,
int);
164 itkGetMacro(PortNumber,
int);
169 itkSetMacro(Hostname, std::string);
174 itkGetMacro(Hostname, std::string);
179 itkGetConstMacro(Name, std::string);
184 itkSetMacro(Name, std::string);
189 itkSetMacro(ReadFully,
bool);
194 itkGetConstMacro(MessageQueue, mitk::IGTLMessageQueue::Pointer);
199 itkGetMacro(MessageFactory, mitk::IGTLMessageFactory::Pointer);
204 void ThreadStartSending();
209 void ThreadStartReceiving();
214 void ThreadStartConnecting();
230 virtual bool TestConnection();
235 bool SendRTSMessage(
const char* type);
240 void EnableNoBufferingMode(mitk::IGTLMessageQueue::Pointer queue,
243 void EnableNoBufferingMode(
bool enable =
true);
248 virtual unsigned int GetNumberOfConnections() = 0;
250 itkGetMacro(LogMessages,
bool);
251 itkSetMacro(LogMessages,
bool);
268 unsigned int SendMessagePrivate(mitk::IGTLMessage::Pointer msg,
269 igtl::Socket::Pointer socket);
276 virtual void Receive() = 0;
292 unsigned int ReceivePrivate(igtl::Socket* device);
298 virtual void Send() = 0;
308 virtual void Connect();
314 virtual void StopCommunicationWithSocket(igtl::Socket* socket) = 0;
319 void SetState(IGTLDeviceState state);
360 std::thread m_SendThread;
362 std::thread m_ReceiveThread;
364 std::thread m_ConnectThread;