The DsoControl abstraction layer for Hantek USB DSOs. TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!).
More...
#include <hantekdsocontrol.h>
The DsoControl abstraction layer for Hantek USB DSOs. TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!).
◆ HantekDsoControl()
| HantekDsoControl::HantekDsoControl |
( |
ScopeDevice * | scopeDevice, |
|
|
const DSOModel * | model, |
|
|
int | verboseLevel ) |
|
explicit |
Creates a dsoControl object. The actual event loop / timer is not started. You can optionally create a thread and move the created object to the thread. You need to call updateInterval() to start the timer. This is done implicitly if run() is called.
- Parameters
-
| device | The usb device. This object does not take ownership. |
◆ ~HantekDsoControl()
| HantekDsoControl::~HantekDsoControl |
( |
| ) |
|
|
override |
◆ addCommand()
| void HantekDsoControl::addCommand |
( |
ControlCommand * | newCommand, |
|
|
bool | pending = true ) |
◆ applySettings
Initializes the device with the current settings.
- Parameters
-
| scope | The settings for the oscilloscope. |
◆ calibrateOffset
| void HantekDsoControl::calibrateOffset |
( |
bool | enable | ) |
|
|
slot |
enable/disable offset calibration
◆ communicationError
| void HantekDsoControl::communicationError |
( |
| ) |
const |
|
signal |
◆ controlSetSamplerate()
| void HantekDsoControl::controlSetSamplerate |
( |
uint8_t | sampleIndex | ) |
|
|
private |
◆ convertRawDataToSamples()
| void HantekDsoControl::convertRawDataToSamples |
( |
| ) |
|
|
private |
Converts raw oscilloscope data to sample data.
◆ deviceNotConnected()
| bool HantekDsoControl::deviceNotConnected |
( |
| ) |
|
|
private |
USB status, always false for demo device.
◆ enableSamplingUI
| void HantekDsoControl::enableSamplingUI |
( |
bool | enabled = true | ) |
|
|
slot |
If sampling is disabled, no samplesAvailable() signals are send anymore, no samples are fetched from the device and no processing takes place.
Start sampling process.
- Parameters
-
| enabled | Enables/Disables sampling |
◆ getCalibrationFromEEPROM()
◆ getCalibrationFromIniFile()
◆ getCommand()
◆ getDevice()
| const ScopeDevice * HantekDsoControl::getDevice |
( |
| ) |
const |
|
inline |
Return the associated usb device.
◆ getModel()
| const DSOModel * HantekDsoControl::getModel |
( |
| ) |
const |
|
inline |
Return the associated scope model.
◆ getRecordLength()
| unsigned HantekDsoControl::getRecordLength |
( |
| ) |
const |
|
private |
◆ getSampleCount()
| unsigned HantekDsoControl::getSampleCount |
( |
| ) |
const |
|
inlineprivate |
Get the number of samples that are expected returned by the scope. In rolling mode this depends on the usb speed and packet size.
- Returns
- The total number of samples the scope should return.
◆ getSamplerate()
| double HantekDsoControl::getSamplerate |
( |
| ) |
const |
|
inline |
◆ getSamplesize()
| unsigned HantekDsoControl::getSamplesize |
( |
| ) |
const |
|
inline |
◆ grossSampleCount()
| unsigned HantekDsoControl::grossSampleCount |
( |
unsigned | net | ) |
const |
|
inlineprivate |
adjust for skipping of minimal 2048 leading samples
◆ hasCommand()
◆ isSamplingUI()
| bool HantekDsoControl::isSamplingUI |
( |
| ) |
const |
|
inline |
◆ isSingleChannel()
| bool HantekDsoControl::isSingleChannel |
( |
| ) |
const |
|
inlineprivate |
◆ liveCalibrationError
| void HantekDsoControl::liveCalibrationError |
( |
| ) |
const |
|
signal |
◆ modifyCommand()
◆ netSampleCount()
| unsigned HantekDsoControl::netSampleCount |
( |
unsigned | gross | ) |
const |
|
inlineprivate |
calculate backwards to get multiples of 1000 (typical 20000 or 10000)
◆ prepareForShutdown()
| void HantekDsoControl::prepareForShutdown |
( |
| ) |
|
Saves calibration settings e.g. to the scope's EEPROM.
◆ quitSampling()
| void HantekDsoControl::quitSampling |
( |
| ) |
|
◆ refreshNeeded()
| bool HantekDsoControl::refreshNeeded |
( |
| ) |
|
|
inlineprivate |
◆ requestRefresh()
| void HantekDsoControl::requestRefresh |
( |
bool | active = true | ) |
|
|
inlineprivate |
◆ restartSampling
| void HantekDsoControl::restartSampling |
( |
| ) |
|
|
slot |
Starts a new sampling block.
◆ restoreTargets()
| void HantekDsoControl::restoreTargets |
( |
| ) |
|
|
private |
Restore the samplerate/timebase targets after divider updates.
◆ samplerateCalculated
| void HantekDsoControl::samplerateCalculated |
( |
double | samplerate, |
|
|
unsigned | oversampling ) |
|
signal |
The samplerate was newly calculated.
◆ samplerateLimitsChanged
| void HantekDsoControl::samplerateLimitsChanged |
( |
double | minimum, |
|
|
double | maximum ) |
|
signal |
The available samplerate range has changed.
◆ samplerateSet
| void HantekDsoControl::samplerateSet |
( |
int | mode, |
|
|
QList< double > | sampleSteps ) |
|
signal |
The available samplerate for fixed samplerate devices has changed.
◆ samplesAvailable
| void HantekDsoControl::samplesAvailable |
( |
const DSOsamples * | samples | ) |
|
|
signal |
New sample data is available.
◆ setCalFreq
Sets the calibration frequency of the oscilloscope.
- Parameters
-
| calfreq | The calibration frequency. |
- Returns
- The tfrequency that has been set, Dso::ErrorCode on error.
◆ setChannelInverted
Enables/disables inverting of the given channel.
- Parameters
-
| channel | The channel that should be set. |
| used | true if the channel is inverted. |
- Returns
- See Dso::ErrorCode.
◆ setChannelUsed
Enables/disables filtering of the given channel.
- Parameters
-
| channel | The channel that should be set. |
| used | true if the channel should be sampled. |
- Returns
- See Dso::ErrorCode.
◆ setCoupling
Sets the coupling for the given channel.
- Parameters
-
| channel | The channel that should be set. |
| coupling | The coupling that should be set. |
- Returns
- error code.
◆ setDownsampling()
| void HantekDsoControl::setDownsampling |
( |
unsigned | downsampling | ) |
|
|
inlineprivate |
◆ setGain
Sets the probe gain for the given channel.
- Parameters
-
| channel | The channel that should be set. |
| probeAttn | gain of probe is set. |
- Returns
- error code.
◆ setProbe
Sets the gain for the given channel. Get the actual gain by specification.gainSteps[gainId].
- Parameters
-
| channel | The channel that should be set. |
| gain | The gain that should be met (V/div). |
- Returns
- The gain that has been set, Dso::ErrorCode on error.
◆ setRecordTime
| Dso::ErrorCode HantekDsoControl::setRecordTime |
( |
double | duration = 0.0 | ) |
|
|
slot |
Sets the time duration of one acquisition by adapting the samplerate.
- Parameters
-
| duration | The record time duration that should be met (s), 0.0 to restore current record time. |
- Returns
- The record time duration that has been set, 0.0 on error.
◆ setSamplerate
| Dso::ErrorCode HantekDsoControl::setSamplerate |
( |
double | samplerate = 0.0 | ) |
|
|
slot |
Sets the samplerate of the oscilloscope.
- Parameters
-
| samplerate | The samplerate that should be met (S/s), 0.0 to restore current samplerate. |
- Returns
- The samplerate that has been set, 0.0 on error.
◆ setSingleChannel()
| void HantekDsoControl::setSingleChannel |
( |
bool | single | ) |
|
|
inlineprivate |
◆ setTriggerLevel
Set the trigger level.
- Parameters
-
| channel | The channel that should be set. |
| level | The new trigger level (V). |
- Returns
- See Dso::ErrorCode.
◆ setTriggerMode
◆ setTriggerPosition
| Dso::ErrorCode HantekDsoControl::setTriggerPosition |
( |
double | position | ) |
|
|
slot |
Set the trigger position.
- Parameters
-
| position | The new trigger position (in s). |
- Returns
- The trigger position that has been set.
◆ setTriggerSlope
Set the trigger slope.
- Parameters
-
| slope | The Slope that should cause a trigger. |
- Returns
- See Dso::ErrorCode.
◆ setTriggerSmooth
◆ setTriggerSource
Set the trigger source.
- Parameters
-
| id | The channel that should be used as trigger. |
- Returns
- See Dso::ErrorCode.
◆ showSamplingStatus
| void HantekDsoControl::showSamplingStatus |
( |
bool | enabled | ) |
|
|
signal |
The oscilloscope started/stopped sampling/waiting for trigger.
◆ stateMachine()
| void HantekDsoControl::stateMachine |
( |
| ) |
|
State machine for the device communication.
Call this to start the processing. This method will call itself periodically from there on. Move this class object to an own thread and call run from there.
◆ statusMessage
| void HantekDsoControl::statusMessage |
( |
const QString & | message, |
|
|
int | timeout ) |
|
signal |
Status message about the oscilloscope.
◆ stopStateMachine()
| void HantekDsoControl::stopStateMachine |
( |
| ) |
|
|
inline |
◆ stringCommand()
| Dso::ErrorCode HantekDsoControl::stringCommand |
( |
const QString & | commandString | ) |
|
Sends control commands directly.
Syntax:
Control command:
cc [hex code] [hex data]
- Parameters
-
| command | The command as string (Has to be parsed). |
- Returns
- See Dso::ErrorCode.
◆ triggerModeNONE()
| bool HantekDsoControl::triggerModeNONE |
( |
| ) |
|
|
inlineprivate |
◆ updateCalibrationValues()
| Dso::ErrorCode HantekDsoControl::updateCalibrationValues |
( |
bool | useEEPROM = false | ) |
|
|
private |
◆ updateInterval()
| void HantekDsoControl::updateInterval |
( |
| ) |
|
|
private |
Updates the interval of the periodic thread timer.
◆ updateSamplerateLimits()
| void HantekDsoControl::updateSamplerateLimits |
( |
| ) |
|
|
private |
Update the minimum and maximum supported samplerate.
◆ writeCalibrationToEEPROM()
◆ acquireInterval
| int HantekDsoControl::acquireInterval = 0 |
|
private |
◆ activeChannels
| unsigned HantekDsoControl::activeChannels = 2 |
|
private |
◆ calibrationHasChanged
| bool HantekDsoControl::calibrationHasChanged = false |
|
private |
◆ calibrationSettings
| std::unique_ptr< QSettings > HantekDsoControl::calibrationSettings |
|
private |
◆ capturing
| bool HantekDsoControl::capturing = false |
|
private |
◆ CapturingThread
| friend HantekDsoControl::CapturingThread |
|
private |
◆ channelOffset
| uint8_t HantekDsoControl::channelOffset[2] = { 0x80, 0x80 } |
|
private |
◆ control
Pointers to control commands.
◆ controlsettings
The current settings of the device.
◆ debugLevel
| unsigned HantekDsoControl::debugLevel = 0 |
|
private |
◆ displayInterval
| int HantekDsoControl::displayInterval = 0 |
|
private |
◆ downsamplingNumber
| unsigned HantekDsoControl::downsamplingNumber = 1 |
|
private |
Number of downsamples to reduce sample rate.
◆ expectedSampleCount
| unsigned HantekDsoControl::expectedSampleCount = 0 |
|
private |
The expected total number of samples at the last check before sampling started
◆ firstControlCommand
◆ gainCorrection
◆ mathChannel
| std::unique_ptr< MathChannel > HantekDsoControl::mathChannel |
|
private |
◆ model
The attached scope model.
◆ offsetCorrection
◆ raw
| Raw HantekDsoControl::raw |
|
private |
◆ refresh
| bool HantekDsoControl::refresh = false |
|
private |
◆ replaceCalibrationEEPROM
| bool HantekDsoControl::replaceCalibrationEEPROM = false |
|
private |
◆ result
◆ samplingStarted
| bool HantekDsoControl::samplingStarted = false |
|
private |
◆ samplingUI
| bool HantekDsoControl::samplingUI = false |
|
private |
true, if the oscilloscope is taking samples
◆ scope
Global scope parameters and configurations.
◆ scopeDevice
The USB device for the oscilloscope.
◆ singleChannel
| bool HantekDsoControl::singleChannel = false |
|
private |
◆ specification
The specifications of the device.
◆ stateMachineRunning
| bool HantekDsoControl::stateMachineRunning = false |
|
private |
◆ triggering
| std::unique_ptr< Triggering > HantekDsoControl::triggering |
|
private |
◆ verboseLevel
| int HantekDsoControl::verboseLevel = 0 |
|
private |
The documentation for this class was generated from the following files: