16 #include "igtlTrackingDataMessage.h" 19 #include <itksys/SystemTools.hxx> 20 #include <itkMutexLockHolder.h> 22 #include <igtlClientSocket.h> 23 #include <igtl_status.h> 41 "Can only try to open the connection if in setup mode. State was " << this->
GetState();
48 if (portNumber == -1 || hostname.size() <= 0)
51 MITK_WARN <<
"Port number or hostname was not correct";
56 m_Socket = igtl::ClientSocket::New();
59 int response =
dynamic_cast<igtl::ClientSocket*
>(
m_Socket.GetPointer())->
60 ConnectToServer(hostname.c_str(), portNumber);
65 MITK_ERROR <<
"The client could not connect to " << hostname <<
" port: " << portNumber;
73 this->InvokeEvent(NewClientConnectionEvent());
84 if (status == IGTL_STATUS_NOT_PRESENT)
88 this->InvokeEvent(LostConnectionEvent());
89 MITK_WARN(
"IGTLClient") <<
"Lost connection to server socket.";
95 mitk::IGTLMessage::Pointer mitkMessage;
101 if (mitkMessage.IsNull())
106 MITK_WARN(
"IGTLDevice") <<
"Could not send the message.";
119 return this->
m_Socket->GetConnected();
IGTLDeviceState GetState() const
Returns current object state (Setup, Ready or Running)
itk::FastMutexLock::Pointer m_StopCommunicationMutex
virtual int GetPortNumber()
Returns the port number of the device.
void SetState(IGTLDeviceState state)
change object state
void Send() override
Call this method to send a message.
unsigned int GetNumberOfConnections() override
Returns the number of connections of this device.
void Receive() override
Call this method to receive a message.
itk::MutexLockHolder< itk::FastMutexLock > MutexLockHolder
unsigned int ReceivePrivate(igtl::Socket *device)
Call this method to receive a message from the given device.
unsigned int SendMessagePrivate(mitk::IGTLMessage::Pointer msg, igtl::Socket::Pointer socket)
Sends a message.
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
void StopCommunicationWithSocket(igtl::Socket *) override
Stops the communication with the given socket.
mitk::IGTLMessageQueue::Pointer m_MessageQueue
Interface for all OpenIGTLink Devices.
#define mitkThrowException(classname)
igtl::Socket::Pointer m_Socket
IGTLClient(bool ReadFully)
virtual std::string GetHostname()
Returns the ip/hostname of the device.
bool OpenConnection() override
Establishes the connection between this client and the IGTL server.