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::TrackIRScaffold Class Reference

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

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

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

Classes

struct  DeviceData
 
struct  StateData
 

Public Member Functions

 TrackIRScaffold (std::shared_ptr< SurgSim::Framework::Logger > logger=nullptr)
 Constructor. More...
 
 ~TrackIRScaffold ()
 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
< TrackIRScaffold
getOrCreateSharedInstance ()
 Gets or creates the scaffold shared by all TrackIRDevice instances. More...
 
static void setDefaultLogLevel (SurgSim::Framework::LogLevel logLevel)
 Sets the default log level. 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< 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...
 

Friends

class TrackIRDevice
 
class TrackIRThread
 
struct StateData
 

Detailed Description

A class that manages Natural Point TRACKIR devices.

See also
SurgSim::Device::TrackIRDevice

Constructor & Destructor Documentation

SurgSim::Device::TrackIRScaffold::TrackIRScaffold ( std::shared_ptr< SurgSim::Framework::Logger logger = nullptr)
explicit

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.
SurgSim::Device::TrackIRScaffold::~TrackIRScaffold ( )

Destructor.

Member Function Documentation

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

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

bool SurgSim::Device::TrackIRScaffold::createPerDeviceThread ( DeviceData data)
private

Creates a thread for the given DeviceData object.

Parameters
dataA DeviceData object
Returns
true on success.
bool SurgSim::Device::TrackIRScaffold::destroyPerDeviceThread ( DeviceData data)
private

Destroys the thread associated with the given DeviceData object.

Parameters
dataA DeviceData object
Returns
true on success.
bool SurgSim::Device::TrackIRScaffold::finalizeSdk ( )
private

Finalizes (de-initializes) the OptiTrack SDK.

Returns
true on success.
std::shared_ptr< SurgSim::Framework::Logger > SurgSim::Device::TrackIRScaffold::getLogger ( ) const

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

Returns
The logger used by this scaffold.
std::shared_ptr< TrackIRScaffold > SurgSim::Device::TrackIRScaffold::getOrCreateSharedInstance ( )
static

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

Initializes the OptiTrack SDK.

Returns
true on success.
bool SurgSim::Device::TrackIRScaffold::registerDevice ( TrackIRDevice 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::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
infoThe internal device data.
Returns
true on success.
void SurgSim::Device::TrackIRScaffold::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.
void SurgSim::Device::TrackIRScaffold::setOrientationScale ( const TrackIRDevice device,
double  scale 
)
private

Sets the orientation scale for the device.

Parameters
deviceThe device whose orientation scale will be set.
scaleScale of the orientation.
void SurgSim::Device::TrackIRScaffold::setPositionScale ( const TrackIRDevice device,
double  scale 
)
private

Sets the position scale for the device.

Parameters
deviceThe device whose position scale will be set.
scaleScale of the position.
bool SurgSim::Device::TrackIRScaffold::startCamera ( DeviceData info)
private

Start the camera, it will start sending frames.

Parameters
infoDeviceData object which contains the camera to be started.
Returns
true on success.
bool SurgSim::Device::TrackIRScaffold::stopCamera ( DeviceData info)
private

Stop the camera, it will stop sending frames.

Parameters
infoDeviceData object which contains the camera to be stopped.
Returns
true on success.
bool SurgSim::Device::TrackIRScaffold::unregisterDevice ( const TrackIRDevice 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::TrackIRScaffold::updateDevice ( TrackIRScaffold::DeviceData info)
private

Updates the device information for a single device.

Parameters
infoThe device data.
Returns
true on success.

Friends And Related Function Documentation

friend struct StateData
friend
friend class TrackIRDevice
friend
friend class TrackIRThread
friend

Member Data Documentation

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

The default logging level.

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

Logger used by the scaffold and all devices.

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

Internal scaffold state.


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