7 #define NOMINMAX 1 // disable windows.h min/max global methods 46 std::vector< unsigned char >
data;
47 mutable QReadWriteLock
lock;
111 return static_cast< T *
>(
control[ uint8_t( code ) ] );
146 unsigned grossSampleCount(
unsigned net )
const {
return ( ( net + 1024 ) / 1024 + 2 ) * 1024; }
149 unsigned netSampleCount(
unsigned gross )
const {
return ( ( gross - 1024 ) / 1000 - 1 ) * 1000; }
205 #define dprintf( level, fmt, ... ) \ 207 if ( debugLevel & level ) \ 208 fprintf( stderr, fmt, __VA_ARGS__ ); \ unsigned received
Definition: hantekdsocontrol.h:45
void samplerateCalculated(double samplerate, unsigned oversampling)
The samplerate was newly calculated.
Dso::ErrorCode setSamplerate(double samplerate=0.0)
Sets the samplerate of the oscilloscope.
Definition: hantekdsocontrol.cpp:106
unsigned downsamplingNumber
Number of downsamples to reduce sample rate.
Definition: hantekdsocontrol.h:180
Slope
The slope that causes a trigger.
Definition: enums.h:45
bool calibrationHasChanged
Definition: hantekdsocontrol.h:184
std::unique_ptr< Triggering > triggering
Definition: hantekdsocontrol.h:126
Dso::ErrorCode setTriggerSlope(Dso::Slope slope)
Set the trigger slope.
Definition: hantekdsocontrol.cpp:380
Dso::ErrorCode setCoupling(ChannelID channel, Dso::Coupling coupling)
Sets the coupling for the given channel.
Definition: hantekdsocontrol.cpp:299
Dso::ErrorCode getCalibrationFromIniFile()
Definition: hantekdsocontrol.cpp:464
int acquireInterval
Definition: hantekdsocontrol.h:191
Dso::ErrorCode setTriggerPosition(double position)
Set the trigger position.
Definition: hantekdsocontrol.cpp:392
ControlCode
All supported control commands.
Definition: controlcode.h:46
unsigned oversampling
Definition: hantekdsocontrol.h:37
bool pending
Definition: controlcommand.h:18
unsigned activeChannels
Definition: hantekdsocontrol.h:193
const DsoSettingsScope * scope
Global scope parameters and configurations.
Definition: hantekdsocontrol.h:177
unsigned size
Definition: hantekdsocontrol.h:44
void updateInterval()
Updates the interval of the periodic thread timer.
Definition: hantekdsocontrol.cpp:841
ControlSettingsSamplerate samplerate
The samplerate settings.
Definition: controlsettings.h:59
const ScopeDevice * getDevice() const
Return the associated usb device.
Definition: hantekdsocontrol.h:90
double offsetCorrection[HANTEK_GAIN_STEPS][HANTEK_CHANNEL_NUMBER]
Definition: hantekdsocontrol.h:186
double samplerate
Definition: hantekdsocontrol.h:36
const int SAMPLESIZE_ROLL
Definition: dsosamples.h:26
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
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:133
#define HANTEK_CHANNEL_NUMBER
Definition: definitions.h:10
bool valid
Definition: hantekdsocontrol.h:42
bool refresh
Definition: hantekdsocontrol.h:194
Definition: dsosamples.h:11
Dso::ErrorCode setTriggerSource(int channel)
Set the trigger source.
Definition: hantekdsocontrol.cpp:343
QReadWriteLock lock
Definition: hantekdsocontrol.h:47
bool deviceNotConnected()
USB status, always false for demo device.
Definition: hantekdsocontrol.cpp:58
Dso::ControlSettings controlsettings
The current settings of the device.
Definition: hantekdsocontrol.h:176
Dso::ErrorCode setChannelUsed(ChannelID channel, bool used)
Enables/disables filtering of the given channel.
Definition: hantekdsocontrol.cpp:203
const DSOModel * getModel() const
Return the associated scope model.
Definition: hantekdsocontrol.h:93
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:288
DSOsamples result
Definition: hantekdsocontrol.h:181
uint8_t channelOffset[2]
Definition: hantekdsocontrol.h:203
unsigned debugLevel
Definition: hantekdsocontrol.h:202
int displayInterval
Definition: hantekdsocontrol.h:192
std::unique_ptr< QSettings > calibrationSettings
Definition: hantekdsocontrol.h:185
int verboseLevel
Definition: hantekdsocontrol.h:128
Dso::ErrorCode setTriggerMode(Dso::TriggerMode mode)
Set the trigger mode.
Definition: hantekdsocontrol.cpp:321
bool refreshNeeded()
Definition: hantekdsocontrol.h:196
bool isSamplingUI() const
Definition: hantekdsocontrol.h:87
void prepareForShutdown()
Saves calibration settings e.g. to the scope's EEPROM.
Definition: hantekdsocontrol.cpp:50
unsigned getSampleCount() const
Definition: hantekdsocontrol.h:143
TriggerMode
The different triggering modes.
Definition: enums.h:35
unsigned channels
Definition: hantekdsocontrol.h:35
bool isSingleChannel() const
Definition: hantekdsocontrol.h:130
Dso::ErrorCode setTriggerSmooth(int smooth)
Set the trigger smoothing.
Definition: hantekdsocontrol.cpp:354
void stateMachine()
State machine for the device communication.
Definition: hantekdsocontrol.cpp:862
HantekDsoControl(ScopeDevice *scopeDevice, const DSOModel *model, int verboseLevel)
Definition: hantekdsocontrol.cpp:19
unsigned grossSampleCount(unsigned net) const
adjust for skipping of minimal 2048 leading samples
Definition: hantekdsocontrol.h:146
Dso::ErrorCode setGain(ChannelID channel, double gain)
Sets the probe gain for the given channel.
Definition: hantekdsocontrol.cpp:250
bool freeRun
Definition: hantekdsocontrol.h:41
void addCommand(ControlCommand *newCommand, bool pending=true)
Definition: hantekdsocontrol.cpp:943
void restartSampling()
Starts a new sampling block.
Definition: hantekdsocontrol.cpp:432
bool singleChannel
Definition: hantekdsocontrol.h:127
unsigned netSampleCount(unsigned gross) const
calculate backwards to get multiples of 1000 (typical 20000 or 10000)
Definition: hantekdsocontrol.h:149
std::unique_ptr< MathChannel > mathChannel
Definition: hantekdsocontrol.h:125
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:80
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:61
void quitSampling()
Stops the device.
Definition: hantekdsocontrol.cpp:668
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 acquisition by adapting the samplerate.
Definition: hantekdsocontrol.cpp:135
unsigned gainValue[2]
Definition: hantekdsocontrol.h:38
void setSingleChannel(bool single)
Definition: hantekdsocontrol.h:129
void stopStateMachine()
Definition: hantekdsocontrol.h:76
bool replaceCalibrationEEPROM
Definition: hantekdsocontrol.h:134
ControlCommand * control[255]
Pointers to control commands.
Definition: hantekdsocontrol.h:165
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
bool capturing
Definition: hantekdsocontrol.h:188
void controlSetSamplerate(uint8_t sampleIndex)
Definition: hantekdsocontrol.cpp:91
double gainCorrection[HANTEK_GAIN_STEPS][HANTEK_CHANNEL_NUMBER]
Definition: hantekdsocontrol.h:187
const int SAMPLESIZE
Definition: dsosamples.h:25
void showSamplingStatus(bool enabled)
The oscilloscope started/stopped sampling/waiting for trigger.
unsigned expectedSampleCount
Definition: hantekdsocontrol.h:182
friend CapturingThread
Definition: hantekdsocontrol.h:55
void samplesAvailable(const DSOsamples *samples)
New sample data is available.
bool triggerModeNONE()
Definition: hantekdsocontrol.h:131
T * modifyCommand(Hantek::ControlCode code)
Definition: hantekdsocontrol.h:109
const DSOModel * model
The attached scope model.
Definition: hantekdsocontrol.h:174
ControlCommand * firstControlCommand
Definition: hantekdsocontrol.h:166
Definition: capturing.h:7
~HantekDsoControl() override
Cleans up.
Definition: hantekdsocontrol.cpp:39
bool samplingStarted
Definition: hantekdsocontrol.h:189
bool rollMode
Definition: hantekdsocontrol.h:43
unsigned ChannelID
Definition: types.h:6
bool hasCommand(Hantek::ControlCode code)
Definition: hantekdsocontrol.h:114
void enableSamplingUI(bool enabled=true)
If sampling is disabled, no samplesAvailable() signals are send anymore, no samples are fetched from ...
Definition: hantekdsocontrol.cpp:441
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:957
Dso::ErrorCode getCalibrationFromEEPROM()
Definition: hantekdsocontrol.cpp:564
void samplerateLimitsChanged(double minimum, double maximum)
The available samplerate range has changed.
#define HANTEK_GAIN_STEPS
Definition: definitions.h:9
void convertRawDataToSamples()
Converts raw oscilloscope data to sample data.
Definition: hantekdsocontrol.cpp:730
bool stateMachineRunning
Definition: hantekdsocontrol.h:190
unsigned getRecordLength() const
Definition: hantekdsocontrol.cpp:454
void statusMessage(const QString &message, int timeout)
Status message about the oscilloscope.
Holds the settings for the oscilloscope.
Definition: scopesettings.h:100
void calibrateOffset(bool enable)
enable/disable offset calibration
Definition: hantekdsocontrol.cpp:657
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:182
double getSamplerate() const
Definition: hantekdsocontrol.h:78
Dso::ErrorCode updateCalibrationValues(bool useEEPROM=false)
Definition: hantekdsocontrol.cpp:516
const ChannelID channels
Definition: controlspecification.h:44
ScopeDevice * scopeDevice
The USB device for the oscilloscope.
Definition: hantekdsocontrol.h:169
std::vector< unsigned char > data
Definition: hantekdsocontrol.h:46
const ControlCommand * getCommand(Hantek::ControlCode code) const
Definition: hantekdsocontrol.h:116
double current
The current samplerate.
Definition: controlsettings.h:29
Dso::ErrorCode writeCalibrationToEEPROM()
Definition: hantekdsocontrol.cpp:617
Free running without any trigger.
Dso::ErrorCode setTriggerLevel(ChannelID channel, double level)
Set the trigger level.
Definition: hantekdsocontrol.cpp:366
bool samplingUI
true, if the oscilloscope is taking samples
Definition: hantekdsocontrol.h:171
void updateSamplerateLimits()
Update the minimum and maximum supported samplerate.
Definition: hantekdsocontrol.cpp:71
Dso::ErrorCode setChannelInverted(ChannelID channel, bool inverted)
Enables/disables inverting of the given channel.
Definition: hantekdsocontrol.cpp:237
Raw raw
Definition: hantekdsocontrol.h:201
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:404
void requestRefresh(bool active=true)
Definition: hantekdsocontrol.h:195
const Dso::ControlSpecification * specification
The specifications of the device.
Definition: hantekdsocontrol.h:175
void liveCalibrationError() const