NifTK
16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
|
Typedefs | |
typedef NDIErrorCallback | PLErrorCallback |
Functions | |
static char * | plDeviceName (int i) |
static int | plProbe (const char *device) |
static polaris * | plOpen (const char *device) |
static void | plClose (polaris *pol) |
static void | plSetThreadMode (polaris *pol, int mode) |
static char * | plCommand (polaris *pol, const char *format,...) |
static char * | plCommandVA (polaris *pol, const char *format, va_list ap) |
static void | plSetErrorCallback (polaris *pol, PLErrorCallback callback, void *userdata) |
These are the primary set of methods for communicating with the POLARIS.
typedef NDIErrorCallback PLErrorCallback |
Error callback type for use with plSetErrorCallback().
Close communication with the POLARIS. You should send a "COMM:00000" command to the POLARIS before you close communication so that you can resume communication on a subsequent call to plOpen() without having to reset the POLARIS.
|
static |
Send a command to the POLARIS using a printf-style format string.
pol | pointer to a valid POLARIS object |
format | a printf-style format string |
... | format arguments as per the format string |
The standard format of a POLARIS command is, for example, "INIT:" or "PENA:AD". A CRC value and a carriage return will be appended to the command before it is sent to the POLARIS.
This function will automatically recogize certain commands and behave accordingly:
The plGetError() function can be used to check whether an error occured or, alternatively, plSetErrorCallback() can be used to set a function that will be called whenever an error occurs.
For convenience, there is a set of macros for sending commands to the POLARIS. These are listed in Polaris Command Macros.
|
static |
This function is identical in behaviour to plCommand(), except that it accepts a va_list instead of an argument list. The use of va_list is described in the standard C header file "stdarg.h".
|
static |
This function will return the name of the i th serial port device, i.e. i = 0 gives "COM1:" on Windows and "/dev/ttyS0" on linux.
i | integer between 0 and 3 |
If i is too large, the return value is zero.
|
static |
Open communication with the POLARIS on the specified device. This also sets serial port parameters to (9600 baud, 8N1, no handshaking) which are the defaults for the POLARIS.
device | name of a valid serial port device |
|
static |
Probe for the polaris on the specified device. This will take the following steps:
device | name of a valid serial port device |
|
static |
Set a function that will be called each time an error occurs.
pol | pointer to a valid POLARIS object |
callback | a callback with the following signature: void callback(int errnum, char *error_description, void *userdata) |
userdata | data to send to the callback each time it is called |
Set up multithreading to increase efficiency.
pol | pointer to a valid POLARIS object |
mode | 1 to turn on threading, 0 to turn off threading |
It can take milliseconds or even tens of milliseconds for the POLARIS to return the transform data after a GX command. During this time, the application normally sits idle.
One way to avoid this idle time is to spawn a separate thread to send the GX commands to the POLARIS and wait for the reply. Then the application can continue to execute and simply pick up the GX reply when the POLARIS has finished sending it.
When the thread mode is set, every time the application sends a GX command to the POLARIS during tracking mode the spawned thread will automatically begin resending the GX command as fast as possible. Then when the application sends the next GX command, the thread will simply send the application the most recent reply instead of forcing the application to wait through a full command/reply cycle.
If the application changes the reply mode for the GX command, then the thread will begin sending GX commands with the new reply format.