RawMultiAxisScaffold.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_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
17 #define SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
18 
19 #include <memory>
20 #include <vector>
21 
24 
25 namespace SurgSim
26 {
27 namespace Devices
28 {
29 
30 class RawMultiAxisDevice;
31 class RawMultiAxisThread;
32 class SystemInputDeviceHandle;
33 
38 {
39 public:
42 
45 
49  static std::shared_ptr<RawMultiAxisScaffold> getOrCreateSharedInstance();
50 
51 private:
53  struct StateData;
55  struct DeviceData;
56 
57  friend class RawMultiAxisDevice;
58  friend class RawMultiAxisThread;
59  friend struct StateData;
60 
66  bool registerDevice(RawMultiAxisDevice* device);
67 
73  bool unregisterDevice(const RawMultiAxisDevice* device);
74 
76  void setPositionScale(const RawMultiAxisDevice* device, double scale);
77 
79  void setOrientationScale(const RawMultiAxisDevice* device, double scale);
80 
82  void setAxisDominance(const RawMultiAxisDevice* device, bool onOff);
83 
88  bool runInputFrame(DeviceData* info);
89 
94  bool runAfterLastFrame(DeviceData* info);
95 
98  bool updateDevice(DeviceData* info);
99 
106  bool findUnusedDeviceAndRegister(RawMultiAxisDevice* device, int* numUsedDevicesSeen);
107 
115  bool registerIfUnused(const std::string& path, RawMultiAxisDevice* device, int* numUsedDevicesSeen);
116 
119  bool createPerDeviceThread(DeviceData* data);
120 
124 
127  std::unique_ptr<SystemInputDeviceHandle> openDevice(const std::string& path);
128 
131 
132 
133 
135  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
137  std::unique_ptr<StateData> m_state;
138 };
139 
140 }; // namespace Devices
141 }; // namespace SurgSim
142 
143 #endif // SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
bool runAfterLastFrame(DeviceData *info)
Executes the operations after the last input frame, as the device input loop thread is shutting down...
Definition: RawMultiAxisScaffold.cpp:296
Definition: CompoundShapeToGraphics.cpp:29
bool createPerDeviceThread(DeviceData *data)
Creates the input loop thread.
Definition: RawMultiAxisScaffold.cpp:526
A class implementing the thread context for sampling RawMultiAxis devices.
Definition: RawMultiAxisThread.h:33
bool unregisterDevice(const RawMultiAxisDevice *device)
Unregisters the specified device object.
Definition: RawMultiAxisScaffold.cpp:225
A class that implements the behavior of RawMultiAxisDevice objects.
Definition: RawMultiAxisScaffold.h:37
A class implementing the communication with a multi-axis controller input device, for example a 3DCon...
Definition: RawMultiAxisDevice.h:56
static std::shared_ptr< RawMultiAxisScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all RawMultiAxisDevice instances.
Definition: RawMultiAxisScaffold.cpp:559
bool runInputFrame(DeviceData *info)
Executes the operations for a single input frame for a single device.
Definition: RawMultiAxisScaffold.cpp:285
void setAxisDominance(const RawMultiAxisDevice *device, bool onOff)
Turns on or off the axis dominance setting for this device.
Definition: RawMultiAxisScaffold.cpp:273
bool registerDevice(RawMultiAxisDevice *device)
Registers the specified device object.
Definition: RawMultiAxisScaffold.cpp:202
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: RawMultiAxisScaffold.cpp:548
~RawMultiAxisScaffold()
Destructor.
Definition: RawMultiAxisScaffold.cpp:180
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: RawMultiAxisScaffold.cpp:319
std::unique_ptr< SystemInputDeviceHandle > openDevice(const std::string &path)
Opens the specified device.
Definition: RawMultiAxisScaffold.cpp:412
A collection of NamedData objects.
Definition: DataGroup.h:68
Definition: RawMultiAxisScaffold.cpp:152
Definition: RawMultiAxisScaffold.cpp:59
bool findUnusedDeviceAndRegister(RawMultiAxisDevice *device, int *numUsedDevicesSeen)
Scans hardware that is present in the system, and if an unused device is found, register an object fo...
Definition: RawMultiAxisScaffold.cpp:424
void setOrientationScale(const RawMultiAxisDevice *device, double scale)
Sets the orientation scale for this device.
Definition: RawMultiAxisScaffold.cpp:261
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.
Definition: RawMultiAxisScaffold.cpp:493
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: RawMultiAxisScaffold.h:135
RawMultiAxisScaffold()
Constructor.
Definition: RawMultiAxisScaffold.cpp:173
void setPositionScale(const RawMultiAxisDevice *device, double scale)
Sets the position scale for this device.
Definition: RawMultiAxisScaffold.cpp:249
bool destroyPerDeviceThread(DeviceData *data)
Destroys the input loop thread.
Definition: RawMultiAxisScaffold.cpp:537
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: RawMultiAxisScaffold.h:137