iMSTK
Interactive Medical Simulation Toolkit
|
connects to the vrpn.exe server and lets iMSTK attach devices to the server More...
#include <imstkVRPNDeviceManager.h>
Public Member Functions | |
VRPNDeviceManager (const std::string &machine="localhost", int port=vrpn_DEFAULT_LISTEN_PORT_NO) | |
Constructor. More... | |
void | addDeviceClient (std::shared_ptr< VRPNDeviceClient > client) |
std::shared_ptr< DeviceClient > | makeDeviceClient (const std::string &deviceName, VRPNDeviceType deviceType) |
Creates a client from the given parameters. More... | |
std::shared_ptr< DeviceClient > | makeDeviceClient (const std::string deviceName) override |
Create a haptic device client and add it to the internal list. More... | |
![]() | |
virtual const std::string | getTypeName () const =0 |
Returns collision detection type string name. | |
SIGNAL (Module, preUpdate) | |
Posted before updateModule is called. | |
SIGNAL (Module, postUpdate) | |
Posted after updateModule is called. | |
SIGNAL (Module, end) | |
Posted when module wants to end. | |
double | getDt () const |
Get/Set the time step. | |
void | setDt (const double dt) |
bool | getInit () const |
Get whether the module is initialized yet. | |
bool | getPaused () const |
Set/Get whether the module is currently paused. | |
void | setPaused (const bool paused) |
void | setMuteUpdateEvents (const bool mute) |
Set/Get whether the module should post pre/post update events. | |
bool | getMuteUpdateEvents () const |
ExecutionType | getExecutionType () const |
Set/Get the execution type (see imstk::ExecutionType) | |
void | setExecutionType (const ExecutionType type) |
void | setSleepDelay (const double ms) |
double | getSleepDelay () const |
void | pause () |
void | resume () |
void | init () |
void | update () |
void | uninit () |
![]() | |
template<typename T > | |
void | postEvent (const T &e) |
Emits the event Direct observers will be immediately called, in sync Queued observers will receive the Command in their queue for later execution, reciever must implement doEvent. | |
template<typename T > | |
void | queueEvent (const T &e) |
Queues event directly to this. | |
void | doEvent () |
Do an event, if none exists return. | |
void | doAllEvents () |
Do all the events in the event queue. | |
void | foreachEvent (std::function< void(Command cmd)> func) |
Thread safe loop over all event commands, one can implement a custom handler. | |
void | rforeachEvent (std::function< void(Command cmd)> func) |
thread safe reverse loop over all event commands, one can implement a custom handler | |
void | clearEvents () |
Removes all events from queue cleans up copies of the event. | |
Protected Member Functions | |
bool | initModule () override |
Initialize the server module. | |
void | updateModule () override |
Run the server module. | |
void | uninitModule () override |
Clean the server module. | |
Additional Inherited Members | |
![]() | |
enum | ExecutionType { SEQUENTIAL, PARALLEL, ADAPTIVE } |
Currently 3 execution types are provided. These inform the driver on how it should run. | |
![]() | |
using | Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> > |
![]() | |
std::atomic< bool > | m_init = ATOMIC_VAR_INIT(false) |
std::atomic< bool > | m_paused = ATOMIC_VAR_INIT(false) |
double | m_dt = 0.0 |
ExecutionType | m_executionType = ExecutionType::PARALLEL |
bool | m_muteUpdateEvents = false |
double | m_sleepDelay = 0.0 |
![]() | |
ParallelUtils::SpinLock | eventQueueLock |
std::deque< Command > | eventQueue |
std::vector< std::pair< std::string, std::vector< Observer > > > | queuedObservers |
std::vector< std::pair< std::string, std::vector< Observer > > > | directObservers |
connects to the vrpn.exe server and lets iMSTK attach devices to the server
This module enables communication with VRPN and lets us map VRPN devices to the imstk DeviceClient interface. The VRPN server is external to iMSTK and needs to be run from the command line vrpn_server
, when using the default vrpn.cfg file needs to be edited represent the projects requirements. For more information on VRPN see the wiki https://github.com/vrpn/vrpn/wiki
Definition at line 41 of file imstkVRPNDeviceManager.h.
imstk::VRPNDeviceManager::VRPNDeviceManager | ( | const std::string & | machine = "localhost" , |
int | port = vrpn_DEFAULT_LISTEN_PORT_NO |
||
) |
Constructor.
machine | The ip address of the machine where the vrpn server is running, "localhost" and "loopback" are also options |
port | The port that the vrpn server is listening to (can set on the command line) |
Definition at line 19 of file imstkVRPNDeviceManager.cpp.
std::shared_ptr< imstk::DeviceClient > imstk::VRPNDeviceManager::makeDeviceClient | ( | const std::string & | deviceName, |
VRPNDeviceType | deviceType | ||
) |
Creates a client from the given parameters.
deviceName | The name of the device that you want, it must match (case-sensitive) with the name in the selected vrpn.cfg file |
deviceType | A binary combination of the parameters that should be updated. Note that this is a request, if the server doesn't supply the requested updates no changes will be observable |
Definition at line 67 of file imstkVRPNDeviceManager.cpp.
|
overridevirtual |
Create a haptic device client and add it to the internal list.
Port | name |
Implements imstk::DeviceManager.
Definition at line 75 of file imstkVRPNDeviceManager.cpp.