SurgSim::Devices::NimbleScaffold Class Reference

A class that manages Nimble devices. More...

`#include <SurgSim/Devices/Nimble/NimbleScaffold.h>`

Inheritance diagram for SurgSim::Devices::NimbleScaffold:

## Classes

struct | StateData

## Public Member Functions

| ~NimbleScaffold ()
| Destructor. More...
Public Member Functions inherited from SurgSim::Framework::BasicThread
| BasicThread (const std::string &name="Unknown Thread")
virtual | ~BasicThread () noexcept(false)
| C++11 introduced noexcept. More...
void | start (std::shared_ptr< Barrier > startupBarrier=nullptr, bool isSynchronous=false)
| C++11 introduced noexcept. More...
void | stop ()
| Stopping the execution, blocks until the running thread has actually stopped,. More...
void | setIdle (bool isIdle)
| Set/Unset the thread in an idle state (doUpdate() called or not in the update() method) More...
bool | isIdle ()
| Query if this thread is in idle state or not. More...
bool | isInitialized ()
| Query if this object is initialized. More...
bool | isRunning () const
| Query if this object is running. More...
void | operator() ()
| This is what boost::thread executes on thread creation. More...
boost::thread & | getThread ()
std::string | getName () const
void | setRate (double val)
| Set the update rate of the thread. More...
bool | setSynchronous (bool val)
| Sets the thread to synchronized execution in concert with the startup barrier, the startup barrier has to exist for this call to succeed. More...
bool | isSynchronous ()
| Query if this object is synchronized. More...
double | getCpuTime () const
size_t | getUpdateCount () const
void | resetCpuTimeAndUpdateCount ()
| Reset the cpu time and the update count to 0. More...

## Static Public Member Functions

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

## Protected Member Functions

bool | doInitialize () override
bool | doStartUp () override
bool | doUpdate (double dt) override
| Implementation of actual work function for this thread, this has a default implementation to handle destruction better, as it could be called while the thread is under destruction, if left unimplemented this would trigger a call to a pure virtual function. More...
void | doBeforeStop () override
| Prepares the thread for its execution to be stopped. More...
Protected Member Functions inherited from SurgSim::Framework::BasicThread
bool | initialize ()
| Trigger the initialization of this object, this will be called before all other threads doStartup() are called. More...
bool | startUp ()
| Trigger the startup of this object, this will be called after all other threads doInit() was called the thread will only enter the run loop triggering upated() if all threads doInit() and doStartup() returned true. More...
bool | waitForBarrier (bool success)
virtual bool | executeInitialization ()

## Private Member Functions

| NimbleScaffold ()
| Constructor. More...
bool | registerDevice (NimbleDevice *device)
| Registers the specified device object. More...
bool | unregisterDevice (const NimbleDevice *device)
| Unregisters the specified device object. More...
void | updateDeviceData ()
| Update the devices based on the data read from the Nimble server. More...
void | resetDeviceData ()
| Reset the device data. 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...
std::string | m_serverIpAddress
| The IP address of the Nimble hand tracking server. More...
std::string | m_serverPort
| The port where the server is communicating. More...
bool | m_serverSocketOpen
| Flag to indicate that the socket is opened successfully. More...

## Static Private Attributes

static std::array< std::pair< std::string, int >, 15 > | m_jointPoseNames
| The data group name for the joint poses, and the corresponding indices within the state data. More...

## Friends

class | NimbleDevice
class | NimbleThread

## Additional Inherited Members

Protected Attributes inherited from SurgSim::Framework::BasicThread
Timer | m_timer
| Timer to measure the actual time taken to doUpdate. More...
std::shared_ptr< SurgSim::Framework::Logger > | m_logger
| Logger for this thread. More...

## Detailed Description

A class that manages Nimble devices.

See also
  SurgSim::Devices::NimbleDevice

## Constructor & Destructor Documentation

## ~NimbleScaffold()

SurgSim::Devices::NimbleScaffold::~NimbleScaffold | ( |  | ) |

Destructor.

## NimbleScaffold()

SurgSim::Devices::NimbleScaffold::NimbleScaffold | ( |  | ) |

private

Constructor.

## Member Function Documentation

## buildDeviceInputData()

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

static private

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

## doBeforeStop()

void SurgSim::Devices::NimbleScaffold::doBeforeStop | ( |  | ) |

override protected virtual

Prepares the thread for its execution to be stopped.

Note
  Called from this thread before joined

Reimplemented from SurgSim::Framework::BasicThread.

## doInitialize()

bool SurgSim::Devices::NimbleScaffold::doInitialize | ( |  | ) |

override protected virtual

Implements SurgSim::Framework::BasicThread.

## doStartUp()

bool SurgSim::Devices::NimbleScaffold::doStartUp | ( |  | ) |

override protected virtual

Implements SurgSim::Framework::BasicThread.

## doUpdate()

bool SurgSim::Devices::NimbleScaffold::doUpdate | ( | double | dt | ) |

override protected virtual

Implementation of actual work function for this thread, this has a default implementation to handle destruction better, as it could be called while the thread is under destruction, if left unimplemented this would trigger a call to a pure virtual function.

Returns
  false when the thread is done, this will stop execution

Reimplemented from SurgSim::Framework::BasicThread.

## getOrCreateSharedInstance()

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

static

Gets or creates the scaffold shared by all NimbleDevice instances.

The scaffold is managed using a SingleInstance object.

Returns
  the scaffold object.

## registerDevice()

bool SurgSim::Devices::NimbleScaffold::registerDevice | ( | NimbleDevice * | device | ) |

private

Registers the specified device object.

Parameters

  device | The device object to be used.

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

Note
  There can be only one NimbleDevice at a time.

## resetDeviceData()

void SurgSim::Devices::NimbleScaffold::resetDeviceData | ( |  | ) |

private

Reset the device data.

## unregisterDevice()

bool SurgSim::Devices::NimbleScaffold::unregisterDevice | ( | const NimbleDevice * | device | ) |

private

Unregisters the specified device object.

Parameters

  device | The device object.

Returns
  true on success, false on failure.

## updateDeviceData()

void SurgSim::Devices::NimbleScaffold::updateDeviceData | ( |  | ) |

private

Update the devices based on the data read from the Nimble server.

## Friends And Related Function Documentation

## NimbleDevice

friend class NimbleDevice

friend

## NimbleThread

friend class NimbleThread

friend

## Member Data Documentation

## m_jointPoseNames

std::array< std::pair< std::string, int >, 15 > SurgSim::Devices::NimbleScaffold::m_jointPoseNames

static private

The data group name for the joint poses, and the corresponding indices within the state data.

## m_logger

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

private

Logger used by the scaffold and all devices.

## m_serverIpAddress

std::string SurgSim::Devices::NimbleScaffold::m_serverIpAddress

private

The IP address of the Nimble hand tracking server.

## m_serverPort

std::string SurgSim::Devices::NimbleScaffold::m_serverPort

private

The port where the server is communicating.

## m_serverSocketOpen

bool SurgSim::Devices::NimbleScaffold::m_serverSocketOpen

private

Flag to indicate that the socket is opened successfully.

## m_state

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

private

Internal scaffold state.

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

- SurgSim/Devices/Nimble/NimbleScaffold.h
- SurgSim/Devices/Nimble/NimbleScaffold.cpp