PhantomScaffold.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_PHANTOM_PHANTOMSCAFFOLD_H
#define SURGSIM_DEVICES_PHANTOM_PHANTOMSCAFFOLD_H
#include <memory>
#include "SurgSim/Framework/Logger.h"
#include "SurgSim/DataStructures/DataGroup.h"
namespace SurgSim
{
namespace Devices
{
class PhantomDevice;
class PhantomScaffold
{
public:
PhantomScaffold();
~PhantomScaffold();
static std::shared_ptr<PhantomScaffold> getOrCreateSharedInstance();
private:
struct StateData;
struct DeviceData;
class Callback;
class Handle;
friend class PhantomDevice;
bool registerDevice(PhantomDevice* device);
bool unregisterDevice(const PhantomDevice* device);
bool initializeDeviceState(DeviceData* info);
bool finalizeDeviceState(DeviceData* info);
bool updateDevice(DeviceData* info);
void calculateForceAndTorque(DeviceData* info);
void setInputData(DeviceData* info);
bool runHapticFrame();
bool createHapticLoop();
bool destroyHapticLoop();
bool startScheduler();
bool stopScheduler();
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_PHANTOM_PHANTOMSCAFFOLD_H
SurgSim::Devices::PhantomScaffold::setInputData
void setInputData(DeviceData *info)
Sets the input DataGroup, which will be pushed to the InputComponent.
Definition: PhantomScaffold.cpp:589
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::PhantomScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: PhantomScaffold.h:136
DataGroup.h
SurgSim::Devices::PhantomScaffold::destroyHapticLoop
bool destroyHapticLoop()
Destroys the haptic loop callback.
Definition: PhantomScaffold.cpp:643
SurgSim::Devices::PhantomScaffold::createHapticLoop
bool createHapticLoop()
Creates the haptic loop callback.
Definition: PhantomScaffold.cpp:622
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::Callback
Definition: PhantomScaffold.cpp:177
SurgSim::Devices::PhantomScaffold::finalizeDeviceState
bool finalizeDeviceState(DeviceData *info)
Finalizes a single device, destroying the necessary HDAPI resources.
Definition: PhantomScaffold.cpp:480
SurgSim::Devices::PhantomScaffold::updateDevice
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: PhantomScaffold.cpp:491
SurgSim::Devices::PhantomScaffold::registerDevice
bool registerDevice(PhantomDevice *device)
Registers the specified device object.
Definition: PhantomScaffold.cpp:365
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::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
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::Devices::PhantomScaffold::StateData
Definition: PhantomScaffold.cpp:290
SurgSim::Devices::PhantomScaffold::DeviceData
Definition: PhantomScaffold.cpp:244
SurgSim::Devices::PhantomScaffold::Handle
Definition: PhantomScaffold.cpp:82
Logger.h
SurgSim::Devices::PhantomScaffold::unregisterDevice
bool unregisterDevice(const PhantomDevice *device)
Unregisters the specified device object.
Definition: PhantomScaffold.cpp:418
SurgSim::Devices::PhantomScaffold::PhantomScaffold
PhantomScaffold()
Constructor.
Definition: PhantomScaffold.cpp:328
SurgSim::Devices::PhantomScaffold::stopScheduler
bool stopScheduler()
Stops the OpenHaptics scheduler.
Definition: PhantomScaffold.cpp:669
SurgSim::Devices::PhantomScaffold::runHapticFrame
bool runHapticFrame()
Executes the operations for a single haptic frame.
Definition: PhantomScaffold.cpp:605
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::~PhantomScaffold
~PhantomScaffold()
Destructor.
Definition: PhantomScaffold.cpp:344
SurgSim::Devices::PhantomScaffold
A class that manages Sensable PHANTOM devices.
Definition: PhantomScaffold.h:38
SurgSim::Devices::PhantomScaffold::startScheduler
bool startScheduler()
Starts the OpenHaptics scheduler.
Definition: PhantomScaffold.cpp:658
SurgSim::Devices::PhantomDevice
A class implementing the communication with a SensAble/Geomagic PHANTOM device.
Definition: PhantomDevice.h:58
SurgSim::Devices::PhantomScaffold::initializeDeviceState
bool initializeDeviceState(DeviceData *info)
Initializes a single device, creating the necessary HDAPI resources.
Definition: PhantomScaffold.cpp:462