Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkNDIProtocol.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 mitkNDIProtocol_h
15 #define mitkNDIProtocol_h
16 
17 #include <itkObject.h>
18 #include <itkObjectFactory.h>
19 
20 #include <MitkIGTExports.h>
22 #include "mitkNDIPassiveTool.h"
23 
24 namespace mitk
25 {
26  class NDITrackingDevice;
27 
32  {
33  NDIOKAY = 0,
34  NDIERROR = 1,
40  NDICRCERROR, // reply has crc error, local computer detected the error
44  NDICRCDOESNOTMATCH, // command had crc error, tracking device detected the error
78  };
79 
86  class MITKIGT_EXPORT NDIProtocol : public itk::Object
87  {
88  public:
90  itkFactorylessNewMacro(Self);
91  itkCloneMacro(Self);
92  itkSetObjectMacro(TrackingDevice, NDITrackingDevice);
93 
101 
104  NDIErrorCode APIREV(std::string* revision);
105  NDIErrorCode PHINF(std::string portHandle, std::string* portInfo);
106  NDIErrorCode PSOUT(std::string portHandle, std::string state);
108  NDIErrorCode INIT();
109  NDIErrorCode DSTART();
110  NDIErrorCode DSTOP();
111  NDIErrorCode IRINIT();
112  NDIErrorCode IRCHK(bool* IRdetected);
113  NDIErrorCode PHSR(PHSRQueryType queryType, std::string* portHandles);
114  NDIErrorCode PHF(std::string* portHandle);
115  NDIErrorCode PHRQ(std::string* portHandle);
116  NDIErrorCode PVWR(std::string* portHandle, const unsigned char* sromData, unsigned int sromDataLength);
117  NDIErrorCode PINIT(std::string* portHandle);
118  NDIErrorCode PENA(std::string* portHandle, TrackingPriority prio);
119  NDIErrorCode PDIS(std::string* portHandle);
121  NDIErrorCode BEEP(unsigned char count);
122  NDIErrorCode SFLIST(std::string* info);
123  NDIErrorCode TSTART(bool resetFrameCounter = false);
124  NDIErrorCode TSTOP();
125  NDIErrorCode TX(bool trackIndividualMarkers = false, MarkerPointContainerType* markerPositions = nullptr);
126  NDIErrorCode BX();
127  NDIErrorCode POS3D(MarkerPointContainerType* markerPositions);
129  NDIErrorCode VSEL(mitk::TrackingDeviceData deviceData);
130  NDIErrorCode TX1000(MarkerPointContainerType* markerPositions);
131  unsigned int ByteToNbBitsOn(char& c) const;
132  itkGetConstMacro(UseCRC, bool);
133  itkSetMacro(UseCRC, bool);
134  itkBooleanMacro(UseCRC);
135  protected:
136  NDIProtocol();
137  ~NDIProtocol() override;
138 
144  NDIErrorCode ParseOkayError();
145 
151  NDIErrorCode GenericCommand(const std::string command, const std::string* parameter = nullptr);
152 
156  NDIErrorCode GetErrorCode(const std::string* input);
157 
159  bool m_UseCRC;
160  };
161 } // namespace mitk
162 #endif
mitk::NDIUNABLETOSTOPTRACKING
@ NDIUNABLETOSTOPTRACKING
Definition: mitkNDIProtocol.h:56
mitk::NDICOMMANDTOOLONG
@ NDICOMMANDTOOLONG
Definition: mitkNDIProtocol.h:42
mitk::NDICOMMANDPARAMETEROUTOFRANGE
@ NDICOMMANDPARAMETEROUTOFRANGE
Definition: mitkNDIProtocol.h:64
mitk::SERIALINTERFACENOTSET
@ SERIALINTERFACENOTSET
Definition: mitkNDIProtocol.h:35
mitk::SerialCommunication::HardwareHandshake
HardwareHandshake
Definition: mitkSerialCommunication.h:110
mitk::NDIUNKNOWNERROR
@ NDIUNKNOWNERROR
Definition: mitkNDIProtocol.h:73
mitk::NDIProtocol::StopBits
mitk::SerialCommunication::StopBits StopBits
Number of stop bits used in the serial connection.
Definition: mitkNDIProtocol.h:98
mitk::NDIERROR
@ NDIERROR
Definition: mitkNDIProtocol.h:34
mitk::NDIINVALIDTRACKINGPRIORITY
@ NDIINVALIDTRACKINGPRIORITY
Definition: mitkNDIProtocol.h:49
mitk::SerialCommunication::Parity
Parity
Definition: mitkSerialCommunication.h:97
mitk::NDIINITIALIZATIONFAILED
@ NDIINITIALIZATIONFAILED
Definition: mitkNDIProtocol.h:58
mitk::NDIINVALIDVOLUMEPARAMETERS
@ NDIINVALIDVOLUMEPARAMETERS
Definition: mitkNDIProtocol.h:59
mitk::NDIPORTHANDLENOTALLOCATED
@ NDIPORTHANDLENOTALLOCATED
Definition: mitkNDIProtocol.h:66
mitk::NDIINVALIDLEDSTATE
@ NDIINVALIDLEDSTATE
Definition: mitkNDIProtocol.h:51
mitk::NDIProtocol::DataBits
mitk::SerialCommunication::DataBits DataBits
Number of data bits used in the serial connection.
Definition: mitkNDIProtocol.h:96
mitk::NDICANTINITIRDIAGNOSTICS
@ NDICANTINITIRDIAGNOSTICS
Definition: mitkNDIProtocol.h:61
mitk::NDIINVALIDLED
@ NDIINVALIDLED
Definition: mitkNDIProtocol.h:50
mitk::BX
@ BX
Definition: mitkTrackingTypes.h:68
mitk::SerialCommunication::BaudRate
BaudRate
Definition: mitkSerialCommunication.h:67
mitk::NDIINVALIDCOMMAND
@ NDIINVALIDCOMMAND
Definition: mitkNDIProtocol.h:41
mitk::NDIProtocol::HardwareHandshake
mitk::SerialCommunication::HardwareHandshake HardwareHandshake
Hardware handshake mode of the serial connection.
Definition: mitkNDIProtocol.h:99
mitk::NDICRCDOESNOTMATCH
@ NDICRCDOESNOTMATCH
Definition: mitkNDIProtocol.h:44
mitk::PHSRQueryType
PHSRQueryType
Query mode for NDI tracking devices.
Definition: mitkTrackingTypes.h:74
mitk::NDIPassiveTool::TrackingPriority
TrackingPriority
tracking priority for NDI tracking devices
Definition: mitkNDIPassiveTool.h:38
mitk::NDIErrorCode
NDIErrorCode
Error codes of NDI tracking devices.
Definition: mitkNDIProtocol.h:31
mitk::NDISYSTEMNOTINITIALIZED
@ NDISYSTEMNOTINITIALIZED
Definition: mitkNDIProtocol.h:55
mitk::NDIOKAY
@ NDIOKAY
Definition: mitkNDIProtocol.h:33
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::NDIFAILURETOWRITESROM
@ NDIFAILURETOWRITESROM
Definition: mitkNDIProtocol.h:62
mitk::TrackingDeviceData
Definition: mitkTrackingTypes.h:34
mitk::MarkerPointContainerType
std::vector< MarkerPointType > MarkerPointContainerType
Definition: mitkTrackingTypes.h:84
mitk::NDINOTOOLFORPORT
@ NDINOTOOLFORPORT
Definition: mitkNDIProtocol.h:53
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::NDIProtocol
The NDI Protocol class provides building and parsing of command strings and answers to and from a NDI...
Definition: mitkNDIProtocol.h:86
mitk::NDIPORTNOTINITIALIZED
@ NDIPORTNOTINITIALIZED
Definition: mitkNDIProtocol.h:54
mitk::TX
@ TX
Definition: mitkTrackingTypes.h:67
mitk::SERIALSENDERROR
@ SERIALSENDERROR
Definition: mitkNDIProtocol.h:36
mitk::SROMFILETOOSMALL
@ SROMFILETOOSMALL
Definition: mitkNDIProtocol.h:39
mitk::TrackingDevice
Interface for all Tracking Devices.
Definition: mitkTrackingDevice.h:34
mitk::TRACKINGDEVICENOTSET
@ TRACKINGDEVICENOTSET
Definition: mitkNDIProtocol.h:77
mitk::NDIOUTOFHANDLES
@ NDIOUTOFHANDLES
Definition: mitkNDIProtocol.h:68
mitk::NDICRCERROR
@ NDICRCERROR
Definition: mitkNDIProtocol.h:40
mitk::SerialCommunication::PortNumber
PortNumber
Definition: mitkSerialCommunication.h:50
mitk::IlluminationActivationRate
IlluminationActivationRate
activation rate of IR illuminator for NDI Polaris tracking device
Definition: mitkTrackingTypes.h:55
mitk::TRACKINGDEVICERESET
@ TRACKINGDEVICERESET
Definition: mitkNDIProtocol.h:76
mitk::UNKNOWNHANDLERETURNED
@ UNKNOWNHANDLERETURNED
Definition: mitkNDIProtocol.h:75
mitkSerialCommunication.h
mitk::SerialCommunication::DataBits
DataBits
Definition: mitkSerialCommunication.h:91
mitk::NDIProtocol::Parity
mitk::SerialCommunication::Parity Parity
Parity mode used in the serial connection.
Definition: mitkNDIProtocol.h:97
mitk::NDICANTSTARTDIAGNOSTICMODE
@ NDICANTSTARTDIAGNOSTICMODE
Definition: mitkNDIProtocol.h:60
mitk::NDINOMEMORYAVAILABLE
@ NDINOMEMORYAVAILABLE
Definition: mitkNDIProtocol.h:65
mitk::NDIProtocol::m_TrackingDevice
NDITrackingDevice * m_TrackingDevice
tracking device to which the commands will be send
Definition: mitkNDIProtocol.h:158
mitk::NDIUNABLETOSETNEWCOMMPARAMETERS
@ NDIUNABLETOSETNEWCOMMPARAMETERS
Definition: mitkNDIProtocol.h:46
mitk::NDICOMMANDTOOSHORT
@ NDICOMMANDTOOSHORT
Definition: mitkNDIProtocol.h:43
mitk::NDIUNABLETOSTARTTRACKING
@ NDIUNABLETOSTARTTRACKING
Definition: mitkNDIProtocol.h:57
mitk::NDIINVALIDPORTHANDLE
@ NDIINVALIDPORTHANDLE
Definition: mitkNDIProtocol.h:48
mitk::NDITrackingDevice
superclass for specific NDI tracking Devices that use serial communication.
Definition: mitkNDITrackingDevice.h:40
mitk::NDIUNEXPECTEDREPLY
@ NDIUNEXPECTEDREPLY
Definition: mitkNDIProtocol.h:74
mitk::SerialCommunication::StopBits
StopBits
Definition: mitkSerialCommunication.h:104
mitk::NDIWARNING
@ NDIWARNING
Definition: mitkNDIProtocol.h:72
mitk::NDIProtocol::m_UseCRC
bool m_UseCRC
whether to append a CRC16 checksum to each message
Definition: mitkNDIProtocol.h:159
mitk::NDICOMMANDINVALIDINCURRENTMODE
@ NDICOMMANDINVALIDINCURRENTMODE
Definition: mitkNDIProtocol.h:52
mitk::SROMFILETOOLARGE
@ SROMFILETOOLARGE
Definition: mitkNDIProtocol.h:38
mitk::NDIINVALIDPORTDESCRIPTION
@ NDIINVALIDPORTDESCRIPTION
Definition: mitkNDIProtocol.h:70
mitk::NDIPORTHASBECOMEUNOCCUPIED
@ NDIPORTHASBECOMEUNOCCUPIED
Definition: mitkNDIProtocol.h:67
mitk::SERIALRECEIVEERROR
@ SERIALRECEIVEERROR
Definition: mitkNDIProtocol.h:37
mitk::NDIINCORRECTNUMBEROFPARAMETERS
@ NDIINCORRECTNUMBEROFPARAMETERS
Definition: mitkNDIProtocol.h:47
mitk::NDIProtocol::BaudRate
mitk::SerialCommunication::BaudRate BaudRate
Baud rate of the serial connection.
Definition: mitkNDIProtocol.h:95
mitkNDIPassiveTool.h
mitk::NDITIMEOUT
@ NDITIMEOUT
Definition: mitkNDIProtocol.h:45
mitk::NDIProtocol::PortNumber
mitk::SerialCommunication::PortNumber PortNumber
Port number of the serial connection.
Definition: mitkNDIProtocol.h:92
mitk::TrackingDeviceType
std::string TrackingDeviceType
Definition: mitkTrackingTypes.h:22
mitk::NDIProtocol::TrackingPriority
mitk::NDIPassiveTool::TrackingPriority TrackingPriority
Tracking priority used for tracking a tool.
Definition: mitkNDIProtocol.h:100
mitk::NDIINVALIDOPERATIONFORDEVICE
@ NDIINVALIDOPERATIONFORDEVICE
Definition: mitkNDIProtocol.h:71
mitk::NDIENABLEDTOOLSNOTSUPPORTED
@ NDIENABLEDTOOLSNOTSUPPORTED
Definition: mitkNDIProtocol.h:63
mitk::NDIINCOMPATIBLEFIRMWAREVERSIONS
@ NDIINCOMPATIBLEFIRMWAREVERSIONS
Definition: mitkNDIProtocol.h:69