PhantomScaffold.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DEVICES_PHANTOM_PHANTOMSCAFFOLD_H
17 #define SURGSIM_DEVICES_PHANTOM_PHANTOMSCAFFOLD_H
18 
19 #include <memory>
20 
23 
24 namespace SurgSim
25 {
26 namespace Devices
27 {
28 
29 class PhantomDevice;
30 
39 {
40 public:
43 
46 
50  static std::shared_ptr<PhantomScaffold> getOrCreateSharedInstance();
51 
52 private:
54  struct StateData;
56  struct DeviceData;
58  class Callback;
60  class Handle;
61 
62  friend class PhantomDevice;
63 
69  bool registerDevice(PhantomDevice* device);
70 
76  bool unregisterDevice(const PhantomDevice* device);
77 
82 
86  bool finalizeDeviceState(DeviceData* info);
87 
91  bool updateDevice(DeviceData* info);
92 
103 
106  void setInputData(DeviceData* info);
107 
111  bool runHapticFrame();
112 
115  bool createHapticLoop();
116 
120  bool destroyHapticLoop();
121 
124  bool startScheduler();
125 
128  bool stopScheduler();
129 
132 
134  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
136  std::unique_ptr<StateData> m_state;
137 };
138 
139 }; // namespace Devices
140 }; // namespace SurgSim
141 
142 #endif // SURGSIM_DEVICES_PHANTOM_PHANTOMSCAFFOLD_H
SurgSim::Devices::PhantomScaffold::stopScheduler
bool stopScheduler()
Stops the OpenHaptics scheduler.
Definition: PhantomScaffold.cpp:669
SurgSim::Devices::PhantomScaffold::updateDevice
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: PhantomScaffold.cpp:491
SurgSim::Devices::PhantomDevice
A class implementing the communication with a SensAble/Geomagic PHANTOM device.
Definition: PhantomDevice.h:58
SurgSim::Devices::PhantomScaffold::destroyHapticLoop
bool destroyHapticLoop()
Destroys the haptic loop callback.
Definition: PhantomScaffold.cpp:643
SurgSim::Devices::PhantomScaffold::setInputData
void setInputData(DeviceData *info)
Sets the input DataGroup, which will be pushed to the InputComponent.
Definition: PhantomScaffold.cpp:589
SurgSim::Devices::PhantomScaffold::PhantomScaffold
PhantomScaffold()
Constructor.
Definition: PhantomScaffold.cpp:328
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::PhantomScaffold::unregisterDevice
bool unregisterDevice(const PhantomDevice *device)
Unregisters the specified device object.
Definition: PhantomScaffold.cpp:418
SurgSim::Devices::PhantomScaffold::runHapticFrame
bool runHapticFrame()
Executes the operations for a single haptic frame.
Definition: PhantomScaffold.cpp:605
SurgSim::Devices::PhantomScaffold
A class that manages Sensable PHANTOM devices.
Definition: PhantomScaffold.h:38
SurgSim::Devices::PhantomScaffold::getOrCreateSharedInstance
static std::shared_ptr< PhantomScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all PhantomDevice instances.
Definition: PhantomScaffold.cpp:691
SurgSim::Devices::PhantomScaffold::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: PhantomScaffold.h:134
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Devices::PhantomScaffold::buildDeviceInputData
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: PhantomScaffold.cpp:679
SurgSim::Devices::PhantomScaffold::startScheduler
bool startScheduler()
Starts the OpenHaptics scheduler.
Definition: PhantomScaffold.cpp:658
SurgSim::Devices::PhantomScaffold::DeviceData
Definition: PhantomScaffold.cpp:244
Logger.h
SurgSim::Devices::PhantomScaffold::calculateForceAndTorque
void calculateForceAndTorque(DeviceData *info)
Calculates forces and torques and sends them to the device library.
Definition: PhantomScaffold.cpp:529
SurgSim::Devices::PhantomScaffold::StateData
Definition: PhantomScaffold.cpp:290
SurgSim::Devices::PhantomScaffold::finalizeDeviceState
bool finalizeDeviceState(DeviceData *info)
Finalizes a single device, destroying the necessary HDAPI resources.
Definition: PhantomScaffold.cpp:480
SurgSim::Devices::PhantomScaffold::registerDevice
bool registerDevice(PhantomDevice *device)
Registers the specified device object.
Definition: PhantomScaffold.cpp:365
SurgSim::Devices::PhantomScaffold::Callback
Definition: PhantomScaffold.cpp:177
SurgSim::Devices::PhantomScaffold::Handle
Definition: PhantomScaffold.cpp:82
DataGroup.h
SurgSim::Devices::PhantomScaffold::~PhantomScaffold
~PhantomScaffold()
Destructor.
Definition: PhantomScaffold.cpp:344
SurgSim::Devices::PhantomScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: PhantomScaffold.h:136
SurgSim::Devices::PhantomScaffold::createHapticLoop
bool createHapticLoop()
Creates the haptic loop callback.
Definition: PhantomScaffold.cpp:622
SurgSim::Devices::PhantomScaffold::initializeDeviceState
bool initializeDeviceState(DeviceData *info)
Initializes a single device, creating the necessary HDAPI resources.
Definition: PhantomScaffold.cpp:462