SurgSim::Devices::SixenseScaffold Class Reference

A class that manages Sixense devices, such as the Razer Hydra. More...

`#include <SurgSim/Devices/Sixense/SixenseScaffold.h>`

## Classes

struct | DeviceData
struct | StateData

## Public Member Functions

| ~SixenseScaffold ()
| Destructor. More...

## Static Public Member Functions

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

## Private Member Functions

| SixenseScaffold ()
| Constructor. More...
bool | registerDevice (SixenseDevice *device)
| Registers the specified device object. More...
bool | unregisterDevice (const SixenseDevice *device)
| Unregisters the specified device object. More...
bool | runInputFrame ()
| Executes the operations for a single input frame. More...
bool | updateDevice (const DeviceData &info)
| Updates the device information for a single device. More...
bool | initializeSdk ()
| Initializes the Sixense SDK. More...
bool | finalizeSdk ()
| Finalizes (de-initializes) the Sixense SDK. More...
bool | findUnusedDeviceAndRegister (SixenseDevice *device, int *numUsedDevicesSeen, bool *fatalError)
| Scans controllers that are present in the system, and if an unused one is found, register a device for it. More...
bool | registerIfUnused (int baseIndex, int controllerIndex, SixenseDevice *device, int *numUsedDevicesSeen)
| Register a device object given a (baseIndex, controllerIndex) pair, if the same pair is not already in use. More...
bool | createThread ()
| Creates the input loop thread. More...
bool | destroyThread ()
| Destroys the input loop thread. 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...

## Static Private Attributes

static int | m_startupDelayMilliseconds = 6000
| How long we're willing to wait for devices to be detected, in milliseconds. More...
static int | m_startupRetryIntervalMilliseconds = 100
| How long to wait between trying to detect devices, in milliseconds. More...

## Friends

class | SixenseDevice
class | SixenseThread
struct | StateData

## Detailed Description

A class that manages Sixense devices, such as the Razer Hydra.

See also
  SurgSim::Devices::SixenseDevice

## Constructor & Destructor Documentation

## ~SixenseScaffold()

SurgSim::Devices::SixenseScaffold::~SixenseScaffold | ( |  | ) |

Destructor.

## SixenseScaffold()

SurgSim::Devices::SixenseScaffold::SixenseScaffold | ( |  | ) |

private

Constructor.

## Member Function Documentation

## buildDeviceInputData()

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

static private

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

## createThread()

bool SurgSim::Devices::SixenseScaffold::createThread | ( |  | ) |

private

Creates the input loop thread.

Returns
  true on success.

## destroyThread()

bool SurgSim::Devices::SixenseScaffold::destroyThread | ( |  | ) |

private

Destroys the input loop thread.

Should be called while NOT holding the internal device list mutex, to prevent deadlock.

Returns
  true on success.

## finalizeSdk()

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

private

Finalizes (de-initializes) the Sixense SDK.

Returns
  true on success.

## findUnusedDeviceAndRegister()

bool SurgSim::Devices::SixenseScaffold::findUnusedDeviceAndRegister | ( | SixenseDevice * | device,
|  | int * | numUsedDevicesSeen,
|  | bool * | fatalError
| ) |  |

private

Scans controllers that are present in the system, and if an unused one is found, register a device for it.

Parameters

  | device | The device object to register if an unused device is found.
  [out] | numUsedDevicesSeen | The number of devices that were found during the scan but were already in use. Can be used if the scan fails to determine the error message that should be displayed.
  [out] | fatalError | Set to true if an error (such as a duplicate device name) prevented device registration such that retrying will not help; false otherwise.

Returns
  true on success.

## getOrCreateSharedInstance()

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

static

Gets or creates the scaffold shared by all SixenseDevice 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::SixenseScaffold::initializeSdk | ( |  | ) |

private

Initializes the Sixense SDK.

Returns
  true on success.

## registerDevice()

bool SurgSim::Devices::SixenseScaffold::registerDevice | ( | SixenseDevice * | 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.

## registerIfUnused()

bool SurgSim::Devices::SixenseScaffold::registerIfUnused | ( | int | baseIndex,
|  | int | controllerIndex,
|  | SixenseDevice * | device,
|  | int * | numUsedDevicesSeen
| ) |  |

private

Register a device object given a (baseIndex, controllerIndex) pair, if the same pair is not already in use.

Parameters

  | baseIndex | Index of the base unit.
  | controllerIndex | Index of the controller within the base unit.
  | device | The device object to register if the index pair is in fact unused.
  [in,out] | numUsedDevicesSeen | The number of devices that were found during the scan but were already in use; incremented when an unused device is seen.

Returns
  true on success.

## runInputFrame()

bool SurgSim::Devices::SixenseScaffold::runInputFrame | ( |  | ) |

private

Executes the operations for a single input frame.

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

Returns
  true on success.

## unregisterDevice()

bool SurgSim::Devices::SixenseScaffold::unregisterDevice | ( | const SixenseDevice * | 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::SixenseScaffold::updateDevice | ( | const DeviceData & | info | ) |

private

Updates the device information for a single device.

Returns
  true on success.

## Friends And Related Function Documentation

## SixenseDevice

friend class SixenseDevice

friend

## SixenseThread

friend class SixenseThread

friend

## StateData

friend struct StateData

friend

## Member Data Documentation

## m_logger

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

private

Logger used by the scaffold and all devices.

## m_startupDelayMilliseconds

int SurgSim::Devices::SixenseScaffold::m_startupDelayMilliseconds = 6000

static private

How long we're willing to wait for devices to be detected, in milliseconds.

## m_startupRetryIntervalMilliseconds

int SurgSim::Devices::SixenseScaffold::m_startupRetryIntervalMilliseconds = 100

static private

How long to wait between trying to detect devices, in milliseconds.

## m_state

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

private

Internal scaffold state.

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

- SurgSim/Devices/Sixense/SixenseScaffold.h
- SurgSim/Devices/Sixense/SixenseScaffold.cpp