MITK-IGT
IGT Extension of MITK
|
Superclass for OpenIGTLink server. More...
#include <mitkIGTLServer.h>
Public Types | |
typedef std::list< igtl::Socket::Pointer > | SocketListType |
typedef SocketListType::iterator | SocketListIteratorType |
![]() | |
enum | IGTLDeviceState { Setup , Ready , Running } |
Type for state variable. The IGTLDevice is always in one of these states. More... | |
Public Member Functions | |
mitkClassMacro (IGTLServer, IGTLDevice) | |
mitkNewMacro1Param (Self, bool) | |
itkCloneMacro (Self) | |
bool | OpenConnection () override |
Initialize the connection for the IGTLServer. | |
bool | CloseConnection () override |
Closes the connection to the device. | |
unsigned int | GetNumberOfConnections () override |
Returns the number of client connections of this device. | |
![]() | |
mitkClassMacroItkParent (IGTLDevice, itk::Object) | |
IGTLDevice (bool ReadFully) | |
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 | |
IGTLServer (bool ReadFully) | |
~IGTLServer () override | |
void | Connect () override |
Call this method to check for other devices that want to connect to this one. | |
void | Receive () override |
Call this method to receive a message. | |
void | Send () override |
Call this method to send a message. The message will be read from the queue. So far the message is send to all connected sockets (broadcast). | |
virtual void | StopCommunicationWithSocket (SocketListType &toBeRemovedSockets) |
Stops the communication with the given sockets. | |
void | StopCommunicationWithSocket (igtl::Socket *client) override |
Stops the communication with the given socket. | |
![]() | |
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. | |
void | SetState (IGTLDeviceState state) |
change object state | |
IGTLDevice () | |
~IGTLDevice () override | |
Protected Attributes | |
SocketListType | m_RegisteredClients |
A list with all registered clients. | |
std::mutex | m_ReceiveListMutex |
std::mutex | m_SentListMutex |
![]() | |
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 |
Superclass for OpenIGTLink server.
Implements the IGTLDevice interface for IGTLServers. In certain points it behaves different than the IGTLClient. The client connects directly to a server (it cannot connect to two different servers) while the server can connect to several clients. Therefore, it is necessary for the server to have a list with registered sockets.
Definition at line 33 of file mitkIGTLServer.h.
SocketListType::iterator mitk::IGTLServer::SocketListIteratorType |
Definition at line 41 of file mitkIGTLServer.h.
std::list<igtl::Socket::Pointer> mitk::IGTLServer::SocketListType |
Definition at line 40 of file mitkIGTLServer.h.
|
protected |
Constructor
Definition at line 23 of file mitkIGTLServer.cpp.
|
overrideprotected |
Destructor
Definition at line 28 of file mitkIGTLServer.cpp.
|
overridevirtual |
Closes the connection to the device.
This may only be called if there is currently a connection to the device, but device is not running (e.g. object is in Ready state)
Reimplemented from mitk::IGTLDevice.
Definition at line 70 of file mitkIGTLServer.cpp.
|
overrideprotectedvirtual |
Call this method to check for other devices that want to connect to this one.
In case of a client this method is doing nothing. In case of a server it is checking for other devices and if there is one it establishes a connection and adds the socket to m_RegisteredClients.
Reimplemented from mitk::IGTLDevice.
Definition at line 83 of file mitkIGTLServer.cpp.
|
overridevirtual |
Returns the number of client connections of this device.
Implements mitk::IGTLDevice.
Definition at line 204 of file mitkIGTLServer.cpp.
mitk::IGTLServer::itkCloneMacro | ( | Self | ) |
mitk::IGTLServer::mitkClassMacro | ( | IGTLServer | , |
IGTLDevice | ) |
mitk::IGTLServer::mitkNewMacro1Param | ( | Self | , |
bool | ) |
|
overridevirtual |
Initialize the connection for the IGTLServer.
OpenConnection() starts the IGTLServer socket so that clients can connect to it.
mitk::Exception | Throws an exception if the given port is occupied. |
Implements mitk::IGTLDevice.
Definition at line 32 of file mitkIGTLServer.cpp.
|
overrideprotectedvirtual |
Call this method to receive a message.
The message will be saved in the receive queue.
Implements mitk::IGTLDevice.
Definition at line 104 of file mitkIGTLServer.cpp.
|
overrideprotectedvirtual |
Call this method to send a message. The message will be read from the queue. So far the message is send to all connected sockets (broadcast).
Implements mitk::IGTLDevice.
Definition at line 142 of file mitkIGTLServer.cpp.
|
overrideprotectedvirtual |
Stops the communication with the given socket.
This method removes the given socket from the registered clients list
Implements mitk::IGTLDevice.
Definition at line 178 of file mitkIGTLServer.cpp.
|
protectedvirtual |
Stops the communication with the given sockets.
This method removes the given sockets from the registered clients list
Definition at line 171 of file mitkIGTLServer.cpp.
|
protected |
mutex to control access to m_RegisteredClients
Definition at line 118 of file mitkIGTLServer.h.
|
protected |
A list with all registered clients.
Definition at line 115 of file mitkIGTLServer.h.
|
protected |
mutex to control access to m_RegisteredClients
Definition at line 121 of file mitkIGTLServer.h.