LabJackScaffold.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_LABJACK_LABJACKSCAFFOLD_H
17 #define SURGSIM_DEVICES_LABJACK_LABJACKSCAFFOLD_H
18 
19 #include <memory>
20 
21 namespace SurgSim
22 {
23 namespace DataStructures
24 {
25 class DataGroup;
26 };
27 
28 namespace Framework
29 {
30 class Logger;
31 }
32 
33 namespace Devices
34 {
35 
36 class LabJackDevice;
37 class LabJackThread;
38 
42 {
43 public:
45  struct DeviceData;
46 
49 
52 
56  static std::shared_ptr<LabJackScaffold> getOrCreateSharedInstance();
57 
61  void configureDevice(DeviceData* device);
62 
63 private:
65  struct StateData;
66 
68  class Handle;
69 
70  friend class LabJackDevice;
71  friend class LabJackThread;
72  friend struct StateData;
73 
78  bool registerDevice(LabJackDevice* device);
79 
84  bool unregisterDevice(const LabJackDevice* device);
85 
90  bool runInputFrame(DeviceData* info);
91 
95  bool updateDevice(DeviceData* info);
96 
101 
105  bool configureClockAndTimers(DeviceData* deviceData);
106 
110  bool configureNumberOfTimers(DeviceData* deviceData);
111 
115  bool configureClock(DeviceData* deviceData);
116 
120  bool configureTimers(DeviceData* deviceData);
121 
125  bool configureDigital(DeviceData* deviceData);
126 
130  bool configureAnalog(DeviceData* deviceData);
131 
134 
136  std::shared_ptr<Framework::Logger> m_logger;
137 
139  std::unique_ptr<StateData> m_state;
140 };
141 
142 }; // namespace Devices
143 }; // namespace SurgSim
144 
145 #endif // SURGSIM_DEVICES_LABJACK_LABJACKSCAFFOLD_H
SurgSim::Devices::LabJackScaffold::configureNumberOfTimers
bool configureNumberOfTimers(DeviceData *deviceData)
One-time configuration of the number of timers.
Definition: LabJackScaffold.cpp:1109
SurgSim::Devices::LabJackScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: LabJackScaffold.h:139
SurgSim::Devices::LabJackScaffold::~LabJackScaffold
~LabJackScaffold()
Destructor.
Definition: LabJackScaffold.cpp:519
SurgSim::Devices::LabJackScaffold::LabJackScaffold
LabJackScaffold()
Constructor.
Definition: LabJackScaffold.cpp:511
SurgSim::Devices::LabJackScaffold::registerDevice
bool registerDevice(LabJackDevice *device)
Registers the specified device object.
Definition: LabJackScaffold.cpp:530
SurgSim::Devices::LabJackScaffold::configureTimers
bool configureTimers(DeviceData *deviceData)
One-time configuration of the timers.
Definition: LabJackScaffold.cpp:1265
SurgSim::Devices::LabJackScaffold
A class that implements the behavior of LabJackDevice objects.
Definition: LabJackScaffold.h:42
SurgSim::Devices::LabJackScaffold::runInputFrame
bool runInputFrame(DeviceData *info)
Executes the operations for a single input frame for a single device.
Definition: LabJackScaffold.cpp:710
SurgSim::Devices::LabJackScaffold::configureDigital
bool configureDigital(DeviceData *deviceData)
One-time configuration of the digital inputs and outputs.
Definition: LabJackScaffold.cpp:1460
SurgSim::Devices::LabJackScaffold::destroyPerDeviceThread
bool destroyPerDeviceThread(DeviceData *data)
Destroys the input loop thread.
SurgSim::Devices::LabJackThread
A class implementing the thread context for communicating with LabJack devices.
Definition: LabJackThread.h:32
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Devices::LabJackScaffold::configureClock
bool configureClock(DeviceData *deviceData)
One-time configuration of the clock.
Definition: LabJackScaffold.cpp:1185
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:69
SurgSim::Devices::LabJackScaffold::configureDevice
void configureDevice(DeviceData *device)
Does one-time configuration of the LabJack for timers, counters, and analog inputs.
Definition: LabJackScaffold.cpp:1092
SurgSim::Devices::LabJackScaffold::configureAnalog
bool configureAnalog(DeviceData *deviceData)
One-time configuration of the analog inputs.
Definition: LabJackScaffold.cpp:1360
SurgSim::Devices::LabJackScaffold::getOrCreateSharedInstance
static std::shared_ptr< LabJackScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all LabJackDevice instances.
Definition: LabJackScaffold.cpp:1086
SurgSim::Devices::LabJackScaffold::unregisterDevice
bool unregisterDevice(const LabJackDevice *device)
Unregisters the specified device object.
Definition: LabJackScaffold.cpp:689
SurgSim::Devices::LabJackScaffold::DeviceData
The per-device data.
Definition: LabJackScaffold.cpp:370
SurgSim::Devices::LabJackScaffold::configureClockAndTimers
bool configureClockAndTimers(DeviceData *deviceData)
One-time configuration of the clock and timers.
Definition: LabJackScaffold.cpp:1098
SurgSim::Devices::LabJackScaffold::StateData
The per-scaffold data (in comparison to DeviceData the per-device data).
Definition: LabJackScaffold.cpp:492
SurgSim::Devices::LabJackScaffold::buildDeviceInputData
static DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: LabJackScaffold.cpp:1061
SurgSim::Devices::LabJackScaffold::m_logger
std::shared_ptr< Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: LabJackScaffold.h:136
SurgSim::Devices::LabJackScaffold::updateDevice
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: LabJackScaffold.cpp:752
SurgSim::Devices::LabJackScaffold::Handle
Definition: LabJackScaffold.cpp:184
SurgSim::Devices::LabJackDevice
A class implementing the communication with a LabJack data acquisition (DAQ) device.
Definition: LabJackDevice.h:275