SixenseScaffold.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_SIXENSE_SIXENSESCAFFOLD_H
17 #define SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
18 
19 #include <memory>
20 
23 
24 namespace SurgSim
25 {
26 namespace Devices
27 {
28 
29 class SixenseDevice;
30 class SixenseThread;
31 
36 {
37 public:
40 
44  static std::shared_ptr<SixenseScaffold> getOrCreateSharedInstance();
45 
46 private:
48  struct StateData;
50  struct DeviceData;
51 
52  friend class SixenseDevice;
53  friend class SixenseThread;
54  friend struct StateData;
55 
58 
64  bool registerDevice(SixenseDevice* device);
65 
71  bool unregisterDevice(const SixenseDevice* device);
72 
76  bool runInputFrame();
77 
80  bool updateDevice(const DeviceData& info);
81 
84  bool initializeSdk();
85 
88  bool finalizeSdk();
89 
98  bool findUnusedDeviceAndRegister(SixenseDevice* device, int* numUsedDevicesSeen, bool* fatalError);
99 
108  bool registerIfUnused(int baseIndex, int controllerIndex, SixenseDevice* device, int* numUsedDevicesSeen);
109 
112  bool createThread();
113 
117  bool destroyThread();
118 
121 
122 
123 
125  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
127  std::unique_ptr<StateData> m_state;
128 
133 };
134 
135 }; // namespace Devices
136 }; // namespace SurgSim
137 
138 #endif // SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
SurgSim::Devices::SixenseScaffold::finalizeSdk
bool finalizeSdk()
Finalizes (de-initializes) the Sixense SDK.
Definition: SixenseScaffold.cpp:309
SurgSim::Devices::SixenseScaffold::unregisterDevice
bool unregisterDevice(const SixenseDevice *device)
Unregisters the specified device object.
Definition: SixenseScaffold.cpp:208
SurgSim::Devices::SixenseScaffold::createThread
bool createThread()
Creates the input loop thread.
Definition: SixenseScaffold.cpp:428
SurgSim::Devices::SixenseScaffold::getOrCreateSharedInstance
static std::shared_ptr< SixenseScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all SixenseDevice instances.
Definition: SixenseScaffold.cpp:468
SurgSim::Devices::SixenseScaffold::runInputFrame
bool runInputFrame()
Executes the operations for a single input frame.
Definition: SixenseScaffold.cpp:228
SurgSim::Devices::SixenseScaffold
A class that manages Sixense devices, such as the Razer Hydra.
Definition: SixenseScaffold.h:36
SurgSim::Devices::SixenseScaffold::registerDevice
bool registerDevice(SixenseDevice *device)
Registers the specified device object.
Definition: SixenseScaffold.cpp:138
SurgSim::Devices::SixenseScaffold::initializeSdk
bool initializeSdk()
Initializes the Sixense SDK.
Definition: SixenseScaffold.cpp:293
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:69
SurgSim::Devices::SixenseScaffold::StateData
Definition: SixenseScaffold.cpp:77
SurgSim::Devices::SixenseThread
A class implementing the thread context for sampling Sixense devices.
Definition: SixenseThread.h:34
Logger.h
SurgSim::Devices::SixenseScaffold::m_startupRetryIntervalMilliseconds
static int m_startupRetryIntervalMilliseconds
How long to wait between trying to detect devices, in milliseconds.
Definition: SixenseScaffold.h:132
SurgSim::Devices::SixenseScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: SixenseScaffold.h:127
SurgSim::Devices::SixenseScaffold::updateDevice
bool updateDevice(const DeviceData &info)
Updates the device information for a single device.
Definition: SixenseScaffold.cpp:244
SurgSim::Devices::SixenseScaffold::buildDeviceInputData
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: SixenseScaffold.cpp:450
SurgSim::Devices::SixenseScaffold::destroyThread
bool destroyThread()
Destroys the input loop thread.
Definition: SixenseScaffold.cpp:439
SurgSim::Devices::SixenseScaffold::findUnusedDeviceAndRegister
bool findUnusedDeviceAndRegister(SixenseDevice *device, int *numUsedDevicesSeen, bool *fatalError)
Scans controllers that are present in the system, and if an unused one is found, register a device fo...
Definition: SixenseScaffold.cpp:325
SurgSim::Devices::SixenseScaffold::~SixenseScaffold
~SixenseScaffold()
Destructor.
Definition: SixenseScaffold.cpp:110
SurgSim::Devices::SixenseDevice
A class implementing the communication with one Sixense controller, for example one of the two on the...
Definition: SixenseDevice.h:54
SurgSim::Devices::SixenseScaffold::DeviceData
Definition: SixenseScaffold.cpp:53
SurgSim::Devices::SixenseScaffold::m_startupDelayMilliseconds
static int m_startupDelayMilliseconds
How long we're willing to wait for devices to be detected, in milliseconds.
Definition: SixenseScaffold.h:130
DataGroup.h
SurgSim::Devices::SixenseScaffold::SixenseScaffold
SixenseScaffold()
Constructor.
Definition: SixenseScaffold.cpp:103
SurgSim::Devices::SixenseScaffold::registerIfUnused
bool registerIfUnused(int baseIndex, int controllerIndex, SixenseDevice *device, int *numUsedDevicesSeen)
Register a device object given a (baseIndex, controllerIndex) pair, if the same pair is not already i...
Definition: SixenseScaffold.cpp:398
SurgSim::Devices::SixenseScaffold::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: SixenseScaffold.h:125