5 #define NOMINMAX // disable windows.h min/max global methods 23 #include <QStringList> 78 return static_cast<T *
>(
control[ uint8_t(
code ) ] );
97 const std::vector<unsigned> &getAvailableRecordLengths()
const {
103 double getMinSamplerate()
const {
110 double getMaxSamplerate()
const {
121 int getConnectionSpeed()
const {
122 ControlGetSpeed response;
124 if (errorCode < 0)
return errorCode;
125 return response.getSpeed();
130 int getPacketSize()
const {
131 const int s = getConnectionSpeed();
137 qWarning() <<
"Unknown USB speed. Please correct source code in USBDevice::getPacketSize()";
138 throw new std::runtime_error(
"Unknown USB speed");
FullSpeed USB, 64 byte bulk transfers.
Definition: usbdevicedefinitions.h:15
Dso::ErrorCode setSamplerate(double samplerate=0.0)
Sets the samplerate of the oscilloscope.
Definition: hantekdsocontrol.cpp:105
unsigned downsamplingNumber
Number of downsamples to reduce sample rate.
Definition: hantekdsocontrol.h:215
std::vector< unsigned > recordLengths
Available record lengths, UINT_MAX means rolling.
Definition: controlspecification.h:19
Slope
The slope that causes a trigger.
Definition: enums.h:44
Dso::ErrorCode setTriggerSlope(Dso::Slope slope)
Set the trigger slope.
Definition: hantekdsocontrol.cpp:321
Dso::ErrorCode setCoupling(ChannelID channel, Dso::Coupling coupling)
Sets the coupling for the given channel.
Definition: hantekdsocontrol.cpp:274
Definition: QtAwesome.h:192
unsigned triggeredPositionRaw
Definition: hantekdsocontrol.h:223
void enableSampling(bool enabled)
If sampling is disabled, no samplesAvailable() signals are send anymore, no samples are fetched from ...
Definition: hantekdsocontrol.cpp:361
int acquireInterval
Definition: hantekdsocontrol.h:220
void recordTimeChanged(double duration)
The record time duration has changed.
ControlCode
All supported control commands.
Definition: controlcode.h:44
bool pending
Definition: controlcommand.h:16
From higher to lower voltage.
void updateInterval()
Updates the interval of the periodic thread timer.
Definition: hantekdsocontrol.cpp:678
ControlSettingsSamplerate samplerate
The samplerate settings.
Definition: controlsettings.h:60
Definition: controlcommand.h:12
Coupling
The coupling modes for the channels.
Definition: enums.h:27
static unsigned calculateTriggerPoint(unsigned value)
Calculates the trigger point from the CommandGetCaptureState data.
void setDownsampling(unsigned downsampling)
Definition: hantekdsocontrol.h:155
bool isSampling() const
Definition: hantekdsocontrol.h:57
ControlSamplerateLimits multi
The limits for multi channel mode.
Definition: controlspecification.h:25
Definition: dsosamples.h:10
Dso::ControlSettings controlsettings
The current settings of the device.
Definition: hantekdsocontrol.h:212
Dso::ErrorCode setChannelUsed(ChannelID channel, bool used)
Enables/disables filtering of the given channel.
Definition: hantekdsocontrol.cpp:191
Dso::ErrorCode setProbe(ChannelID channel, double probeAttn)
Sets the gain for the given channel. Get the actual gain by specification.gainSteps[gainId].
Definition: hantekdsocontrol.cpp:265
DSOsamples result
Definition: hantekdsocontrol.h:216
~HantekDsoControl()
Cleans up.
Definition: hantekdsocontrol.cpp:45
int displayInterval
Definition: hantekdsocontrol.h:221
bool isFastRate() const
Definition: hantekdsocontrol.h:149
Dso::ErrorCode setTriggerSource(ChannelID channel, bool smooth)
Set the trigger source.
Definition: hantekdsocontrol.cpp:300
HantekDsoControl(USBDevice *device)
Definition: hantekdsocontrol.cpp:28
Dso::ErrorCode setTriggerMode(Dso::TriggerMode mode)
Set the trigger mode.
Definition: hantekdsocontrol.cpp:290
unsigned updateSamplerate(unsigned downsampler, bool fastRate)
Sets the samplerate based on the parameters calculated by Control::getBestSamplerate.
Definition: hantekdsocontrol.cpp:54
unsigned getSampleCount() const
Definition: hantekdsocontrol.h:162
TriggerMode
The different triggering modes.
Definition: enums.h:35
const USBDevice * getDevice() const
Return the associated usb device.
Definition: hantekdsocontrol.h:60
unsigned softwareTrigger()
Definition: hantekdsocontrol.cpp:591
Dso::ErrorCode setGain(ChannelID channel, double gain)
Sets the probe gain for the given channel.
Definition: hantekdsocontrol.cpp:238
void addCommand(ControlCommand *newCommand, bool pending=true)
Definition: hantekdsocontrol.cpp:763
int controlRead(const T *command)
Control read to the oscilloscope.
Definition: usbdevice.h:122
unsigned getSamplesize() const
Definition: hantekdsocontrol.h:55
unsigned channelCount
Number of activated channels.
Definition: controlsettings.h:64
USBDevice * device
The USB device for the oscilloscope.
Definition: hantekdsocontrol.h:207
HighSpeed USB, 512 byte bulk transfers.
Definition: usbdevicedefinitions.h:16
void restoreTargets()
Restore the samplerate/timebase targets after divider updates.
Definition: hantekdsocontrol.cpp:80
void samplerateSet(int mode, QList< double > sampleSteps)
The available samplerate for fixed samplerate devices has changed.
void run()
Definition: hantekdsocontrol.cpp:696
Dso::ErrorCode setRecordTime(double duration=0.0)
Sets the time duration of one aquisition by adapting the samplerate.
Definition: hantekdsocontrol.cpp:134
std::vector< unsigned char > getSamples(unsigned &expectedSampleCount) const
Gets sample data from the oscilloscope.
Definition: hantekdsocontrol.cpp:397
unsigned int maxDownsampler
The maximum downsampling ratio.
Definition: controlspecification.h:18
void samplingStatusChanged(bool enabled)
The oscilloscope started/stopped sampling/waiting for trigger.
ControlCommand * control[255]
Pointers to control commands.
Definition: hantekdsocontrol.h:203
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
Dso::Slope mirrorSlope(Dso::Slope slope)
Definition: hantekdsocontrol.h:194
double base
The base for sample rate calculations.
Definition: controlspecification.h:16
From lower to higher voltage.
unsigned expectedSampleCount
Definition: hantekdsocontrol.h:217
ControlSpecificationSamplerate samplerate
The samplerate specifications.
Definition: controlspecification.h:47
void samplesAvailable(const DSOsamples *samples)
New sample data is available.
T * modifyCommand(Hantek::ControlCode code)
Definition: hantekdsocontrol.h:76
unsigned searchTriggerPoint(Dso::Slope dsoSlope, unsigned int startPos=0)
Definition: hantekdsocontrol.cpp:530
ControlCommand * firstControlCommand
Definition: hantekdsocontrol.h:204
bool samplingStarted
Definition: hantekdsocontrol.h:219
unsigned ChannelID
Definition: types.h:6
bool hasCommand(Hantek::ControlCode code)
Definition: hantekdsocontrol.h:81
ErrorCode
The return codes for device control methods.
Definition: errorcodes.h:8
Dso::ErrorCode stringCommand(const QString &commandString)
Sends control commands directly.
Definition: hantekdsocontrol.cpp:771
void samplerateLimitsChanged(double minimum, double maximum)
The available samplerate range has changed.
double max
The maximum sample rate.
Definition: controlspecification.h:17
unsigned getRecordLength() const
Definition: hantekdsocontrol.cpp:368
Dso::ErrorCode setTriggerOffset(double position)
Set the trigger position.
Definition: hantekdsocontrol.cpp:331
void statusMessage(const QString &message, int timeout)
Status message about the oscilloscope.
Holds the settings for the oscilloscope.
Definition: scopesettings.h:75
Stores the current settings of the device.
Definition: controlsettings.h:55
This class handles the USB communication with an usb device that has one in and one out endpoint...
Definition: usbdevice.h:28
void communicationError() const
Dso::ErrorCode setCalFreq(double calfreq=0.0)
Sets the calibration frequency of the oscilloscope.
Definition: hantekdsocontrol.cpp:177
void convertRawDataToSamples(const std::vector< unsigned char > &rawData)
Converts raw oscilloscope data to sample data.
Definition: hantekdsocontrol.cpp:433
double getSamplerate() const
Definition: hantekdsocontrol.h:53
const ChannelID channels
Definition: controlspecification.h:44
std::vector< ControlSettingsVoltage > voltage
The amplification settings.
Definition: controlsettings.h:61
bool triggering()
Definition: hantekdsocontrol.cpp:650
void samplerateChanged(double samplerate)
The samplerate has changed.
const ControlCommand * getCommand(Hantek::ControlCode code) const
Definition: hantekdsocontrol.h:83
double current
The current samplerate.
Definition: controlsettings.h:29
bool sampling
true, if the oscilloscope is taking samples
Definition: hantekdsocontrol.h:208
Dso::ErrorCode setTriggerLevel(ChannelID channel, double level)
Set the trigger level.
Definition: hantekdsocontrol.cpp:310
ControlSamplerateLimits single
The limits for single channel mode.
Definition: controlspecification.h:24
void updateSamplerateLimits()
Update the minimum and maximum supported samplerate.
Definition: hantekdsocontrol.cpp:89
Dso::ErrorCode retrieveChannelLevelData()
Definition: hantekdsocontrol.cpp:377
Dso::ErrorCode setChannelInverted(ChannelID channel, bool inverted)
Enables/disables inverting of the given channel.
Definition: hantekdsocontrol.cpp:226
The DsoControl abstraction layer for Hantek USB DSOs. TODO Please anyone, refactor this class into sm...
Definition: hantekdsocontrol.h:31
void applySettings(DsoSettingsScope *scope)
Initializes the device with the current settings.
Definition: hantekdsocontrol.cpp:341
const Dso::ControlSpecification * specification
The specifications of the device.
Definition: hantekdsocontrol.h:211
#define SAMPLESIZE_USED
Definition: viewconstants.h:5
const ControlSamplerateLimits * limits
The samplerate limits.
Definition: controlsettings.h:27
bool channelSetupChanged
Definition: hantekdsocontrol.h:222