5 #define NOMINMAX // disable windows.h min/max global methods 24 #include <QReadLocker> 25 #include <QReadWriteLock> 26 #include <QStringList> 29 #include <QWriteLocker> 46 std::vector< unsigned char >
data;
47 mutable QReadWriteLock
lock;
113 return static_cast< T *
>(
control[ uint8_t(
code ) ] );
139 unsigned grossSampleCount(
unsigned net )
const {
return ( ( net + 1024 ) / 1024 + 2 ) * 1024; }
142 unsigned netSampleCount(
unsigned gross )
const {
return ( ( gross - 1024 ) / 1000 - 1 ) * 1000; }
211 std::vector< QString >
controlNames = {
"SETGAIN_CH1",
"SETGAIN_CH2",
"SETSAMPLERATE",
"STARTSAMPLING",
212 "SETNUMCHANNELS",
"SETCOUPLING",
"SETCALFREQ" };
216 #define dprintf( level, fmt, ... ) \ 218 if ( debugLevel & level ) \ 219 fprintf( stderr, fmt, __VA_ARGS__ ); \ unsigned received
Definition: hantekdsocontrol.h:45
Dso::ErrorCode setSamplerate(double samplerate=0.0)
Sets the samplerate of the oscilloscope.
Definition: hantekdsocontrol.cpp:100
unsigned downsamplingNumber
Number of downsamples to reduce sample rate.
Definition: hantekdsocontrol.h:191
Slope
The slope that causes a trigger.
Definition: enums.h:45
Dso::ErrorCode setTriggerSlope(Dso::Slope slope)
Set the trigger slope.
Definition: hantekdsocontrol.cpp:366
Dso::ErrorCode setCoupling(ChannelID channel, Dso::Coupling coupling)
Sets the coupling for the given channel.
Definition: hantekdsocontrol.cpp:285
Definition: QtAwesome.h:298
unsigned triggeredPositionRaw
Definition: hantekdsocontrol.h:200
void enableSampling(bool enabled)
If sampling is disabled, no samplesAvailable() signals are send anymore, no samples are fetched from ...
Definition: hantekdsocontrol.cpp:424
int acquireInterval
Definition: hantekdsocontrol.h:198
static const unsigned SAMPLESIZE_ROLL
Definition: hantekdsocontrol.h:81
Dso::ErrorCode setTriggerPosition(double position)
Set the trigger position.
Definition: hantekdsocontrol.cpp:378
ControlCode
All supported control commands.
Definition: controlcode.h:44
unsigned oversampling
Definition: hantekdsocontrol.h:37
bool pending
Definition: controlcommand.h:18
unsigned activeChannels
Definition: hantekdsocontrol.h:201
const DsoSettingsScope * scope
Global scope parameters and configuations.
Definition: hantekdsocontrol.h:188
unsigned size
Definition: hantekdsocontrol.h:44
From higher to lower voltage.
void updateInterval()
Updates the interval of the periodic thread timer.
Definition: hantekdsocontrol.cpp:734
ControlSettingsSamplerate samplerate
The samplerate settings.
Definition: controlsettings.h:59
const ScopeDevice * getDevice() const
Return the associated usb device.
Definition: hantekdsocontrol.h:92
double samplerate
Definition: hantekdsocontrol.h:36
Definition: controlcommand.h:12
unsigned gainIndex[2]
Definition: hantekdsocontrol.h:39
unsigned tag
Definition: hantekdsocontrol.h:40
Definition: hantekdsocontrol.h:34
Coupling
The coupling modes for the channels.
Definition: enums.h:27
static unsigned calculateTriggerPoint(unsigned value)
Calculates the trigger point from the CommandGetCaptureState data.
Dso::TriggerMode mode
The trigger mode.
Definition: controlsettings.h:37
ControlSettingsTrigger trigger
The trigger settings.
Definition: controlsettings.h:61
void setDownsampling(unsigned downsampling)
Definition: hantekdsocontrol.h:130
bool isSampling() const
Definition: hantekdsocontrol.h:89
Definition: capturing.h:7
bool valid
Definition: hantekdsocontrol.h:42
Definition: dsosamples.h:10
Dso::ErrorCode setTriggerSource(int channel)
Set the trigger source.
Definition: hantekdsocontrol.cpp:329
QReadWriteLock lock
Definition: hantekdsocontrol.h:47
bool deviceNotConnected()
USB status, always false for demo device.
Definition: hantekdsocontrol.cpp:54
Dso::ControlSettings controlsettings
The current settings of the device.
Definition: hantekdsocontrol.h:187
Dso::ErrorCode setChannelUsed(ChannelID channel, bool used)
Enables/disables filtering of the given channel.
Definition: hantekdsocontrol.cpp:192
const DSOModel * getModel() const
Return the associated scope model.
Definition: hantekdsocontrol.h:95
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:274
DSOsamples result
Definition: hantekdsocontrol.h:192
~HantekDsoControl()
Cleans up.
Definition: hantekdsocontrol.cpp:43
unsigned debugLevel
Definition: hantekdsocontrol.h:214
int displayInterval
Definition: hantekdsocontrol.h:199
Dso::ErrorCode setTriggerMode(Dso::TriggerMode mode)
Set the trigger mode.
Definition: hantekdsocontrol.cpp:307
unsigned getSampleCount() const
Definition: hantekdsocontrol.h:136
TriggerMode
The different triggering modes.
Definition: enums.h:35
unsigned channels
Definition: hantekdsocontrol.h:35
bool isSingleChannel() const
Definition: hantekdsocontrol.h:127
Dso::ErrorCode setTriggerSmooth(int smooth)
Set the trigger smoothing.
Definition: hantekdsocontrol.cpp:340
void stateMachine()
State machine for the device communication.
Definition: hantekdsocontrol.cpp:755
unsigned grossSampleCount(unsigned net) const
adjust for skipping of minimal 2048 leading samples
Definition: hantekdsocontrol.h:139
Dso::ErrorCode setGain(ChannelID channel, double gain)
Sets the probe gain for the given channel.
Definition: hantekdsocontrol.cpp:238
bool freeRun
Definition: hantekdsocontrol.h:41
void addCommand(ControlCommand *newCommand, bool pending=true)
Definition: hantekdsocontrol.cpp:828
void restartSampling()
Starts a new sampling block.
Definition: hantekdsocontrol.cpp:415
bool singleChannel
Definition: hantekdsocontrol.h:124
unsigned netSampleCount(unsigned gross) const
calculate backwards to get multiples of 1000 (typical 20000 or 10000)
Definition: hantekdsocontrol.h:142
This class handles the USB communication with an usb device that has one in and one out endpoint...
Definition: scopedevice.h:33
unsigned getSamplesize() const
Definition: hantekdsocontrol.h:82
Describes a device This is the central class to describe a hantek compatible DSO. It contains all usb...
Definition: dsomodel.h:17
void restoreTargets()
Restore the samplerate/timebase targets after divider updates.
Definition: hantekdsocontrol.cpp:57
void quitSampling()
Stops the device.
Definition: hantekdsocontrol.cpp:472
bool provideTriggeredData()
Definition: hantekdsocontrol.cpp:705
friend Capturing
Definition: hantekdsocontrol.h:55
void samplerateSet(int mode, QList< double > sampleSteps)
The available samplerate for fixed samplerate devices has changed.
Dso::ErrorCode setRecordTime(double duration=0.0)
Sets the time duration of one aquisition by adapting the samplerate.
Definition: hantekdsocontrol.cpp:128
unsigned gainValue[2]
Definition: hantekdsocontrol.h:38
bool triggerChanged()
Definition: hantekdsocontrol.h:203
void setSingleChannel(bool single)
Definition: hantekdsocontrol.h:126
void stopStateMachine()
Definition: hantekdsocontrol.h:76
unsigned verboseLevel
Definition: hantekdsocontrol.h:125
void samplingStatusChanged(bool enabled)
The oscilloscope started/stopped sampling/waiting for trigger.
ControlCommand * control[255]
Pointers to control commands.
Definition: hantekdsocontrol.h:176
bool newTriggerParam
Definition: hantekdsocontrol.h:202
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
Dso::Slope mirrorSlope(Dso::Slope slope)
Definition: hantekdsocontrol.h:165
bool capturing
Definition: hantekdsocontrol.h:195
void controlSetSamplerate(uint8_t sampleIndex)
Definition: hantekdsocontrol.cpp:87
HantekDsoControl(ScopeDevice *scopeDevice, const DSOModel *model, unsigned verboseLevel)
Definition: hantekdsocontrol.cpp:27
From lower to higher voltage.
unsigned expectedSampleCount
Definition: hantekdsocontrol.h:193
void samplesAvailable(const DSOsamples *samples)
New sample data is available.
bool triggerModeNONE()
Definition: hantekdsocontrol.h:128
T * modifyCommand(Hantek::ControlCode code)
Definition: hantekdsocontrol.h:111
const DSOModel * model
The attached scope model.
Definition: hantekdsocontrol.h:185
unsigned searchTriggeredPosition()
Definition: hantekdsocontrol.cpp:650
unsigned searchTriggerPoint(Dso::Slope dsoSlope, unsigned int startPos=0)
Definition: hantekdsocontrol.cpp:572
ControlCommand * firstControlCommand
Definition: hantekdsocontrol.h:177
bool samplingStarted
Definition: hantekdsocontrol.h:196
bool rollMode
Definition: hantekdsocontrol.h:43
unsigned ChannelID
Definition: types.h:6
bool hasCommand(Hantek::ControlCode code)
Definition: hantekdsocontrol.h:116
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:841
void samplerateLimitsChanged(double minimum, double maximum)
The available samplerate range has changed.
void convertRawDataToSamples()
Converts raw oscilloscope data to sample data.
Definition: hantekdsocontrol.cpp:492
bool stateMachineRunning
Definition: hantekdsocontrol.h:197
unsigned getRecordLength() const
Definition: hantekdsocontrol.cpp:433
void statusMessage(const QString &message, int timeout)
Status message about the oscilloscope.
Holds the settings for the oscilloscope.
Definition: scopesettings.h:82
std::vector< QString > controlNames
Definition: hantekdsocontrol.h:211
Stores the current settings of the device.
Definition: controlsettings.h:54
void communicationError() const
Dso::ErrorCode setCalFreq(double calfreq=0.0)
Sets the calibration frequency of the oscilloscope.
Definition: hantekdsocontrol.cpp:173
double getSamplerate() const
Definition: hantekdsocontrol.h:78
const ChannelID channels
Definition: controlspecification.h:44
ScopeDevice * scopeDevice
The USB device for the oscilloscope.
Definition: hantekdsocontrol.h:180
static const unsigned SAMPLESIZE
Definition: hantekdsocontrol.h:80
void samplerateChanged(double samplerate)
The samplerate has changed.
std::vector< unsigned char > data
Definition: hantekdsocontrol.h:46
const ControlCommand * getCommand(Hantek::ControlCode code) const
Definition: hantekdsocontrol.h:118
double current
The current samplerate.
Definition: controlsettings.h:29
Free running without any trigger.
bool sampling
true, if the oscilloscope is taking samples
Definition: hantekdsocontrol.h:182
Dso::ErrorCode setTriggerLevel(ChannelID channel, double level)
Set the trigger level.
Definition: hantekdsocontrol.cpp:352
void updateSamplerateLimits()
Update the minimum and maximum supported samplerate.
Definition: hantekdsocontrol.cpp:67
Dso::ErrorCode retrieveChannelLevelData()
Definition: hantekdsocontrol.cpp:443
Dso::ErrorCode setChannelInverted(ChannelID channel, bool inverted)
Enables/disables inverting of the given channel.
Definition: hantekdsocontrol.cpp:225
Raw raw
Definition: hantekdsocontrol.h:209
The DsoControl abstraction layer for Hantek USB DSOs. TODO Please anyone, refactor this class into sm...
Definition: hantekdsocontrol.h:53
void applySettings(DsoSettingsScope *scope)
Initializes the device with the current settings.
Definition: hantekdsocontrol.cpp:390
const Dso::ControlSpecification * specification
The specifications of the device.
Definition: hantekdsocontrol.h:186