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 |
( |
USBDevice * |
device | ) |
|
|
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 |
( |
| ) |
|
◆ addCommand()
| void HantekDsoControl::addCommand |
( |
ControlCommand * |
newCommand, |
|
|
bool |
pending = true |
|
) |
| |
◆ applySettings
Initializes the device with the current settings.
- Parameters
-
| scope | The settings for the oscilloscope. |
◆ calculateTriggerPoint()
| static unsigned HantekDsoControl::calculateTriggerPoint |
( |
unsigned |
value | ) |
|
|
staticprivate |
Calculates the trigger point from the CommandGetCaptureState data.
- Parameters
-
| value | The data value that contains the trigger point. |
- Returns
- The calculated trigger point for the given data.
◆ communicationError
| void HantekDsoControl::communicationError |
( |
| ) |
const |
|
signal |
◆ convertRawDataToSamples()
| void HantekDsoControl::convertRawDataToSamples |
( |
const std::vector< unsigned char > & |
rawData | ) |
|
|
private |
Converts raw oscilloscope data to sample data.
◆ enableSampling
| void HantekDsoControl::enableSampling |
( |
bool |
enabled | ) |
|
|
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 |
◆ getCommand()
◆ getDevice()
| const USBDevice* HantekDsoControl::getDevice |
( |
| ) |
const |
|
inline |
Return the associated usb device.
◆ 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 is depends on the usb speed and packet size.
- Returns
- The total number of samples the scope should return.
◆ getSamplerate()
| double HantekDsoControl::getSamplerate |
( |
| ) |
const |
|
inline |
◆ getSamples()
| std::vector< unsigned char > HantekDsoControl::getSamples |
( |
unsigned & |
expectedSampleCount | ) |
const |
|
private |
Gets sample data from the oscilloscope.
◆ getSamplesize()
| unsigned HantekDsoControl::getSamplesize |
( |
| ) |
const |
|
inline |
◆ hasCommand()
◆ isFastRate()
| bool HantekDsoControl::isFastRate |
( |
| ) |
const |
|
inlineprivate |
◆ isSampling()
| bool HantekDsoControl::isSampling |
( |
| ) |
const |
|
inline |
◆ mirrorSlope()
◆ modifyCommand()
◆ recordTimeChanged
| void HantekDsoControl::recordTimeChanged |
( |
double |
duration | ) |
|
|
signal |
The record time duration has changed.
◆ restoreTargets()
| void HantekDsoControl::restoreTargets |
( |
| ) |
|
|
private |
Restore the samplerate/timebase targets after divider updates.
◆ retrieveChannelLevelData()
◆ run()
| void HantekDsoControl::run |
( |
| ) |
|
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.
◆ samplerateChanged
| void HantekDsoControl::samplerateChanged |
( |
double |
samplerate | ) |
|
|
signal |
The samplerate has changed.
◆ 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.
◆ samplingStatusChanged
| void HantekDsoControl::samplingStatusChanged |
( |
bool |
enabled | ) |
|
|
signal |
The oscilloscope started/stopped sampling/waiting for trigger.
◆ searchTriggerPoint()
| unsigned HantekDsoControl::searchTriggerPoint |
( |
Dso::Slope |
dsoSlope, |
|
|
unsigned int |
startPos = 0 |
|
) |
| |
|
private |
< number of available samples
◆ 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 aquisition 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.
◆ setTriggerLevel
Set the trigger level.
- Parameters
-
| channel | The channel that should be set. |
| level | The new trigger level (V). |
- Returns
- See Dso::ErrorCode.
◆ setTriggerMode
◆ setTriggerOffset
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.
◆ setTriggerSource
Set the trigger source.
- Parameters
-
| id | The channel that should be used as trigger. |
- Returns
- See Dso::ErrorCode.
◆ softwareTrigger()
| unsigned HantekDsoControl::softwareTrigger |
( |
| ) |
|
|
private |
◆ statusMessage
| void HantekDsoControl::statusMessage |
( |
const QString & |
message, |
|
|
int |
timeout |
|
) |
| |
|
signal |
Status message about the oscilloscope.
◆ stringCommand()
| Dso::ErrorCode HantekDsoControl::stringCommand |
( |
const QString & |
commandString | ) |
|
Sends control commands directly.
Syntax:
Control command:
send control [hex code] [hex data]
- Parameters
-
| command | The command as string (Has to be parsed). |
- Returns
- See Dso::ErrorCode.
◆ triggering()
| bool HantekDsoControl::triggering |
( |
| ) |
|
|
private |
◆ updateInterval()
| void HantekDsoControl::updateInterval |
( |
| ) |
|
|
private |
Updates the interval of the periodic thread timer.
◆ updateSamplerate()
| unsigned HantekDsoControl::updateSamplerate |
( |
unsigned |
downsampler, |
|
|
bool |
fastRate |
|
) |
| |
|
private |
Sets the samplerate based on the parameters calculated by Control::getBestSamplerate.
- Parameters
-
| downsampler | The downsampling factor. |
| fastRate | true, if one channel uses all buffers. |
- Returns
- The downsampling factor that has been set.
◆ updateSamplerateLimits()
| void HantekDsoControl::updateSamplerateLimits |
( |
| ) |
|
|
private |
Update the minimum and maximum supported samplerate.
◆ acquireInterval
| int HantekDsoControl::acquireInterval = 0 |
|
private |
◆ channelSetupChanged
| bool HantekDsoControl::channelSetupChanged = false |
|
private |
◆ control
Pointers to control commands.
◆ controlsettings
The current settings of the device.
◆ device
The USB device for the oscilloscope.
◆ 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
◆ result
◆ sampling
| bool HantekDsoControl::sampling = false |
|
private |
true, if the oscilloscope is taking samples
◆ samplingStarted
| bool HantekDsoControl::samplingStarted = false |
|
private |
◆ specification
The specifications of the device.
◆ triggeredPositionRaw
| unsigned HantekDsoControl::triggeredPositionRaw = 0 |
|
private |
The documentation for this class was generated from the following files: