All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SurgSim::Device::SixenseScaffold Class Reference

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

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

Collaboration diagram for SurgSim::Device::SixenseScaffold:
Collaboration graph
[legend]

Classes

struct  DeviceData
 
struct  StateData
 

Public Member Functions

 ~SixenseScaffold ()
 Destructor. More...
 
std::shared_ptr
< SurgSim::Framework::Logger
getLogger () const
 Gets the logger used by this object and the devices it manages. More...
 

Static Public Member Functions

static std::shared_ptr
< SixenseScaffold
getOrCreateSharedInstance ()
 Gets or creates the scaffold shared by all SixenseDevice instances. More...
 
static void setDefaultLogLevel (SurgSim::Framework::LogLevel logLevel)
 Sets the default log level. More...
 

Private Member Functions

 SixenseScaffold (std::shared_ptr< SurgSim::Framework::Logger > logger=nullptr)
 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< StateDatam_state
 Internal scaffold state. More...
 

Static Private Attributes

static SurgSim::Framework::LogLevel m_defaultLogLevel = SurgSim::Framework::LOG_LEVEL_INFO
 The default logging level. More...
 
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::Device::SixenseDevice

Constructor & Destructor Documentation

SurgSim::Device::SixenseScaffold::~SixenseScaffold ( )

Destructor.

SurgSim::Device::SixenseScaffold::SixenseScaffold ( std::shared_ptr< SurgSim::Framework::Logger logger = nullptr)
explicitprivate

Constructor.

Parameters
logger(optional) The logger to be used for the scaffold object and the devices it manages. If unspecified or empty, a console logger will be created and used.

Member Function Documentation

SurgSim::DataStructures::DataGroup SurgSim::Device::SixenseScaffold::buildDeviceInputData ( )
staticprivate

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

bool SurgSim::Device::SixenseScaffold::createThread ( )
private

Creates the input loop thread.

Returns
true on success.
bool SurgSim::Device::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.
bool SurgSim::Device::SixenseScaffold::finalizeSdk ( )
private

Finalizes (de-initializes) the Sixense SDK.

Returns
true on success.
bool SurgSim::Device::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
deviceThe device object to register if an unused device is found.
[out]numUsedDevicesSeenThe 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]fatalErrorSet 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.
std::shared_ptr<SurgSim::Framework::Logger> SurgSim::Device::SixenseScaffold::getLogger ( ) const
inline

Gets the logger used by this object and the devices it manages.

Returns
The logger.
std::shared_ptr< SixenseScaffold > SurgSim::Device::SixenseScaffold::getOrCreateSharedInstance ( )
static

Gets or creates the scaffold shared by all SixenseDevice instances.

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

Returns
the scaffold object.
bool SurgSim::Device::SixenseScaffold::initializeSdk ( )
private

Initializes the Sixense SDK.

Returns
true on success.
bool SurgSim::Device::SixenseScaffold::registerDevice ( SixenseDevice device)
private

Registers the specified device object.

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

Parameters
deviceThe device object to be used, which should have a unique name.
Returns
True if the initialization succeeds, false if it fails.
bool SurgSim::Device::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
baseIndexIndex of the base unit.
controllerIndexIndex of the controller within the base unit.
deviceThe device object to register if the index pair is in fact unused.
[in,out]numUsedDevicesSeenThe 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.
bool SurgSim::Device::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.
void SurgSim::Device::SixenseScaffold::setDefaultLogLevel ( SurgSim::Framework::LogLevel  logLevel)
static

Sets the default log level.

Has no effect unless called before a scaffold is created (i.e. before the first device).

Parameters
logLevelThe log level.
bool SurgSim::Device::SixenseScaffold::unregisterDevice ( const SixenseDevice device)
private

Unregisters the specified device object.

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

Parameters
deviceThe device object.
Returns
true on success, false on failure.
bool SurgSim::Device::SixenseScaffold::updateDevice ( const DeviceData info)
private

Updates the device information for a single device.

Returns
true on success.

Friends And Related Function Documentation

friend class SixenseDevice
friend
friend class SixenseThread
friend
friend struct StateData
friend

Member Data Documentation

SurgSim::Framework::LogLevel SurgSim::Device::SixenseScaffold::m_defaultLogLevel = SurgSim::Framework::LOG_LEVEL_INFO
staticprivate

The default logging level.

std::shared_ptr<SurgSim::Framework::Logger> SurgSim::Device::SixenseScaffold::m_logger
private

Logger used by the scaffold and all devices.

int SurgSim::Device::SixenseScaffold::m_startupDelayMilliseconds = 6000
staticprivate

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

int SurgSim::Device::SixenseScaffold::m_startupRetryIntervalMilliseconds = 100
staticprivate

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

std::unique_ptr<StateData> SurgSim::Device::SixenseScaffold::m_state
private

Internal scaffold state.


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