Go to the documentation of this file.
16 #ifndef SURGSIM_DEVICES_LABJACK_LABJACKDEVICE_H
17 #define SURGSIM_DEVICES_LABJACK_LABJACKDEVICE_H
21 #include <unordered_map>
22 #include <unordered_set>
31 class LabJackScaffold;
33 SURGSIM_STATIC_REGISTRATION(LabJackDevice);
406 void setTimers(
const std::unordered_map<int, LabJack::TimerSettings>& timers);
409 const std::unordered_map<int, LabJack::TimerSettings>&
getTimers()
const;
438 void setAnalogInputs(
const std::unordered_map<int, LabJack::AnalogInputSettings>& analogInputs);
441 const std::unordered_map<int, LabJack::AnalogInputSettings>&
getAnalogInputs()
const;
521 std::unordered_map<int, LabJack::TimerSettings>
m_timers;
536 #endif // SURGSIM_DEVICES_LABJACK_LABJACKDEVICE_H
void setTimerCounterPinOffset(int offset)
The timers and counters are always on consecutive pins, but the start pin can be varied within limits...
Definition: LabJackDevice.cpp:190
@ AIN5
Definition: LabJackDevice.h:96
LabJack::Connection m_connection
The type of communication connection, e.g., USB.
Definition: LabJackDevice.h:489
bool operator==(const TimerSettings &other) const
Equality comparison.
Definition: LabJackDevice.h:185
@ MIO2
Definition: LabJackDevice.h:86
@ EIO2
Definition: LabJackDevice.h:66
@ EIO1
Definition: LabJackDevice.h:65
LabJack::TimerBase getTimerBase() const
Definition: LabJackDevice.cpp:174
@ TIMERMODE_SYSTEM_TIMER_LOWER_32BITS
Definition: LabJackDevice.h:172
int getTimerCounterPinOffset() const
Definition: LabJackDevice.cpp:197
@ FIO5
Definition: LabJackDevice.h:57
@ RANGE_0_POINT_625
Definition: LabJackDevice.h:208
bool isInitialized() const override
Definition: LabJackDevice.cpp:85
MIO_LINE
Definition: LabJackDevice.h:82
@ TIMER4
Definition: LabJackDevice.h:46
@ DAC1
Definition: LabJackDevice.h:112
void setAddress(std::string address)
Set the address of the LabJack, e.g., "1" or "192.168.7.23".
Definition: LabJackDevice.cpp:112
@ TIMER3
Definition: LabJackDevice.h:45
@ CIO3
Definition: LabJackDevice.h:79
DAC
Definition: LabJackDevice.h:109
@ TIMERBASE_26
Definition: LabJackDevice.h:154
int m_timerClockDivisor
The timer clock's divisor, see m_timerBase.
Definition: LabJackDevice.h:515
@ CIO1
Definition: LabJackDevice.h:77
@ CONNECTION_SEARCH
Definition: LabJackDevice.h:128
int m_analogInputResolution
The resolution for all the analog inputs.
Definition: LabJackDevice.h:527
int getAnalogInputSettling() const
Definition: LabJackDevice.cpp:305
int getAnalogInputResolution() const
Definition: LabJackDevice.cpp:293
A class that implements the behavior of LabJackDevice objects.
Definition: LabJackScaffold.h:41
int m_timerCounterPinOffset
The number of the lowest FIO pin that is a timer or counter.
Definition: LabJackDevice.h:518
@ MODEL_SEARCH
Definition: LabJackDevice.h:119
@ CONNECTION_ETHERNET
Definition: LabJackDevice.h:130
const std::unordered_map< int, LabJack::AnalogInputSettings > & getAnalogInputs() const
Definition: LabJackDevice.cpp:264
SURGSIM_CLASSNAME(SurgSim::Devices::LabJackDevice)
@ FIO6
Definition: LabJackDevice.h:58
@ TIMERMODE_RISING_EDGES_16BIT
Definition: LabJackDevice.h:174
@ FIO7
Definition: LabJackDevice.h:59
void enableAnalogOutput(int channel)
Enable analog output.
Definition: LabJackDevice.cpp:269
@ TIMER0
Definition: LabJackDevice.h:42
@ EIO0
Definition: LabJackDevice.h:64
@ RANGE_0_POINT_01
Definition: LabJackDevice.h:210
std::unordered_map< int, LabJack::TimerSettings > m_timers
A map from the timers' line numbers to their mode and optional initial value.
Definition: LabJackDevice.h:521
@ EIO6
Definition: LabJackDevice.h:70
void setTimerClockDivisor(int divisor)
If the Timer type ends in "_DIV", then the actual timer frequency is divided by the divisor.
Definition: LabJackDevice.cpp:179
void setDigitalInputs(const std::unordered_set< int > &digitalInputChannels)
Set which digital input lines are enabled.
Definition: LabJackDevice.cpp:139
@ CONNECTION_ETHERNET_MB
Definition: LabJackDevice.h:131
@ MODEL_U6
Definition: LabJackDevice.h:122
void setResetOnDestruct(bool reset)
Reset LabJack during destruct.
Definition: LabJackDevice.cpp:123
@ TIMERMODE_PWM_16BIT
Definition: LabJackDevice.h:162
@ AIN2
Definition: LabJackDevice.h:93
TIMER
Definition: LabJackDevice.h:40
const std::unordered_map< int, LabJack::TimerSettings > & getTimers() const
Definition: LabJackDevice.cpp:222
double getMaximumUpdateRate() const
Definition: LabJackDevice.cpp:234
void setConnection(LabJack::Connection connection)
Set the connection type of the LabJack, e.g., USB.
Definition: LabJackDevice.cpp:101
@ CONNECTION_ETHERNET_DATA_ONLY
Definition: LabJackDevice.h:132
void setDigitalOutputs(const std::unordered_set< int > &digitalOutputChannels)
Set which digital output lines are enabled.
Definition: LabJackDevice.cpp:156
Definition: CompoundShapeToGraphics.cpp:29
@ AIN9
Definition: LabJackDevice.h:100
@ TIMERBASE_3
Definition: LabJackDevice.h:144
const std::string & getAddress() const
Definition: LabJackDevice.cpp:118
@ TIMERMODE_FALLING_EDGES_16BIT
Definition: LabJackDevice.h:175
@ TIMERBASE_4
Definition: LabJackDevice.h:145
Range
The analog input ranges. Equivalent to gain. Ignored for Linux scaffold, which auto-ranges.
Definition: LabJackDevice.h:198
@ TIMERMODE_RISING_EDGES_32BIT
Definition: LabJackDevice.h:164
double m_threadRate
The maximum update rate for the LabJackThread.
Definition: LabJackDevice.h:524
std::shared_ptr< LabJackScaffold > m_scaffold
The single scaffold object that handles communications with all instances of LabJackDevice.
Definition: LabJackDevice.h:483
void setAnalogInputSettling(int settling)
Set the settling time for all the analog inputs.
Definition: LabJackDevice.cpp:298
LabJack::Model m_model
The model, e.g., U6.
Definition: LabJackDevice.h:486
LabJack::TimerBase m_timerBase
The timer base, which is the frequency of all the output timers unless it ends in "_DIV",...
Definition: LabJackDevice.h:512
@ AIN3
Definition: LabJackDevice.h:94
void enableDigitalOutput(int channel)
Enable digital output line.
Definition: LabJackDevice.cpp:150
@ EIO4
Definition: LabJackDevice.h:68
@ TIMERBASE_6
Definition: LabJackDevice.h:147
CIO_LINE
Definition: LabJackDevice.h:74
@ AIN7
Definition: LabJackDevice.h:98
@ RANGE_1_POINT_25
Definition: LabJackDevice.h:206
@ TIMERMODE_TIMER_STOP
Definition: LabJackDevice.h:171
@ TIMERBASE_DEFAULT
Definition: LabJackDevice.h:140
@ RANGE_10
Definition: LabJackDevice.h:201
AIN
Definition: LabJackDevice.h:89
@ TIMERBASE_25
Definition: LabJackDevice.h:153
void setAnalogOutputs(const std::unordered_set< int > &analogOutputChannels)
Set which analog outputs are enabled.
Definition: LabJackDevice.cpp:275
@ TIMERBASE_23
Definition: LabJackDevice.h:151
LabJackDevice(const std::string &uniqueName)
Constructor.
Definition: LabJackDevice.cpp:28
void setModel(LabJack::Model model)
Set the model, e.g., U6.
Definition: LabJackDevice.cpp:90
@ AIN8
Definition: LabJackDevice.h:99
@ RANGE_1
Definition: LabJackDevice.h:207
EIO_LINE
Definition: LabJackDevice.h:62
@ TIMERBASE_21
Definition: LabJackDevice.h:149
Connection
The connection (i.e., communication media) for LabJacks. Numbers come from LabJackUD....
Definition: LabJackDevice.h:126
@ AIN6
Definition: LabJackDevice.h:97
@ AIN4
Definition: LabJackDevice.h:95
void setAnalogInputResolution(int resolution)
Set the resolution for all the analog inputs.
Definition: LabJackDevice.cpp:286
std::unordered_set< int > m_analogOutputChannels
The line numbers for the analog outputs.
Definition: LabJackDevice.h:507
TimerMode
The timer modes.
Definition: LabJackDevice.h:160
@ RANGE_2_POINT_5
Definition: LabJackDevice.h:204
@ TIMER1
Definition: LabJackDevice.h:43
const std::unordered_set< int > & getAnalogOutputs() const
Definition: LabJackDevice.cpp:281
@ MIO0
Definition: LabJackDevice.h:84
@ TIMER2
Definition: LabJackDevice.h:44
void enableTimer(int index, LabJack::TimerMode mode)
Enable timer.
Definition: LabJackDevice.cpp:202
@ TIMERMODE_QUADRATURE
Definition: LabJackDevice.h:170
@ AIN15
Definition: LabJackDevice.h:106
std::string m_address
The address, or a zero-length string to indicate the first-found device of this type on this connecti...
Definition: LabJackDevice.h:492
@ TIMERBASE_5
Definition: LabJackDevice.h:146
@ RANGE_20
Definition: LabJackDevice.h:200
@ TIMERBASE_20
Definition: LabJackDevice.h:148
const std::unordered_set< int > & getDigitalInputs() const
Definition: LabJackDevice.cpp:145
@ FIO3
Definition: LabJackDevice.h:55
void setAnalogInputs(const std::unordered_map< int, LabJack::AnalogInputSettings > &analogInputs)
Set which analog inputs are enabled.
Definition: LabJackDevice.cpp:256
std::unordered_set< int > m_digitalOutputChannels
The line numbers for the digital outputs.
Definition: LabJackDevice.h:504
@ TIMERBASE_0
Definition: LabJackDevice.h:141
FIO_LINE
Definition: LabJackDevice.h:50
@ TIMERMODE_DUTY_CYCLE
Definition: LabJackDevice.h:166
@ MODEL_UE9
Definition: LabJackDevice.h:120
@ AIN14
Definition: LabJackDevice.h:105
TimerMode mode
The mode.
Definition: LabJackDevice.h:191
void setTimerBase(LabJack::TimerBase base)
Set the timer base rate.
Definition: LabJackDevice.cpp:168
void enableDigitalInput(int channel)
Enable digital input line.
Definition: LabJackDevice.cpp:133
@ AIN10
Definition: LabJackDevice.h:101
@ TIMER5
Definition: LabJackDevice.h:47
@ RANGE_4
Definition: LabJackDevice.h:203
void enableAnalogInput(int positiveChannel, LabJack::Range range, int negativeChannel)
Enable differential analog input.
Definition: LabJackDevice.cpp:239
@ TIMERBASE_22
Definition: LabJackDevice.h:150
@ TIMERBASE_1
Definition: LabJackDevice.h:142
@ FIO2
Definition: LabJackDevice.h:54
@ AIN11
Definition: LabJackDevice.h:102
@ FIO4
Definition: LabJackDevice.h:56
@ AIN13
Definition: LabJackDevice.h:104
@ DAC0
Definition: LabJackDevice.h:111
TimerBase
The timer base frequencies for LabJacks.
Definition: LabJackDevice.h:138
@ TIMERBASE_2
Definition: LabJackDevice.h:143
bool initialize() override
Fully initialize the device.
Definition: LabJackDevice.cpp:51
@ RANGE_2
Definition: LabJackDevice.h:205
SurgSim::DataStructures::OptionalValue< int > initialValue
The initial value.
Definition: LabJackDevice.h:194
bool m_reset
Whether or not the hardware should reset when this object destructs.
Definition: LabJackDevice.h:495
@ TIMERMODE_LINE_TO_LINE
Definition: LabJackDevice.h:176
bool finalize() override
Finalize (de-initialize) the device.
Definition: LabJackDevice.cpp:77
@ TIMERBASE_24
Definition: LabJackDevice.h:152
@ TIMERMODE_FIRMWARE_COUNTER_DEBOUNCED
Definition: LabJackDevice.h:168
@ MODEL_U3
Definition: LabJackDevice.h:121
@ AIN0
Definition: LabJackDevice.h:91
int m_analogInputSettling
The settling time for all the analog inputs.
Definition: LabJackDevice.h:530
int getTimerClockDivisor() const
Definition: LabJackDevice.cpp:185
bool getResetOnDestruct() const
Get whether or not the hardware should reset when the LabJackDevice object destructs.
Definition: LabJackDevice.cpp:128
@ EIO5
Definition: LabJackDevice.h:69
@ TIMERMODE_SYSTEM_TIMER_UPPR_32BITS
Definition: LabJackDevice.h:173
const std::unordered_set< int > & getDigitalOutputs() const
Definition: LabJackDevice.cpp:163
@ EIO7
Definition: LabJackDevice.h:71
A class implementing the communication with a LabJack data acquisition (DAQ) device.
Definition: LabJackDevice.h:274
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
@ CIO0
Definition: LabJackDevice.h:76
LabJack::Connection getConnection() const
Definition: LabJackDevice.cpp:107
void setTimers(const std::unordered_map< int, LabJack::TimerSettings > &timers)
Set which timers are enabled.
Definition: LabJackDevice.cpp:216
LabJack::Model getModel() const
Definition: LabJackDevice.cpp:96
@ RANGE_0_POINT_1
Definition: LabJackDevice.h:209
@ TIMERMODE_FIRMWARE_COUNTER
Definition: LabJackDevice.h:167
@ EIO3
Definition: LabJackDevice.h:67
Model
The models of LabJack devices. Numbers come from LabJackUD.h.
Definition: LabJackDevice.h:117
virtual ~LabJackDevice()
Destructor.
Definition: LabJackDevice.cpp:43
@ AIN1
Definition: LabJackDevice.h:92
@ AIN12
Definition: LabJackDevice.h:103
@ FIO1
Definition: LabJackDevice.h:53
@ CIO2
Definition: LabJackDevice.h:78
@ TIMERMODE_PWM_8BIT
Definition: LabJackDevice.h:163
@ FIO0
Definition: LabJackDevice.h:52
@ CONNECTION_USB
Definition: LabJackDevice.h:129
@ TIMERMODE_FALLING_EDGES_32BIT
Definition: LabJackDevice.h:165
void setMaximumUpdateRate(double rate)
Set the maximum update rate for the LabJackThread.
Definition: LabJackDevice.cpp:227
A struct holding the data to be associated with a Timer.
Definition: LabJackDevice.h:180
std::unordered_set< int > m_digitalInputChannels
The line numbers for the digital inputs.
Definition: LabJackDevice.h:498
std::unordered_map< int, LabJack::AnalogInputSettings > m_analogInputs
The analog inputs. The key is the positive channel.
Definition: LabJackDevice.h:501
@ RANGE_5
Definition: LabJackDevice.h:202
@ TIMERMODE_FREQUENCY_OUTPUT
Definition: LabJackDevice.h:169
@ MIO1
Definition: LabJackDevice.h:85