RawMultiAxisScaffold.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_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
#define SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
#include <memory>
#include <vector>
#include "SurgSim/Framework/Logger.h"
#include "SurgSim/DataStructures/DataGroup.h"
namespace SurgSim
{
namespace Devices
{
class RawMultiAxisDevice;
class RawMultiAxisThread;
class SystemInputDeviceHandle;
class RawMultiAxisScaffold
{
public:
RawMultiAxisScaffold();
~RawMultiAxisScaffold();
static std::shared_ptr<RawMultiAxisScaffold> getOrCreateSharedInstance();
private:
struct StateData;
struct DeviceData;
friend class RawMultiAxisDevice;
friend class RawMultiAxisThread;
friend struct StateData;
bool registerDevice(RawMultiAxisDevice* device);
bool unregisterDevice(const RawMultiAxisDevice* device);
void setPositionScale(const RawMultiAxisDevice* device, double scale);
void setOrientationScale(const RawMultiAxisDevice* device, double scale);
void setAxisDominance(const RawMultiAxisDevice* device, bool onOff);
bool runInputFrame(DeviceData* info);
bool runAfterLastFrame(DeviceData* info);
bool updateDevice(DeviceData* info);
bool findUnusedDeviceAndRegister(RawMultiAxisDevice* device, int* numUsedDevicesSeen);
bool registerIfUnused(const std::string& path, RawMultiAxisDevice* device, int* numUsedDevicesSeen);
bool createPerDeviceThread(DeviceData* data);
bool destroyPerDeviceThread(DeviceData* data);
std::unique_ptr<SystemInputDeviceHandle> openDevice(const std::string& path);
static SurgSim::DataStructures::DataGroup buildDeviceInputData();
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
std::unique_ptr<StateData> m_state;
};
}; // namespace Devices
}; // namespace SurgSim
#endif // SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
SurgSim::Devices::RawMultiAxisScaffold::runAfterLastFrame
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
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::RawMultiAxisScaffold::createPerDeviceThread
bool createPerDeviceThread(DeviceData *data)
Creates the input loop thread.
Definition: RawMultiAxisScaffold.cpp:526
SurgSim::Devices::RawMultiAxisThread
A class implementing the thread context for sampling RawMultiAxis devices.
Definition: RawMultiAxisThread.h:33
DataGroup.h
SurgSim::Devices::RawMultiAxisScaffold::unregisterDevice
bool unregisterDevice(const RawMultiAxisDevice *device)
Unregisters the specified device object.
Definition: RawMultiAxisScaffold.cpp:225
SurgSim::Devices::RawMultiAxisScaffold
A class that implements the behavior of RawMultiAxisDevice objects.
Definition: RawMultiAxisScaffold.h:37
SurgSim::Devices::RawMultiAxisDevice
A class implementing the communication with a multi-axis controller input device, for example a 3DCon...
Definition: RawMultiAxisDevice.h:56
SurgSim::Devices::RawMultiAxisScaffold::getOrCreateSharedInstance
static std::shared_ptr< RawMultiAxisScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all RawMultiAxisDevice instances.
Definition: RawMultiAxisScaffold.cpp:559
SurgSim::Devices::RawMultiAxisScaffold::runInputFrame
bool runInputFrame(DeviceData *info)
Executes the operations for a single input frame for a single device.
Definition: RawMultiAxisScaffold.cpp:285
SurgSim::Devices::RawMultiAxisScaffold::setAxisDominance
void setAxisDominance(const RawMultiAxisDevice *device, bool onOff)
Turns on or off the axis dominance setting for this device.
Definition: RawMultiAxisScaffold.cpp:273
SurgSim::Devices::RawMultiAxisScaffold::registerDevice
bool registerDevice(RawMultiAxisDevice *device)
Registers the specified device object.
Definition: RawMultiAxisScaffold.cpp:202
SurgSim::Devices::RawMultiAxisScaffold::buildDeviceInputData
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: RawMultiAxisScaffold.cpp:548
SurgSim::Devices::RawMultiAxisScaffold::~RawMultiAxisScaffold
~RawMultiAxisScaffold()
Destructor.
Definition: RawMultiAxisScaffold.cpp:180
SurgSim::Devices::RawMultiAxisScaffold::updateDevice
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: RawMultiAxisScaffold.cpp:319
SurgSim::Devices::RawMultiAxisScaffold::openDevice
std::unique_ptr< SystemInputDeviceHandle > openDevice(const std::string &path)
Opens the specified device.
Definition: RawMultiAxisScaffold.cpp:412
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Devices::RawMultiAxisScaffold::StateData
Definition: RawMultiAxisScaffold.cpp:152
Logger.h
SurgSim::Devices::RawMultiAxisScaffold::DeviceData
Definition: RawMultiAxisScaffold.cpp:59
SurgSim::Devices::RawMultiAxisScaffold::findUnusedDeviceAndRegister
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
SurgSim::Devices::RawMultiAxisScaffold::setOrientationScale
void setOrientationScale(const RawMultiAxisDevice *device, double scale)
Sets the orientation scale for this device.
Definition: RawMultiAxisScaffold.cpp:261
SurgSim::Devices::RawMultiAxisScaffold::registerIfUnused
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
SurgSim::Devices::RawMultiAxisScaffold::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: RawMultiAxisScaffold.h:135
SurgSim::Devices::RawMultiAxisScaffold::RawMultiAxisScaffold
RawMultiAxisScaffold()
Constructor.
Definition: RawMultiAxisScaffold.cpp:173
SurgSim::Devices::RawMultiAxisScaffold::setPositionScale
void setPositionScale(const RawMultiAxisDevice *device, double scale)
Sets the position scale for this device.
Definition: RawMultiAxisScaffold.cpp:249
SurgSim::Devices::RawMultiAxisScaffold::destroyPerDeviceThread
bool destroyPerDeviceThread(DeviceData *data)
Destroys the input loop thread.
Definition: RawMultiAxisScaffold.cpp:537
SurgSim::Devices::RawMultiAxisScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: RawMultiAxisScaffold.h:137