Medical Imaging Interaction Toolkit  2018.4.99-ef453c4b
Medical Imaging Interaction Toolkit
mitkNDITrackingDevice.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef MITKNDITRACKINGDEVICE_H_HEADER_INCLUDED_C1C2FCD2
15 #define MITKNDITRACKINGDEVICE_H_HEADER_INCLUDED_C1C2FCD2
16 
17 #include "mitkTrackingDevice.h"
18 
19 #include <MitkIGTExports.h>
20 #include <itkMultiThreader.h>
21 #include "itkFastMutexLock.h"
22 #include <vector>
23 
24 #include "mitkNDIProtocol.h"
25 #include "mitkNDIPassiveTool.h"
27 
28 
29 namespace mitk
30 {
31  class NDIProtocol;
32 
41  {
42  friend class NDIProtocol;
43 
44  public:
45  typedef std::vector<NDIPassiveTool::Pointer> Tool6DContainerType;
46 
55 
57  itkFactorylessNewMacro(Self);
58  itkCloneMacro(Self);
59 
63  //itkSetMacro(Type, TrackingDeviceType);
64 
65 
78  bool OpenConnection() override;
79 
85  bool CloseConnection() override;
86 
88  bool InitializeWiredTools();
89 
93  void SetRotationMode(RotationMode r) override;
94 
102  virtual mitk::TrackingDeviceType TestConnection();
103 
113  bool DiscoverWiredTools();
114 
123  bool StartTracking() override;
124 
128  TrackingTool* GetTool(unsigned int toolNumber) const override;
129 
130  mitk::TrackingTool* GetToolByName(std::string name) const override;
134  unsigned int GetToolCount() const override;
135 
148  mitk::TrackingTool* AddTool(const char* toolName, const char* fileName, TrackingPriority p = NDIPassiveTool::Dynamic);
149 
155  virtual bool RemoveTool(TrackingTool* tool);
156 
160  virtual bool UpdateTool(mitk::TrackingTool* tool);
161 
162  virtual void SetPortNumber(const PortNumber _arg);
163  itkGetConstMacro(PortNumber, PortNumber);
164  virtual void SetDeviceName(std::string _arg);
165  itkGetStringMacro(DeviceName);
166  virtual void SetBaudRate(const BaudRate _arg);
167  itkGetConstMacro(BaudRate, BaudRate);
168  virtual void SetDataBits(const DataBits _arg);
169  itkGetConstMacro(DataBits, DataBits);
170  virtual void SetParity(const Parity _arg);
171  itkGetConstMacro(Parity, Parity);
172  virtual void SetStopBits(const StopBits _arg);
173  itkGetConstMacro(StopBits, StopBits);
174  virtual void SetHardwareHandshake(const HardwareHandshake _arg);
175  itkGetConstMacro(HardwareHandshake, HardwareHandshake);
176  virtual void SetIlluminationActivationRate(const IlluminationActivationRate _arg);
178  virtual void SetDataTransferMode(const DataTransferMode _arg);
179  itkGetConstMacro(DataTransferMode, DataTransferMode);
180  virtual bool Beep(unsigned char count);
181 
182  NDIErrorCode GetErrorCode(const std::string* input);
183 
184  virtual bool SetOperationMode(OperationMode mode);
185  virtual OperationMode GetOperationMode();
186 
190  virtual bool GetMarkerPositions(MarkerPointContainerType* markerpositions);
191 
196  virtual int GetMajorFirmwareRevisionNumber();
197 
202  virtual const char* GetFirmwareRevisionNumber();
203 
205  bool AutoDetectToolsAvailable() override;
206 
208  bool AddSingleToolIsAvailable() override;
209 
214  mitk::NavigationToolStorage::Pointer AutoDetectTools() override;
215 
216 
217 
218  protected:
219 
220  typedef std::vector<std::string> NDITrackingVolumeContainerType;
221  typedef std::vector<int> TrackingVolumeDimensionType;
222 
228  virtual bool GetSupportedVolumes(unsigned int* numberOfVolumes, NDITrackingVolumeContainerType* volumes, TrackingVolumeDimensionType* volumesDimensions);
229 
234  virtual bool SetVolume(mitk::TrackingDeviceData volume);
235 
241  virtual bool InternalAddTool(NDIPassiveTool* tool);
242 
243  /* Methods for NDIProtocol friend class */
244  virtual void InvalidateAll();
245  NDIPassiveTool* GetInternalTool(std::string portHandle);
246 
257  NDIErrorCode FreePortHandles();
258 
259  NDIErrorCode Send(const std::string* message, bool addCRC = true);
260  NDIErrorCode Receive(std::string* answer, unsigned int numberOfBytes);
261  NDIErrorCode ReceiveByte(char* answer);
262  NDIErrorCode ReceiveLine(std::string* answer);
263  void ClearSendBuffer();
264  void ClearReceiveBuffer();
265  const std::string CalcCRC(const std::string* input);
266 
267 public:
268 
277  virtual void TrackTools();
278 
286  virtual void TrackMarkerPositions();
287 
295  virtual void TrackToolsAndMarkers();
296 
300  static ITK_THREAD_RETURN_TYPE ThreadStartTracking(void* data);
301 
302  protected:
304  ~NDITrackingDevice() override;
305 
306  std::string m_DeviceName;
307  PortNumber m_PortNumber;
308  BaudRate m_BaudRate;
309  DataBits m_DataBits;
310  Parity m_Parity;
311  StopBits m_StopBits;
312  HardwareHandshake m_HardwareHandshake;
313  IlluminationActivationRate m_IlluminationActivationRate;
316  Tool6DContainerType m_6DTools;
317 
318  itk::FastMutexLock::Pointer m_ToolsMutex;
319  mitk::SerialCommunication::Pointer m_SerialCommunication;
320  itk::FastMutexLock::Pointer m_SerialCommunicationMutex;
321  NDIProtocol::Pointer m_DeviceProtocol;
322 
323  itk::MultiThreader::Pointer m_MultiThreader;
326  itk::FastMutexLock::Pointer m_MarkerPointsMutex;
328  };
329 } // namespace mitk
330 #endif /* MITKNDITRACKINGDEVICE_H_HEADER_INCLUDED_C1C2FCD2 */
NDIProtocol::Pointer m_DeviceProtocol
create and parse NDI protocol strings
HardwareHandshake m_HardwareHandshake
which tracking volume is currently used (if device supports multiple volumes) (
mitk::SerialCommunication::DataBits DataBits
Number of data bits used in the serial connection.
Interface for all Tracking Tools.
std::vector< std::string > NDITrackingVolumeContainerType
vector of tracking volumes
mitk::SerialCommunication::StopBits StopBits
Number of stop bits used in the serial connection.
OperationMode
Error codes of NDI tracking devices.
int m_ThreadID
ID of tracking thread.
IlluminationActivationRate
activation rate of IR illuminator for NDI Polaris tracking device
DataCollection - Class to facilitate loading/accessing structured data.
Tool6DContainerType m_6DTools
list of 6D tools
PortNumber m_PortNumber
COM Port Number.
itk::MultiThreader::Pointer m_MultiThreader
creates tracking thread that continuously polls serial interface for new tracking data ...
mitk::SerialCommunication::BaudRate BaudRate
Baud rate of the serial connection.
DataTransferMode m_DataTransferMode
use TX (text) or BX (binary) (
std::vector< NDIPassiveTool::Pointer > Tool6DContainerType
List of 6D tools of the correct type for this tracking device.
mitk::SerialCommunication::HardwareHandshake HardwareHandshake
Hardware handshake mode of the serial connection.
std::vector< int > TrackingVolumeDimensionType
List of the supported tracking volume dimensions.
mitk::SerialCommunication::Pointer m_SerialCommunication
serial communication interface
#define MITKIGT_EXPORT
std::string m_DeviceName
Device Name.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Interface for all Tracking Devices.
mitk::SerialCommunication::Parity Parity
Parity mode used in the serial connection.
std::vector< MarkerPointType > MarkerPointContainerType
itk::FastMutexLock::Pointer m_MarkerPointsMutex
mutex for marker point data container
mitk::SerialCommunication::PortNumber PortNumber
Port number of the serial connection.
OperationMode m_OperationMode
tracking mode (6D tool tracking, 3D marker tracking,...)
Implementation of a passive NDI optical tool.
Parity m_Parity
Parity mode for communication.
std::string TrackingDeviceType
BaudRate m_BaudRate
COM Port Baud Rate.
superclass for specific NDI tracking Devices that use serial communication.
mitk::NDIPassiveTool::TrackingPriority TrackingPriority
Tracking priority used for tracking a tool.
DataBits m_DataBits
Number of Data Bits per token.
TrackingPriority
tracking priority for NDI tracking devices
NDIErrorCode
Error codes of NDI tracking devices.
MarkerPointContainerType m_MarkerPoints
container for markers (3D point tracking mode)
DataTransferMode
Data transfer mode for NDI tracking devices.
StopBits m_StopBits
number of stop bits per token
itk::FastMutexLock::Pointer m_SerialCommunicationMutex
mutex for coordinated access of serial communication interface
The NDI Protocol class provides building and parsing of command strings and answers to and from a NDI...
itk::FastMutexLock::Pointer m_ToolsMutex
mutex for coordinated access of tool container
mitk::TrackingDeviceType NDITrackingDeviceType
This enumeration includes the two types of NDI tracking devices (Polaris, Aurora).