SurgSim::Devices::TrackIRScaffold Class Reference

A class that manages Natural Point TRACKIR devices. More...

`#include <SurgSim/Devices/TrackIR/TrackIRScaffold.h>`

## Classes

struct | DeviceData
struct | StateData

## Public Member Functions

| TrackIRScaffold ()
| Constructor. More...
| ~TrackIRScaffold ()
| Destructor. More...

## Static Public Member Functions

static std::shared_ptr< TrackIRScaffold > | getOrCreateSharedInstance ()
| Gets or creates the scaffold shared by all TrackIRDevice instances. More...

## Private Member Functions

bool | registerDevice (TrackIRDevice *device)
| Registers the specified device object. More...
bool | unregisterDevice (const TrackIRDevice *device)
| Unregisters the specified device object. More...
void | setPositionScale (const TrackIRDevice *device, double scale)
| Sets the position scale for the device. More...
void | setOrientationScale (const TrackIRDevice *device, double scale)
| Sets the orientation scale for the device. More...
bool | initializeSdk ()
| Initializes the OptiTrack SDK. More...
bool | finalizeSdk ()
| Finalizes (de-initializes) the OptiTrack SDK. More...
bool | startCamera (DeviceData *info)
| Start the camera, it will start sending frames. More...
bool | stopCamera (DeviceData *info)
| Stop the camera, it will stop sending frames. More...
bool | runInputFrame (DeviceData *info)
| Executes the operations for a single input frame for a single device. More...
bool | updateDevice (DeviceData *info)
| Updates the device information for a single device. More...
bool | createPerDeviceThread (DeviceData *data)
| Creates a thread for the given DeviceData object. More...
bool | destroyPerDeviceThread (DeviceData *data)
| Destroys the thread associated with the given DeviceData object. More...

## Static Private Member Functions

static SurgSim::DataStructures::DataGroup | buildDeviceInputData ()
| Builds the data layout for the application input (i.e. device output). More...

## Private Attributes

std::shared_ptr< SurgSim::Framework::Logger > | m_logger
| Logger used by the scaffold and all devices. More...
std::unique_ptr< StateData > | m_state
| Internal scaffold state. More...

## Friends

class | TrackIRDevice
class | TrackIRThread
struct | StateData

## Detailed Description

A class that manages Natural Point TRACKIR devices.

See also
  SurgSim::Devices::TrackIRDevice

## Constructor & Destructor Documentation

## TrackIRScaffold()

SurgSim::Devices::TrackIRScaffold::TrackIRScaffold | ( |  | ) |

Constructor.

## ~TrackIRScaffold()

SurgSim::Devices::TrackIRScaffold::~TrackIRScaffold | ( |  | ) |

Destructor.

## Member Function Documentation

## buildDeviceInputData()

SurgSim::DataStructures::DataGroup SurgSim::Devices::TrackIRScaffold::buildDeviceInputData | ( |  | ) |

static private

Builds the data layout for the application input (i.e. device output).

## createPerDeviceThread()

bool SurgSim::Devices::TrackIRScaffold::createPerDeviceThread | ( | DeviceData * | data | ) |

private

Creates a thread for the given DeviceData object.

Parameters

  data | A DeviceData object

Returns
  true on success.

## destroyPerDeviceThread()

bool SurgSim::Devices::TrackIRScaffold::destroyPerDeviceThread | ( | DeviceData * | data | ) |

private

Destroys the thread associated with the given DeviceData object.

Parameters

  data | A DeviceData object

Returns
  true on success.

## finalizeSdk()

bool SurgSim::Devices::TrackIRScaffold::finalizeSdk | ( |  | ) |

private

Finalizes (de-initializes) the OptiTrack SDK.

Returns
  true on success.

## getOrCreateSharedInstance()

std::shared_ptr< TrackIRScaffold > SurgSim::Devices::TrackIRScaffold::getOrCreateSharedInstance | ( |  | ) |

static

Gets or creates the scaffold shared by all TrackIRDevice instances.

The scaffold is managed using a SharedInstance object, so it will be destroyed when all devices are released.

Returns
  the scaffold object.

## initializeSdk()

bool SurgSim::Devices::TrackIRScaffold::initializeSdk | ( |  | ) |

private

Initializes the OptiTrack SDK.

Returns
  true on success.

## registerDevice()

bool SurgSim::Devices::TrackIRScaffold::registerDevice | ( | TrackIRDevice * | device | ) |

private

Registers the specified device object.

If successful, the device object will become connected to an unused controller.

Parameters

  device | The device object to be used, which should have a unique name.

Returns
  True if the initialization succeeds, false if it fails.

## runInputFrame()

bool SurgSim::Devices::TrackIRScaffold::runInputFrame | ( | TrackIRScaffold::DeviceData * | info | ) |

private

Executes the operations for a single input frame for a single device.

Should only be called from the context of the input loop thread.

Parameters

  info | The internal device data.

Returns
  true on success.

## setOrientationScale()

void SurgSim::Devices::TrackIRScaffold::setOrientationScale | ( | const TrackIRDevice * | device,
|  | double | scale
| ) |  |

private

Sets the orientation scale for the device.

Parameters

  device | The device whose orientation scale will be set.
  scale | Scale of the orientation.

## setPositionScale()

void SurgSim::Devices::TrackIRScaffold::setPositionScale | ( | const TrackIRDevice * | device,
|  | double | scale
| ) |  |

private

Sets the position scale for the device.

Parameters

  device | The device whose position scale will be set.
  scale | Scale of the position.

## startCamera()

bool SurgSim::Devices::TrackIRScaffold::startCamera | ( | DeviceData * | info | ) |

private

Start the camera, it will start sending frames.

Parameters

  info | DeviceData object which contains the camera to be started.

Returns
  true on success.

## stopCamera()

bool SurgSim::Devices::TrackIRScaffold::stopCamera | ( | DeviceData * | info | ) |

private

Stop the camera, it will stop sending frames.

Parameters

  info | DeviceData object which contains the camera to be stopped.

Returns
  true on success.

## unregisterDevice()

bool SurgSim::Devices::TrackIRScaffold::unregisterDevice | ( | const TrackIRDevice * | device | ) |

private

Unregisters the specified device object.

The corresponding controller will become unused, and can be re-registered later.

Parameters

  device | The device object.

Returns
  true on success, false on failure.

## updateDevice()

bool SurgSim::Devices::TrackIRScaffold::updateDevice | ( | TrackIRScaffold::DeviceData * | info | ) |

private

Updates the device information for a single device.

Parameters

  info | The device data.

Returns
  true on success.

## Friends And Related Function Documentation

## StateData

friend struct StateData

friend

## TrackIRDevice

friend class TrackIRDevice

friend

## TrackIRThread

friend class TrackIRThread

friend

## Member Data Documentation

## m_logger

std::shared_ptr<SurgSim::Framework::Logger> SurgSim::Devices::TrackIRScaffold::m_logger

private

Logger used by the scaffold and all devices.

## m_state

std::unique_ptr<StateData> SurgSim::Devices::TrackIRScaffold::m_state

private

Internal scaffold state.

The documentation for this class was generated from the following files:

- SurgSim/Devices/TrackIR/TrackIRScaffold.h
- SurgSim/Devices/TrackIR/linux/TrackIRScaffold.cpp