MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitk::IGTLClient Class Reference

Superclass for OpenIGTLink clients. More...

#include <mitkIGTLClient.h>

Inheritance diagram for mitk::IGTLClient:
mitk::IGTLDevice

Public Member Functions

 mitkClassMacro (IGTLClient, IGTLDevice)
 
 mitkNewMacro1Param (Self, bool)
 
 itkCloneMacro (Self)
 
bool OpenConnection () override
 Establishes the connection between this client and the IGTL server.
 
unsigned int GetNumberOfConnections () override
 Returns the number of connections of this device.
 
- Public Member Functions inherited from mitk::IGTLDevice
 mitkClassMacroItkParent (IGTLDevice, itk::Object)
 
 IGTLDevice (bool ReadFully)
 
virtual bool CloseConnection ()
 Closes the connection to the device.
 
virtual bool StopCommunication ()
 Stops the communication between the two devices.
 
bool StartCommunication ()
 Starts the communication between the two devices.
 
void RunCommunication (void(IGTLDevice::*ComFunction)(void), std::mutex &mutex)
 Continuously calls the given function.
 
void SendMessage (mitk::IGTLMessage::Pointer msg)
 Adds the given message to the sending queue.
 
IGTLDeviceState GetState () const
 Returns current object state (Setup, Ready or Running)
 
igtl::MessageBase::Pointer GetNextCommand ()
 Returns the oldest message in the command queue.
 
igtl::ImageMessage::Pointer GetNextImage2dMessage ()
 Returns the oldest message in the receive queue.
 
igtl::ImageMessage::Pointer GetNextImage3dMessage ()
 
igtl::TransformMessage::Pointer GetNextTransformMessage ()
 
igtl::TrackingDataMessage::Pointer GetNextTrackingDataMessage ()
 
igtl::StringMessage::Pointer GetNextStringMessage ()
 
igtl::MessageBase::Pointer GetNextMiscMessage ()
 
 itkSetMacro (PortNumber, int)
 Sets the port number of the device.
 
 itkGetMacro (PortNumber, int)
 Returns the port number of the device.
 
 itkSetMacro (Hostname, std::string)
 Sets the ip/hostname of the device.
 
 itkGetMacro (Hostname, std::string)
 Returns the ip/hostname of the device.
 
 itkGetConstMacro (Name, std::string)
 Returns the name of this device.
 
 itkSetMacro (Name, std::string)
 Sets the name of this device.
 
 itkSetMacro (ReadFully, bool)
 Advises this IGTL Device to always block until the whole message is read.
 
 itkGetConstMacro (MessageQueue, mitk::IGTLMessageQueue::Pointer)
 Returns a const reference to the receive queue.
 
 itkGetMacro (MessageFactory, mitk::IGTLMessageFactory::Pointer)
 Returns the message factory.
 
void ThreadStartSending ()
 start method for the sending thread.
 
void ThreadStartReceiving ()
 start method for the receiving thread.
 
void ThreadStartConnecting ()
 start method for the connection thread.
 
virtual bool TestConnection ()
 TestConnection() tries to connect to a IGTL device on the current ip and port.
 
bool SendRTSMessage (const char *type)
 Send RTS message of given type.
 
void EnableNoBufferingMode (mitk::IGTLMessageQueue::Pointer queue, bool enable=true)
 Sets the buffering mode of the given queue.
 
void EnableNoBufferingMode (bool enable=true)
 
 itkGetMacro (LogMessages, bool)
 
 itkSetMacro (LogMessages, bool)
 

Protected Member Functions

 IGTLClient (bool ReadFully)
 
 ~IGTLClient () override
 
void Receive () override
 Call this method to receive a message.
 
void Send () override
 Call this method to send a message.
 
void StopCommunicationWithSocket (igtl::Socket *) override
 Stops the communication with the given socket.
 
- Protected Member Functions inherited from mitk::IGTLDevice
unsigned int SendMessagePrivate (mitk::IGTLMessage::Pointer msg, igtl::Socket::Pointer socket)
 Sends a message.
 
unsigned int ReceivePrivate (igtl::Socket *device)
 Call this method to receive a message from the given device.
 
virtual void Connect ()
 Call this method to check for other devices that want to connect to this one.
 
void SetState (IGTLDeviceState state)
 change object state
 
 IGTLDevice ()
 
 ~IGTLDevice () override
 

Additional Inherited Members

- Public Types inherited from mitk::IGTLDevice
enum  IGTLDeviceState { Setup , Ready , Running }
 Type for state variable. The IGTLDevice is always in one of these states. More...
 
- Protected Attributes inherited from mitk::IGTLDevice
IGTLDeviceState m_State
 
std::string m_Name
 
bool m_StopCommunication
 
std::mutex m_StopCommunicationMutex
 
std::mutex m_SendingFinishedMutex
 
std::mutex m_ReceivingFinishedMutex
 
std::mutex m_ConnectingFinishedMutex
 
std::mutex m_StateMutex
 
std::string m_Hostname
 
int m_PortNumber
 
igtl::Socket::Pointer m_Socket
 
mitk::IGTLMessageQueue::Pointer m_MessageQueue
 
mitk::IGTLMessageFactory::Pointer m_MessageFactory
 
bool m_LogMessages
 

Detailed Description

Superclass for OpenIGTLink clients.

Implements the IGTLDevice interface for IGTLClients. In certain points it behaves different than the IGTLServer. The client connects directly to a server (it cannot connect to two different servers). Therefore, it has to check only this one connection.

Definition at line 35 of file mitkIGTLClient.h.

Constructor & Destructor Documentation

◆ IGTLClient()

mitk::IGTLClient::IGTLClient ( bool ReadFully)
protected

Constructor

Definition at line 24 of file mitkIGTLClient.cpp.

◆ ~IGTLClient()

mitk::IGTLClient::~IGTLClient ( )
overrideprotected

Destructor

Definition at line 29 of file mitkIGTLClient.cpp.

Member Function Documentation

◆ GetNumberOfConnections()

unsigned int mitk::IGTLClient::GetNumberOfConnections ( )
overridevirtual

Returns the number of connections of this device.

A client can connect to one sever only, therefore, the number is either 0 or 1

Implements mitk::IGTLDevice.

Definition at line 114 of file mitkIGTLClient.cpp.

◆ itkCloneMacro()

mitk::IGTLClient::itkCloneMacro ( Self )

◆ mitkClassMacro()

mitk::IGTLClient::mitkClassMacro ( IGTLClient ,
IGTLDevice  )

◆ mitkNewMacro1Param()

mitk::IGTLClient::mitkNewMacro1Param ( Self ,
bool  )

◆ OpenConnection()

bool mitk::IGTLClient::OpenConnection ( )
overridevirtual

Establishes the connection between this client and the IGTL server.

Exceptions
mitk::ExceptionThrows an exception if the client is not in Setup mode or if it cannot connect to the defined host.

Implements mitk::IGTLDevice.

Definition at line 33 of file mitkIGTLClient.cpp.

◆ Receive()

void mitk::IGTLClient::Receive ( )
overrideprotectedvirtual

Call this method to receive a message.

The message will be saved in the receive queue. If the connection is lost it will stop the communication.

Implements mitk::IGTLDevice.

Definition at line 75 of file mitkIGTLClient.cpp.

◆ Send()

void mitk::IGTLClient::Send ( )
overrideprotectedvirtual

Call this method to send a message.

The message will be read from the queue.

Implements mitk::IGTLDevice.

Definition at line 90 of file mitkIGTLClient.cpp.

◆ StopCommunicationWithSocket()

void mitk::IGTLClient::StopCommunicationWithSocket ( igtl::Socket * )
overrideprotectedvirtual

Stops the communication with the given socket.

The client uses just one socket. Therefore, calling this function causes the stop of the communication.

Implements mitk::IGTLDevice.

Definition at line 107 of file mitkIGTLClient.cpp.


The documentation for this class was generated from the following files: