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 Device
34 {
35 
36 class LabJackDevice;
37 class LabJackThread;
38 
42 {
43 public:
45  struct DeviceData;
46 
49 
52 
55  std::shared_ptr<SurgSim::Framework::Logger> getLogger() const;
56 
60  static std::shared_ptr<LabJackScaffold> getOrCreateSharedInstance();
61 
66  bool configureDevice(DeviceData* device);
67 
68 private:
70  struct StateData;
71 
73  class Handle;
74 
75  friend class LabJackDevice;
76  friend class LabJackThread;
77  friend struct StateData;
78 
83  bool registerDevice(LabJackDevice* device);
84 
89  bool unregisterDevice(const LabJackDevice* device);
90 
95  bool runInputFrame(DeviceData* info);
96 
100  bool updateDevice(DeviceData* info);
101 
106 
110  bool configureClockAndTimers(DeviceData* deviceData);
111 
115  bool configureNumberOfTimers(DeviceData* deviceData);
116 
120  bool configureClock(DeviceData* deviceData);
121 
125  bool configureTimers(DeviceData* deviceData);
126 
130  bool configureDigital(DeviceData* deviceData);
131 
135  bool configureAnalog(DeviceData* deviceData);
136 
139 
141  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
142 
144  std::unique_ptr<StateData> m_state;
145 };
146 
147 }; // namespace Device
148 }; // namespace SurgSim
149 
150 #endif // SURGSIM_DEVICES_LABJACK_LABJACKSCAFFOLD_H
bool registerDevice(LabJackDevice *device)
Registers the specified device object.
Definition: LabJackScaffold.cpp:473
Definition: DriveElementFromInputBehavior.cpp:27
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: LabJackScaffold.cpp:1021
bool destroyPerDeviceThread(DeviceData *data)
Destroys the input loop thread.
Definition: LabJackScaffold.cpp:1010
~LabJackScaffold()
Destructor.
Definition: LabJackScaffold.cpp:454
bool configureAnalog(DeviceData *deviceData)
One-time configuration of the analog inputs.
Definition: LabJackScaffold.cpp:1319
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: LabJackScaffold.h:144
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: LabJackScaffold.h:141
bool configureTimers(DeviceData *deviceData)
One-time configuration of the timers.
Definition: LabJackScaffold.cpp:1224
bool unregisterDevice(const LabJackDevice *device)
Unregisters the specified device object.
Definition: LabJackScaffold.cpp:629
bool configureClock(DeviceData *deviceData)
One-time configuration of the clock.
Definition: LabJackScaffold.cpp:1144
A class implementing the thread context for communicating with LabJack devices.
Definition: LabJackThread.h:31
The per-device data.
Definition: LabJackScaffold.cpp:313
bool configureDevice(DeviceData *device)
Does one-time configuration of the LabJack for timers, counters, and analog inputs.
Definition: LabJackScaffold.cpp:1052
bool configureClockAndTimers(DeviceData *deviceData)
One-time configuration of the clock and timers.
Definition: LabJackScaffold.cpp:1057
A collection of NamedData objects.
Definition: DataGroup.h:66
static std::shared_ptr< LabJackScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all LabJackDevice instances.
Definition: LabJackScaffold.cpp:1046
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: LabJackScaffold.cpp:701
Definition: LabJackScaffold.cpp:183
bool runInputFrame(DeviceData *info)
Executes the operations for a single input frame for a single device.
Definition: LabJackScaffold.cpp:657
bool configureNumberOfTimers(DeviceData *deviceData)
One-time configuration of the number of timers.
Definition: LabJackScaffold.cpp:1068
LabJackScaffold()
Constructor.
Definition: LabJackScaffold.cpp:446
The per-scaffold data (in comparison to DeviceData the per-device data).
Definition: LabJackScaffold.cpp:426
A class implementing the communication with a LabJack data acquisition (DAQ) device.
Definition: LabJackDevice.h:272
A class that implements the behavior of LabJackDevice objects.
Definition: LabJackScaffold.h:41
bool configureDigital(DeviceData *deviceData)
One-time configuration of the digital inputs and outputs.
Definition: LabJackScaffold.cpp:1419
std::shared_ptr< SurgSim::Framework::Logger > getLogger() const
Gets the logger used by this object and the devices it manages.
Definition: LabJackScaffold.cpp:1506