5 #define NOMINMAX // disable windows.h min/max global methods 8 #include "controlsettings.h" 9 #include "controlspecification.h" 10 #include "dsosamples.h" 11 #include "errorcodes.h" 13 #include "utils/printutils.h" 15 #include "hantekprotocol/bulkStructs.h" 16 #include "hantekprotocol/controlStructs.h" 17 #include "hantekprotocol/definitions.h" 22 #include <QStringList> 73 bool isSampling()
const;
102 void addCommand(
BulkCommand *newCommand,
bool pending =
true);
103 template <
class T> T *modifyCommand(Hantek::BulkCode code) {
104 command[(uint8_t)code]->pending =
true;
105 return static_cast<T *
>(command[(uint8_t)code]);
107 const BulkCommand *getCommand(Hantek::BulkCode code)
const;
110 template <
class T> T *modifyCommand(Hantek::ControlCode code) {
111 control[(uint8_t)code]->pending =
true;
112 return static_cast<T *
>(control[(uint8_t)code]);
117 bool isRollMode()
const;
118 bool isFastRate()
const;
119 unsigned getRecordLength()
const;
121 Dso::ErrorCode retrieveChannelLevelData();
132 double getBestSamplerate(
double samplerate,
bool fastRate =
false,
bool maximum =
false,
133 unsigned *downsampler = 0)
const;
138 unsigned getSampleCount()
const;
140 void updateInterval();
145 static unsigned calculateTriggerPoint(
unsigned value);
149 std::pair<int, unsigned> getCaptureState()
const;
152 std::vector<unsigned char> getSamples(
unsigned &expectedSampleCount)
const;
155 void convertRawDataToSamples(
const std::vector<unsigned char> &rawData);
160 unsigned updateRecordLength(RecordLengthID size);
167 unsigned updateSamplerate(
unsigned downsampler,
bool fastRate);
170 void restoreTargets();
173 void updateSamplerateLimits();
184 bool sampling =
false;
192 unsigned expectedSampleCount = 0;
196 int captureState = Hantek::CAPTURE_WAITING;
197 Hantek::RollState rollState = Hantek::RollState::STARTSAMPLING;
198 bool _samplingStarted =
false;
199 Dso::TriggerMode lastTriggerMode = (Dso::TriggerMode)-1;
200 int cycleCounter = 0;
208 int bulkCommand(
const std::vector<unsigned char> *command,
int attempts = HANTEK_ATTEMPTS)
const;
240 Dso::ErrorCode
setCoupling(ChannelID channel, Dso::Coupling coupling);
246 Dso::ErrorCode
setGain(ChannelID channel,
double gain);
251 Dso::ErrorCode
setOffset(ChannelID channel,
const double offset);
293 void communicationError()
const;
Dso::ErrorCode setSamplerate(double samplerate=0.0)
Sets the samplerate of the oscilloscope.
Definition: hantekdsocontrol.cpp:613
Definition: bulkcommand.h:12
Dso::ErrorCode setTriggerSlope(Dso::Slope slope)
Set the trigger slope.
Definition: hantekdsocontrol.cpp:939
Dso::ErrorCode setCoupling(ChannelID channel, Dso::Coupling coupling)
Set the coupling for the given channel.
Definition: hantekdsocontrol.cpp:768
void enableSampling(bool enabled)
If sampling is disabled, no samplesAvailable() signals are send anymore, no samples are fetched from ...
Definition: hantekdsocontrol.cpp:25
void recordTimeChanged(double duration)
The record time duration has changed.
void availableRecordLengthsChanged(const std::vector< unsigned > &recordLengths)
Definition: controlcommand.h:12
const DSOsamples & getLastSamples()
Return the last sample set.
Definition: hantekdsocontrol.cpp:40
Dso::ErrorCode setPretriggerPosition(double position)
Set the trigger position.
Definition: hantekdsocontrol.cpp:968
const std::vector< unsigned > & getAvailableRecordLengths() const
Get available record lengths for this oscilloscope.
Definition: hantekdsocontrol.cpp:85
Dso::ErrorCode setOffset(ChannelID channel, const double offset)
Set the offset for the given channel. Get the actual offset for the channel from controlsettings.voltage[channel].offsetReal.
Definition: hantekdsocontrol.cpp:818
Definition: dsosamples.h:10
Dso::ErrorCode setChannelUsed(ChannelID channel, bool used)
Enables/disables filtering of the given channel.
Definition: hantekdsocontrol.cpp:711
int getConnectionSpeed() const
Gets the speed of the connection.
Definition: hantekdsocontrol.cpp:1311
~HantekDsoControl()
Cleans up.
Definition: hantekdsocontrol.cpp:57
double getMinSamplerate() const
Get minimum samplerate for this oscilloscope.
Definition: hantekdsocontrol.cpp:89
HantekDsoControl(USBDevice *device)
Definition: hantekdsocontrol.cpp:42
Dso::ErrorCode setTriggerMode(Dso::TriggerMode mode)
Set the trigger mode.
Definition: hantekdsocontrol.cpp:845
Dso::ErrorCode setGain(ChannelID channel, double gain)
Sets the gain for the given channel. Get the actual gain by specification.gainSteps[gainId].
Definition: hantekdsocontrol.cpp:782
Dso::ErrorCode setRecordLength(unsigned size)
Sets the size of the oscilloscopes sample buffer.
Definition: hantekdsocontrol.cpp:601
void samplerateSet(int mode, QList< double > sampleSteps)
The available samplerate for fixed samplerate devices has changed.
void run()
Definition: hantekdsocontrol.cpp:1064
Dso::ErrorCode setRecordTime(double duration=0.0)
Sets the time duration of one aquisition by adapting the samplerate.
Definition: hantekdsocontrol.cpp:658
void samplingStatusChanged(bool enabled)
The oscilloscope started/stopped sampling/waiting for trigger.
const USBDevice * getDevice() const
Return the associated usb device.
Definition: hantekdsocontrol.cpp:38
Stores the specifications of the currently connected device.
Definition: controlspecification.h:47
void samplesAvailable(const DSOsamples *samples)
New sample data is available.
Dso::ErrorCode stringCommand(const QString &commandString)
Sends bulk/control commands directly.
Definition: hantekdsocontrol.cpp:1017
void samplerateLimitsChanged(double minimum, double maximum)
The available samplerate range has changed.
void statusMessage(const QString &message, int timeout)
Status message about the oscilloscope.
Stores the current settings of the device.
Definition: controlsettings.h:51
This class handles the USB communication with an usb device that has one in and one out endpoint...
Definition: usbdevice.h:24
int getPacketSize() const
Gets the maximum size of one packet transmitted via bulk transfer.
Definition: hantekdsocontrol.cpp:1320
const Dso::ControlSettings * getDeviceSettings() const
Definition: hantekdsocontrol.cpp:83
void recordLengthChanged(unsigned long duration)
The record length has changed.
void samplerateChanged(double samplerate)
The samplerate has changed.
double getMaxSamplerate() const
Get maximum samplerate for this oscilloscope.
Definition: hantekdsocontrol.cpp:93
Dso::ErrorCode setTriggerSource(bool special, unsigned id)
Set the trigger source.
Definition: hantekdsocontrol.cpp:852
Dso::ErrorCode setTriggerLevel(ChannelID channel, double level)
Set the trigger level.
Definition: hantekdsocontrol.cpp:898
unsigned getChannelCount() const
Gets the physical channel count for this oscilloscope.
Definition: hantekdsocontrol.cpp:81
The DsoControl abstraction layer for Hantek USB DSOs. TODO Please anyone, refactor this class into sm...
Definition: hantekdsocontrol.h:30