SixenseScaffold.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
#define SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
#include <memory>
#include "SurgSim/Framework/Logger.h"
#include "SurgSim/DataStructures/DataGroup.h"
namespace SurgSim
{
namespace Devices
{
class SixenseDevice;
class SixenseThread;
class SixenseScaffold
{
public:
~SixenseScaffold();
static std::shared_ptr<SixenseScaffold> getOrCreateSharedInstance();
private:
struct StateData;
struct DeviceData;
friend class SixenseDevice;
friend class SixenseThread;
friend struct StateData;
SixenseScaffold();
bool registerDevice(SixenseDevice* device);
bool unregisterDevice(const SixenseDevice* device);
bool runInputFrame();
bool updateDevice(const DeviceData& info);
bool initializeSdk();
bool finalizeSdk();
bool findUnusedDeviceAndRegister(SixenseDevice* device, int* numUsedDevicesSeen, bool* fatalError);
bool registerIfUnused(int baseIndex, int controllerIndex, SixenseDevice* device, int* numUsedDevicesSeen);
bool createThread();
bool destroyThread();
static SurgSim::DataStructures::DataGroup buildDeviceInputData();
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
std::unique_ptr<StateData> m_state;
static int m_startupDelayMilliseconds;
static int m_startupRetryIntervalMilliseconds;
};
}; // namespace Devices
}; // namespace SurgSim
#endif // SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
SurgSim::Devices::SixenseScaffold::unregisterDevice
bool unregisterDevice(const SixenseDevice *device)
Unregisters the specified device object.
Definition: SixenseScaffold.cpp:208
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::SixenseScaffold
A class that manages Sixense devices, such as the Razer Hydra.
Definition: SixenseScaffold.h:35
DataGroup.h
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::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: SixenseScaffold.h:125
SurgSim::Devices::SixenseScaffold::runInputFrame
bool runInputFrame()
Executes the operations for a single input frame.
Definition: SixenseScaffold.cpp:228
SurgSim::Devices::SixenseScaffold::createThread
bool createThread()
Creates the input loop thread.
Definition: SixenseScaffold.cpp:428
SurgSim::Devices::SixenseScaffold::initializeSdk
bool initializeSdk()
Initializes the Sixense SDK.
Definition: SixenseScaffold.cpp:293
SurgSim::Devices::SixenseScaffold::StateData
Definition: SixenseScaffold.cpp:76
SurgSim::Devices::SixenseDevice
A class implementing the communication with one Sixense controller, for example one of the two on the...
Definition: SixenseDevice.h:53
SurgSim::Devices::SixenseScaffold::registerDevice
bool registerDevice(SixenseDevice *device)
Registers the specified device object.
Definition: SixenseScaffold.cpp:138
SurgSim::Devices::SixenseScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: SixenseScaffold.h:127
SurgSim::Devices::SixenseScaffold::destroyThread
bool destroyThread()
Destroys the input loop thread.
Definition: SixenseScaffold.cpp:439
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::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Devices::SixenseScaffold::SixenseScaffold
SixenseScaffold()
Constructor.
Definition: SixenseScaffold.cpp:103
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::SixenseThread
A class implementing the thread context for sampling Sixense devices.
Definition: SixenseThread.h:33
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_startupDelayMilliseconds
static int m_startupDelayMilliseconds
How long we&#39;re willing to wait for devices to be detected, in milliseconds.
Definition: SixenseScaffold.h:130
SurgSim::Devices::SixenseScaffold::updateDevice
bool updateDevice(const DeviceData &info)
Updates the device information for a single device.
Definition: SixenseScaffold.cpp:244
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::DeviceData
Definition: SixenseScaffold.cpp:52
SurgSim::Devices::SixenseScaffold::finalizeSdk
bool finalizeSdk()
Finalizes (de-initializes) the Sixense SDK.
Definition: SixenseScaffold.cpp:309