7 #ifndef __VTKPLUSOPENIGTLINKSERVER_H 8 #define __VTKPLUSOPENIGTLINKSERVER_H 11 #include "vtkPlusServerExport.h" 15 #include "vtkIGSIOTransformRepository.h" 18 #include <vtkMultiThreader.h> 19 #include <vtkObject.h> 20 #include <vtkSmartPointer.h> 26 #if (_MSC_VER == 1500) 31 #include <igtlMessageBase.h> 32 #include <igtlServerSocket.h> 40 class vtkIGSIORecursiveCriticalSection;
90 typedef std::map<int, std::vector<igtl::MessageBase::Pointer> > ClientIdToMessageListMap;
95 virtual void PrintSelf(ostream& os, vtkIndent indent)
VTK_OVERRIDE;
98 PlusStatus Start(
vtkPlusDataCollector* dataCollector, vtkIGSIOTransformRepository* transformRepository, vtkXMLDataElement* serverElement,
const std::string& configFilePath);
105 virtual PlusStatus ReadConfiguration(vtkXMLDataElement* serverElement,
const std::string& aFilename);
108 vtkSetMacro(ListeningPort,
int);
110 vtkGetMacroConst(ListeningPort,
int);
112 vtkGetStdStringMacro(OutputChannelId);
114 vtkSetMacro(MissingInputGracePeriodSec,
double);
115 vtkGetMacroConst(MissingInputGracePeriodSec,
double);
117 vtkSetMacro(MaxTimeSpentWithProcessingMs,
double);
118 vtkGetMacroConst(MaxTimeSpentWithProcessingMs,
double);
120 vtkSetMacro(SendValidTransformsOnly,
bool);
121 vtkGetMacroConst(SendValidTransformsOnly,
bool);
123 vtkSetMacro(DefaultClientSendTimeoutSec,
float);
124 vtkGetMacroConst(DefaultClientSendTimeoutSec,
float);
126 vtkSetMacro(DefaultClientReceiveTimeoutSec,
float);
127 vtkGetMacroConst(DefaultClientReceiveTimeoutSec,
float);
134 vtkSetMacro(TransformRepository, vtkIGSIOTransformRepository*);
135 vtkGetMacroConst(TransformRepository, vtkIGSIOTransformRepository*);
138 virtual unsigned int GetNumberOfConnectedClients()
const;
151 vtkGetStdStringMacro(ConfigFilename);
153 vtkGetMacro(IGTLProtocolVersion,
int);
154 vtkGetMacro(IGTLHeaderVersion,
int);
160 int ProcessPendingCommands();
167 PlusStatus QueueMessageResponseForClient(
int clientId, igtl::MessageBase::Pointer
message);
170 static void* ConnectionReceiverThread(vtkMultiThreader::ThreadInfo*
data);
173 static void* DataSenderThread(vtkMultiThreader::ThreadInfo*
data);
185 static void* DataReceiverThread(vtkMultiThreader::ThreadInfo*
data);
188 virtual PlusStatus SendTrackedFrame(igsioTrackedFrame& trackedFrame);
194 virtual void KeepAlive();
197 void DisconnectClient(
int clientId);
200 vtkSetMacro(IgtlMessageCrcCheckEnabled,
bool);
202 vtkGetMacroConst(IgtlMessageCrcCheckEnabled,
bool);
204 vtkSetMacro(LogWarningOnNoDataAvailable,
bool);
205 vtkGetMacroConst(LogWarningOnNoDataAvailable,
bool);
207 vtkSetMacro(MaxNumberOfIgtlMessagesToSend,
int);
208 vtkGetMacroConst(MaxNumberOfIgtlMessagesToSend,
int);
210 vtkSetMacro(NumberOfRetryAttempts,
int);
211 vtkGetMacroConst(NumberOfRetryAttempts,
int);
213 vtkSetMacro(DelayBetweenRetryAttemptsSec,
double);
214 vtkGetMacroConst(DelayBetweenRetryAttemptsSec,
double);
216 vtkSetMacro(KeepAliveIntervalSec,
double);
217 vtkGetMacroConst(KeepAliveIntervalSec,
double);
219 vtkSetStdStringMacro(OutputChannelId);
220 vtkSetStdStringMacro(ConfigFilename);
222 bool HasGracePeriodExpired();
229 igtl::ServerSocket::Pointer ServerSocket;
232 vtkSmartPointer<vtkIGSIOTransformRepository> TransformRepository;
235 vtkSmartPointer<vtkPlusDataCollector> DataCollector;
238 vtkSmartPointer<vtkMultiThreader> Threader;
241 int IGTLProtocolVersion;
242 int IGTLHeaderVersion;
248 int NumberOfRetryAttempts;
251 double DelayBetweenRetryAttemptsSec;
254 int MaxNumberOfIgtlMessagesToSend;
266 ThreadFlags ConnectionActive;
267 ThreadFlags DataSenderActive;
270 int ConnectionReceiverThreadId;
271 int DataSenderThreadId;
274 std::list<ClientData> IgtlClients;
277 vtkSmartPointer<vtkPlusIgtlMessageFactory> IgtlMessageFactory;
280 vtkSmartPointer<vtkIGSIORecursiveCriticalSection> IgtlClientsMutex;
283 double LastSentTrackedFrameTimestamp;
286 int MaxTimeSpentWithProcessingMs;
289 int LastProcessingTimePerFrameMs;
292 bool SendValidTransformsOnly;
300 float DefaultClientSendTimeoutSec;
301 float DefaultClientReceiveTimeoutSec;
304 bool IgtlMessageCrcCheckEnabled;
307 vtkSmartPointer<vtkPlusCommandProcessor> PlusCommandProcessor;
310 ClientIdToMessageListMap MessageResponseQueue;
313 vtkSmartPointer<vtkIGSIORecursiveCriticalSection> MessageResponseQueueMutex;
316 std::string OutputChannelId;
321 bool LogWarningOnNoDataAvailable;
323 double KeepAliveIntervalSec;
325 std::string ConfigFilename;
327 vtkPlusLogger::LogLevelType GracePeriodLogLevel;
328 double MissingInputGracePeriodSec;
329 double BroadcastStartTime;
332 static int ClientIdCounter;
334 static const float CLIENT_SOCKET_TIMEOUT_SEC;
336 bool NewClientConnected;
uint32_t ClientSocketReceiveTimeout
PlusIgtlClientInfo ClientInfo
Creates a PlusCommand from a string. If the commands are to be executed on the main thread then call ...
vtkPlusOpenIGTLinkServer * Server
std::pair< bool, bool > DataReceiverActive
Active flag for thread (first: request, second: respond )
int ClientId
Unique client identifier. First valid value is 1.
uint32_t ClientSocketSendTimeout
Client specific timeouts.
Manages devices that record image or positional data.
igtl::ClientSocket::Pointer ClientSocket
IGTL client socket instance.
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
This class provides a network interface for data acquired by Plus as an OpenIGTLink server.
This class provides client information for vtkPlusOpenIGTLinkServer.