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

A class that implements the behavior of RawMultiAxisDevice objects. More...

#include <SurgSim/Devices/MultiAxis/RawMultiAxisScaffold.h>

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

Classes

struct  DeviceData
 
struct  StateData
 

Public Member Functions

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

Private Member Functions

bool registerDevice (RawMultiAxisDevice *device)
 Registers the specified device object. More...
 
bool unregisterDevice (const RawMultiAxisDevice *device)
 Unregisters the specified device object. More...
 
void setPositionScale (const RawMultiAxisDevice *device, double scale)
 Sets the position scale for this device. More...
 
void setOrientationScale (const RawMultiAxisDevice *device, double scale)
 Sets the orientation scale for this device. More...
 
void setAxisDominance (const RawMultiAxisDevice *device, bool onOff)
 Turns on or off the axis dominance setting for this device. More...
 
bool runInputFrame (DeviceData *info)
 Executes the operations for a single input frame for a single device. More...
 
bool runAfterLastFrame (DeviceData *info)
 Executes the operations after the last input frame, as the device input loop thread is shutting down. More...
 
bool updateDevice (DeviceData *info)
 Updates the device information for a single device. More...
 
bool initializeSdk ()
 Initializes the RawMultiAxis SDK. More...
 
bool finalizeSdk ()
 Finalizes (de-initializes) the RawMultiAxis SDK. More...
 
bool findUnusedDeviceAndRegister (RawMultiAxisDevice *device, int *numUsedDevicesSeen)
 Scans hardware that is present in the system, and if an unused device is found, register an object for it. More...
 
bool registerIfUnused (const std::string &path, RawMultiAxisDevice *device, int *numUsedDevicesSeen)
 Register a device object given a device path, if the same path is not already in use. More...
 
bool createPerDeviceThread (DeviceData *data)
 Creates the input loop thread. More...
 
bool destroyPerDeviceThread (DeviceData *data)
 Destroys the input loop thread. More...
 
std::unique_ptr
< SystemInputDeviceHandle
openDevice (const std::string &path)
 Opens the specified device. 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 RawMultiAxisDevice
 
class RawMultiAxisThread
 
struct StateData
 

Detailed Description

A class that implements the behavior of RawMultiAxisDevice objects.

See also
SurgSim::Device::RawMultiAxisDevice

Constructor & Destructor Documentation

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

Destructor.

Member Function Documentation

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

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

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

Creates the input loop thread.

Returns
true on success.
bool SurgSim::Device::RawMultiAxisScaffold::destroyPerDeviceThread ( DeviceData data)
private

Destroys the input loop thread.

Returns
true on success.
bool SurgSim::Device::RawMultiAxisScaffold::finalizeSdk ( )
private

Finalizes (de-initializes) the RawMultiAxis SDK.

Returns
true on success.
bool SurgSim::Device::RawMultiAxisScaffold::findUnusedDeviceAndRegister ( RawMultiAxisDevice device,
int *  numUsedDevicesSeen 
)
private

Scans hardware that is present in the system, and if an unused device is found, register an object 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.
Returns
true on success.
std::shared_ptr<SurgSim::Framework::Logger> SurgSim::Device::RawMultiAxisScaffold::getLogger ( ) const
inline

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

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

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

Initializes the RawMultiAxis SDK.

Returns
true on success.
std::unique_ptr< SystemInputDeviceHandle > SurgSim::Device::RawMultiAxisScaffold::openDevice ( const std::string &  path)
private

Opens the specified device.

Returns
The system-specific wrapper for the device.
bool SurgSim::Device::RawMultiAxisScaffold::registerDevice ( RawMultiAxisDevice device)
private

Registers the specified device object.

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

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::RawMultiAxisScaffold::registerIfUnused ( const std::string &  path,
RawMultiAxisDevice device,
int *  numUsedDevicesSeen 
)
private

Register a device object given a device path, if the same path is not already in use.

Parameters
pathA unique system path that can be used to communicate with the device.
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::RawMultiAxisScaffold::runAfterLastFrame ( RawMultiAxisScaffold::DeviceData info)
private

Executes the operations after the last input frame, as the device input loop thread is shutting down.

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

Parameters
infoThe internal device data.
Returns
true on success.
bool SurgSim::Device::RawMultiAxisScaffold::runInputFrame ( RawMultiAxisScaffold::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::RawMultiAxisScaffold::setAxisDominance ( const RawMultiAxisDevice device,
bool  onOff 
)
private

Turns on or off the axis dominance setting for this device.

void SurgSim::Device::RawMultiAxisScaffold::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::RawMultiAxisScaffold::setOrientationScale ( const RawMultiAxisDevice device,
double  scale 
)
private

Sets the orientation scale for this device.

void SurgSim::Device::RawMultiAxisScaffold::setPositionScale ( const RawMultiAxisDevice device,
double  scale 
)
private

Sets the position scale for this device.

bool SurgSim::Device::RawMultiAxisScaffold::unregisterDevice ( const RawMultiAxisDevice device)
private

Unregisters the specified device object.

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

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

Updates the device information for a single device.

Returns
true on success.

Friends And Related Function Documentation

friend class RawMultiAxisDevice
friend
friend class RawMultiAxisThread
friend
friend struct StateData
friend

Member Data Documentation

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

The default logging level.

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

Logger used by the scaffold and all devices.

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

Internal scaffold state.


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