18 #ifndef __igstkNDICommandInterpreter_h
19 #define __igstkNDICommandInterpreter_h
70 NDI_BAD_COMMAND_CRC = 0x04,
71 NDI_INTERN_TIMEOUT = 0x05,
73 NDI_PARAMETERS = 0x07,
74 NDI_INVALID_PORT = 0x08,
75 NDI_INVALID_MODE = 0x09,
76 NDI_INVALID_LED = 0x0a,
80 NDI_PORT_NOT_INIT = 0x0e,
81 NDI_PORT_DISABLED = 0x0f,
82 NDI_INITIALIZATION = 0x10,
83 NDI_TSTOP_FAIL = 0x11,
84 NDI_TSTART_FAIL = 0x12,
85 NDI_PINIT_FAIL = 0x13,
88 NDI_DSTART_FAIL = 0x16,
89 NDI_DSTOP_FAIL = 0x17,
90 NDI_IRCHK_FAIL = 0x18,
93 NDI_IRINIT_FAIL = 0x1b,
97 NDI_SROM_WRITE = 0x1f,
98 NDI_SROM_SELECT = 0x20,
99 NDI_PORT_CURRENT = 0x21,
100 NDI_WAVELENGTH = 0x22,
101 NDI_PARAMETER_RANGE = 0x23,
104 NDI_ERROR_0X26 = 0x26,
105 NDI_ERROR_0X27 = 0x27,
106 NDI_SCU_STATE = 0x28,
109 NDI_NOT_ALLOCATED = 0x2B,
110 NDI_NOT_OCCUPIED = 0x2C,
111 NDI_NO_HANDLES = 0x2D,
112 NDI_INCOMPATIBLE = 0x2E,
113 NDI_DESCRIPTION = 0x2F,
115 NDI_INVALID_STATE = 0x31,
116 NDI_OPERATION = 0x32,
119 NDI_ENVIRONMENT = 0xf1,
121 NDI_EPROM_ERASE = 0xf4,
122 NDI_EPROM_WRITE = 0xf5,
123 NDI_EPROM_READ = 0xf6,
127 NDI_BAD_CRC = 0x0100,
128 NDI_OPEN_ERROR = 0x0200,
129 NDI_BAD_COMM = 0x0300,
130 NDI_TIMEOUT = 0x0400,
131 NDI_WRITE_ERROR = 0x0500,
132 NDI_READ_ERROR = 0x0600,
133 NDI_RESET_FAIL = 0x0700,
134 NDI_PROBE_FAIL = 0x0800,
444 const char *
Command(
const char *command);
464 this->
Command(
"COMM:%d%03d%d", baud, dps, handshake); }
491 this->
Command(
"IRCHK:%04X", mode); }
506 this->
Command(
"LED:%02X%d%c", ph, led, state); }
511 this->
Command(
"PDIS:%02X", ph); }
518 this->
Command(
"PENA:%02X%c", ph, mode); }
523 this->
Command(
"PHF:%02X", ph); }
548 this->
Command(
"PHINF:%02X%04X", ph, mode); }
561 void PHRQ(
const char* num,
const char* sys,
const char* tool,
562 const char* port,
const char* chan)
564 this->
Command(
"PHRQ:%-8.8s%1.1s%1.1s%2.2s%2.2s", num, sys, tool,
584 this->
Command(
"PHSR:%02X", mode); }
590 this->
Command(
"PINIT:%02X", ph); }
600 void PSOUT(
int ph,
int a,
int b,
int c) {
601 this->
Command(
"PSOUT:%02X%c%c%c", ph, a, b, c); };
608 this->
Command(
"PVCLR:%c", port); }
616 void PVWR(
int ph,
int a,
const char* x) {
617 this->
Command(
"PVWR:%02X%04X%.128s", ph, a, x); }
641 this->
Command(
"SFLIST:%02X", mode); }
658 this->
Command(
"SSTAT:%04X", mode); }
690 this->
Command(
"TX:%04X", mode); }
716 this->
Command(
"BX:%04X", mode); }
1312 static char*
HexEncode(
char* cp,
const void* data,
int n);
1321 static void*
HexDecode(
void* data,
const char* cp,
int n);
1331 virtual void PrintSelf( std::ostream& os, itk::Indent indent )
const;
1336 itkStaticConstMacro( NDI_MAX_HANDLES,
int, 24 );
1342 char *m_CommandReply;
1343 char *m_SerialCommand;
1344 char *m_SerialReply;
1353 char m_SSTATControl[2];
1354 char m_SSTATSensor[2];
1358 int m_IRCHKDetected;
1359 char m_IRCHKSources[128];
1362 char m_PHRQReply[2];
1365 char m_PHSRReply[1284];
1368 int m_PHINFOccupied;
1369 char m_PHINFBasic[34];
1370 char m_PHINFTesting[8];
1371 char m_PHINFPartNumber[20];
1372 char m_PHINFAccessories[2];
1373 char m_PHINFMarkerType[2];
1374 char m_PHINFPortLocation[14];
1375 char m_PHINFGPIOStatus[2];
1378 int m_TXNumberOfHandles;
1379 unsigned char m_TXHandles[NDI_MAX_HANDLES];
1380 unsigned char m_TXHandleStatus[NDI_MAX_HANDLES];
1381 char m_TXSystemStatus[4];
1384 char m_TXTransforms[NDI_MAX_HANDLES][52];
1385 char m_TXPortStatus[NDI_MAX_HANDLES][8];
1386 char m_TXFrame[NDI_MAX_HANDLES][8];
1389 char m_TXInformation[NDI_MAX_HANDLES][12];
1392 char m_TXSingleStray[NDI_MAX_HANDLES][24];
1395 int m_TXNumberOfPassiveStrays;
1396 char m_TXPassiveStrayOutOfVolume[14];
1397 char m_TXPassiveStray[1052];
1400 int m_BXNumberOfHandles;
1401 unsigned char m_BXHandles[NDI_MAX_HANDLES];
1402 unsigned char m_BXHandleStatus[NDI_MAX_HANDLES];
1403 unsigned short m_BXSystemStatus;
1406 float m_BXTransforms[NDI_MAX_HANDLES][8];
1407 unsigned int m_BXPortStatus[NDI_MAX_HANDLES];
1408 unsigned int m_BXFrame[NDI_MAX_HANDLES];
1411 unsigned char m_BXToolInformation[NDI_MAX_HANDLES];
1412 unsigned char m_BXMarkerInformation[NDI_MAX_HANDLES][20];
1415 unsigned char m_BXSingleStrayStatus[NDI_MAX_HANDLES];
1416 float m_BXSingleStrayPosition[NDI_MAX_HANDLES][3];
1419 int m_BXNumberOfPassiveStrays;
1420 unsigned char m_BXPassiveStrayOutOfVolume[7];
1421 float m_BXPassiveStrayPosition[50][3];
1424 char m_VERText[1028];
1427 const char*
Command(
const char* format,
int a);
1429 const char*
Command(
const char* format,
int a,
int b);
1431 const char*
Command(
const char* format,
int a,
int b,
int c);
1433 const char*
Command(
const char* format,
int a,
int b,
int c,
int d);
1435 const char*
Command(
const char* format,
int a,
int b,
const char* c);
1437 const char*
Command(
const char* format,
const char* a,
const char* b,
1438 const char* c,
const char* d,
const char* e);
1441 int WriteSerialBreak();
1446 int WriteCommand(
unsigned int *nc);
1453 int ReadBinaryReply(
unsigned int offset);
1460 int ReadAsciiReply(
unsigned int offset);
1463 int SetErrorCode(
int errnum);
1468 void HelperForCOMM(
const char* cp,
const char* crp);
1469 void HelperForPHINF(
const char* cp,
const char* crp);
1470 void HelperForPHRQ(
const char* cp,
const char* crp);
1471 void HelperForPHSR(
const char* cp,
const char* crp);
1472 void HelperForTX(
const char* cp,
const char* crp);
1473 void HelperForBX(
const char* cp,
const char* crp);
1474 void HelperForIRCHK(
const char* cp,
const char* crp);
1475 void HelperForSSTAT(
const char* cp,
const char* crp);
1476 void HelperForVER(
const char* cp,
const char* crp);
1480 int TXIndexFromPortHandle(
int ph,
int *ip)
const;
1487 static unsigned int HexadecimalStringToUnsignedInt(
const char* cp,
int n);
1494 static int HexadecimalStringToInt(
const char* cp,
int n);
1501 static int StringToInt(
const char* cp,
int n);
1509 static int SignedStringToInt(
const char* cp,
int n);
1513 int BXIndexFromPortHandle(
int ph,
int *ip)
const;
1517 static unsigned char BinaryToUnsignedChar(
const char *cp) {
1518 const unsigned char *ucp = (
const unsigned char *)cp;
1523 static unsigned short BinaryToUnsignedShort(
const char *cp) {
1524 const unsigned char *ucp = (
const unsigned char *)cp;
1525 return ((ucp[1] << 8) | ucp[0]); }
1528 static unsigned int BinaryToUnsignedInt(
const char *cp) {
1529 const unsigned char *ucp = (
const unsigned char *)cp;
1530 return (((ucp[3] << 8) | ucp[2]) << 16) | ((ucp[1] << 8) | ucp[0]); }
1533 static float BinaryToFloat(
const char *cp) {
1534 const unsigned char *ucp = (
const unsigned char *)cp;
1535 union {
float f;
unsigned int i; } u;
1536 u.i = (((ucp[3] << 8) | ucp[2]) << 16) | ((ucp[1] << 8) | ucp[0]);
1541 void operator=(
const Self&);
transform has been returned
int GetSSTATSensors() const
Get the status of the sensor processors.
void DSTART()
Put the device into diagnostic mode.
static const char * ErrorString(int errnum)
Convert an error code returned by GetError() into a string that describes the error.
Mediate between a Tracker and its Communication object.
port unoccupied or no information
void DSTOP()
Take the device out of diagnostic mode.
unsigned int GetPHINFCurrentTest() const
Return the results of a current test on the IREDS on an active POLARIS tool.
void PHF(int ph)
Free the specified port handle.
IRCHKModeType
IRCHK() reply mode bits.
PSOUTStateType
PSOUT() states for General Purpose Input Output (GPIO)
PHINFMarkerType
GetPHINFMarkerType() return value.
PHINFAccessoriesType
GetPHINFAccessories() return value bits.
TXTransformType
GetTXTransform() and general-purpose transform return values.
void PVWR(int ph, int a, const char *x)
Write to a virtual SROM address on the specified port handle.
int GetTXNumberOfPassiveStrays() const
Get the number of passive stray markers detected.
void BEEP(int n)
Cause the device to beep.
CommunicationType * GetCommunication()
Get the communication object.
tool has tool-in-port switch
int GetPHINFAccessories() const
Get the 8-bit value specifying the tool accessories.
void PHSR(PHSRModeType mode)
List the port handles.
number of passive tool ports
PHINFModeType
PHINF() reply mode bits.
int GetPHINFToolType() const
Get an integer that describes the tool type.
void PSOUT(int ph, int a, int b, int c)
Set the three GPIO wire states for an AURORA tool.
void RESET()
Send a serial break to reset the device.
STATSensorType
GetSSTATSensor() return value bits.
void PINIT(int ph)
Initialize the tool on the specified port handle.
Base class for all the IGSTK classes.
Object Self
General Typedefs.
COMMBaudType
Macro with standard traits declarations.
SFLISTModeType
SFLIST() reply mode.
int GetBXPassiveStrayOutOfVolume(int i) const
Determine whether a passive stray is outside of the characterized volume.
int GetBXPassiveStray(int i, double coord[3]) const
Copy the coordinates of the specified stray marker into the supplied array.
int GetSSTATTIU() const
Get the status of the sensor processors.
relatively immobile tool (reference)
TXSystemStatusType
GetTXSystemStatus() return value bits.
int GetBXNumberOfPassiveStrays() const
Get the number of passive stray markers detected.
TXPortStatusType
GetTXPortStatus() return value bits.
#define igstkStandardClassTraitsMacro(classname, superclassname)
Convenience macro for traits of a non-templated class.
int GetBXPortStatus(int ph) const
Get the 16-bit status value for the specified port handle.
active tool ports are available
simple yes/no whether IR detected
int GetPHRQHandle() const
Get the port handle returned by a PHRQ() command.
int GetTXSystemStatus() const
Get an 16-bit status bitfield for the system.
int GetPHSRNumberOfHandles() const
Get the number of port handles as returned by a PHSR() command.
SerialCommunication CommunicationType
Some required typedefs.
static char * HexEncode(char *cp, const void *data, int n)
This function is used to convert raw binary data into a stream of hexadecimal digits that can be sent...
int GetPHINFToolInfo(char information[32]) const
Get a 31-byte string describing the tool.
SSTATControlType
GetSSTATControl() return value bits.
TXToolInfoType
GetTXToolInfo() return value bits.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Print object information.
dynamic tool (most tools)
int GetPHSRInformation(int i) const
Get the information for a port handle returned by a PHSR() command.
void TSTART()
Put the device into tracking mode.
void TSTOP()
Take the device out of tracking mode.
PENATrackingModeType
PENA() tracking modes.
int GetError() const
Get error code from the last command.
void PDIS(int ph)
Disable transform reporting on the specified port handle.
number of ports with current sensing
additional tool transform info
tool is out of view or otherwise missing
int GetPHINFMarkerType() const
Get an 8-bit value describing the marker type for the tool.
void IRINIT()
Initialize the diagnostic environmental infrared checking system.
COMMDataType
COMM() data bits, parity and stop bits.
tool-in-port sensing is available
::itk::SmartPointer< Self > Pointer
PHSRModeType
PHSR() handle types.
stray active marker reporting
void SFLIST(SFLISTModeType mode)
Get a feature list for this device.
void PHRQ(const char *num, const char *sys, const char *tool, const char *port, const char *chan)
Request a port handle given specific tool criteria.
void INIT()
Initialize the device.
int GetPHSRHandle(int i) const
Get one of the port handles returned by a PHSR() command.
IRCHKSensorType
GetIRCHKNumberOfSources(), GetIRCHKSourceXY() sensor arguments.
void VER(VERModeType n)
Get a string that describes the device firmware version.
control processor information
SSTATModeType
SSTAT() reply format bits.
int GetIRCHKSourceXY(int side, int i, double xy[2]) const
Get the coordinates of one of the infrared sources seen by one of the two sensors.
int GetBXSingleStray(int ph, double coord[3]) const
Get the coordinates of a stray marker on a wired POLARIS tool.
LEDStateType
LED() states.
TXMarkerInfoType
GetTXMarkerInfo() return value bits.
unsigned int GetTXFrame(int ph) const
Get the camera frame number for the latest transform.
int GetTXTransform(int ph, double transform[8]) const
Get the transformation for the specified port.
list of volumes available (see NDI docs)
int GetTXToolInfo(int ph) const
Get additional information about the tool transformation.
COMMHandshakeType
COMM() hardware handshaking.
const char * Command(const char *command)
Send a text command to the device and receive a text reply.
VERModeType
VER() reply mode types.
int GetTXSingleStray(int ph, double coord[3]) const
Get the coordinates of a stray marker on a wired POLARIS tool.
int GetIRCHKDetected() const
Check to see whether environmental infrared was detected.
static void * HexDecode(void *data, const char *cp, int n)
This function converts a hex-encoded string into binary data.
void PHINF(int ph, int mode)
Ask the device for information about a tool handle.
int GetPHINFPortLocation(char location[15]) const
Get a 14-byte description of the physical location of the tool on the system.
passive tool ports are available
int GetIRCHKNumberOfSources(int side) const
Get the number of infrared sources seen by one of the two sensors.
port is disabled or tool was unplugged
STATTIUType
GetSSTATTIU() return value bits.
int GetBXMarkerInfo(int ph, int marker) const
Get additional information about the tool markers.
This class implements communication over a serial port via RS-232.
void SSTAT(int mode)
Request status information from the device.
void PVCLR(int port)
Clear the virtual SROM for the specified port.
void PENA(int ph, int mode)
Enable transform reporting on the specified port handle.
int GetTXMarkerInfo(int ph, int marker) const
Get additional information about the tool markers.
void BX(int mode)
Request tracking information from the device.
SFLISTSummaryType
SFLIST() summary bits.
include out-of-volume tools
TXModeType
TX() & BX() reply mode bit definitions.
void SetCommunication(CommunicationType *communication)
Set the communication object that commands will be sent to.
unsigned int GetBXFrame(int ph) const
Get the camera frame number for the latest transform.
void IRCHK(int mode)
Check for sources of environmental infrared.
int GetPHINFGPIOStatus() const
Get the 8-bit GPIO status for this tool.
int GetBXToolInfo(int ph) const
Get additional information about the tool transformation.
locations of up to 20 sources per camera
int GetTXPortStatus(int ph) const
Get the 16-bit status value for the specified port handle.
int GetPHINFPartNumber(char part[21]) const
Get a 20-byte string that contains the part number of the tool.
int GetSSTATControl() const
Get the status of the control processor.
number of active tool ports
control firmware with enhanced versioning
int GetBXTransform(int ph, double transform[8]) const
Get the transformation for the specified port.
int GetTXPassiveStray(int i, double coord[3]) const
Copy the coordinates of the specified stray marker into the supplied array.
void TX(int mode)
Request tracking information from the device.
virtual ~NDICommandInterpreter()
Destructor.
void COMM(COMMBaudType baud, COMMDataType dps, COMMHandshakeType handshake)
Change the device communication parameters.
int GetBXSystemStatus() const
Get an 16-bit status bitfield for the system.
int GetTXPassiveStrayOutOfVolume(int i) const
Determine whether a passive stray is outside of the characterized volume.
int GetPHINFPortStatus() const
Get the 8-bit status value for the port handle.
multiple volumes are available
tool with no IREDs (foot pedal)
stray passive marker reporting
const char * GetVERText() const
Get the version information returned by the VER() command.
PHINFToolInfoType
Tool type specifiers returned by GetPHINFToolType()
NDICommandInterpreter()
Constructor.
void LED(int ph, int led, LEDStateType state)
Set a tool LED to a particular state.