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