Commit dfda706a6e3419cc1308b3c89dcb7852806fa0e4
1 parent
bff9d5ae
First DSO-2250 support attempt
Showing
13 changed files
with
1160 additions
and
525 deletions
openhantek/ChangeLog
| @@ -143,3 +143,7 @@ | @@ -143,3 +143,7 @@ | ||
| 143 | 2012-09-01 Oliver Haag <oliver.haag@gmail.com> | 143 | 2012-09-01 Oliver Haag <oliver.haag@gmail.com> |
| 144 | * Updated documentation with first DSO-2250 details | 144 | * Updated documentation with first DSO-2250 details |
| 145 | * General documentation improvements | 145 | * General documentation improvements |
| 146 | + | ||
| 147 | +2012-09-01 Oliver Haag <oliver.haag@gmail.com> | ||
| 148 | +* First attempt to add DSO-2250 support | ||
| 149 | +* More documentation updates |
openhantek/src/dataanalyzer.cpp
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | DataAnalyzer::DataAnalyzer(DsoSettings *settings, QObject *parent) : QThread(parent) { | 45 | DataAnalyzer::DataAnalyzer(DsoSettings *settings, QObject *parent) : QThread(parent) { |
| 46 | this->settings = settings; | 46 | this->settings = settings; |
| 47 | 47 | ||
| 48 | - this->lastBufferSize = 0; | 48 | + this->lastRecordLength = 0; |
| 49 | this->lastWindow = (Dso::WindowFunction) -1; | 49 | this->lastWindow = (Dso::WindowFunction) -1; |
| 50 | this->window = 0; | 50 | this->window = 0; |
| 51 | 51 | ||
| @@ -189,33 +189,33 @@ void DataAnalyzer::run() { | @@ -189,33 +189,33 @@ void DataAnalyzer::run() { | ||
| 189 | for(int channel = 0; channel < this->analyzedData.count(); channel++) { | 189 | for(int channel = 0; channel < this->analyzedData.count(); channel++) { |
| 190 | if(this->analyzedData[channel]->samples.voltage.sample) { | 190 | if(this->analyzedData[channel]->samples.voltage.sample) { |
| 191 | // Calculate new window | 191 | // Calculate new window |
| 192 | - if(this->lastWindow != this->settings->scope.spectrumWindow || this->lastBufferSize != this->analyzedData[channel]->samples.voltage.count) { | ||
| 193 | - if(this->lastBufferSize != this->analyzedData[channel]->samples.voltage.count) { | ||
| 194 | - this->lastBufferSize = this->analyzedData[channel]->samples.voltage.count; | 192 | + if(this->lastWindow != this->settings->scope.spectrumWindow || this->lastRecordLength != this->analyzedData[channel]->samples.voltage.count) { |
| 193 | + if(this->lastRecordLength != this->analyzedData[channel]->samples.voltage.count) { | ||
| 194 | + this->lastRecordLength = this->analyzedData[channel]->samples.voltage.count; | ||
| 195 | 195 | ||
| 196 | if(this->window) | 196 | if(this->window) |
| 197 | fftw_free(this->window); | 197 | fftw_free(this->window); |
| 198 | - this->window = (double *) fftw_malloc(sizeof(double) * this->lastBufferSize); | 198 | + this->window = (double *) fftw_malloc(sizeof(double) * this->lastRecordLength); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | - unsigned int windowEnd = this->lastBufferSize - 1; | 201 | + unsigned int windowEnd = this->lastRecordLength - 1; |
| 202 | this->lastWindow = this->settings->scope.spectrumWindow; | 202 | this->lastWindow = this->settings->scope.spectrumWindow; |
| 203 | 203 | ||
| 204 | switch(this->settings->scope.spectrumWindow) { | 204 | switch(this->settings->scope.spectrumWindow) { |
| 205 | case Dso::WINDOW_HAMMING: | 205 | case Dso::WINDOW_HAMMING: |
| 206 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 206 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 207 | *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd); | 207 | *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd); |
| 208 | break; | 208 | break; |
| 209 | case Dso::WINDOW_HANN: | 209 | case Dso::WINDOW_HANN: |
| 210 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 210 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 211 | *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd)); | 211 | *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd)); |
| 212 | break; | 212 | break; |
| 213 | case Dso::WINDOW_COSINE: | 213 | case Dso::WINDOW_COSINE: |
| 214 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 214 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 215 | *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd); | 215 | *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd); |
| 216 | break; | 216 | break; |
| 217 | case Dso::WINDOW_LANCZOS: | 217 | case Dso::WINDOW_LANCZOS: |
| 218 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) { | 218 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) { |
| 219 | double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI; | 219 | double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI; |
| 220 | if(sincParameter == 0) | 220 | if(sincParameter == 0) |
| 221 | *(this->window + windowPosition) = 1; | 221 | *(this->window + windowPosition) = 1; |
| @@ -224,55 +224,55 @@ void DataAnalyzer::run() { | @@ -224,55 +224,55 @@ void DataAnalyzer::run() { | ||
| 224 | } | 224 | } |
| 225 | break; | 225 | break; |
| 226 | case Dso::WINDOW_BARTLETT: | 226 | case Dso::WINDOW_BARTLETT: |
| 227 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 227 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 228 | *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2)); | 228 | *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2)); |
| 229 | break; | 229 | break; |
| 230 | case Dso::WINDOW_TRIANGULAR: | 230 | case Dso::WINDOW_TRIANGULAR: |
| 231 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | ||
| 232 | - *(this->window + windowPosition) = 2.0 / this->lastBufferSize * (this->lastBufferSize / 2 - abs(windowPosition - windowEnd / 2)); | 231 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 232 | + *(this->window + windowPosition) = 2.0 / this->lastRecordLength * (this->lastRecordLength / 2 - abs(windowPosition - windowEnd / 2)); | ||
| 233 | break; | 233 | break; |
| 234 | case Dso::WINDOW_GAUSS: | 234 | case Dso::WINDOW_GAUSS: |
| 235 | { | 235 | { |
| 236 | double sigma = 0.4; | 236 | double sigma = 0.4; |
| 237 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 237 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 238 | *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2)); | 238 | *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2)); |
| 239 | } | 239 | } |
| 240 | break; | 240 | break; |
| 241 | case Dso::WINDOW_BARTLETTHANN: | 241 | case Dso::WINDOW_BARTLETTHANN: |
| 242 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 242 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 243 | *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd); | 243 | *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd); |
| 244 | break; | 244 | break; |
| 245 | case Dso::WINDOW_BLACKMAN: | 245 | case Dso::WINDOW_BLACKMAN: |
| 246 | { | 246 | { |
| 247 | double alpha = 0.16; | 247 | double alpha = 0.16; |
| 248 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 248 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 249 | *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd); | 249 | *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd); |
| 250 | } | 250 | } |
| 251 | break; | 251 | break; |
| 252 | //case WINDOW_KAISER: | 252 | //case WINDOW_KAISER: |
| 253 | // TODO | 253 | // TODO |
| 254 | //double alpha = 3.0; | 254 | //double alpha = 3.0; |
| 255 | - //for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 255 | + //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 256 | //*(this->window + windowPosition) = ; | 256 | //*(this->window + windowPosition) = ; |
| 257 | //break; | 257 | //break; |
| 258 | case Dso::WINDOW_NUTTALL: | 258 | case Dso::WINDOW_NUTTALL: |
| 259 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 259 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 260 | *(this->window + windowPosition) = 0.355768 - 0.487396 * cos(2 * M_PI * windowPosition / windowEnd) + 0.144232 * cos(4 * M_PI * windowPosition / windowEnd) - 0.012604 * cos(6 * M_PI * windowPosition / windowEnd); | 260 | *(this->window + windowPosition) = 0.355768 - 0.487396 * cos(2 * M_PI * windowPosition / windowEnd) + 0.144232 * cos(4 * M_PI * windowPosition / windowEnd) - 0.012604 * cos(6 * M_PI * windowPosition / windowEnd); |
| 261 | break; | 261 | break; |
| 262 | case Dso::WINDOW_BLACKMANHARRIS: | 262 | case Dso::WINDOW_BLACKMANHARRIS: |
| 263 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 263 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 264 | *(this->window + windowPosition) = 0.35875 - 0.48829 * cos(2 * M_PI * windowPosition / windowEnd) + 0.14128 * cos(4 * M_PI * windowPosition / windowEnd) - 0.01168 * cos(6 * M_PI * windowPosition / windowEnd); | 264 | *(this->window + windowPosition) = 0.35875 - 0.48829 * cos(2 * M_PI * windowPosition / windowEnd) + 0.14128 * cos(4 * M_PI * windowPosition / windowEnd) - 0.01168 * cos(6 * M_PI * windowPosition / windowEnd); |
| 265 | break; | 265 | break; |
| 266 | case Dso::WINDOW_BLACKMANNUTTALL: | 266 | case Dso::WINDOW_BLACKMANNUTTALL: |
| 267 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 267 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 268 | *(this->window + windowPosition) = 0.3635819 - 0.4891775 * cos(2 * M_PI * windowPosition / windowEnd) + 0.1365995 * cos(4 * M_PI * windowPosition / windowEnd) - 0.0106411 * cos(6 * M_PI * windowPosition / windowEnd); | 268 | *(this->window + windowPosition) = 0.3635819 - 0.4891775 * cos(2 * M_PI * windowPosition / windowEnd) + 0.1365995 * cos(4 * M_PI * windowPosition / windowEnd) - 0.0106411 * cos(6 * M_PI * windowPosition / windowEnd); |
| 269 | break; | 269 | break; |
| 270 | case Dso::WINDOW_FLATTOP: | 270 | case Dso::WINDOW_FLATTOP: |
| 271 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 271 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 272 | *(this->window + windowPosition) = 1.0 - 1.93 * cos(2 * M_PI * windowPosition / windowEnd) + 1.29 * cos(4 * M_PI * windowPosition / windowEnd) - 0.388 * cos(6 * M_PI * windowPosition / windowEnd) + 0.032 * cos(8 * M_PI * windowPosition / windowEnd); | 272 | *(this->window + windowPosition) = 1.0 - 1.93 * cos(2 * M_PI * windowPosition / windowEnd) + 1.29 * cos(4 * M_PI * windowPosition / windowEnd) - 0.388 * cos(6 * M_PI * windowPosition / windowEnd) + 0.032 * cos(8 * M_PI * windowPosition / windowEnd); |
| 273 | break; | 273 | break; |
| 274 | default: // Dso::WINDOW_RECTANGULAR | 274 | default: // Dso::WINDOW_RECTANGULAR |
| 275 | - for(unsigned int windowPosition = 0; windowPosition < this->lastBufferSize; windowPosition++) | 275 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) |
| 276 | *(this->window + windowPosition) = 1.0; | 276 | *(this->window + windowPosition) = 1.0; |
| 277 | } | 277 | } |
| 278 | } | 278 | } |
| @@ -297,7 +297,7 @@ void DataAnalyzer::run() { | @@ -297,7 +297,7 @@ void DataAnalyzer::run() { | ||
| 297 | windowedValues[position] = this->window[position] * this->analyzedData[channel]->samples.voltage.sample[position]; | 297 | windowedValues[position] = this->window[position] * this->analyzedData[channel]->samples.voltage.sample[position]; |
| 298 | 298 | ||
| 299 | // Do discrete real to half-complex transformation | 299 | // Do discrete real to half-complex transformation |
| 300 | - /// \todo Check if buffer size is multiple of 2 | 300 | + /// \todo Check if record length is multiple of 2 |
| 301 | /// \todo Reuse plan and use FFTW_MEASURE to get fastest algorithm | 301 | /// \todo Reuse plan and use FFTW_MEASURE to get fastest algorithm |
| 302 | fftw_plan fftPlan = fftw_plan_r2r_1d(this->analyzedData[channel]->samples.voltage.count, windowedValues, this->analyzedData[channel]->samples.spectrum.sample, FFTW_R2HC, FFTW_ESTIMATE); | 302 | fftw_plan fftPlan = fftw_plan_r2r_1d(this->analyzedData[channel]->samples.voltage.count, windowedValues, this->analyzedData[channel]->samples.spectrum.sample, FFTW_R2HC, FFTW_ESTIMATE); |
| 303 | fftw_execute(fftPlan); | 303 | fftw_execute(fftPlan); |
openhantek/src/dataanalyzer.h
| @@ -89,8 +89,8 @@ class DataAnalyzer : public QThread { | @@ -89,8 +89,8 @@ class DataAnalyzer : public QThread { | ||
| 89 | QList<AnalyzedData *> analyzedData; ///< The analyzed data for each channel | 89 | QList<AnalyzedData *> analyzedData; ///< The analyzed data for each channel |
| 90 | QMutex *analyzedDataMutex; ///< A mutex for the analyzed data of all channels | 90 | QMutex *analyzedDataMutex; ///< A mutex for the analyzed data of all channels |
| 91 | 91 | ||
| 92 | - unsigned long int lastBufferSize; ///< The buffer size of the previously analyzed data | ||
| 93 | - unsigned long int maxSamples; ///< The maximum buffer size of the analyzed data | 92 | + unsigned long int lastRecordLength; ///< The record length of the previously analyzed data |
| 93 | + unsigned long int maxSamples; ///< The maximum record length of the analyzed data | ||
| 94 | Dso::WindowFunction lastWindow; ///< The previously used dft window function | 94 | Dso::WindowFunction lastWindow; ///< The previously used dft window function |
| 95 | double *window; ///< The array for the dft window factors | 95 | double *window; ///< The array for the dft window factors |
| 96 | 96 |
openhantek/src/dso.h
| @@ -38,6 +38,16 @@ | @@ -38,6 +38,16 @@ | ||
| 38 | /// \brief All DSO specific things for different modes and so on. | 38 | /// \brief All DSO specific things for different modes and so on. |
| 39 | namespace Dso { | 39 | namespace Dso { |
| 40 | ////////////////////////////////////////////////////////////////////////////// | 40 | ////////////////////////////////////////////////////////////////////////////// |
| 41 | + /// \enum ErrorCode hantek/control.h | ||
| 42 | + /// \brief The return codes for device control methods. | ||
| 43 | + enum ErrorCode { | ||
| 44 | + ERROR_NONE = 0, ///< Successful operation | ||
| 45 | + ERROR_CONNECTION = -1, ///< Device not connected or communication error | ||
| 46 | + ERROR_UNSUPPORTED = -2, ///< Not supported by this device | ||
| 47 | + ERROR_PARAMETER = -3 ///< Parameter out of range | ||
| 48 | + }; | ||
| 49 | + | ||
| 50 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 41 | /// \enum ChannelMode dso.h | 51 | /// \enum ChannelMode dso.h |
| 42 | /// \brief The channel display modes. | 52 | /// \brief The channel display modes. |
| 43 | enum ChannelMode { | 53 | enum ChannelMode { |
openhantek/src/dsocontrol.h
| @@ -72,13 +72,13 @@ class DsoControl : public QThread { | @@ -72,13 +72,13 @@ class DsoControl : public QThread { | ||
| 72 | virtual void stopSampling(); | 72 | virtual void stopSampling(); |
| 73 | 73 | ||
| 74 | virtual unsigned long int setSamplerate(unsigned long int samplerate) = 0; ///< Set the samplerate that should be met | 74 | virtual unsigned long int setSamplerate(unsigned long int samplerate) = 0; ///< Set the samplerate that should be met |
| 75 | - virtual unsigned long int setBufferSize(unsigned long int size) = 0; ///< Set the needed buffer size | 75 | + virtual unsigned long int setRecordLength(unsigned long int size) = 0; ///< Set the required record length |
| 76 | 76 | ||
| 77 | virtual int setTriggerMode(Dso::TriggerMode mode) = 0; ///< Set the trigger mode | 77 | virtual int setTriggerMode(Dso::TriggerMode mode) = 0; ///< Set the trigger mode |
| 78 | virtual int setTriggerSource(bool special, unsigned int id) = 0; ///< Set the trigger source | 78 | virtual int setTriggerSource(bool special, unsigned int id) = 0; ///< Set the trigger source |
| 79 | virtual double setTriggerLevel(unsigned int channel, double level) = 0; ///< Set the trigger level for a channel | 79 | virtual double setTriggerLevel(unsigned int channel, double level) = 0; ///< Set the trigger level for a channel |
| 80 | virtual int setTriggerSlope(Dso::Slope slope) = 0; ///< Set the slope that causes triggering | 80 | virtual int setTriggerSlope(Dso::Slope slope) = 0; ///< Set the slope that causes triggering |
| 81 | - virtual double setTriggerPosition(double position) = 0; ///< Set the pretrigger position (0.0 = left, 1.0 = right side) | 81 | + virtual double setPretriggerPosition(double position) = 0; ///< Set the pretrigger position (0.0 = left, 1.0 = right side) |
| 82 | 82 | ||
| 83 | virtual int setChannelUsed(unsigned int channel, bool used) = 0; ///< Enable/disable a channel | 83 | virtual int setChannelUsed(unsigned int channel, bool used) = 0; ///< Enable/disable a channel |
| 84 | virtual int setCoupling(unsigned int channel, Dso::Coupling coupling) = 0; ///< Set the coupling for a channel | 84 | virtual int setCoupling(unsigned int channel, Dso::Coupling coupling) = 0; ///< Set the coupling for a channel |
openhantek/src/dsowidget.cpp
| @@ -114,12 +114,12 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -114,12 +114,12 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 114 | // The table for the settings | 114 | // The table for the settings |
| 115 | this->settingsTriggerLabel = new QLabel(); | 115 | this->settingsTriggerLabel = new QLabel(); |
| 116 | this->settingsTriggerLabel->setMinimumWidth(160); | 116 | this->settingsTriggerLabel->setMinimumWidth(160); |
| 117 | - this->settingsBufferLabel = new QLabel(); | ||
| 118 | - this->settingsBufferLabel->setAlignment(Qt::AlignRight); | ||
| 119 | - this->settingsBufferLabel->setPalette(palette); | ||
| 120 | - this->settingsRateLabel = new QLabel(); | ||
| 121 | - this->settingsRateLabel->setAlignment(Qt::AlignRight); | ||
| 122 | - this->settingsRateLabel->setPalette(palette); | 117 | + this->settingsRecordLengthLabel = new QLabel(); |
| 118 | + this->settingsRecordLengthLabel->setAlignment(Qt::AlignRight); | ||
| 119 | + this->settingsRecordLengthLabel->setPalette(palette); | ||
| 120 | + this->settingsSamplerateLabel = new QLabel(); | ||
| 121 | + this->settingsSamplerateLabel->setAlignment(Qt::AlignRight); | ||
| 122 | + this->settingsSamplerateLabel->setPalette(palette); | ||
| 123 | this->settingsTimebaseLabel = new QLabel(); | 123 | this->settingsTimebaseLabel = new QLabel(); |
| 124 | this->settingsTimebaseLabel->setAlignment(Qt::AlignRight); | 124 | this->settingsTimebaseLabel->setAlignment(Qt::AlignRight); |
| 125 | this->settingsTimebaseLabel->setPalette(palette); | 125 | this->settingsTimebaseLabel->setPalette(palette); |
| @@ -128,8 +128,8 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -128,8 +128,8 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 128 | this->settingsFrequencybaseLabel->setPalette(palette); | 128 | this->settingsFrequencybaseLabel->setPalette(palette); |
| 129 | this->settingsLayout = new QHBoxLayout(); | 129 | this->settingsLayout = new QHBoxLayout(); |
| 130 | this->settingsLayout->addWidget(this->settingsTriggerLabel); | 130 | this->settingsLayout->addWidget(this->settingsTriggerLabel); |
| 131 | - this->settingsLayout->addWidget(this->settingsBufferLabel, 1); | ||
| 132 | - this->settingsLayout->addWidget(this->settingsRateLabel, 1); | 131 | + this->settingsLayout->addWidget(this->settingsRecordLengthLabel, 1); |
| 132 | + this->settingsLayout->addWidget(this->settingsSamplerateLabel, 1); | ||
| 133 | this->settingsLayout->addWidget(this->settingsTimebaseLabel, 1); | 133 | this->settingsLayout->addWidget(this->settingsTimebaseLabel, 1); |
| 134 | this->settingsLayout->addWidget(this->settingsFrequencybaseLabel, 1); | 134 | this->settingsLayout->addWidget(this->settingsFrequencybaseLabel, 1); |
| 135 | 135 | ||
| @@ -225,7 +225,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -225,7 +225,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 225 | 225 | ||
| 226 | // Apply settings and update measured values | 226 | // Apply settings and update measured values |
| 227 | this->updateTriggerDetails(); | 227 | this->updateTriggerDetails(); |
| 228 | - this->updateBufferSize(this->settings->scope.horizontal.samples); | 228 | + this->updateRecordLength(this->settings->scope.horizontal.samples); |
| 229 | this->updateFrequencybase(); | 229 | this->updateFrequencybase(); |
| 230 | this->updateTimebase(); | 230 | this->updateTimebase(); |
| 231 | this->updateZoom(this->settings->view.zoom); | 231 | this->updateZoom(this->settings->view.zoom); |
| @@ -246,7 +246,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -246,7 +246,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 246 | 246 | ||
| 247 | // Connect other signals | 247 | // Connect other signals |
| 248 | this->connect(this->dataAnalyzer, SIGNAL(analyzed(unsigned int)), this, SLOT(dataAnalyzed())); | 248 | this->connect(this->dataAnalyzer, SIGNAL(analyzed(unsigned int)), this, SLOT(dataAnalyzed())); |
| 249 | - this->connect(this->dataAnalyzer, SIGNAL(analyzed(unsigned int)), this, SLOT(updateBufferSize(unsigned int))); | 249 | + this->connect(this->dataAnalyzer, SIGNAL(analyzed(unsigned int)), this, SLOT(updateRecordLength(unsigned int))); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | /// \brief Stops the oscilloscope thread and the timer. | 252 | /// \brief Stops the oscilloscope thread and the timer. |
| @@ -332,7 +332,7 @@ void DsoWidget::updateFrequencybase() { | @@ -332,7 +332,7 @@ void DsoWidget::updateFrequencybase() { | ||
| 332 | 332 | ||
| 333 | /// \brief Updates the samplerate field after changing the samplerate. | 333 | /// \brief Updates the samplerate field after changing the samplerate. |
| 334 | void DsoWidget::updateSamplerate() { | 334 | void DsoWidget::updateSamplerate() { |
| 335 | - this->settingsRateLabel->setText(Helper::valueToString(this->settings->scope.horizontal.samplerate, Helper::UNIT_SAMPLES) + tr("/s")); | 335 | + this->settingsSamplerateLabel->setText(Helper::valueToString(this->settings->scope.horizontal.samplerate, Helper::UNIT_SAMPLES) + tr("/s")); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | /// \brief Handles timebaseChanged signal from the horizontal dock. | 338 | /// \brief Handles timebaseChanged signal from the horizontal dock. |
| @@ -424,9 +424,9 @@ void DsoWidget::updateVoltageUsed(unsigned int channel, bool used) { | @@ -424,9 +424,9 @@ void DsoWidget::updateVoltageUsed(unsigned int channel, bool used) { | ||
| 424 | this->updateVoltageDetails(channel); | 424 | this->updateVoltageDetails(channel); |
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | -/// \brief Change the buffer size. | ||
| 428 | -void DsoWidget::updateBufferSize(unsigned int size) { | ||
| 429 | - this->settingsBufferLabel->setText(tr("%1 S").arg(size)); | 427 | +/// \brief Change the record length. |
| 428 | +void DsoWidget::updateRecordLength(unsigned int size) { | ||
| 429 | + this->settingsRecordLengthLabel->setText(tr("%1 S").arg(size)); | ||
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | /// \brief Export the oscilloscope screen to a file. | 432 | /// \brief Export the oscilloscope screen to a file. |
openhantek/src/dsowidget.h
| @@ -69,8 +69,8 @@ class DsoWidget : public QWidget { | @@ -69,8 +69,8 @@ class DsoWidget : public QWidget { | ||
| 69 | 69 | ||
| 70 | QHBoxLayout *settingsLayout; ///< The table for the settings info | 70 | QHBoxLayout *settingsLayout; ///< The table for the settings info |
| 71 | QLabel *settingsTriggerLabel; ///< The trigger details | 71 | QLabel *settingsTriggerLabel; ///< The trigger details |
| 72 | - QLabel *settingsBufferLabel; ///< The buffer size | ||
| 73 | - QLabel *settingsRateLabel; ///< The samplerate | 72 | + QLabel *settingsRecordLengthLabel; ///< The record length |
| 73 | + QLabel *settingsSamplerateLabel; ///< The samplerate | ||
| 74 | QLabel *settingsTimebaseLabel; ///< The timebase of the main scope | 74 | QLabel *settingsTimebaseLabel; ///< The timebase of the main scope |
| 75 | QLabel *settingsFrequencybaseLabel; ///< The frequencybase of the main scope | 75 | QLabel *settingsFrequencybaseLabel; ///< The frequencybase of the main scope |
| 76 | 76 | ||
| @@ -116,7 +116,7 @@ class DsoWidget : public QWidget { | @@ -116,7 +116,7 @@ class DsoWidget : public QWidget { | ||
| 116 | void updateVoltageUsed(unsigned int channel, bool used); | 116 | void updateVoltageUsed(unsigned int channel, bool used); |
| 117 | 117 | ||
| 118 | // Menus | 118 | // Menus |
| 119 | - void updateBufferSize(unsigned int size); | 119 | + void updateRecordLength(unsigned int size); |
| 120 | 120 | ||
| 121 | // Export | 121 | // Export |
| 122 | bool exportAs(); | 122 | bool exportAs(); |
openhantek/src/hantek/control.cpp
| @@ -42,11 +42,12 @@ namespace Hantek { | @@ -42,11 +42,12 @@ namespace Hantek { | ||
| 42 | /// \param parent The parent widget. | 42 | /// \param parent The parent widget. |
| 43 | Control::Control(QObject *parent) : DsoControl(parent) { | 43 | Control::Control(QObject *parent) : DsoControl(parent) { |
| 44 | // Use DSO-2090 specification as default | 44 | // Use DSO-2090 specification as default |
| 45 | - this->specification.command.bulk.setBuffer = BULK_SETTRIGGERANDSAMPLERATE; | 45 | + this->specification.command.bulk.setRecordLength = BULK_SETTRIGGERANDSAMPLERATE; |
| 46 | this->specification.command.bulk.setFilter = BULK_SETFILTER; | 46 | this->specification.command.bulk.setFilter = BULK_SETFILTER; |
| 47 | this->specification.command.bulk.setGain = BULK_SETGAIN; | 47 | this->specification.command.bulk.setGain = BULK_SETGAIN; |
| 48 | this->specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE; | 48 | this->specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE; |
| 49 | this->specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE; | 49 | this->specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE; |
| 50 | + this->specification.command.bulk.setPretrigger = BULK_SETTRIGGERANDSAMPLERATE; | ||
| 50 | this->specification.command.control.setOffset = CONTROL_SETOFFSET; | 51 | this->specification.command.control.setOffset = CONTROL_SETOFFSET; |
| 51 | this->specification.command.control.setRelays = CONTROL_SETRELAYS; | 52 | this->specification.command.control.setRelays = CONTROL_SETRELAYS; |
| 52 | this->specification.command.values.offsetLimits = VALUE_OFFSETLIMITS; | 53 | this->specification.command.values.offsetLimits = VALUE_OFFSETLIMITS; |
| @@ -65,7 +66,7 @@ namespace Hantek { | @@ -65,7 +66,7 @@ namespace Hantek { | ||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | // Set settings to default values | 68 | // Set settings to default values |
| 68 | - this->settings.bufferSizeId = 0; | 69 | + this->settings.recordLengthId = 0; |
| 69 | this->settings.samplerate.limits = &(this->specification.samplerate.single); | 70 | this->settings.samplerate.limits = &(this->specification.samplerate.single); |
| 70 | this->settings.samplerate.downsampling = 1; | 71 | this->settings.samplerate.downsampling = 1; |
| 71 | this->settings.trigger.position = 0; | 72 | this->settings.trigger.position = 0; |
| @@ -76,23 +77,11 @@ namespace Hantek { | @@ -76,23 +77,11 @@ namespace Hantek { | ||
| 76 | // Special trigger sources | 77 | // Special trigger sources |
| 77 | this->specialTriggerSources << tr("EXT") << tr("EXT/10"); | 78 | this->specialTriggerSources << tr("EXT") << tr("EXT/10"); |
| 78 | 79 | ||
| 79 | - // Transmission-ready bulk commands | ||
| 80 | - this->command[BULK_SETFILTER] = new BulkSetFilter(); | ||
| 81 | - this->command[BULK_SETTRIGGERANDSAMPLERATE] = new BulkSetTriggerAndSamplerate(); | ||
| 82 | - this->command[BULK_FORCETRIGGER] = new BulkForceTrigger(); | ||
| 83 | - this->command[BULK_STARTSAMPLING] = new BulkCaptureStart(); | ||
| 84 | - this->command[BULK_ENABLETRIGGER] = new BulkTriggerEnabled(); | ||
| 85 | - this->command[BULK_GETDATA] = new BulkGetData(); | ||
| 86 | - this->command[BULK_GETCAPTURESTATE] = new BulkGetCaptureState(); | ||
| 87 | - this->command[BULK_SETGAIN] = new BulkSetGain(); | ||
| 88 | - this->command[BULK_SETLOGICALDATA] = new BulkSetLogicalData(); | ||
| 89 | - this->command[BULK_GETLOGICALDATA] = new BulkGetLogicalData(); | ||
| 90 | - this->command[BULK_SETSAMPLERATE5200] = new BulkSetSamplerate5200(); | ||
| 91 | - this->command[BULK_SETBUFFER5200] = new BulkSetBuffer5200(); | ||
| 92 | - this->command[BULK_SETTRIGGER5200] = new BulkSetTrigger5200(); | ||
| 93 | - | ||
| 94 | - for(int command = 0; command < BULK_COUNT; command++) | 80 | + // Instantiate bulk command later, some are not the same for all models |
| 81 | + for(int command = 0; command < BULK_COUNT; ++command) { | ||
| 82 | + this->command[command] = 0; | ||
| 95 | this->commandPending[command] = false; | 83 | this->commandPending[command] = false; |
| 84 | + } | ||
| 96 | 85 | ||
| 97 | // Transmission-ready control commands | 86 | // Transmission-ready control commands |
| 98 | this->control[CONTROLINDEX_SETOFFSET] = new ControlSetOffset(); | 87 | this->control[CONTROLINDEX_SETOFFSET] = new ControlSetOffset(); |
| @@ -118,6 +107,12 @@ namespace Hantek { | @@ -118,6 +107,12 @@ namespace Hantek { | ||
| 118 | /// \brief Disconnects the device. | 107 | /// \brief Disconnects the device. |
| 119 | Control::~Control() { | 108 | Control::~Control() { |
| 120 | this->device->disconnect(); | 109 | this->device->disconnect(); |
| 110 | + | ||
| 111 | + // Clean up commands | ||
| 112 | + for(int command = 0; command < BULK_COUNT; ++command) { | ||
| 113 | + if(this->command[command]) | ||
| 114 | + delete this->command[command]; | ||
| 115 | + } | ||
| 121 | } | 116 | } |
| 122 | 117 | ||
| 123 | /// \brief Gets the physical channel count for this oscilloscope. | 118 | /// \brief Gets the physical channel count for this oscilloscope. |
| @@ -186,7 +181,7 @@ namespace Hantek { | @@ -186,7 +181,7 @@ namespace Hantek { | ||
| 186 | 181 | ||
| 187 | // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled | 182 | // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled |
| 188 | // Not more often than every 10 ms though | 183 | // Not more often than every 10 ms though |
| 189 | - int cycleTime = qMax((unsigned long int) (this->specification.bufferSizes[this->settings.bufferSizeId] / this->settings.samplerate.current * 250), (long unsigned int) 10); | 184 | + int cycleTime = qMax((unsigned long int) (this->specification.recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), (long unsigned int) 10); |
| 190 | this->msleep(cycleTime); | 185 | this->msleep(cycleTime); |
| 191 | 186 | ||
| 192 | if(!this->sampling) { | 187 | if(!this->sampling) { |
| @@ -296,7 +291,7 @@ namespace Hantek { | @@ -296,7 +291,7 @@ namespace Hantek { | ||
| 296 | } | 291 | } |
| 297 | 292 | ||
| 298 | /// \brief Gets the current state. | 293 | /// \brief Gets the current state. |
| 299 | - /// \return The current CaptureState of the oscilloscope. | 294 | + /// \return The current CaptureState of the oscilloscope, libusb error code on error. |
| 300 | int Control::getCaptureState() { | 295 | int Control::getCaptureState() { |
| 301 | int errorCode; | 296 | int errorCode; |
| 302 | 297 | ||
| @@ -325,7 +320,7 @@ namespace Hantek { | @@ -325,7 +320,7 @@ namespace Hantek { | ||
| 325 | return errorCode; | 320 | return errorCode; |
| 326 | 321 | ||
| 327 | // Save raw data to temporary buffer | 322 | // Save raw data to temporary buffer |
| 328 | - unsigned int dataCount = this->specification.bufferSizes[this->settings.bufferSizeId] * HANTEK_CHANNELS; | 323 | + unsigned int dataCount = this->specification.recordLengths[this->settings.recordLengthId] * HANTEK_CHANNELS; |
| 329 | unsigned int dataLength = dataCount; | 324 | unsigned int dataLength = dataCount; |
| 330 | bool using10Bits = false; | 325 | bool using10Bits = false; |
| 331 | if(this->device->getModel() == MODEL_DSO5200 || this->device->getModel() == MODEL_DSO5200A) { | 326 | if(this->device->getModel() == MODEL_DSO5200 || this->device->getModel() == MODEL_DSO5200A) { |
| @@ -350,16 +345,28 @@ namespace Hantek { | @@ -350,16 +345,28 @@ namespace Hantek { | ||
| 350 | this->samplesMutex.lock(); | 345 | this->samplesMutex.lock(); |
| 351 | 346 | ||
| 352 | // Get oscilloscope settings | 347 | // Get oscilloscope settings |
| 353 | - bool fastRate; | ||
| 354 | - UsedChannels usedChannels; | ||
| 355 | - if(this->specification.command.bulk.setTrigger == BULK_SETTRIGGERANDSAMPLERATE) { | ||
| 356 | - fastRate = ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getFastRate(); | ||
| 357 | - usedChannels = (UsedChannels) ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getUsedChannels(); | ||
| 358 | - } | ||
| 359 | - else { | ||
| 360 | - fastRate = ((BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200])->getFastRate(); | ||
| 361 | - usedChannels = (UsedChannels) ((BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200])->getUsedChannels(); | 348 | + bool fastRate = false; |
| 349 | + UsedChannels usedChannels = USED_NONE; | ||
| 350 | + switch(this->specification.command.bulk.setTrigger) { | ||
| 351 | + case BULK_SETTRIGGERANDSAMPLERATE: | ||
| 352 | + fastRate = ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getFastRate(); | ||
| 353 | + usedChannels = (UsedChannels) ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getUsedChannels(); | ||
| 354 | + break; | ||
| 355 | + | ||
| 356 | + case BULK_CSETTRIGGERORSAMPLERATE: | ||
| 357 | + fastRate = ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate(); | ||
| 358 | + usedChannels = (UsedChannels) ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getUsedChannels(); | ||
| 359 | + break; | ||
| 360 | + | ||
| 361 | + case BULK_ESETTRIGGERORSAMPLERATE: | ||
| 362 | + fastRate = ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate(); | ||
| 363 | + usedChannels = (UsedChannels) ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getUsedChannels(); | ||
| 364 | + break; | ||
| 365 | + | ||
| 366 | + default: | ||
| 367 | + break; | ||
| 362 | } | 368 | } |
| 369 | + | ||
| 363 | // Convert channel data | 370 | // Convert channel data |
| 364 | if(fastRate) { | 371 | if(fastRate) { |
| 365 | // Fast rate mode, one channel is using all buffers | 372 | // Fast rate mode, one channel is using all buffers |
| @@ -462,50 +469,64 @@ namespace Hantek { | @@ -462,50 +469,64 @@ namespace Hantek { | ||
| 462 | } | 469 | } |
| 463 | 470 | ||
| 464 | /// \brief Sets the size of the sample buffer without updating dependencies. | 471 | /// \brief Sets the size of the sample buffer without updating dependencies. |
| 465 | - /// \param size The buffer size that should be met (S). | ||
| 466 | - /// \return The buffer size that has been set, 0 on error. | ||
| 467 | - unsigned long int Control::updateBufferSize(unsigned long int size) { | ||
| 468 | - // Get the buffer size supporting the highest samplerate while meeting the requirement | 472 | + /// \param size The record length that should be met (S). |
| 473 | + /// \return The record length that has been set, 0 on error. | ||
| 474 | + unsigned long int Control::updateRecordLength(unsigned long int size) { | ||
| 475 | + // Get the record length supporting the highest samplerate while meeting the requirement | ||
| 469 | int bestSizeId = -1; | 476 | int bestSizeId = -1; |
| 470 | - for(int sizeId = 0; sizeId < this->specification.bufferSizes.count(); sizeId++) { | ||
| 471 | - if(this->specification.bufferSizes[sizeId] >= size) { | 477 | + for(int sizeId = 0; sizeId < this->specification.recordLengths.count(); sizeId++) { |
| 478 | + if(this->specification.recordLengths[sizeId] >= size) { | ||
| 472 | // We meet the size-requirement, check if we provide the highest possible samplerate | 479 | // We meet the size-requirement, check if we provide the highest possible samplerate |
| 473 | - if(bestSizeId == -1 || this->specification.bufferSizes[bestSizeId] < size || this->specification.bufferDividers[sizeId] < this->specification.bufferDividers[bestSizeId]) | 480 | + if(bestSizeId == -1 || this->specification.recordLengths[bestSizeId] < size || this->specification.bufferDividers[sizeId] < this->specification.bufferDividers[bestSizeId]) |
| 474 | bestSizeId = sizeId; | 481 | bestSizeId = sizeId; |
| 475 | } | 482 | } |
| 476 | else { | 483 | else { |
| 477 | // We don't meet the size-requirement, but maybe we're still the one coming closest | 484 | // We don't meet the size-requirement, but maybe we're still the one coming closest |
| 478 | - if(bestSizeId == -1 || this->specification.bufferSizes[sizeId] > this->specification.bufferSizes[bestSizeId]) | 485 | + if(bestSizeId == -1 || this->specification.recordLengths[sizeId] > this->specification.recordLengths[bestSizeId]) |
| 479 | bestSizeId = sizeId; | 486 | bestSizeId = sizeId; |
| 480 | } | 487 | } |
| 481 | } | 488 | } |
| 482 | 489 | ||
| 483 | - switch(this->specification.command.bulk.setBuffer) { | 490 | + switch(this->specification.command.bulk.setRecordLength) { |
| 484 | case BULK_SETTRIGGERANDSAMPLERATE: | 491 | case BULK_SETTRIGGERANDSAMPLERATE: |
| 485 | - // SetTriggerAndSamplerate bulk command for buffer size | ||
| 486 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setBufferSize(bestSizeId); | 492 | + // SetTriggerAndSamplerate bulk command for record length |
| 493 | + ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setRecordLength(bestSizeId); | ||
| 487 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 494 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 488 | 495 | ||
| 489 | break; | 496 | break; |
| 490 | 497 | ||
| 491 | - case BULK_SETBUFFER5200: { | ||
| 492 | - // SetBuffer5200 bulk command for buffer size | ||
| 493 | - BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_SETBUFFER5200]; | ||
| 494 | - commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON); | ||
| 495 | - commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON); | ||
| 496 | - commandSetBuffer5200->setBufferSize(bestSizeId); | ||
| 497 | - this->commandPending[BULK_SETBUFFER5200] = true; | ||
| 498 | - | 498 | + case BULK_DSETBUFFER: |
| 499 | + if(this->specification.command.bulk.setPretrigger == BULK_FSETBUFFER) { | ||
| 500 | + // Pointers to needed commands | ||
| 501 | + BulkSetRecordLength2250 *commandSetRecordLength2250 = (BulkSetRecordLength2250 *) this->command[BULK_DSETBUFFER]; | ||
| 502 | + BulkSetBuffer2250 *commandSetBuffer2250 = (BulkSetBuffer2250 *) this->command[BULK_FSETBUFFER]; | ||
| 503 | + | ||
| 504 | + commandSetRecordLength2250->setRecordLength(bestSizeId); | ||
| 505 | + commandSetBuffer2250->setUsedPre(FTRIGGERPOSITION_ON); | ||
| 506 | + commandSetBuffer2250->setUsedPost(FTRIGGERPOSITION_ON); | ||
| 507 | + commandSetBuffer2250->setLargeBuffer(bestSizeId == RECORDLENGTHID_LARGE); | ||
| 508 | + commandSetBuffer2250->setSlowBuffer(bestSizeId != RECORDLENGTHID_SMALL); | ||
| 509 | + | ||
| 510 | + this->commandPending[BULK_DSETBUFFER] = true; | ||
| 511 | + this->commandPending[BULK_FSETBUFFER] = true; | ||
| 512 | + } | ||
| 513 | + else { | ||
| 514 | + // SetBuffer5200 bulk command for record length | ||
| 515 | + BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_DSETBUFFER]; | ||
| 516 | + commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON); | ||
| 517 | + commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON); | ||
| 518 | + commandSetBuffer5200->setRecordLength(bestSizeId); | ||
| 519 | + this->commandPending[BULK_DSETBUFFER] = true; | ||
| 520 | + } | ||
| 499 | break; | 521 | break; |
| 500 | - } | ||
| 501 | 522 | ||
| 502 | default: | 523 | default: |
| 503 | return 0; | 524 | return 0; |
| 504 | } | 525 | } |
| 505 | 526 | ||
| 506 | - this->settings.bufferSizeId = bestSizeId; | 527 | + this->settings.recordLengthId = bestSizeId; |
| 507 | 528 | ||
| 508 | - return this->specification.bufferSizes[this->settings.bufferSizeId]; | 529 | + return this->specification.recordLengths[this->settings.recordLengthId]; |
| 509 | } | 530 | } |
| 510 | 531 | ||
| 511 | /// \brief Try to connect to the oscilloscope. | 532 | /// \brief Try to connect to the oscilloscope. |
| @@ -516,28 +537,26 @@ namespace Hantek { | @@ -516,28 +537,26 @@ namespace Hantek { | ||
| 516 | if(!this->device->isConnected()) | 537 | if(!this->device->isConnected()) |
| 517 | return; | 538 | return; |
| 518 | 539 | ||
| 519 | - // Initialize the commands used on the DSO-2090 as pending | ||
| 520 | - this->commandPending[BULK_SETFILTER] = true; | ||
| 521 | - this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | ||
| 522 | - this->commandPending[BULK_FORCETRIGGER] = false; | ||
| 523 | - this->commandPending[BULK_STARTSAMPLING] = false; | ||
| 524 | - this->commandPending[BULK_ENABLETRIGGER] = false; | ||
| 525 | - this->commandPending[BULK_GETDATA] = false; | ||
| 526 | - this->commandPending[BULK_GETCAPTURESTATE] = false; | ||
| 527 | - this->commandPending[BULK_SETGAIN] = true; | ||
| 528 | - this->commandPending[BULK_SETLOGICALDATA] = false; | ||
| 529 | - this->commandPending[BULK_GETLOGICALDATA] = false; | ||
| 530 | - this->commandPending[BULK_UNKNOWN_0A] = false; | ||
| 531 | - this->commandPending[BULK_UNKNOWN_0B] = false; | ||
| 532 | - this->commandPending[BULK_SETSAMPLERATE5200] = false; | ||
| 533 | - this->commandPending[BULK_SETBUFFER5200] = false; | ||
| 534 | - this->commandPending[BULK_SETTRIGGER5200] = false; | 540 | + // Clean up commands and their pending state |
| 541 | + for(int command = 0; command < BULK_COUNT; ++command) { | ||
| 542 | + if(this->command[command]) | ||
| 543 | + delete this->command[command]; | ||
| 544 | + this->commandPending[command] = false; | ||
| 545 | + } | ||
| 546 | + // Instantiate the commands needed for all models | ||
| 547 | + this->command[BULK_FORCETRIGGER] = new BulkForceTrigger(); | ||
| 548 | + this->command[BULK_STARTSAMPLING] = new BulkCaptureStart(); | ||
| 549 | + this->command[BULK_ENABLETRIGGER] = new BulkTriggerEnabled(); | ||
| 550 | + this->command[BULK_GETDATA] = new BulkGetData(); | ||
| 551 | + this->command[BULK_GETCAPTURESTATE] = new BulkGetCaptureState(); | ||
| 552 | + this->command[BULK_SETGAIN] = new BulkSetGain(); | ||
| 535 | // Initialize the command versions to the ones used on the DSO-2090 | 553 | // Initialize the command versions to the ones used on the DSO-2090 |
| 536 | - this->specification.command.bulk.setBuffer = BULK_SETTRIGGERANDSAMPLERATE; | 554 | + this->specification.command.bulk.setRecordLength = BULK_SETTRIGGERANDSAMPLERATE; |
| 537 | this->specification.command.bulk.setFilter = BULK_SETFILTER; | 555 | this->specification.command.bulk.setFilter = BULK_SETFILTER; |
| 538 | this->specification.command.bulk.setGain = BULK_SETGAIN; | 556 | this->specification.command.bulk.setGain = BULK_SETGAIN; |
| 539 | this->specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE; | 557 | this->specification.command.bulk.setSamplerate = BULK_SETTRIGGERANDSAMPLERATE; |
| 540 | this->specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE; | 558 | this->specification.command.bulk.setTrigger = BULK_SETTRIGGERANDSAMPLERATE; |
| 559 | + this->specification.command.bulk.setPretrigger = BULK_SETTRIGGERANDSAMPLERATE; | ||
| 541 | this->specification.command.control.setOffset = CONTROL_SETOFFSET; | 560 | this->specification.command.control.setOffset = CONTROL_SETOFFSET; |
| 542 | this->specification.command.control.setRelays = CONTROL_SETRELAYS; | 561 | this->specification.command.control.setRelays = CONTROL_SETRELAYS; |
| 543 | this->specification.command.values.offsetLimits = VALUE_OFFSETLIMITS; | 562 | this->specification.command.values.offsetLimits = VALUE_OFFSETLIMITS; |
| @@ -550,23 +569,50 @@ namespace Hantek { | @@ -550,23 +569,50 @@ namespace Hantek { | ||
| 550 | unsupported = true; | 569 | unsupported = true; |
| 551 | 570 | ||
| 552 | case MODEL_DSO2090: | 571 | case MODEL_DSO2090: |
| 553 | - // Keep the defaults we've set before | 572 | + // Instantiate additional commands for the DSO-2090 |
| 573 | + this->command[BULK_SETFILTER] = new BulkSetFilter(); | ||
| 574 | + this->command[BULK_SETTRIGGERANDSAMPLERATE] = new BulkSetTriggerAndSamplerate(); | ||
| 575 | + // Initialize those as pending | ||
| 576 | + this->commandPending[BULK_SETFILTER] = true; | ||
| 577 | + this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | ||
| 554 | break; | 578 | break; |
| 555 | 579 | ||
| 556 | case MODEL_DSO2250: | 580 | case MODEL_DSO2250: |
| 581 | + // Instantiate additional commands for the DSO-2250 | ||
| 582 | + this->command[BULK_BSETFILTER] = new BulkSetFilter2250(); | ||
| 583 | + this->command[BULK_CSETTRIGGERORSAMPLERATE] = new BulkSetTrigger2250(); | ||
| 584 | + this->command[BULK_DSETBUFFER] = new BulkSetRecordLength2250(); | ||
| 585 | + this->command[BULK_ESETTRIGGERORSAMPLERATE] = new BulkSetSamplerate2250(); | ||
| 586 | + this->specification.command.bulk.setRecordLength = BULK_DSETBUFFER; | ||
| 587 | + this->specification.command.bulk.setFilter = BULK_BSETFILTER; | ||
| 588 | + this->specification.command.bulk.setSamplerate = BULK_ESETTRIGGERORSAMPLERATE; | ||
| 589 | + this->specification.command.bulk.setTrigger = BULK_CSETTRIGGERORSAMPLERATE; | ||
| 590 | + this->specification.command.bulk.setPretrigger = BULK_FSETBUFFER; | ||
| 591 | + | ||
| 592 | + this->commandPending[BULK_BSETFILTER] = true; | ||
| 593 | + this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; | ||
| 594 | + this->commandPending[BULK_DSETBUFFER] = true; | ||
| 595 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 596 | + | ||
| 597 | + break; | ||
| 598 | + | ||
| 557 | case MODEL_DSO5200A: | 599 | case MODEL_DSO5200A: |
| 558 | unsupported = true; | 600 | unsupported = true; |
| 559 | 601 | ||
| 560 | case MODEL_DSO5200: | 602 | case MODEL_DSO5200: |
| 561 | - this->specification.command.bulk.setBuffer = BULK_SETBUFFER5200; | ||
| 562 | - this->specification.command.bulk.setSamplerate = BULK_SETSAMPLERATE5200; | ||
| 563 | - this->specification.command.bulk.setTrigger = BULK_SETTRIGGER5200; | ||
| 564 | - this->specification.command.values.voltageLimits = VALUE_VOLTAGELIMITS; | 603 | + // Instantiate additional commands for the DSO-5200 |
| 604 | + this->command[BULK_CSETTRIGGERORSAMPLERATE] = new BulkSetSamplerate5200(); | ||
| 605 | + this->command[BULK_DSETBUFFER] = new BulkSetBuffer5200(); | ||
| 606 | + this->command[BULK_ESETTRIGGERORSAMPLERATE] = new BulkSetTrigger5200(); | ||
| 607 | + this->specification.command.bulk.setRecordLength = BULK_DSETBUFFER; | ||
| 608 | + this->specification.command.bulk.setSamplerate = BULK_CSETTRIGGERORSAMPLERATE; | ||
| 609 | + this->specification.command.bulk.setTrigger = BULK_ESETTRIGGERORSAMPLERATE; | ||
| 610 | + this->specification.command.bulk.setPretrigger = BULK_ESETTRIGGERORSAMPLERATE; | ||
| 611 | + //this->specification.command.values.voltageLimits = VALUE_ETSCORRECTION; | ||
| 565 | 612 | ||
| 566 | - this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = false; | ||
| 567 | - this->commandPending[BULK_SETSAMPLERATE5200] = true; | ||
| 568 | - this->commandPending[BULK_SETBUFFER5200] = true; | ||
| 569 | - this->commandPending[BULK_SETTRIGGER5200] = true; | 613 | + this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; |
| 614 | + this->commandPending[BULK_DSETBUFFER] = true; | ||
| 615 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 570 | 616 | ||
| 571 | break; | 617 | break; |
| 572 | 618 | ||
| @@ -582,15 +628,14 @@ namespace Hantek { | @@ -582,15 +628,14 @@ namespace Hantek { | ||
| 582 | for(int control = 0; control < CONTROLINDEX_COUNT; control++) | 628 | for(int control = 0; control < CONTROLINDEX_COUNT; control++) |
| 583 | this->controlPending[control] = true; | 629 | this->controlPending[control] = true; |
| 584 | 630 | ||
| 585 | - // Maximum possible samplerate for a single channel and dividers for buffer sizes | 631 | + // Maximum possible samplerate for a single channel and dividers for record lengths |
| 586 | this->specification.bufferDividers.clear(); | 632 | this->specification.bufferDividers.clear(); |
| 587 | - this->specification.bufferSizes.clear(); | 633 | + this->specification.recordLengths.clear(); |
| 588 | this->specification.gainSteps.clear(); | 634 | this->specification.gainSteps.clear(); |
| 589 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 635 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) |
| 590 | this->specification.voltageLimit[channel].clear(); | 636 | this->specification.voltageLimit[channel].clear(); |
| 591 | 637 | ||
| 592 | switch(this->device->getModel()) { | 638 | switch(this->device->getModel()) { |
| 593 | - case MODEL_DSO2250: | ||
| 594 | case MODEL_DSO5200: | 639 | case MODEL_DSO5200: |
| 595 | case MODEL_DSO5200A: | 640 | case MODEL_DSO5200A: |
| 596 | this->specification.samplerate.single.base = 100e6; | 641 | this->specification.samplerate.single.base = 100e6; |
| @@ -598,7 +643,7 @@ namespace Hantek { | @@ -598,7 +643,7 @@ namespace Hantek { | ||
| 598 | this->specification.samplerate.multi.base = 200e6; | 643 | this->specification.samplerate.multi.base = 200e6; |
| 599 | this->specification.samplerate.multi.max = 250e6; | 644 | this->specification.samplerate.multi.max = 250e6; |
| 600 | this->specification.bufferDividers << 1000 << 1 << 2; | 645 | this->specification.bufferDividers << 1000 << 1 << 2; |
| 601 | - this->specification.bufferSizes << ULONG_MAX << 10240 << 14336; | 646 | + this->specification.recordLengths << ULONG_MAX << 10240 << 14336; |
| 602 | this->specification.gainSteps | 647 | this->specification.gainSteps |
| 603 | << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; | 648 | << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; |
| 604 | /// \todo Use calibration data to get the DSO-5200(A) sample ranges | 649 | /// \todo Use calibration data to get the DSO-5200(A) sample ranges |
| @@ -609,13 +654,29 @@ namespace Hantek { | @@ -609,13 +654,29 @@ namespace Hantek { | ||
| 609 | << 1 << 0 << 0 << 1 << 0 << 0 << 1 << 0 << 0; | 654 | << 1 << 0 << 0 << 1 << 0 << 0 << 1 << 0 << 0; |
| 610 | break; | 655 | break; |
| 611 | 656 | ||
| 657 | + case MODEL_DSO2250: | ||
| 658 | + this->specification.samplerate.single.base = 200e6; | ||
| 659 | + this->specification.samplerate.single.max = 125e6; | ||
| 660 | + this->specification.samplerate.multi.base = 200e6; | ||
| 661 | + this->specification.samplerate.multi.max = 250e6; | ||
| 662 | + this->specification.bufferDividers << 1000 << 1 << 2; | ||
| 663 | + this->specification.recordLengths << ULONG_MAX << 10240 << 524288; | ||
| 664 | + this->specification.gainSteps | ||
| 665 | + << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; | ||
| 666 | + for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | ||
| 667 | + this->specification.voltageLimit[channel] | ||
| 668 | + << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | ||
| 669 | + this->specification.gainIndex | ||
| 670 | + << 0 << 1 << 2 << 0 << 1 << 2 << 0 << 1 << 2; | ||
| 671 | + break; | ||
| 672 | + | ||
| 612 | case MODEL_DSO2150: | 673 | case MODEL_DSO2150: |
| 613 | this->specification.samplerate.single.base = 50e6; | 674 | this->specification.samplerate.single.base = 50e6; |
| 614 | this->specification.samplerate.single.max = 75e6; | 675 | this->specification.samplerate.single.max = 75e6; |
| 615 | this->specification.samplerate.multi.base = 100e6; | 676 | this->specification.samplerate.multi.base = 100e6; |
| 616 | this->specification.samplerate.multi.max = 150e6; | 677 | this->specification.samplerate.multi.max = 150e6; |
| 617 | this->specification.bufferDividers << 1000 << 1 << 2; | 678 | this->specification.bufferDividers << 1000 << 1 << 2; |
| 618 | - this->specification.bufferSizes << ULONG_MAX << 10240 << 32768; | 679 | + this->specification.recordLengths << ULONG_MAX << 10240 << 32768; |
| 619 | this->specification.gainSteps | 680 | this->specification.gainSteps |
| 620 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; | 681 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 621 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 682 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) |
| @@ -631,7 +692,7 @@ namespace Hantek { | @@ -631,7 +692,7 @@ namespace Hantek { | ||
| 631 | this->specification.samplerate.multi.base = 100e6; | 692 | this->specification.samplerate.multi.base = 100e6; |
| 632 | this->specification.samplerate.multi.max = 100e6; | 693 | this->specification.samplerate.multi.max = 100e6; |
| 633 | this->specification.bufferDividers << 1000 << 1 << 2; | 694 | this->specification.bufferDividers << 1000 << 1 << 2; |
| 634 | - this->specification.bufferSizes << ULONG_MAX << 10240 << 32768; | 695 | + this->specification.recordLengths << ULONG_MAX << 10240 << 32768; |
| 635 | this->specification.gainSteps | 696 | this->specification.gainSteps |
| 636 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; | 697 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 637 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 698 | for(int channel = 0; channel < HANTEK_CHANNELS; channel++) |
| @@ -656,23 +717,23 @@ namespace Hantek { | @@ -656,23 +717,23 @@ namespace Hantek { | ||
| 656 | } | 717 | } |
| 657 | 718 | ||
| 658 | /// \brief Sets the size of the oscilloscopes sample buffer. | 719 | /// \brief Sets the size of the oscilloscopes sample buffer. |
| 659 | - /// \param size The buffer size that should be met (S). | ||
| 660 | - /// \return The buffer size that has been set. | ||
| 661 | - unsigned long int Control::setBufferSize(unsigned long int size) { | 720 | + /// \param size The record length that should be met (S). |
| 721 | + /// \return The record length that has been set, 0 on error. | ||
| 722 | + unsigned long int Control::setRecordLength(unsigned long int size) { | ||
| 662 | if(!this->device->isConnected()) | 723 | if(!this->device->isConnected()) |
| 663 | return 0; | 724 | return 0; |
| 664 | 725 | ||
| 665 | - this->updateBufferSize(size); | 726 | + this->updateRecordLength(size); |
| 666 | 727 | ||
| 667 | - this->setTriggerPosition(this->settings.trigger.position); | 728 | + this->setPretriggerPosition(this->settings.trigger.position); |
| 668 | this->setSamplerate(); | 729 | this->setSamplerate(); |
| 669 | 730 | ||
| 670 | - return this->specification.bufferSizes[this->settings.bufferSizeId]; | 731 | + return this->specification.recordLengths[this->settings.recordLengthId]; |
| 671 | } | 732 | } |
| 672 | 733 | ||
| 673 | /// \brief Sets the samplerate of the oscilloscope. | 734 | /// \brief Sets the samplerate of the oscilloscope. |
| 674 | /// \param samplerate The samplerate that should be met (S/s). | 735 | /// \param samplerate The samplerate that should be met (S/s). |
| 675 | - /// \return The samplerate that has been set. | 736 | + /// \return The samplerate that has been set, 0 on error. |
| 676 | unsigned long int Control::setSamplerate(unsigned long int samplerate) { | 737 | unsigned long int Control::setSamplerate(unsigned long int samplerate) { |
| 677 | if(!this->device->isConnected()) | 738 | if(!this->device->isConnected()) |
| 678 | return 0; | 739 | return 0; |
| @@ -693,24 +754,24 @@ namespace Hantek { | @@ -693,24 +754,24 @@ namespace Hantek { | ||
| 693 | } | 754 | } |
| 694 | 755 | ||
| 695 | // Get downsampling factor that would provide the requested rate | 756 | // Get downsampling factor that would provide the requested rate |
| 696 | - this->settings.samplerate.downsampling = this->settings.samplerate.limits->base / this->specification.bufferDividers[this->settings.bufferSizeId] / samplerate; | 757 | + this->settings.samplerate.downsampling = this->settings.samplerate.limits->base / this->specification.bufferDividers[this->settings.recordLengthId] / samplerate; |
| 697 | // A downsampling factor of zero will result in the maximum rate | 758 | // A downsampling factor of zero will result in the maximum rate |
| 698 | if(this->settings.samplerate.downsampling) | 759 | if(this->settings.samplerate.downsampling) |
| 699 | - this->settings.samplerate.current = this->settings.samplerate.limits->base / this->specification.bufferDividers[this->settings.bufferSizeId] / this->settings.samplerate.downsampling; | 760 | + this->settings.samplerate.current = this->settings.samplerate.limits->base / this->specification.bufferDividers[this->settings.recordLengthId] / this->settings.samplerate.downsampling; |
| 700 | else | 761 | else |
| 701 | - this->settings.samplerate.current = this->settings.samplerate.limits->max / this->specification.bufferDividers[this->settings.bufferSizeId]; | 762 | + this->settings.samplerate.current = this->settings.samplerate.limits->max / this->specification.bufferDividers[this->settings.recordLengthId]; |
| 702 | 763 | ||
| 703 | // Maybe normal mode would be sufficient or even better than fast rate mode | 764 | // Maybe normal mode would be sufficient or even better than fast rate mode |
| 704 | if(fastRate) { | 765 | if(fastRate) { |
| 705 | // Don't set the downsampling factor to zero (maximum rate) if we could use fast rate mode anyway | 766 | // Don't set the downsampling factor to zero (maximum rate) if we could use fast rate mode anyway |
| 706 | - unsigned long int slowDownsampling = qMax(this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.bufferSizeId] / samplerate, (long unsigned int) 1); | 767 | + unsigned long int slowDownsampling = qMax(this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / samplerate, (long unsigned int) 1); |
| 707 | 768 | ||
| 708 | // Use normal mode if we need valueSlow or it would meet the rate at least as exactly as fast rate mode | 769 | // Use normal mode if we need valueSlow or it would meet the rate at least as exactly as fast rate mode |
| 709 | - if(this->settings.samplerate.downsampling > 4 || (qAbs((double) this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.bufferSizeId] / slowDownsampling - samplerate) <= qAbs(this->settings.samplerate.current - samplerate))) { | 770 | + if(this->settings.samplerate.downsampling > 4 || (qAbs((double) this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / slowDownsampling - samplerate) <= qAbs(this->settings.samplerate.current - samplerate))) { |
| 710 | fastRate = false; | 771 | fastRate = false; |
| 711 | this->settings.samplerate.limits = &(this->specification.samplerate.single); | 772 | this->settings.samplerate.limits = &(this->specification.samplerate.single); |
| 712 | this->settings.samplerate.downsampling = slowDownsampling; | 773 | this->settings.samplerate.downsampling = slowDownsampling; |
| 713 | - this->settings.samplerate.current = this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.bufferSizeId] / this->settings.samplerate.downsampling; | 774 | + this->settings.samplerate.current = this->specification.samplerate.single.base / this->specification.bufferDividers[this->settings.recordLengthId] / this->settings.samplerate.downsampling; |
| 714 | } | 775 | } |
| 715 | } | 776 | } |
| 716 | 777 | ||
| @@ -735,10 +796,11 @@ namespace Hantek { | @@ -735,10 +796,11 @@ namespace Hantek { | ||
| 735 | 796 | ||
| 736 | break; | 797 | break; |
| 737 | } | 798 | } |
| 738 | - case BULK_SETSAMPLERATE5200: { | 799 | + case BULK_CSETTRIGGERORSAMPLERATE: { |
| 739 | // Pointers to needed commands | 800 | // Pointers to needed commands |
| 740 | - BulkSetSamplerate5200 *commandSetSamplerate5200 = (BulkSetSamplerate5200 *) this->command[BULK_SETSAMPLERATE5200]; | ||
| 741 | - BulkSetTrigger5200 *commandSetTrigger5200 = (BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200]; | 801 | + BulkSetSamplerate5200 *commandSetSamplerate5200 = (BulkSetSamplerate5200 *) this->command[BULK_CSETTRIGGERORSAMPLERATE]; |
| 802 | + BulkSetTrigger5200 *commandSetTrigger5200 = (BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE]; | ||
| 803 | + | ||
| 742 | // Store samplerate fast value | 804 | // Store samplerate fast value |
| 743 | commandSetSamplerate5200->setSamplerateFast(4 - valueFast); | 805 | commandSetSamplerate5200->setSamplerateFast(4 - valueFast); |
| 744 | // Store samplerate slow value (two's complement) | 806 | // Store samplerate slow value (two's complement) |
| @@ -746,8 +808,23 @@ namespace Hantek { | @@ -746,8 +808,23 @@ namespace Hantek { | ||
| 746 | // Set fast rate when used | 808 | // Set fast rate when used |
| 747 | commandSetTrigger5200->setFastRate(fastRate); | 809 | commandSetTrigger5200->setFastRate(fastRate); |
| 748 | 810 | ||
| 749 | - this->commandPending[BULK_SETSAMPLERATE5200] = true; | ||
| 750 | - this->commandPending[BULK_SETTRIGGER5200] = true; | 811 | + this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; |
| 812 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 813 | + | ||
| 814 | + break; | ||
| 815 | + } | ||
| 816 | + case BULK_ESETTRIGGERORSAMPLERATE: { | ||
| 817 | + // Pointers to needed commands | ||
| 818 | + BulkSetSamplerate2250 *commandSetSamplerate2250 = (BulkSetSamplerate2250 *) this->command[BULK_ESETTRIGGERORSAMPLERATE]; | ||
| 819 | + | ||
| 820 | + // Store samplerate fast value | ||
| 821 | + commandSetSamplerate2250->setSamplerateFast(4 - valueFast); | ||
| 822 | + // Store samplerate slow value (two's complement) | ||
| 823 | + commandSetSamplerate2250->setSamplerateSlow(valueSlow == 0 ? 0 : 0xffff - valueSlow); | ||
| 824 | + // Set fast rate when used | ||
| 825 | + commandSetSamplerate2250->setFastRate(fastRate); | ||
| 826 | + | ||
| 827 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 751 | 828 | ||
| 752 | break; | 829 | break; |
| 753 | } | 830 | } |
| @@ -755,81 +832,102 @@ namespace Hantek { | @@ -755,81 +832,102 @@ namespace Hantek { | ||
| 755 | return 0; | 832 | return 0; |
| 756 | } | 833 | } |
| 757 | 834 | ||
| 758 | - this->updateBufferSize(this->specification.bufferSizes[this->settings.bufferSizeId]); | ||
| 759 | - this->setTriggerPosition(this->settings.trigger.position); | 835 | + this->updateRecordLength(this->specification.recordLengths[this->settings.recordLengthId]); |
| 836 | + this->setPretriggerPosition(this->settings.trigger.position); | ||
| 760 | return this->settings.samplerate.current; | 837 | return this->settings.samplerate.current; |
| 761 | } | 838 | } |
| 762 | 839 | ||
| 763 | /// \brief Enables/disables filtering of the given channel. | 840 | /// \brief Enables/disables filtering of the given channel. |
| 764 | /// \param channel The channel that should be set. | 841 | /// \param channel The channel that should be set. |
| 765 | /// \param used true if the channel should be sampled. | 842 | /// \param used true if the channel should be sampled. |
| 766 | - /// \return 0 on success, -1 on invalid channel. | 843 | + /// \return See ::Dso::ErrorCode. |
| 767 | int Control::setChannelUsed(unsigned int channel, bool used) { | 844 | int Control::setChannelUsed(unsigned int channel, bool used) { |
| 768 | if(!this->device->isConnected()) | 845 | if(!this->device->isConnected()) |
| 769 | - return -2; | 846 | + return Dso::ERROR_CONNECTION; |
| 770 | 847 | ||
| 771 | if(channel >= HANTEK_CHANNELS) | 848 | if(channel >= HANTEK_CHANNELS) |
| 772 | - return -1; | ||
| 773 | - | ||
| 774 | - // SetFilter bulk command for channel filter (used has to be inverted!) | ||
| 775 | - BulkSetFilter *commandSetFilter = (BulkSetFilter *) this->command[BULK_SETFILTER]; | ||
| 776 | - commandSetFilter->setChannel(channel, !used); | ||
| 777 | - this->commandPending[BULK_SETFILTER] = true; | 849 | + return Dso::ERROR_PARAMETER; |
| 778 | 850 | ||
| 779 | unsigned char usedChannels = USED_CH1; | 851 | unsigned char usedChannels = USED_CH1; |
| 780 | - if(!commandSetFilter->getChannel(1)) { | ||
| 781 | - if(commandSetFilter->getChannel(0)) | ||
| 782 | - usedChannels = USED_CH2; | ||
| 783 | - else | ||
| 784 | - usedChannels = USED_CH1CH2; | ||
| 785 | - } | ||
| 786 | 852 | ||
| 787 | - switch(this->specification.command.bulk.setTrigger) { | ||
| 788 | - case BULK_SETTRIGGER5200: { | ||
| 789 | - // SetTrigger5200s bulk command for trigger source | ||
| 790 | - ((BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200])->setUsedChannels(usedChannels); | ||
| 791 | - this->commandPending[BULK_SETTRIGGER5200] = true; | 853 | + switch(this->specification.command.bulk.setFilter) { |
| 854 | + case BULK_SETFILTER: { | ||
| 855 | + // SetFilter bulk command for channel filter (used has to be inverted!) | ||
| 856 | + BulkSetFilter *commandSetFilter = (BulkSetFilter *) this->command[BULK_SETFILTER]; | ||
| 857 | + commandSetFilter->setChannel(channel, !used); | ||
| 858 | + this->commandPending[BULK_SETFILTER] = true; | ||
| 859 | + | ||
| 860 | + if(!commandSetFilter->getChannel(1)) { | ||
| 861 | + if(commandSetFilter->getChannel(0)) | ||
| 862 | + usedChannels = USED_CH2; | ||
| 863 | + else | ||
| 864 | + usedChannels = USED_CH1CH2; | ||
| 865 | + } | ||
| 866 | + | ||
| 792 | break; | 867 | break; |
| 793 | } | 868 | } |
| 794 | - default: { | ||
| 795 | - // SetTriggerAndSamplerate bulk command for trigger source | ||
| 796 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setUsedChannels(usedChannels); | ||
| 797 | - this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 869 | + case BULK_BSETFILTER: { |
| 870 | + // SetFilter2250 bulk command for channel filter (used has to be inverted!) | ||
| 871 | + BulkSetFilter2250 *commandSetFilter2250 = (BulkSetFilter2250 *) this->command[BULK_BSETFILTER]; | ||
| 872 | + commandSetFilter2250->setChannel(channel, !used); | ||
| 873 | + this->commandPending[BULK_BSETFILTER] = true; | ||
| 874 | + | ||
| 798 | break; | 875 | break; |
| 799 | } | 876 | } |
| 877 | + default: | ||
| 878 | + return Dso::ERROR_UNSUPPORTED; | ||
| 800 | } | 879 | } |
| 801 | 880 | ||
| 802 | - return 0; | 881 | + if(this->specification.command.bulk.setTrigger == BULK_SETTRIGGERANDSAMPLERATE || this->specification.command.bulk.setTrigger == BULK_ESETTRIGGERORSAMPLERATE) { |
| 882 | + switch(this->specification.command.bulk.setTrigger) { | ||
| 883 | + case BULK_SETTRIGGERANDSAMPLERATE: { | ||
| 884 | + // SetTriggerAndSamplerate bulk command for trigger source | ||
| 885 | + ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setUsedChannels(usedChannels); | ||
| 886 | + this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | ||
| 887 | + break; | ||
| 888 | + } | ||
| 889 | + case BULK_ESETTRIGGERORSAMPLERATE: { | ||
| 890 | + // SetTrigger5200s bulk command for trigger source | ||
| 891 | + ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setUsedChannels(usedChannels); | ||
| 892 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 893 | + break; | ||
| 894 | + } | ||
| 895 | + default: | ||
| 896 | + break; | ||
| 897 | + } | ||
| 898 | + } | ||
| 899 | + | ||
| 900 | + return Dso::ERROR_NONE; | ||
| 803 | } | 901 | } |
| 804 | 902 | ||
| 805 | /// \brief Set the coupling for the given channel. | 903 | /// \brief Set the coupling for the given channel. |
| 806 | /// \param channel The channel that should be set. | 904 | /// \param channel The channel that should be set. |
| 807 | /// \param coupling The new coupling for the channel. | 905 | /// \param coupling The new coupling for the channel. |
| 808 | - /// \return 0 on success, -1 on invalid channel. | 906 | + /// \return See ::Dso::ErrorCode. |
| 809 | int Control::setCoupling(unsigned int channel, Dso::Coupling coupling) { | 907 | int Control::setCoupling(unsigned int channel, Dso::Coupling coupling) { |
| 810 | if(!this->device->isConnected()) | 908 | if(!this->device->isConnected()) |
| 811 | - return -2; | 909 | + return Dso::ERROR_CONNECTION; |
| 812 | 910 | ||
| 813 | if(channel >= HANTEK_CHANNELS) | 911 | if(channel >= HANTEK_CHANNELS) |
| 814 | - return -1; | 912 | + return Dso::ERROR_PARAMETER; |
| 815 | 913 | ||
| 816 | // SetRelays control command for coupling relays | 914 | // SetRelays control command for coupling relays |
| 817 | ((ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS])->setCoupling(channel, coupling != Dso::COUPLING_AC); | 915 | ((ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS])->setCoupling(channel, coupling != Dso::COUPLING_AC); |
| 818 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; | 916 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| 819 | 917 | ||
| 820 | - return 0; | 918 | + return Dso::ERROR_NONE; |
| 821 | } | 919 | } |
| 822 | 920 | ||
| 823 | /// \brief Sets the gain for the given channel. | 921 | /// \brief Sets the gain for the given channel. |
| 824 | /// \param channel The channel that should be set. | 922 | /// \param channel The channel that should be set. |
| 825 | /// \param gain The gain that should be met (V/div). | 923 | /// \param gain The gain that should be met (V/div). |
| 826 | - /// \return The gain that has been set, -1 on invalid channel. | 924 | + /// \return The gain that has been set, ::Dso::ErrorCode on error. |
| 827 | double Control::setGain(unsigned int channel, double gain) { | 925 | double Control::setGain(unsigned int channel, double gain) { |
| 828 | if(!this->device->isConnected()) | 926 | if(!this->device->isConnected()) |
| 829 | - return -2; | 927 | + return Dso::ERROR_CONNECTION; |
| 830 | 928 | ||
| 831 | if(channel >= HANTEK_CHANNELS) | 929 | if(channel >= HANTEK_CHANNELS) |
| 832 | - return -1; | 930 | + return Dso::ERROR_PARAMETER; |
| 833 | 931 | ||
| 834 | // Find lowest gain voltage thats at least as high as the requested | 932 | // Find lowest gain voltage thats at least as high as the requested |
| 835 | int gainId; | 933 | int gainId; |
| @@ -857,13 +955,13 @@ namespace Hantek { | @@ -857,13 +955,13 @@ namespace Hantek { | ||
| 857 | /// \brief Set the offset for the given channel. | 955 | /// \brief Set the offset for the given channel. |
| 858 | /// \param channel The channel that should be set. | 956 | /// \param channel The channel that should be set. |
| 859 | /// \param offset The new offset value (0.0 - 1.0). | 957 | /// \param offset The new offset value (0.0 - 1.0). |
| 860 | - /// \return The offset that has been set, -1.0 on invalid channel. | 958 | + /// \return The offset that has been set, ::Dso::ErrorCode on error. |
| 861 | double Control::setOffset(unsigned int channel, double offset) { | 959 | double Control::setOffset(unsigned int channel, double offset) { |
| 862 | if(!this->device->isConnected()) | 960 | if(!this->device->isConnected()) |
| 863 | - return -2; | 961 | + return Dso::ERROR_CONNECTION; |
| 864 | 962 | ||
| 865 | if(channel >= HANTEK_CHANNELS) | 963 | if(channel >= HANTEK_CHANNELS) |
| 866 | - return -1; | 964 | + return Dso::ERROR_PARAMETER; |
| 867 | 965 | ||
| 868 | // Calculate the offset value | 966 | // Calculate the offset value |
| 869 | // The range is given by the calibration data (convert from big endian) | 967 | // The range is given by the calibration data (convert from big endian) |
| @@ -885,28 +983,28 @@ namespace Hantek { | @@ -885,28 +983,28 @@ namespace Hantek { | ||
| 885 | } | 983 | } |
| 886 | 984 | ||
| 887 | /// \brief Set the trigger mode. | 985 | /// \brief Set the trigger mode. |
| 888 | - /// \return 0 on success, -1 on invalid mode. | 986 | + /// \return See ::Dso::ErrorCode. |
| 889 | int Control::setTriggerMode(Dso::TriggerMode mode) { | 987 | int Control::setTriggerMode(Dso::TriggerMode mode) { |
| 890 | if(!this->device->isConnected()) | 988 | if(!this->device->isConnected()) |
| 891 | - return -2; | 989 | + return Dso::ERROR_CONNECTION; |
| 892 | 990 | ||
| 893 | if(mode < Dso::TRIGGERMODE_AUTO || mode > Dso::TRIGGERMODE_SINGLE) | 991 | if(mode < Dso::TRIGGERMODE_AUTO || mode > Dso::TRIGGERMODE_SINGLE) |
| 894 | - return -1; | 992 | + return Dso::ERROR_PARAMETER; |
| 895 | 993 | ||
| 896 | this->settings.trigger.mode = mode; | 994 | this->settings.trigger.mode = mode; |
| 897 | - return 0; | 995 | + return Dso::ERROR_NONE; |
| 898 | } | 996 | } |
| 899 | 997 | ||
| 900 | /// \brief Set the trigger source. | 998 | /// \brief Set the trigger source. |
| 901 | /// \param special true for a special channel (EXT, ...) as trigger source. | 999 | /// \param special true for a special channel (EXT, ...) as trigger source. |
| 902 | /// \param id The number of the channel, that should be used as trigger. | 1000 | /// \param id The number of the channel, that should be used as trigger. |
| 903 | - /// \return 0 on success, -1 on invalid channel. | 1001 | + /// \return See ::Dso::ErrorCode. |
| 904 | int Control::setTriggerSource(bool special, unsigned int id) { | 1002 | int Control::setTriggerSource(bool special, unsigned int id) { |
| 905 | if(!this->device->isConnected()) | 1003 | if(!this->device->isConnected()) |
| 906 | - return -2; | 1004 | + return Dso::ERROR_CONNECTION; |
| 907 | 1005 | ||
| 908 | if((!special && id >= HANTEK_CHANNELS) || (special && id >= HANTEK_SPECIAL_CHANNELS)) | 1006 | if((!special && id >= HANTEK_CHANNELS) || (special && id >= HANTEK_SPECIAL_CHANNELS)) |
| 909 | - return -1; | 1007 | + return Dso::ERROR_PARAMETER; |
| 910 | 1008 | ||
| 911 | // Generate trigger source value that will be transmitted | 1009 | // Generate trigger source value that will be transmitted |
| 912 | int sourceValue; | 1010 | int sourceValue; |
| @@ -916,17 +1014,26 @@ namespace Hantek { | @@ -916,17 +1014,26 @@ namespace Hantek { | ||
| 916 | sourceValue = TRIGGER_CH1 - id; | 1014 | sourceValue = TRIGGER_CH1 - id; |
| 917 | 1015 | ||
| 918 | switch(this->specification.command.bulk.setTrigger) { | 1016 | switch(this->specification.command.bulk.setTrigger) { |
| 919 | - case BULK_SETTRIGGER5200: | ||
| 920 | - // SetTrigger5200 bulk command for trigger source | ||
| 921 | - ((BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200])->setTriggerSource(sourceValue); | ||
| 922 | - this->commandPending[BULK_SETTRIGGER5200] = true; | ||
| 923 | - break; | ||
| 924 | - | ||
| 925 | - default: | 1017 | + case BULK_SETTRIGGERANDSAMPLERATE: |
| 926 | // SetTriggerAndSamplerate bulk command for trigger source | 1018 | // SetTriggerAndSamplerate bulk command for trigger source |
| 927 | ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); | 1019 | ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); |
| 928 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1020 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 929 | break; | 1021 | break; |
| 1022 | + | ||
| 1023 | + case BULK_CSETTRIGGERORSAMPLERATE: | ||
| 1024 | + // SetTrigger2250 bulk command for trigger source | ||
| 1025 | + ((BulkSetTrigger2250 *) this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | ||
| 1026 | + this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; | ||
| 1027 | + break; | ||
| 1028 | + | ||
| 1029 | + case BULK_ESETTRIGGERORSAMPLERATE: | ||
| 1030 | + // SetTrigger5200 bulk command for trigger source | ||
| 1031 | + ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | ||
| 1032 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 1033 | + break; | ||
| 1034 | + | ||
| 1035 | + default: | ||
| 1036 | + return Dso::ERROR_UNSUPPORTED; | ||
| 930 | } | 1037 | } |
| 931 | 1038 | ||
| 932 | // SetRelays control command for external trigger relay | 1039 | // SetRelays control command for external trigger relay |
| @@ -945,19 +1052,19 @@ namespace Hantek { | @@ -945,19 +1052,19 @@ namespace Hantek { | ||
| 945 | else | 1052 | else |
| 946 | this->setTriggerLevel(id, this->settings.trigger.level[id]); | 1053 | this->setTriggerLevel(id, this->settings.trigger.level[id]); |
| 947 | 1054 | ||
| 948 | - return 0; | 1055 | + return Dso::ERROR_NONE; |
| 949 | } | 1056 | } |
| 950 | 1057 | ||
| 951 | /// \brief Set the trigger level. | 1058 | /// \brief Set the trigger level. |
| 952 | /// \param channel The channel that should be set. | 1059 | /// \param channel The channel that should be set. |
| 953 | /// \param level The new trigger level (V). | 1060 | /// \param level The new trigger level (V). |
| 954 | - /// \return The trigger level that has been set, -1.0 on invalid channel. | 1061 | + /// \return The trigger level that has been set, ::Dso::ErrorCode on error. |
| 955 | double Control::setTriggerLevel(unsigned int channel, double level) { | 1062 | double Control::setTriggerLevel(unsigned int channel, double level) { |
| 956 | if(!this->device->isConnected()) | 1063 | if(!this->device->isConnected()) |
| 957 | - return -2; | 1064 | + return Dso::ERROR_CONNECTION; |
| 958 | 1065 | ||
| 959 | if(channel >= HANTEK_CHANNELS) | 1066 | if(channel >= HANTEK_CHANNELS) |
| 960 | - return -1.0; | 1067 | + return Dso::ERROR_PARAMETER; |
| 961 | 1068 | ||
| 962 | // Calculate the trigger level value | 1069 | // Calculate the trigger level value |
| 963 | unsigned short int minimum, maximum; | 1070 | unsigned short int minimum, maximum; |
| @@ -994,22 +1101,16 @@ namespace Hantek { | @@ -994,22 +1101,16 @@ namespace Hantek { | ||
| 994 | 1101 | ||
| 995 | /// \brief Set the trigger slope. | 1102 | /// \brief Set the trigger slope. |
| 996 | /// \param slope The Slope that should cause a trigger. | 1103 | /// \param slope The Slope that should cause a trigger. |
| 997 | - /// \return 0 on success, -1 on invalid slope. | 1104 | + /// \return See ::Dso::ErrorCode. |
| 998 | int Control::setTriggerSlope(Dso::Slope slope) { | 1105 | int Control::setTriggerSlope(Dso::Slope slope) { |
| 999 | if(!this->device->isConnected()) | 1106 | if(!this->device->isConnected()) |
| 1000 | - return -2; | 1107 | + return Dso::ERROR_CONNECTION; |
| 1001 | 1108 | ||
| 1002 | if(slope != Dso::SLOPE_NEGATIVE && slope != Dso::SLOPE_POSITIVE) | 1109 | if(slope != Dso::SLOPE_NEGATIVE && slope != Dso::SLOPE_POSITIVE) |
| 1003 | - return -1; | 1110 | + return Dso::ERROR_PARAMETER; |
| 1004 | 1111 | ||
| 1005 | switch(this->specification.command.bulk.setTrigger) { | 1112 | switch(this->specification.command.bulk.setTrigger) { |
| 1006 | - case BULK_SETTRIGGER5200: { | ||
| 1007 | - // SetTrigger5200 bulk command for trigger slope | ||
| 1008 | - ((BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200])->setTriggerSlope(slope); | ||
| 1009 | - this->commandPending[BULK_SETTRIGGER5200] = true; | ||
| 1010 | - break; | ||
| 1011 | - } | ||
| 1012 | - default: { | 1113 | + case BULK_SETTRIGGERANDSAMPLERATE: { |
| 1013 | // SetTriggerAndSamplerate bulk command for trigger slope | 1114 | // SetTriggerAndSamplerate bulk command for trigger slope |
| 1014 | BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = (BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE]; | 1115 | BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = (BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE]; |
| 1015 | 1116 | ||
| @@ -1017,54 +1118,87 @@ namespace Hantek { | @@ -1017,54 +1118,87 @@ namespace Hantek { | ||
| 1017 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1118 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1018 | break; | 1119 | break; |
| 1019 | } | 1120 | } |
| 1121 | + case BULK_CSETTRIGGERORSAMPLERATE: { | ||
| 1122 | + // SetTrigger2250 bulk command for trigger slope | ||
| 1123 | + ((BulkSetTrigger2250 *) this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | ||
| 1124 | + this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; | ||
| 1125 | + break; | ||
| 1126 | + } | ||
| 1127 | + case BULK_ESETTRIGGERORSAMPLERATE: { | ||
| 1128 | + // SetTrigger5200 bulk command for trigger slope | ||
| 1129 | + ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | ||
| 1130 | + this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | ||
| 1131 | + break; | ||
| 1132 | + } | ||
| 1133 | + default: | ||
| 1134 | + return Dso::ERROR_UNSUPPORTED; | ||
| 1020 | } | 1135 | } |
| 1021 | 1136 | ||
| 1022 | this->settings.trigger.slope = slope; | 1137 | this->settings.trigger.slope = slope; |
| 1023 | - return 0; | 1138 | + return Dso::ERROR_NONE; |
| 1024 | } | 1139 | } |
| 1025 | 1140 | ||
| 1026 | /// \brief Set the trigger position. | 1141 | /// \brief Set the trigger position. |
| 1027 | /// \param position The new trigger position (in s). | 1142 | /// \param position The new trigger position (in s). |
| 1028 | /// \return The trigger position that has been set. | 1143 | /// \return The trigger position that has been set. |
| 1029 | - double Control::setTriggerPosition(double position) { | 1144 | + double Control::setPretriggerPosition(double position) { |
| 1030 | if(!this->device->isConnected()) | 1145 | if(!this->device->isConnected()) |
| 1031 | return -2; | 1146 | return -2; |
| 1032 | 1147 | ||
| 1033 | // All trigger positions are measured in samples | 1148 | // All trigger positions are measured in samples |
| 1034 | unsigned long int positionSamples = position * this->settings.samplerate.current; | 1149 | unsigned long int positionSamples = position * this->settings.samplerate.current; |
| 1035 | 1150 | ||
| 1036 | - switch(this->specification.command.bulk.setTrigger) { | ||
| 1037 | - case BULK_SETTRIGGER5200: { | 1151 | + switch(this->specification.command.bulk.setPretrigger) { |
| 1152 | + case BULK_SETTRIGGERANDSAMPLERATE: { | ||
| 1038 | // Fast rate mode uses both channels | 1153 | // Fast rate mode uses both channels |
| 1039 | - if(((BulkSetTrigger5200 *) this->command[BULK_SETTRIGGER5200])->getFastRate()) | 1154 | + if(((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getFastRate()) |
| 1155 | + positionSamples /= HANTEK_CHANNELS; | ||
| 1156 | + | ||
| 1157 | + // Calculate the position value (Start point depending on record length) | ||
| 1158 | + unsigned long int position = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; | ||
| 1159 | + | ||
| 1160 | + // SetTriggerAndSamplerate bulk command for trigger position | ||
| 1161 | + ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); | ||
| 1162 | + this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | ||
| 1163 | + | ||
| 1164 | + break; | ||
| 1165 | + } | ||
| 1166 | + case BULK_FSETBUFFER: { | ||
| 1167 | + // Fast rate mode uses both channels | ||
| 1168 | + if(((BulkSetSamplerate2250 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate()) | ||
| 1040 | positionSamples /= HANTEK_CHANNELS; | 1169 | positionSamples /= HANTEK_CHANNELS; |
| 1041 | 1170 | ||
| 1042 | // Calculate the position values (Inverse, maximum is 0xffff) | 1171 | // Calculate the position values (Inverse, maximum is 0xffff) |
| 1043 | - unsigned short int positionPre = 0xffff - this->specification.bufferSizes[this->settings.bufferSizeId] + positionSamples; | 1172 | + unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; |
| 1044 | unsigned short int positionPost = 0xffff - positionSamples; | 1173 | unsigned short int positionPost = 0xffff - positionSamples; |
| 1045 | 1174 | ||
| 1046 | - // SetBuffer5200 bulk command for trigger position | ||
| 1047 | - BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_SETBUFFER5200]; | ||
| 1048 | - commandSetBuffer5200->setTriggerPositionPre(positionPre); | ||
| 1049 | - commandSetBuffer5200->setTriggerPositionPost(positionPost); | ||
| 1050 | - this->commandPending[BULK_SETBUFFER5200] = true; | 1175 | + // SetBuffer2250 bulk command for trigger position |
| 1176 | + BulkSetBuffer2250 *commandSetBuffer2250 = (BulkSetBuffer2250 *) this->command[BULK_FSETBUFFER]; | ||
| 1177 | + commandSetBuffer2250->setTriggerPositionPre(positionPre); | ||
| 1178 | + commandSetBuffer2250->setTriggerPositionPost(positionPost); | ||
| 1179 | + this->commandPending[BULK_FSETBUFFER] = true; | ||
| 1051 | 1180 | ||
| 1052 | break; | 1181 | break; |
| 1053 | } | 1182 | } |
| 1054 | - default: { | 1183 | + case BULK_ESETTRIGGERORSAMPLERATE: { |
| 1055 | // Fast rate mode uses both channels | 1184 | // Fast rate mode uses both channels |
| 1056 | - if(((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->getFastRate()) | 1185 | + if(((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->getFastRate()) |
| 1057 | positionSamples /= HANTEK_CHANNELS; | 1186 | positionSamples /= HANTEK_CHANNELS; |
| 1058 | 1187 | ||
| 1059 | - // Calculate the position value (Start point depending on buffer size) | ||
| 1060 | - unsigned long int position = 0x7ffff - this->specification.bufferSizes[this->settings.bufferSizeId] + positionSamples; | 1188 | + // Calculate the position values (Inverse, maximum is 0xffff) |
| 1189 | + unsigned short int positionPre = 0xffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; | ||
| 1190 | + unsigned short int positionPost = 0xffff - positionSamples; | ||
| 1061 | 1191 | ||
| 1062 | - // SetTriggerAndSamplerate bulk command for trigger position | ||
| 1063 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); | ||
| 1064 | - this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1192 | + // SetBuffer5200 bulk command for trigger position |
| 1193 | + BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_DSETBUFFER]; | ||
| 1194 | + commandSetBuffer5200->setTriggerPositionPre(positionPre); | ||
| 1195 | + commandSetBuffer5200->setTriggerPositionPost(positionPost); | ||
| 1196 | + this->commandPending[BULK_DSETBUFFER] = true; | ||
| 1065 | 1197 | ||
| 1066 | break; | 1198 | break; |
| 1067 | } | 1199 | } |
| 1200 | + default: | ||
| 1201 | + return Dso::ERROR_UNSUPPORTED; | ||
| 1068 | } | 1202 | } |
| 1069 | 1203 | ||
| 1070 | this->settings.trigger.position = position; | 1204 | this->settings.trigger.position = position; |
| @@ -1073,11 +1207,19 @@ namespace Hantek { | @@ -1073,11 +1207,19 @@ namespace Hantek { | ||
| 1073 | 1207 | ||
| 1074 | #ifdef DEBUG | 1208 | #ifdef DEBUG |
| 1075 | /// \brief Sends bulk/control commands directly. | 1209 | /// \brief Sends bulk/control commands directly. |
| 1210 | + /// <p> | ||
| 1211 | + /// <b>Syntax:</b><br /> | ||
| 1212 | + /// <br /> | ||
| 1213 | + /// Bulk command: | ||
| 1214 | + /// <pre>send bulk [<em>hex data</em>]</pre> | ||
| 1215 | + /// %Control command: | ||
| 1216 | + /// <pre>send control [<em>hex code</em>] [<em>hex data</em>]</pre> | ||
| 1217 | + /// </p> | ||
| 1076 | /// \param command The command as string (Has to be parsed). | 1218 | /// \param command The command as string (Has to be parsed). |
| 1077 | - /// \return 0 on success, -1 on unknown command, -2 on syntax error. | 1219 | + /// \return See ::Dso::ErrorCode. |
| 1078 | int Control::stringCommand(QString command) { | 1220 | int Control::stringCommand(QString command) { |
| 1079 | if(!this->device->isConnected()) | 1221 | if(!this->device->isConnected()) |
| 1080 | - return -3; | 1222 | + return Dso::ERROR_CONNECTION; |
| 1081 | 1223 | ||
| 1082 | QStringList commandParts = command.split(' ', QString::SkipEmptyParts); | 1224 | QStringList commandParts = command.split(' ', QString::SkipEmptyParts); |
| 1083 | 1225 | ||
| @@ -1091,17 +1233,14 @@ namespace Hantek { | @@ -1091,17 +1233,14 @@ namespace Hantek { | ||
| 1091 | // Read command code (First byte) | 1233 | // Read command code (First byte) |
| 1092 | Helper::hexParse(data, &commandCode, 1); | 1234 | Helper::hexParse(data, &commandCode, 1); |
| 1093 | if(commandCode > BULK_COUNT) | 1235 | if(commandCode > BULK_COUNT) |
| 1094 | - return -2; | 1236 | + return Dso::ERROR_UNSUPPORTED; |
| 1095 | 1237 | ||
| 1096 | // Update bulk command and mark as pending | 1238 | // Update bulk command and mark as pending |
| 1097 | Helper::hexParse(data, this->command[commandCode]->data(), this->command[commandCode]->getSize()); | 1239 | Helper::hexParse(data, this->command[commandCode]->data(), this->command[commandCode]->getSize()); |
| 1098 | this->commandPending[commandCode] = true; | 1240 | this->commandPending[commandCode] = true; |
| 1099 | - return 0; | 1241 | + return Dso::ERROR_NONE; |
| 1100 | } | 1242 | } |
| 1101 | else if(commandParts[1] == "control") { | 1243 | else if(commandParts[1] == "control") { |
| 1102 | - if(commandParts.count() <= 1) | ||
| 1103 | - return -2; | ||
| 1104 | - | ||
| 1105 | // Get control code from third part | 1244 | // Get control code from third part |
| 1106 | unsigned char controlCode = commandParts[2].toUShort(); | 1245 | unsigned char controlCode = commandParts[2].toUShort(); |
| 1107 | int control; | 1246 | int control; |
| @@ -1110,20 +1249,26 @@ namespace Hantek { | @@ -1110,20 +1249,26 @@ namespace Hantek { | ||
| 1110 | break; | 1249 | break; |
| 1111 | } | 1250 | } |
| 1112 | if(control >= CONTROLINDEX_COUNT) | 1251 | if(control >= CONTROLINDEX_COUNT) |
| 1113 | - return -2; | 1252 | + return Dso::ERROR_UNSUPPORTED; |
| 1114 | 1253 | ||
| 1115 | QString data = command.section(' ', 3, -1, QString::SectionSkipEmpty); | 1254 | QString data = command.section(' ', 3, -1, QString::SectionSkipEmpty); |
| 1116 | 1255 | ||
| 1117 | // Update control command and mark as pending | 1256 | // Update control command and mark as pending |
| 1118 | Helper::hexParse(data, this->control[control]->data(), this->control[control]->getSize()); | 1257 | Helper::hexParse(data, this->control[control]->data(), this->control[control]->getSize()); |
| 1119 | this->controlPending[control] = true; | 1258 | this->controlPending[control] = true; |
| 1120 | - return 0; | 1259 | + return Dso::ERROR_NONE; |
| 1121 | } | 1260 | } |
| 1122 | } | 1261 | } |
| 1262 | + else { | ||
| 1263 | + return Dso::ERROR_PARAMETER; | ||
| 1264 | + } | ||
| 1123 | } | 1265 | } |
| 1124 | } | 1266 | } |
| 1267 | + else { | ||
| 1268 | + return Dso::ERROR_PARAMETER; | ||
| 1269 | + } | ||
| 1125 | 1270 | ||
| 1126 | - return -1; | 1271 | + return Dso::ERROR_UNSUPPORTED; |
| 1127 | } | 1272 | } |
| 1128 | #endif | 1273 | #endif |
| 1129 | } | 1274 | } |
openhantek/src/hantek/control.h
| @@ -59,8 +59,9 @@ namespace Hantek { | @@ -59,8 +59,9 @@ namespace Hantek { | ||
| 59 | BulkCode setFilter; ///< Command for setting used channels | 59 | BulkCode setFilter; ///< Command for setting used channels |
| 60 | BulkCode setSamplerate; ///< Command for samplerate settings | 60 | BulkCode setSamplerate; ///< Command for samplerate settings |
| 61 | BulkCode setGain; ///< Command for gain settings (Usually in combination with CONTROL_SETRELAYS) | 61 | BulkCode setGain; ///< Command for gain settings (Usually in combination with CONTROL_SETRELAYS) |
| 62 | - BulkCode setBuffer; ///< Command for buffer settings | 62 | + BulkCode setRecordLength; ///< Command for buffer settings |
| 63 | BulkCode setTrigger; ///< Command for trigger settings | 63 | BulkCode setTrigger; ///< Command for trigger settings |
| 64 | + BulkCode setPretrigger; ///< Command for pretrigger settings | ||
| 64 | }; | 65 | }; |
| 65 | 66 | ||
| 66 | ////////////////////////////////////////////////////////////////////////////// | 67 | ////////////////////////////////////////////////////////////////////////////// |
| @@ -113,8 +114,8 @@ namespace Hantek { | @@ -113,8 +114,8 @@ namespace Hantek { | ||
| 113 | 114 | ||
| 114 | // Limits | 115 | // Limits |
| 115 | ControlSpecificationSamplerate samplerate; ///< The samplerate specifications | 116 | ControlSpecificationSamplerate samplerate; ///< The samplerate specifications |
| 116 | - QList<unsigned long int> bufferSizes; ///< Available buffer sizes, ULONG_MAX means rolling | ||
| 117 | - QList<unsigned long int> bufferDividers; ///< Samplerate dividers for buffer sizes | 117 | + QList<unsigned long int> recordLengths; ///< Available record lengths, ULONG_MAX means rolling |
| 118 | + QList<unsigned long int> bufferDividers; ///< Samplerate dividers for record lengths | ||
| 118 | QList<double> gainSteps; ///< Available voltage steps in V/screenheight | 119 | QList<double> gainSteps; ///< Available voltage steps in V/screenheight |
| 119 | 120 | ||
| 120 | // Calibration | 121 | // Calibration |
| @@ -166,7 +167,7 @@ namespace Hantek { | @@ -166,7 +167,7 @@ namespace Hantek { | ||
| 166 | ControlSettingsSamplerate samplerate; ///< The samplerate settings | 167 | ControlSettingsSamplerate samplerate; ///< The samplerate settings |
| 167 | ControlSettingsVoltage voltage[HANTEK_CHANNELS]; ///< The amplification settings | 168 | ControlSettingsVoltage voltage[HANTEK_CHANNELS]; ///< The amplification settings |
| 168 | ControlSettingsTrigger trigger; ///< The trigger settings | 169 | ControlSettingsTrigger trigger; ///< The trigger settings |
| 169 | - unsigned int bufferSizeId; ///< The id in the buffer size array | 170 | + unsigned int recordLengthId; ///< The id in the record length array |
| 170 | unsigned short int usedChannels; ///< Number of activated channels | 171 | unsigned short int usedChannels; ///< Number of activated channels |
| 171 | }; | 172 | }; |
| 172 | 173 | ||
| @@ -188,7 +189,7 @@ namespace Hantek { | @@ -188,7 +189,7 @@ namespace Hantek { | ||
| 188 | unsigned short int calculateTriggerPoint(unsigned short int value); | 189 | unsigned short int calculateTriggerPoint(unsigned short int value); |
| 189 | int getCaptureState(); | 190 | int getCaptureState(); |
| 190 | int getSamples(bool process); | 191 | int getSamples(bool process); |
| 191 | - unsigned long int updateBufferSize(unsigned long int size); | 192 | + unsigned long int updateRecordLength(unsigned long int size); |
| 192 | 193 | ||
| 193 | // Communication with device | 194 | // Communication with device |
| 194 | Device *device; ///< The USB device for the oscilloscope | 195 | Device *device; ///< The USB device for the oscilloscope |
| @@ -212,7 +213,7 @@ namespace Hantek { | @@ -212,7 +213,7 @@ namespace Hantek { | ||
| 212 | virtual void connectDevice(); | 213 | virtual void connectDevice(); |
| 213 | 214 | ||
| 214 | unsigned long int setSamplerate(unsigned long int samplerate = 0); | 215 | unsigned long int setSamplerate(unsigned long int samplerate = 0); |
| 215 | - unsigned long int setBufferSize(unsigned long int size); | 216 | + unsigned long int setRecordLength(unsigned long int size); |
| 216 | 217 | ||
| 217 | int setChannelUsed(unsigned int channel, bool used); | 218 | int setChannelUsed(unsigned int channel, bool used); |
| 218 | int setCoupling(unsigned int channel, Dso::Coupling coupling); | 219 | int setCoupling(unsigned int channel, Dso::Coupling coupling); |
| @@ -223,7 +224,7 @@ namespace Hantek { | @@ -223,7 +224,7 @@ namespace Hantek { | ||
| 223 | int setTriggerSource(bool special, unsigned int id); | 224 | int setTriggerSource(bool special, unsigned int id); |
| 224 | double setTriggerLevel(unsigned int channel, double level); | 225 | double setTriggerLevel(unsigned int channel, double level); |
| 225 | int setTriggerSlope(Dso::Slope slope); | 226 | int setTriggerSlope(Dso::Slope slope); |
| 226 | - double setTriggerPosition(double position); | 227 | + double setPretriggerPosition(double position); |
| 227 | 228 | ||
| 228 | #ifdef DEBUG | 229 | #ifdef DEBUG |
| 229 | int stringCommand(QString command); | 230 | int stringCommand(QString command); |
openhantek/src/hantek/types.cpp
| @@ -104,16 +104,16 @@ namespace Hantek { | @@ -104,16 +104,16 @@ namespace Hantek { | ||
| 104 | /// \param samplerateSlow The SamplerateSlow value. | 104 | /// \param samplerateSlow The SamplerateSlow value. |
| 105 | /// \param triggerPosition The trigger position value. | 105 | /// \param triggerPosition The trigger position value. |
| 106 | /// \param triggerSource The trigger source id (Tsr1). | 106 | /// \param triggerSource The trigger source id (Tsr1). |
| 107 | - /// \param bufferSize The buffer size id (Tsr1). | 107 | + /// \param recordLength The record length id (Tsr1). |
| 108 | /// \param samplerateFast The samplerateFast value (Tsr1). | 108 | /// \param samplerateFast The samplerateFast value (Tsr1). |
| 109 | /// \param usedChannels The enabled channels (Tsr2). | 109 | /// \param usedChannels The enabled channels (Tsr2). |
| 110 | /// \param fastRate The fastRate state (Tsr2). | 110 | /// \param fastRate The fastRate state (Tsr2). |
| 111 | /// \param triggerSlope The triggerSlope value (Tsr2). | 111 | /// \param triggerSlope The triggerSlope value (Tsr2). |
| 112 | - BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(unsigned short int samplerateSlow, unsigned long int triggerPosition, unsigned char triggerSource, unsigned char bufferSize, unsigned char samplerateFast, unsigned char usedChannels, bool fastRate, unsigned char triggerSlope) : Helper::DataArray<unsigned char>(12) { | 112 | + BulkSetTriggerAndSamplerate::BulkSetTriggerAndSamplerate(unsigned short int samplerateSlow, unsigned long int triggerPosition, unsigned char triggerSource, unsigned char recordLength, unsigned char samplerateFast, unsigned char usedChannels, bool fastRate, unsigned char triggerSlope) : Helper::DataArray<unsigned char>(12) { |
| 113 | this->init(); | 113 | this->init(); |
| 114 | 114 | ||
| 115 | this->setTriggerSource(triggerSource); | 115 | this->setTriggerSource(triggerSource); |
| 116 | - this->setBufferSize(bufferSize); | 116 | + this->setRecordLength(recordLength); |
| 117 | this->setSamplerateFast(samplerateFast); | 117 | this->setSamplerateFast(samplerateFast); |
| 118 | this->setUsedChannels(usedChannels); | 118 | this->setUsedChannels(usedChannels); |
| 119 | this->setFastRate(fastRate); | 119 | this->setFastRate(fastRate); |
| @@ -134,16 +134,16 @@ namespace Hantek { | @@ -134,16 +134,16 @@ namespace Hantek { | ||
| 134 | ((Tsr1Bits *) &(this->array[2]))->triggerSource = value; | 134 | ((Tsr1Bits *) &(this->array[2]))->triggerSource = value; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | - /// \brief Get the bufferSize value in Tsr1Bits. | ||
| 138 | - /// \return The ::BufferSizeId value. | ||
| 139 | - unsigned char BulkSetTriggerAndSamplerate::getBufferSize() { | ||
| 140 | - return ((Tsr1Bits *) &(this->array[2]))->bufferSize; | 137 | + /// \brief Get the recordLength value in Tsr1Bits. |
| 138 | + /// \return The ::RecordLengthId value. | ||
| 139 | + unsigned char BulkSetTriggerAndSamplerate::getRecordLength() { | ||
| 140 | + return ((Tsr1Bits *) &(this->array[2]))->recordLength; | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | - /// \brief Set the bufferSize in Tsr1Bits to the given value. | ||
| 144 | - /// \param value The new ::BufferSizeId value. | ||
| 145 | - void BulkSetTriggerAndSamplerate::setBufferSize(unsigned char value) { | ||
| 146 | - ((Tsr1Bits *) &(this->array[2]))->bufferSize = value; | 143 | + /// \brief Set the recordLength in Tsr1Bits to the given value. |
| 144 | + /// \param value The new ::RecordLengthId value. | ||
| 145 | + void BulkSetTriggerAndSamplerate::setRecordLength(unsigned char value) { | ||
| 146 | + ((Tsr1Bits *) &(this->array[2]))->recordLength = value; | ||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | /// \brief Get the samplerateFast value in Tsr1Bits. | 149 | /// \brief Get the samplerateFast value in Tsr1Bits. |
| @@ -376,190 +376,94 @@ namespace Hantek { | @@ -376,190 +376,94 @@ namespace Hantek { | ||
| 376 | 376 | ||
| 377 | 377 | ||
| 378 | ////////////////////////////////////////////////////////////////////////////// | 378 | ////////////////////////////////////////////////////////////////////////////// |
| 379 | - // class BulkGetSpeed | ||
| 380 | - /// \brief Initializes the array. | ||
| 381 | - ControlGetSpeed::ControlGetSpeed() : Helper::DataArray<unsigned char>(10) { | ||
| 382 | - } | ||
| 383 | - | ||
| 384 | - /// \brief Gets the speed of the connection. | ||
| 385 | - /// \return The speed level of the USB connection. | ||
| 386 | - ConnectionSpeed ControlGetSpeed::getSpeed() { | ||
| 387 | - return (ConnectionSpeed) this->array[0]; | 379 | + // class BulkSetFilter2250 |
| 380 | + /// \brief Sets the data array to needed values. | ||
| 381 | + BulkSetFilter2250::BulkSetFilter2250() : Helper::DataArray<unsigned char>(4) { | ||
| 382 | + this->init(); | ||
| 388 | } | 383 | } |
| 389 | 384 | ||
| 390 | - | ||
| 391 | - ////////////////////////////////////////////////////////////////////////////// | ||
| 392 | - // class BulkBeginCommand | ||
| 393 | - /// \brief Sets the command index to the given value. | ||
| 394 | - /// \param index The CommandIndex for the command. | ||
| 395 | - ControlBeginCommand::ControlBeginCommand(BulkIndex index) : Helper::DataArray<unsigned char>(10) { | 385 | + /// \brief Sets the used channels. |
| 386 | + /// \param channel1 true if channel 1 is filtered. | ||
| 387 | + /// \param channel2 true if channel 2 is filtered. | ||
| 388 | + BulkSetFilter2250::BulkSetFilter2250(bool channel1, bool channel2) : Helper::DataArray<unsigned char>(4) { | ||
| 396 | this->init(); | 389 | this->init(); |
| 397 | 390 | ||
| 398 | - this->setIndex(index); | ||
| 399 | - } | ||
| 400 | - | ||
| 401 | - /// \brief Gets the command index. | ||
| 402 | - /// \return The CommandIndex for the command. | ||
| 403 | - BulkIndex ControlBeginCommand::getIndex() { | ||
| 404 | - return (BulkIndex) this->array[1]; | ||
| 405 | - } | ||
| 406 | - | ||
| 407 | - /// \brief Sets the command index to the given value. | ||
| 408 | - /// \param index The new CommandIndex for the command. | ||
| 409 | - void ControlBeginCommand::setIndex(BulkIndex index) { | ||
| 410 | - memset(&(this->array[1]), (unsigned char) index, 3); | ||
| 411 | - } | ||
| 412 | - | ||
| 413 | - /// \brief Initialize the array to the needed values. | ||
| 414 | - void ControlBeginCommand::init() { | ||
| 415 | - this->array[0] = 0x0f; | ||
| 416 | - } | ||
| 417 | - | ||
| 418 | - | ||
| 419 | - ////////////////////////////////////////////////////////////////////////////// | ||
| 420 | - // class BulkSetOffset | ||
| 421 | - /// \brief Sets the data array to the default values. | ||
| 422 | - ControlSetOffset::ControlSetOffset() : Helper::DataArray<unsigned char>(17) { | ||
| 423 | - } | ||
| 424 | - | ||
| 425 | - /// \brief Sets the offsets to the given values. | ||
| 426 | - /// \param channel1 The offset for channel 1. | ||
| 427 | - /// \param channel2 The offset for channel 2. | ||
| 428 | - /// \param trigger The offset for ext. trigger. | ||
| 429 | - ControlSetOffset::ControlSetOffset(unsigned short int channel1, unsigned short int channel2, unsigned short int trigger) : Helper::DataArray<unsigned char>(17) { | ||
| 430 | this->setChannel(0, channel1); | 391 | this->setChannel(0, channel1); |
| 431 | this->setChannel(1, channel2); | 392 | this->setChannel(1, channel2); |
| 432 | - this->setTrigger(trigger); | ||
| 433 | } | 393 | } |
| 434 | 394 | ||
| 435 | - /// \brief Get the offset for the given channel. | ||
| 436 | - /// \param channel The channel whose offset should be returned. | ||
| 437 | - /// \return The channel offset value. | ||
| 438 | - unsigned short int ControlSetOffset::getChannel(unsigned int channel) { | 395 | + /// \brief Gets the filtering state of one channel. |
| 396 | + /// \param channel The channel whose filtering state should be returned. | ||
| 397 | + /// \return The filtering state of the channel. | ||
| 398 | + bool BulkSetFilter2250::getChannel(unsigned int channel) { | ||
| 399 | + FilterBits *filterBits = (FilterBits *) &(this->array[2]); | ||
| 439 | if(channel == 0) | 400 | if(channel == 0) |
| 440 | - return ((this->array[0] & 0x0f) << 8) | this->array[1]; | 401 | + return filterBits->channel1 == 1; |
| 441 | else | 402 | else |
| 442 | - return ((this->array[2] & 0x0f) << 8) | this->array[3]; | 403 | + return filterBits->channel2 == 1; |
| 443 | } | 404 | } |
| 444 | 405 | ||
| 445 | - /// \brief Set the offset for the given channel. | 406 | + /// \brief Enables/disables filtering of one channel. |
| 446 | /// \param channel The channel that should be set. | 407 | /// \param channel The channel that should be set. |
| 447 | - /// \param offset The new channel offset value. | ||
| 448 | - void ControlSetOffset::setChannel(unsigned int channel, unsigned short int offset) { | ||
| 449 | - if(channel == 0) { | ||
| 450 | - this->array[0] = (unsigned char) (offset >> 8); | ||
| 451 | - this->array[1] = (unsigned char) offset; | ||
| 452 | - } | ||
| 453 | - else { | ||
| 454 | - this->array[2] = (unsigned char) (offset >> 8); | ||
| 455 | - this->array[3] = (unsigned char) offset; | ||
| 456 | - } | ||
| 457 | - } | ||
| 458 | - | ||
| 459 | - /// \brief Get the trigger level. | ||
| 460 | - /// \return The trigger level value. | ||
| 461 | - unsigned short int ControlSetOffset::getTrigger() { | ||
| 462 | - return ((this->array[4] & 0x0f) << 8) | this->array[5]; | 408 | + /// \param filtered true if the channel should be filtered. |
| 409 | + void BulkSetFilter2250::setChannel(unsigned int channel, bool filtered) { | ||
| 410 | + FilterBits *filterBits = (FilterBits *) &(this->array[2]); | ||
| 411 | + if(channel == 0) | ||
| 412 | + filterBits->channel1 = filtered ? 1 : 0; | ||
| 413 | + else | ||
| 414 | + filterBits->channel2 = filtered ? 1 : 0; | ||
| 463 | } | 415 | } |
| 464 | 416 | ||
| 465 | - /// \brief Set the trigger level. | ||
| 466 | - /// \param level The new trigger level value. | ||
| 467 | - void ControlSetOffset::setTrigger(unsigned short int level) { | ||
| 468 | - this->array[4] = (unsigned char) (level >> 8); | ||
| 469 | - this->array[5] = (unsigned char) level; | 417 | + /// \brief Initialize the array to the needed values. |
| 418 | + void BulkSetFilter2250::init() { | ||
| 419 | + this->array[0] = BULK_BSETFILTER; | ||
| 470 | } | 420 | } |
| 471 | 421 | ||
| 472 | 422 | ||
| 473 | ////////////////////////////////////////////////////////////////////////////// | 423 | ////////////////////////////////////////////////////////////////////////////// |
| 474 | - // class BulkSetRelays | ||
| 475 | - /// \brief Sets all relay states. | ||
| 476 | - /// \param ch1Below1V Sets the state of the Channel 1 below 1 V relay. | ||
| 477 | - /// \param ch1Below100mV Sets the state of the Channel 1 below 100 mV relay. | ||
| 478 | - /// \param ch1CouplingDC Sets the state of the Channel 1 coupling relay. | ||
| 479 | - /// \param ch2Below1V Sets the state of the Channel 2 below 1 V relay. | ||
| 480 | - /// \param ch2Below100mV Sets the state of the Channel 2 below 100 mV relay. | ||
| 481 | - /// \param ch2CouplingDC Sets the state of the Channel 2 coupling relay. | ||
| 482 | - /// \param triggerExt Sets the state of the external trigger relay. | ||
| 483 | - ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) : Helper::DataArray<unsigned char>(17) { | ||
| 484 | - this->setBelow1V(0, ch1Below1V); | ||
| 485 | - this->setBelow100mV(0, ch1Below100mV); | ||
| 486 | - this->setCoupling(0, ch1CouplingDC); | ||
| 487 | - this->setBelow1V(1, ch2Below1V); | ||
| 488 | - this->setBelow100mV(1, ch2Below100mV); | ||
| 489 | - this->setCoupling(1, ch2CouplingDC); | ||
| 490 | - this->setTrigger(triggerExt); | ||
| 491 | - } | ||
| 492 | - | ||
| 493 | - /// \brief Get the below 1 V relay state for the given channel. | ||
| 494 | - /// \param channel The channel whose relay state should be returned. | ||
| 495 | - /// \return true, if the gain of the channel is below 1 V. | ||
| 496 | - bool ControlSetRelays::getBelow1V(unsigned int channel) { | ||
| 497 | - if(channel == 0) | ||
| 498 | - return (this->array[1] & 0x04) == 0x00; | ||
| 499 | - else | ||
| 500 | - return (this->array[4] & 0x20) == 0x00; | ||
| 501 | - } | ||
| 502 | - | ||
| 503 | - /// \brief Set the below 1 V relay for the given channel. | ||
| 504 | - /// \param channel The channel that should be set. | ||
| 505 | - /// \param below true, if the gain of the channel should be below 1 V. | ||
| 506 | - void ControlSetRelays::setBelow1V(unsigned int channel, bool below) { | ||
| 507 | - if(channel == 0) | ||
| 508 | - this->array[1] = below ? 0xfb : 0x04; | ||
| 509 | - else | ||
| 510 | - this->array[4] = below ? 0xdf : 0x20; | 424 | + // class BulkSetTrigger2250 |
| 425 | + /// \brief Sets the data array to needed values. | ||
| 426 | + BulkSetTrigger2250::BulkSetTrigger2250() : Helper::DataArray<unsigned char>(8) { | ||
| 427 | + this->init(); | ||
| 511 | } | 428 | } |
| 512 | 429 | ||
| 513 | - /// \brief Get the below 1 V relay state for the given channel. | ||
| 514 | - /// \param channel The channel whose relay state should be returned. | ||
| 515 | - /// \return true, if the gain of the channel is below 1 V. | ||
| 516 | - bool ControlSetRelays::getBelow100mV(unsigned int channel) { | ||
| 517 | - if(channel == 0) | ||
| 518 | - return (this->array[2] & 0x08) == 0x00; | ||
| 519 | - else | ||
| 520 | - return (this->array[5] & 0x40) == 0x00; | 430 | + /// \brief Sets the used channels. |
| 431 | + /// \param triggerSource The trigger source id (CTriggerBits). | ||
| 432 | + /// \param triggerSlope The triggerSlope value (CTriggerBits). | ||
| 433 | + BulkSetTrigger2250::BulkSetTrigger2250(unsigned char triggerSource, unsigned char triggerSlope) : Helper::DataArray<unsigned char>(8) { | ||
| 434 | + this->init(); | ||
| 435 | + | ||
| 436 | + this->setTriggerSource(triggerSource); | ||
| 437 | + this->setTriggerSlope(triggerSlope); | ||
| 521 | } | 438 | } |
| 522 | - | ||
| 523 | - /// \brief Set the below 100 mV relay for the given channel. | ||
| 524 | - /// \param channel The channel that should be set. | ||
| 525 | - /// \param below true, if the gain of the channel should be below 100 mV. | ||
| 526 | - void ControlSetRelays::setBelow100mV(unsigned int channel, bool below) { | ||
| 527 | - if(channel == 0) | ||
| 528 | - this->array[2] = below ? 0xf7 : 0x08; | ||
| 529 | - else | ||
| 530 | - this->array[5] = below ? 0xbf : 0x40; | 439 | + |
| 440 | + /// \brief Get the triggerSource value in CTriggerBits. | ||
| 441 | + /// \return The triggerSource value. | ||
| 442 | + unsigned char BulkSetTrigger2250::getTriggerSource() { | ||
| 443 | + return ((CTriggerBits *) &(this->array[2]))->triggerSource; | ||
| 531 | } | 444 | } |
| 532 | 445 | ||
| 533 | - /// \brief Get the coupling relay state for the given channel. | ||
| 534 | - /// \param channel The channel whose relay state should be returned. | ||
| 535 | - /// \return true, if the coupling of the channel is DC. | ||
| 536 | - bool ControlSetRelays::getCoupling(unsigned int channel) { | ||
| 537 | - if(channel == 0) | ||
| 538 | - return (this->array[3] & 0x02) == 0x00; | ||
| 539 | - else | ||
| 540 | - return (this->array[6] & 0x10) == 0x00; | 446 | + /// \brief Set the triggerSource in CTriggerBits to the given value. |
| 447 | + /// \param value The new triggerSource value. | ||
| 448 | + void BulkSetTrigger2250::setTriggerSource(unsigned char value) { | ||
| 449 | + ((CTriggerBits *) &(this->array[2]))->triggerSource = value; | ||
| 541 | } | 450 | } |
| 542 | 451 | ||
| 543 | - /// \brief Set the coupling relay for the given channel. | ||
| 544 | - /// \param channel The channel that should be set. | ||
| 545 | - /// \param dc true, if the coupling of the channel should be DC. | ||
| 546 | - void ControlSetRelays::setCoupling(unsigned int channel, bool dc) { | ||
| 547 | - if(channel == 0) | ||
| 548 | - this->array[3] = dc ? 0xfd : 0x02; | ||
| 549 | - else | ||
| 550 | - this->array[6] = dc ? 0xef : 0x10; | 452 | + /// \brief Get the triggerSlope value in CTriggerBits. |
| 453 | + /// \return The triggerSlope value. | ||
| 454 | + unsigned char BulkSetTrigger2250::getTriggerSlope() { | ||
| 455 | + return ((CTriggerBits *) &(this->array[2]))->triggerSlope; | ||
| 551 | } | 456 | } |
| 552 | 457 | ||
| 553 | - /// \brief Get the external trigger relay state. | ||
| 554 | - /// \return true, if the trigger is external (EXT-Connector). | ||
| 555 | - bool ControlSetRelays::getTrigger() { | ||
| 556 | - return (this->array[7] & 0x01) == 0x00; | 458 | + /// \brief Set the triggerSlope in CTriggerBits to the given value. |
| 459 | + /// \param slope The new triggerSlope value. | ||
| 460 | + void BulkSetTrigger2250::setTriggerSlope(unsigned char slope) { | ||
| 461 | + ((CTriggerBits *) &(this->array[2]))->triggerSlope = slope; | ||
| 557 | } | 462 | } |
| 558 | - | ||
| 559 | - /// \brief Set the external trigger relay. | ||
| 560 | - /// \param ext true, if the trigger should be external (EXT-Connector). | ||
| 561 | - void ControlSetRelays::setTrigger(bool ext) { | ||
| 562 | - this->array[7] = ext ? 0xfe : 0x01; | 463 | + |
| 464 | + /// \brief Initialize the array to the needed values. | ||
| 465 | + void BulkSetTrigger2250::init() { | ||
| 466 | + this->array[0] = BULK_CSETTRIGGERORSAMPLERATE; | ||
| 563 | } | 467 | } |
| 564 | 468 | ||
| 565 | 469 | ||
| @@ -607,7 +511,40 @@ namespace Hantek { | @@ -607,7 +511,40 @@ namespace Hantek { | ||
| 607 | 511 | ||
| 608 | /// \brief Initialize the array to the needed values. | 512 | /// \brief Initialize the array to the needed values. |
| 609 | void BulkSetSamplerate5200::init() { | 513 | void BulkSetSamplerate5200::init() { |
| 610 | - this->array[0] = BULK_SETSAMPLERATE5200; | 514 | + this->array[0] = BULK_CSETTRIGGERORSAMPLERATE; |
| 515 | + } | ||
| 516 | + | ||
| 517 | + | ||
| 518 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 519 | + // class BulkSetBuffer2250 | ||
| 520 | + /// \brief Sets the data array to the default values. | ||
| 521 | + BulkSetRecordLength2250::BulkSetRecordLength2250() : Helper::DataArray<unsigned char>(4) { | ||
| 522 | + this->init(); | ||
| 523 | + } | ||
| 524 | + | ||
| 525 | + /// \brief Sets the data bytes to the specified values. | ||
| 526 | + /// \param recordLength The ::RecordLengthId value. | ||
| 527 | + BulkSetRecordLength2250::BulkSetRecordLength2250(unsigned char recordLength) : Helper::DataArray<unsigned char>(4) { | ||
| 528 | + this->init(); | ||
| 529 | + | ||
| 530 | + this->setRecordLength(recordLength); | ||
| 531 | + } | ||
| 532 | + | ||
| 533 | + /// \brief Get the ::RecordLengthId value. | ||
| 534 | + /// \return The ::RecordLengthId value. | ||
| 535 | + unsigned char BulkSetRecordLength2250::getRecordLength() { | ||
| 536 | + return this->array[2]; | ||
| 537 | + } | ||
| 538 | + | ||
| 539 | + /// \brief Set the ::RecordLengthId to the given value. | ||
| 540 | + /// \param value The new ::RecordLengthId value. | ||
| 541 | + void BulkSetRecordLength2250::setRecordLength(unsigned char value) { | ||
| 542 | + this->array[2] = value; | ||
| 543 | + } | ||
| 544 | + | ||
| 545 | + /// \brief Initialize the array to the needed values. | ||
| 546 | + void BulkSetRecordLength2250::init() { | ||
| 547 | + this->array[0] = BULK_DSETBUFFER; | ||
| 611 | } | 548 | } |
| 612 | 549 | ||
| 613 | 550 | ||
| @@ -623,15 +560,15 @@ namespace Hantek { | @@ -623,15 +560,15 @@ namespace Hantek { | ||
| 623 | /// \param triggerPositionPost The TriggerPositionPost value. | 560 | /// \param triggerPositionPost The TriggerPositionPost value. |
| 624 | /// \param usedPre The TriggerPositionUsedPre value. | 561 | /// \param usedPre The TriggerPositionUsedPre value. |
| 625 | /// \param usedPost The TriggerPositionUsedPost value. | 562 | /// \param usedPost The TriggerPositionUsedPost value. |
| 626 | - /// \param bufferSize The ::BufferSizeId value. | ||
| 627 | - BulkSetBuffer5200::BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, unsigned char bufferSize) : Helper::DataArray<unsigned char>(10) { | 563 | + /// \param recordLength The ::RecordLengthId value. |
| 564 | + BulkSetBuffer5200::BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, unsigned char recordLength) : Helper::DataArray<unsigned char>(10) { | ||
| 628 | this->init(); | 565 | this->init(); |
| 629 | 566 | ||
| 630 | this->setTriggerPositionPre(triggerPositionPre); | 567 | this->setTriggerPositionPre(triggerPositionPre); |
| 631 | this->setTriggerPositionPost(triggerPositionPost); | 568 | this->setTriggerPositionPost(triggerPositionPost); |
| 632 | this->setUsedPre(usedPre); | 569 | this->setUsedPre(usedPre); |
| 633 | this->setUsedPost(usedPost); | 570 | this->setUsedPost(usedPost); |
| 634 | - this->setBufferSize(bufferSize); | 571 | + this->setRecordLength(recordLength); |
| 635 | } | 572 | } |
| 636 | 573 | ||
| 637 | /// \brief Get the TriggerPositionPre value. | 574 | /// \brief Get the TriggerPositionPre value. |
| @@ -684,27 +621,89 @@ namespace Hantek { | @@ -684,27 +621,89 @@ namespace Hantek { | ||
| 684 | ((DBufferBits *) &(this->array[8]))->triggerPositionUsed = value; | 621 | ((DBufferBits *) &(this->array[8]))->triggerPositionUsed = value; |
| 685 | } | 622 | } |
| 686 | 623 | ||
| 687 | - /// \brief Get the bufferSize value in DBufferBits. | ||
| 688 | - /// \return The ::BufferSizeId value. | ||
| 689 | - unsigned char BulkSetBuffer5200::getBufferSize() { | ||
| 690 | - return ((DBufferBits *) &(this->array[8]))->bufferSize; | 624 | + /// \brief Get the recordLength value in DBufferBits. |
| 625 | + /// \return The ::RecordLengthId value. | ||
| 626 | + unsigned char BulkSetBuffer5200::getRecordLength() { | ||
| 627 | + return ((DBufferBits *) &(this->array[8]))->recordLength; | ||
| 691 | } | 628 | } |
| 692 | 629 | ||
| 693 | - /// \brief Set the bufferSize in DBufferBits to the given value. | ||
| 694 | - /// \param value The new ::BufferSizeId value. | ||
| 695 | - void BulkSetBuffer5200::setBufferSize(unsigned char value) { | ||
| 696 | - ((DBufferBits *) &(this->array[8]))->bufferSize = value; | 630 | + /// \brief Set the recordLength in DBufferBits to the given value. |
| 631 | + /// \param value The new ::RecordLengthId value. | ||
| 632 | + void BulkSetBuffer5200::setRecordLength(unsigned char value) { | ||
| 633 | + ((DBufferBits *) &(this->array[8]))->recordLength = value; | ||
| 697 | } | 634 | } |
| 698 | 635 | ||
| 699 | /// \brief Initialize the array to the needed values. | 636 | /// \brief Initialize the array to the needed values. |
| 700 | void BulkSetBuffer5200::init() { | 637 | void BulkSetBuffer5200::init() { |
| 701 | - this->array[0] = BULK_SETBUFFER5200; | 638 | + this->array[0] = BULK_DSETBUFFER; |
| 702 | this->array[5] = 0xff; | 639 | this->array[5] = 0xff; |
| 703 | this->array[9] = 0xff; | 640 | this->array[9] = 0xff; |
| 704 | } | 641 | } |
| 705 | 642 | ||
| 706 | 643 | ||
| 707 | ////////////////////////////////////////////////////////////////////////////// | 644 | ////////////////////////////////////////////////////////////////////////////// |
| 645 | + // class BulkSetSamplerate2250 | ||
| 646 | + /// \brief Sets the data array to the default values. | ||
| 647 | + BulkSetSamplerate2250::BulkSetSamplerate2250() : Helper::DataArray<unsigned char>(8) { | ||
| 648 | + this->init(); | ||
| 649 | + } | ||
| 650 | + | ||
| 651 | + /// \brief Sets the data bytes to the specified values. | ||
| 652 | + /// \param fastRate The fastRate state (ESamplerateBits). | ||
| 653 | + /// \param samplerateFast The SamplerateFast value (ESamplerateBits). | ||
| 654 | + /// \param samplerateSlow The SamplerateSlow value. | ||
| 655 | + BulkSetSamplerate2250::BulkSetSamplerate2250(bool fastRate, unsigned char samplerateFast, unsigned short int samplerateSlow) : Helper::DataArray<unsigned char>(8) { | ||
| 656 | + this->init(); | ||
| 657 | + | ||
| 658 | + this->setFastRate(fastRate); | ||
| 659 | + this->setSamplerateFast(samplerateFast); | ||
| 660 | + this->setSamplerateSlow(samplerateSlow); | ||
| 661 | + } | ||
| 662 | + | ||
| 663 | + /// \brief Get the fastRate state in ESamplerateBits. | ||
| 664 | + /// \return The fastRate state. | ||
| 665 | + bool BulkSetSamplerate2250::getFastRate() { | ||
| 666 | + return ((ESamplerateBits *) &(this->array[2]))->fastRate == 1; | ||
| 667 | + } | ||
| 668 | + | ||
| 669 | + /// \brief Set the fastRate in ESamplerateBits to the given state. | ||
| 670 | + /// \param fastRate The new fastRate state. | ||
| 671 | + void BulkSetSamplerate2250::setFastRate(bool fastRate) { | ||
| 672 | + ((ESamplerateBits *) &(this->array[2]))->fastRate = fastRate ? 1 : 0; | ||
| 673 | + } | ||
| 674 | + | ||
| 675 | + /// \brief Get the samplerateFast value in ESamplerateBits. | ||
| 676 | + /// \return The samplerateFast value in ESamplerateBits. | ||
| 677 | + unsigned char BulkSetSamplerate2250::getSamplerateFast() { | ||
| 678 | + return ((ESamplerateBits *) &(this->array[2]))->samplerateFast; | ||
| 679 | + } | ||
| 680 | + | ||
| 681 | + /// \brief Set the samplerateFast in ESamplerateBits to the given value. | ||
| 682 | + /// \param value The new samplerateFast value. | ||
| 683 | + void BulkSetSamplerate2250::setSamplerateFast(unsigned char value) { | ||
| 684 | + ((ESamplerateBits *) &(this->array[2]))->samplerateFast = value; | ||
| 685 | + } | ||
| 686 | + | ||
| 687 | + /// \brief Get the SamplerateSlow value. | ||
| 688 | + /// \return The SamplerateSlow value. | ||
| 689 | + unsigned short int BulkSetSamplerate2250::getSamplerateSlow() { | ||
| 690 | + return (unsigned short int) this->array[4] | ((unsigned short int) this->array[5] << 8); | ||
| 691 | + } | ||
| 692 | + | ||
| 693 | + /// \brief Set the SamplerateSlow to the given value. | ||
| 694 | + /// \param samplerate The new SamplerateSlow value. | ||
| 695 | + void BulkSetSamplerate2250::setSamplerateSlow(unsigned short int samplerate) { | ||
| 696 | + this->array[4] = (unsigned char) samplerate; | ||
| 697 | + this->array[5] = (unsigned char) (samplerate >> 8); | ||
| 698 | + } | ||
| 699 | + | ||
| 700 | + /// \brief Initialize the array to the needed values. | ||
| 701 | + void BulkSetSamplerate2250::init() { | ||
| 702 | + this->array[0] = BULK_ESETTRIGGERORSAMPLERATE; | ||
| 703 | + } | ||
| 704 | + | ||
| 705 | + | ||
| 706 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 708 | // class BulkSetTrigger5200 | 707 | // class BulkSetTrigger5200 |
| 709 | /// \brief Sets the data array to the default values. | 708 | /// \brief Sets the data array to the default values. |
| 710 | BulkSetTrigger5200::BulkSetTrigger5200() : Helper::DataArray<unsigned char>(8) { | 709 | BulkSetTrigger5200::BulkSetTrigger5200() : Helper::DataArray<unsigned char>(8) { |
| @@ -789,7 +788,301 @@ namespace Hantek { | @@ -789,7 +788,301 @@ namespace Hantek { | ||
| 789 | 788 | ||
| 790 | /// \brief Initialize the array to the needed values. | 789 | /// \brief Initialize the array to the needed values. |
| 791 | void BulkSetTrigger5200::init() { | 790 | void BulkSetTrigger5200::init() { |
| 792 | - this->array[0] = BULK_SETTRIGGER5200; | 791 | + this->array[0] = BULK_ESETTRIGGERORSAMPLERATE; |
| 793 | this->array[4] = 0x02; | 792 | this->array[4] = 0x02; |
| 794 | } | 793 | } |
| 794 | + | ||
| 795 | + | ||
| 796 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 797 | + /// \class BulkSetBuffer2250 hantek/types.h | ||
| 798 | + /// \brief The DSO-2250 BULK_FSETBUFFER builder. | ||
| 799 | + /// \brief Sets the data array to the default values. | ||
| 800 | + BulkSetBuffer2250::BulkSetBuffer2250() : Helper::DataArray<unsigned char>(10) { | ||
| 801 | + this->init(); | ||
| 802 | + } | ||
| 803 | + | ||
| 804 | + /// \brief Sets the data bytes to the specified values. | ||
| 805 | + /// \param triggerPositionPre The TriggerPositionPre value. | ||
| 806 | + /// \param triggerPositionPost The TriggerPositionPost value. | ||
| 807 | + /// \param usedPre The TriggerPositionUsedPre value. | ||
| 808 | + /// \param usedPost The TriggerPositionUsedPost value. | ||
| 809 | + /// \param largeBuffer The largeBuffer state. | ||
| 810 | + /// \param slowBuffer The slowBuffer state. | ||
| 811 | + BulkSetBuffer2250::BulkSetBuffer2250(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, bool largeBuffer, bool slowBuffer) : Helper::DataArray<unsigned char>(10) { | ||
| 812 | + this->init(); | ||
| 813 | + | ||
| 814 | + this->setTriggerPositionPre(triggerPositionPre); | ||
| 815 | + this->setTriggerPositionPost(triggerPositionPost); | ||
| 816 | + this->setUsedPre(usedPre); | ||
| 817 | + this->setUsedPost(usedPost); | ||
| 818 | + this->setLargeBuffer(largeBuffer); | ||
| 819 | + this->setSlowBuffer(slowBuffer); | ||
| 820 | + } | ||
| 821 | + | ||
| 822 | + /// \brief Get the TriggerPositionPre value. | ||
| 823 | + /// \return The TriggerPositionPre value. | ||
| 824 | + unsigned short int BulkSetBuffer2250::getTriggerPositionPre() { | ||
| 825 | + return (unsigned short int) this->array[2] | ((unsigned short int) this->array[3] << 8); | ||
| 826 | + } | ||
| 827 | + | ||
| 828 | + /// \brief Set the TriggerPositionPre to the given value. | ||
| 829 | + /// \param position The new TriggerPositionPre value. | ||
| 830 | + void BulkSetBuffer2250::setTriggerPositionPre(unsigned short int position) { | ||
| 831 | + this->array[2] = (unsigned char) position; | ||
| 832 | + this->array[3] = (unsigned char) (position >> 8); | ||
| 833 | + } | ||
| 834 | + | ||
| 835 | + /// \brief Get the TriggerPositionPost value. | ||
| 836 | + /// \return The TriggerPositionPost value. | ||
| 837 | + unsigned short int BulkSetBuffer2250::getTriggerPositionPost() { | ||
| 838 | + return (unsigned short int) this->array[6] | ((unsigned short int) this->array[7] << 8); | ||
| 839 | + } | ||
| 840 | + | ||
| 841 | + /// \brief Set the TriggerPositionPost to the given value. | ||
| 842 | + /// \param position The new TriggerPositionPost value. | ||
| 843 | + void BulkSetBuffer2250::setTriggerPositionPost(unsigned short int position) { | ||
| 844 | + this->array[6] = (unsigned char) position; | ||
| 845 | + this->array[7] = (unsigned char) (position >> 8); | ||
| 846 | + } | ||
| 847 | + | ||
| 848 | + /// \brief Get the TriggerPositionUsedPre value. | ||
| 849 | + /// \return The ::DTriggerPositionUsed value for the pre position. | ||
| 850 | + unsigned char BulkSetBuffer2250::getUsedPre() { | ||
| 851 | + return ((FBuffer1Bits *) &(this->array[4]))->triggerPositionUsed; | ||
| 852 | + } | ||
| 853 | + | ||
| 854 | + /// \brief Set the TriggerPositionUsedPre to the given value. | ||
| 855 | + /// \param value The new ::DTriggerPositionUsed value for the pre position. | ||
| 856 | + void BulkSetBuffer2250::setUsedPre(unsigned char value) { | ||
| 857 | + ((FBuffer1Bits *) &(this->array[4]))->triggerPositionUsed = value; | ||
| 858 | + } | ||
| 859 | + | ||
| 860 | + /// \brief Get the TriggerPositionUsedPost value. | ||
| 861 | + /// \return The ::DTriggerPositionUsed value for the post position. | ||
| 862 | + unsigned char BulkSetBuffer2250::getUsedPost() { | ||
| 863 | + return ((FBuffer1Bits *) &(this->array[8]))->triggerPositionUsed; | ||
| 864 | + } | ||
| 865 | + | ||
| 866 | + /// \brief Set the TriggerPositionUsedPost to the given value. | ||
| 867 | + /// \param value The new ::DTriggerPositionUsed value for the post position. | ||
| 868 | + void BulkSetBuffer2250::setUsedPost(unsigned char value) { | ||
| 869 | + ((FBuffer1Bits *) &(this->array[8]))->triggerPositionUsed = value; | ||
| 870 | + } | ||
| 871 | + | ||
| 872 | + /// \brief Get the largeBuffer state in FBuffer1Bits. | ||
| 873 | + /// \return The largeBuffer state. | ||
| 874 | + bool BulkSetBuffer2250::getLargeBuffer() { | ||
| 875 | + return ((FBuffer1Bits *) &(this->array[2]))->largeBuffer == 0; | ||
| 876 | + } | ||
| 877 | + | ||
| 878 | + /// \brief Set the largeBuffer in FBuffer1Bits to the given state. | ||
| 879 | + /// \param largeBuffer The new largeBuffer state. | ||
| 880 | + void BulkSetBuffer2250::setLargeBuffer(bool largeBuffer) { | ||
| 881 | + ((FBuffer1Bits *) &(this->array[2]))->largeBuffer = largeBuffer ? 0 : 1; | ||
| 882 | + } | ||
| 883 | + | ||
| 884 | + /// \brief Get the slowBuffer state in FBuffer2Bits. | ||
| 885 | + /// \return The slowBuffer state. | ||
| 886 | + bool BulkSetBuffer2250::getSlowBuffer() { | ||
| 887 | + return ((FBuffer2Bits *) &(this->array[2]))->slowBuffer == 1; | ||
| 888 | + } | ||
| 889 | + | ||
| 890 | + /// \brief Set the slowBuffer in FBuffer2Bits to the given state. | ||
| 891 | + /// \param slowBuffer The new slowBuffer state. | ||
| 892 | + void BulkSetBuffer2250::setSlowBuffer(bool slowBuffer) { | ||
| 893 | + ((FBuffer2Bits *) &(this->array[2]))->slowBuffer = slowBuffer ? 1 : 0; | ||
| 894 | + } | ||
| 895 | + | ||
| 896 | + /// \brief Initialize the array to the needed values. | ||
| 897 | + void BulkSetBuffer2250::init() { | ||
| 898 | + this->array[0] = BULK_FSETBUFFER; | ||
| 899 | + } | ||
| 900 | + | ||
| 901 | + | ||
| 902 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 903 | + // class ControlGetSpeed | ||
| 904 | + /// \brief Initializes the array. | ||
| 905 | + ControlGetSpeed::ControlGetSpeed() : Helper::DataArray<unsigned char>(10) { | ||
| 906 | + } | ||
| 907 | + | ||
| 908 | + /// \brief Gets the speed of the connection. | ||
| 909 | + /// \return The speed level of the USB connection. | ||
| 910 | + ConnectionSpeed ControlGetSpeed::getSpeed() { | ||
| 911 | + return (ConnectionSpeed) this->array[0]; | ||
| 912 | + } | ||
| 913 | + | ||
| 914 | + | ||
| 915 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 916 | + // class ControlBeginCommand | ||
| 917 | + /// \brief Sets the command index to the given value. | ||
| 918 | + /// \param index The CommandIndex for the command. | ||
| 919 | + ControlBeginCommand::ControlBeginCommand(BulkIndex index) : Helper::DataArray<unsigned char>(10) { | ||
| 920 | + this->init(); | ||
| 921 | + | ||
| 922 | + this->setIndex(index); | ||
| 923 | + } | ||
| 924 | + | ||
| 925 | + /// \brief Gets the command index. | ||
| 926 | + /// \return The CommandIndex for the command. | ||
| 927 | + BulkIndex ControlBeginCommand::getIndex() { | ||
| 928 | + return (BulkIndex) this->array[1]; | ||
| 929 | + } | ||
| 930 | + | ||
| 931 | + /// \brief Sets the command index to the given value. | ||
| 932 | + /// \param index The new CommandIndex for the command. | ||
| 933 | + void ControlBeginCommand::setIndex(BulkIndex index) { | ||
| 934 | + memset(&(this->array[1]), (unsigned char) index, 3); | ||
| 935 | + } | ||
| 936 | + | ||
| 937 | + /// \brief Initialize the array to the needed values. | ||
| 938 | + void ControlBeginCommand::init() { | ||
| 939 | + this->array[0] = 0x0f; | ||
| 940 | + } | ||
| 941 | + | ||
| 942 | + | ||
| 943 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 944 | + // class ControlSetOffset | ||
| 945 | + /// \brief Sets the data array to the default values. | ||
| 946 | + ControlSetOffset::ControlSetOffset() : Helper::DataArray<unsigned char>(17) { | ||
| 947 | + } | ||
| 948 | + | ||
| 949 | + /// \brief Sets the offsets to the given values. | ||
| 950 | + /// \param channel1 The offset for channel 1. | ||
| 951 | + /// \param channel2 The offset for channel 2. | ||
| 952 | + /// \param trigger The offset for ext. trigger. | ||
| 953 | + ControlSetOffset::ControlSetOffset(unsigned short int channel1, unsigned short int channel2, unsigned short int trigger) : Helper::DataArray<unsigned char>(17) { | ||
| 954 | + this->setChannel(0, channel1); | ||
| 955 | + this->setChannel(1, channel2); | ||
| 956 | + this->setTrigger(trigger); | ||
| 957 | + } | ||
| 958 | + | ||
| 959 | + /// \brief Get the offset for the given channel. | ||
| 960 | + /// \param channel The channel whose offset should be returned. | ||
| 961 | + /// \return The channel offset value. | ||
| 962 | + unsigned short int ControlSetOffset::getChannel(unsigned int channel) { | ||
| 963 | + if(channel == 0) | ||
| 964 | + return ((this->array[0] & 0x0f) << 8) | this->array[1]; | ||
| 965 | + else | ||
| 966 | + return ((this->array[2] & 0x0f) << 8) | this->array[3]; | ||
| 967 | + } | ||
| 968 | + | ||
| 969 | + /// \brief Set the offset for the given channel. | ||
| 970 | + /// \param channel The channel that should be set. | ||
| 971 | + /// \param offset The new channel offset value. | ||
| 972 | + void ControlSetOffset::setChannel(unsigned int channel, unsigned short int offset) { | ||
| 973 | + if(channel == 0) { | ||
| 974 | + this->array[0] = (unsigned char) (offset >> 8); | ||
| 975 | + this->array[1] = (unsigned char) offset; | ||
| 976 | + } | ||
| 977 | + else { | ||
| 978 | + this->array[2] = (unsigned char) (offset >> 8); | ||
| 979 | + this->array[3] = (unsigned char) offset; | ||
| 980 | + } | ||
| 981 | + } | ||
| 982 | + | ||
| 983 | + /// \brief Get the trigger level. | ||
| 984 | + /// \return The trigger level value. | ||
| 985 | + unsigned short int ControlSetOffset::getTrigger() { | ||
| 986 | + return ((this->array[4] & 0x0f) << 8) | this->array[5]; | ||
| 987 | + } | ||
| 988 | + | ||
| 989 | + /// \brief Set the trigger level. | ||
| 990 | + /// \param level The new trigger level value. | ||
| 991 | + void ControlSetOffset::setTrigger(unsigned short int level) { | ||
| 992 | + this->array[4] = (unsigned char) (level >> 8); | ||
| 993 | + this->array[5] = (unsigned char) level; | ||
| 994 | + } | ||
| 995 | + | ||
| 996 | + | ||
| 997 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 998 | + // class ControlSetRelays | ||
| 999 | + /// \brief Sets all relay states. | ||
| 1000 | + /// \param ch1Below1V Sets the state of the Channel 1 below 1 V relay. | ||
| 1001 | + /// \param ch1Below100mV Sets the state of the Channel 1 below 100 mV relay. | ||
| 1002 | + /// \param ch1CouplingDC Sets the state of the Channel 1 coupling relay. | ||
| 1003 | + /// \param ch2Below1V Sets the state of the Channel 2 below 1 V relay. | ||
| 1004 | + /// \param ch2Below100mV Sets the state of the Channel 2 below 100 mV relay. | ||
| 1005 | + /// \param ch2CouplingDC Sets the state of the Channel 2 coupling relay. | ||
| 1006 | + /// \param triggerExt Sets the state of the external trigger relay. | ||
| 1007 | + ControlSetRelays::ControlSetRelays(bool ch1Below1V, bool ch1Below100mV, bool ch1CouplingDC, bool ch2Below1V, bool ch2Below100mV, bool ch2CouplingDC, bool triggerExt) : Helper::DataArray<unsigned char>(17) { | ||
| 1008 | + this->setBelow1V(0, ch1Below1V); | ||
| 1009 | + this->setBelow100mV(0, ch1Below100mV); | ||
| 1010 | + this->setCoupling(0, ch1CouplingDC); | ||
| 1011 | + this->setBelow1V(1, ch2Below1V); | ||
| 1012 | + this->setBelow100mV(1, ch2Below100mV); | ||
| 1013 | + this->setCoupling(1, ch2CouplingDC); | ||
| 1014 | + this->setTrigger(triggerExt); | ||
| 1015 | + } | ||
| 1016 | + | ||
| 1017 | + /// \brief Get the below 1 V relay state for the given channel. | ||
| 1018 | + /// \param channel The channel whose relay state should be returned. | ||
| 1019 | + /// \return true, if the gain of the channel is below 1 V. | ||
| 1020 | + bool ControlSetRelays::getBelow1V(unsigned int channel) { | ||
| 1021 | + if(channel == 0) | ||
| 1022 | + return (this->array[1] & 0x04) == 0x00; | ||
| 1023 | + else | ||
| 1024 | + return (this->array[4] & 0x20) == 0x00; | ||
| 1025 | + } | ||
| 1026 | + | ||
| 1027 | + /// \brief Set the below 1 V relay for the given channel. | ||
| 1028 | + /// \param channel The channel that should be set. | ||
| 1029 | + /// \param below true, if the gain of the channel should be below 1 V. | ||
| 1030 | + void ControlSetRelays::setBelow1V(unsigned int channel, bool below) { | ||
| 1031 | + if(channel == 0) | ||
| 1032 | + this->array[1] = below ? 0xfb : 0x04; | ||
| 1033 | + else | ||
| 1034 | + this->array[4] = below ? 0xdf : 0x20; | ||
| 1035 | + } | ||
| 1036 | + | ||
| 1037 | + /// \brief Get the below 1 V relay state for the given channel. | ||
| 1038 | + /// \param channel The channel whose relay state should be returned. | ||
| 1039 | + /// \return true, if the gain of the channel is below 1 V. | ||
| 1040 | + bool ControlSetRelays::getBelow100mV(unsigned int channel) { | ||
| 1041 | + if(channel == 0) | ||
| 1042 | + return (this->array[2] & 0x08) == 0x00; | ||
| 1043 | + else | ||
| 1044 | + return (this->array[5] & 0x40) == 0x00; | ||
| 1045 | + } | ||
| 1046 | + | ||
| 1047 | + /// \brief Set the below 100 mV relay for the given channel. | ||
| 1048 | + /// \param channel The channel that should be set. | ||
| 1049 | + /// \param below true, if the gain of the channel should be below 100 mV. | ||
| 1050 | + void ControlSetRelays::setBelow100mV(unsigned int channel, bool below) { | ||
| 1051 | + if(channel == 0) | ||
| 1052 | + this->array[2] = below ? 0xf7 : 0x08; | ||
| 1053 | + else | ||
| 1054 | + this->array[5] = below ? 0xbf : 0x40; | ||
| 1055 | + } | ||
| 1056 | + | ||
| 1057 | + /// \brief Get the coupling relay state for the given channel. | ||
| 1058 | + /// \param channel The channel whose relay state should be returned. | ||
| 1059 | + /// \return true, if the coupling of the channel is DC. | ||
| 1060 | + bool ControlSetRelays::getCoupling(unsigned int channel) { | ||
| 1061 | + if(channel == 0) | ||
| 1062 | + return (this->array[3] & 0x02) == 0x00; | ||
| 1063 | + else | ||
| 1064 | + return (this->array[6] & 0x10) == 0x00; | ||
| 1065 | + } | ||
| 1066 | + | ||
| 1067 | + /// \brief Set the coupling relay for the given channel. | ||
| 1068 | + /// \param channel The channel that should be set. | ||
| 1069 | + /// \param dc true, if the coupling of the channel should be DC. | ||
| 1070 | + void ControlSetRelays::setCoupling(unsigned int channel, bool dc) { | ||
| 1071 | + if(channel == 0) | ||
| 1072 | + this->array[3] = dc ? 0xfd : 0x02; | ||
| 1073 | + else | ||
| 1074 | + this->array[6] = dc ? 0xef : 0x10; | ||
| 1075 | + } | ||
| 1076 | + | ||
| 1077 | + /// \brief Get the external trigger relay state. | ||
| 1078 | + /// \return true, if the trigger is external (EXT-Connector). | ||
| 1079 | + bool ControlSetRelays::getTrigger() { | ||
| 1080 | + return (this->array[7] & 0x01) == 0x00; | ||
| 1081 | + } | ||
| 1082 | + | ||
| 1083 | + /// \brief Set the external trigger relay. | ||
| 1084 | + /// \param ext true, if the trigger should be external (EXT-Connector). | ||
| 1085 | + void ControlSetRelays::setTrigger(bool ext) { | ||
| 1086 | + this->array[7] = ext ? 0xfe : 0x01; | ||
| 1087 | + } | ||
| 795 | } | 1088 | } |
openhantek/src/hantek/types.h
| @@ -51,7 +51,7 @@ namespace Hantek { | @@ -51,7 +51,7 @@ namespace Hantek { | ||
| 51 | /// \brief All supported bulk commands. | 51 | /// \brief All supported bulk commands. |
| 52 | /// Indicies given in square brackets specify byte numbers in little endian format. | 52 | /// Indicies given in square brackets specify byte numbers in little endian format. |
| 53 | enum BulkCode { | 53 | enum BulkCode { |
| 54 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 54 | + /// BulkSetFilter [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 55 | /// <p> | 55 | /// <p> |
| 56 | /// This command sets channel and trigger filter: | 56 | /// This command sets channel and trigger filter: |
| 57 | /// <table> | 57 | /// <table> |
| @@ -70,7 +70,7 @@ namespace Hantek { | @@ -70,7 +70,7 @@ namespace Hantek { | ||
| 70 | /// <p><br /></p> | 70 | /// <p><br /></p> |
| 71 | BULK_SETFILTER, | 71 | BULK_SETFILTER, |
| 72 | 72 | ||
| 73 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150]</em> | 73 | + /// BulkSetTriggerAndSamplerate [<em>::MODEL_DSO2090, ::MODEL_DSO2150</em>] |
| 74 | /// <p> | 74 | /// <p> |
| 75 | /// This command sets trigger and timebase: | 75 | /// This command sets trigger and timebase: |
| 76 | /// <table> | 76 | /// <table> |
| @@ -99,7 +99,7 @@ namespace Hantek { | @@ -99,7 +99,7 @@ namespace Hantek { | ||
| 99 | /// Without using fast rate mode, the samplerate is:<br /> | 99 | /// Without using fast rate mode, the samplerate is:<br /> |
| 100 | /// <i>Samplerate = SamplerateMax / (1comp(SamplerateSlow) * 2 + Tsr1Bits.samplerateFast)</i><br /> | 100 | /// <i>Samplerate = SamplerateMax / (1comp(SamplerateSlow) * 2 + Tsr1Bits.samplerateFast)</i><br /> |
| 101 | /// SamplerateMax is 50 MHz for the DSO-2090.<br /> | 101 | /// SamplerateMax is 50 MHz for the DSO-2090.<br /> |
| 102 | - /// When using fast rate mode the resulting samplerate is twice (For DSO-2150 three times) as fast, when using the large buffer it is half as fast. When Tsr1Bits.bufferSize is 0 (Roll mode) the sampling rate is divided by 1000. Setting Tsr1Bits.samplerateFast to 0 doesn't work, the result will be the same as Tsr1Bits.samplerateFast = 1. SamplerateSlow can't be used together with fast rate mode, the result is always the the same as SlowValue = 0. | 102 | + /// When using fast rate mode the resulting samplerate is twice (For DSO-2150 three times) as fast, when using the large buffer it is half as fast. When Tsr1Bits.recordLength is 0 (Roll mode) the sampling rate is divided by 1000. Setting Tsr1Bits.samplerateFast to 0 doesn't work, the result will be the same as Tsr1Bits.samplerateFast = 1. SamplerateSlow can't be used together with fast rate mode, the result is always the the same as SlowValue = 0. |
| 103 | /// </p> | 103 | /// </p> |
| 104 | /// <p> | 104 | /// <p> |
| 105 | /// The TriggerPosition sets the position of the pretrigger in samples. The left side (0 %) is 0x77660 when using the small buffer and 0x78000 when using the large buffer. | 105 | /// The TriggerPosition sets the position of the pretrigger in samples. The left side (0 %) is 0x77660 when using the small buffer and 0x78000 when using the large buffer. |
| @@ -107,7 +107,7 @@ namespace Hantek { | @@ -107,7 +107,7 @@ namespace Hantek { | ||
| 107 | /// <p><br /></p> | 107 | /// <p><br /></p> |
| 108 | BULK_SETTRIGGERANDSAMPLERATE, | 108 | BULK_SETTRIGGERANDSAMPLERATE, |
| 109 | 109 | ||
| 110 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 110 | + /// BulkForceTrigger [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 111 | /// <p> | 111 | /// <p> |
| 112 | /// This command forces triggering: | 112 | /// This command forces triggering: |
| 113 | /// <table> | 113 | /// <table> |
| @@ -120,7 +120,7 @@ namespace Hantek { | @@ -120,7 +120,7 @@ namespace Hantek { | ||
| 120 | /// <p><br /></p> | 120 | /// <p><br /></p> |
| 121 | BULK_FORCETRIGGER, | 121 | BULK_FORCETRIGGER, |
| 122 | 122 | ||
| 123 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 123 | + /// BulkCaptureStart [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 124 | /// <p> | 124 | /// <p> |
| 125 | /// This command starts to capture data: | 125 | /// This command starts to capture data: |
| 126 | /// <table> | 126 | /// <table> |
| @@ -133,7 +133,7 @@ namespace Hantek { | @@ -133,7 +133,7 @@ namespace Hantek { | ||
| 133 | /// <p><br /></p> | 133 | /// <p><br /></p> |
| 134 | BULK_STARTSAMPLING, | 134 | BULK_STARTSAMPLING, |
| 135 | 135 | ||
| 136 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 136 | + /// BulkTriggerEnabled [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 137 | /// <p> | 137 | /// <p> |
| 138 | /// This command sets the trigger: | 138 | /// This command sets the trigger: |
| 139 | /// <table> | 139 | /// <table> |
| @@ -146,7 +146,7 @@ namespace Hantek { | @@ -146,7 +146,7 @@ namespace Hantek { | ||
| 146 | /// <p><br /></p> | 146 | /// <p><br /></p> |
| 147 | BULK_ENABLETRIGGER, | 147 | BULK_ENABLETRIGGER, |
| 148 | 148 | ||
| 149 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 149 | + /// BulkGetData [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 150 | /// <p> | 150 | /// <p> |
| 151 | /// This command reads data from the hardware: | 151 | /// This command reads data from the hardware: |
| 152 | /// <table> | 152 | /// <table> |
| @@ -194,7 +194,7 @@ namespace Hantek { | @@ -194,7 +194,7 @@ namespace Hantek { | ||
| 194 | /// <p><br /></p> | 194 | /// <p><br /></p> |
| 195 | BULK_GETDATA, | 195 | BULK_GETDATA, |
| 196 | 196 | ||
| 197 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 197 | + /// BulkGetCaptureState [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 198 | /// <p> | 198 | /// <p> |
| 199 | /// This command checks the capture state: | 199 | /// This command checks the capture state: |
| 200 | /// <table> | 200 | /// <table> |
| @@ -219,7 +219,7 @@ namespace Hantek { | @@ -219,7 +219,7 @@ namespace Hantek { | ||
| 219 | /// <p><br /></p> | 219 | /// <p><br /></p> |
| 220 | BULK_GETCAPTURESTATE, | 220 | BULK_GETCAPTURESTATE, |
| 221 | 221 | ||
| 222 | - /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 222 | + /// BulkSetGain [<em>::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A</em>] |
| 223 | /// <p> | 223 | /// <p> |
| 224 | /// This command sets the gain: | 224 | /// This command sets the gain: |
| 225 | /// <table> | 225 | /// <table> |
| @@ -239,9 +239,9 @@ namespace Hantek { | @@ -239,9 +239,9 @@ namespace Hantek { | ||
| 239 | /// <p><br /></p> | 239 | /// <p><br /></p> |
| 240 | BULK_SETGAIN, | 240 | BULK_SETGAIN, |
| 241 | 241 | ||
| 242 | - /// <em>[]</em> | 242 | + /// BulkSetLogicalData [<em></em>] |
| 243 | /// <p> | 243 | /// <p> |
| 244 | - /// This command sets the logical data (Not used in official Hantek software): | 244 | + /// This command sets the logical data (Not used in official %Hantek software): |
| 245 | /// <table> | 245 | /// <table> |
| 246 | /// <tr> | 246 | /// <tr> |
| 247 | /// <td>0x08</td> | 247 | /// <td>0x08</td> |
| @@ -258,9 +258,9 @@ namespace Hantek { | @@ -258,9 +258,9 @@ namespace Hantek { | ||
| 258 | /// <p><br /></p> | 258 | /// <p><br /></p> |
| 259 | BULK_SETLOGICALDATA, | 259 | BULK_SETLOGICALDATA, |
| 260 | 260 | ||
| 261 | - /// <em>[::MODEL_DSO2250]</em> | 261 | + /// BulkGetLogicalData [<em></em>] |
| 262 | /// <p> | 262 | /// <p> |
| 263 | - /// This command reads the logical data (Not used in official Hantek software): | 263 | + /// This command reads the logical data (Not used in official %Hantek software): |
| 264 | /// <table> | 264 | /// <table> |
| 265 | /// <tr> | 265 | /// <tr> |
| 266 | /// <td>0x09</td> | 266 | /// <td>0x09</td> |
| @@ -280,7 +280,7 @@ namespace Hantek { | @@ -280,7 +280,7 @@ namespace Hantek { | ||
| 280 | /// <p><br /></p> | 280 | /// <p><br /></p> |
| 281 | BULK_GETLOGICALDATA, | 281 | BULK_GETLOGICALDATA, |
| 282 | 282 | ||
| 283 | - /// <em>[]</em> | 283 | + /// [<em></em>] |
| 284 | /// <p> | 284 | /// <p> |
| 285 | /// This command isn't used for any supported model: | 285 | /// This command isn't used for any supported model: |
| 286 | /// <table> | 286 | /// <table> |
| @@ -291,24 +291,41 @@ namespace Hantek { | @@ -291,24 +291,41 @@ namespace Hantek { | ||
| 291 | /// </table> | 291 | /// </table> |
| 292 | /// </p> | 292 | /// </p> |
| 293 | /// <p><br /></p> | 293 | /// <p><br /></p> |
| 294 | - BULK_UNKNOWN_0A, | 294 | + BULK_AUNKNOWN, |
| 295 | 295 | ||
| 296 | - /// <em>[::MODEL_DSO2250]</em> | 296 | + /// BulkSetFilter2250 [<em>::MODEL_DSO2250</em>] |
| 297 | /// <p> | 297 | /// <p> |
| 298 | - /// This command is used for the DSO-2250: | 298 | + /// This command sets the activated channels for the DSO-2250: |
| 299 | /// <table> | 299 | /// <table> |
| 300 | /// <tr> | 300 | /// <tr> |
| 301 | /// <td>0x0b</td> | 301 | /// <td>0x0b</td> |
| 302 | /// <td>0x00</td> | 302 | /// <td>0x00</td> |
| 303 | - /// <td>(unknown)</td> | 303 | + /// <td>::UsedChannels</td> |
| 304 | /// <td>0x00</td> | 304 | /// <td>0x00</td> |
| 305 | /// </tr> | 305 | /// </tr> |
| 306 | /// </table> | 306 | /// </table> |
| 307 | /// </p> | 307 | /// </p> |
| 308 | /// <p><br /></p> | 308 | /// <p><br /></p> |
| 309 | - BULK_UNKNOWN_0B, | 309 | + BULK_BSETFILTER, |
| 310 | 310 | ||
| 311 | - /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 311 | + /// BulkSetTrigger2250 [<em>::MODEL_DSO2250</em>] |
| 312 | + /// <p> | ||
| 313 | + /// This command sets the trigger source for the DSO-2250: | ||
| 314 | + /// <table> | ||
| 315 | + /// <tr> | ||
| 316 | + /// <td>0x0c</td> | ||
| 317 | + /// <td>0x0f</td> | ||
| 318 | + /// <td>CTriggerBits</td> | ||
| 319 | + /// <td>0x00</td> | ||
| 320 | + /// <td>0x02</td> | ||
| 321 | + /// <td>0x00</td> | ||
| 322 | + /// <td>0x00</td> | ||
| 323 | + /// <td>0x00</td> | ||
| 324 | + /// </tr> | ||
| 325 | + /// </table> | ||
| 326 | + /// </p> | ||
| 327 | + /// <p><br /></p> | ||
| 328 | + /// BulkSetSamplerate5200 [<em>::MODEL_DSO5200, ::MODEL_DSO5200A</em>] | ||
| 312 | /// <p> | 329 | /// <p> |
| 313 | /// This command sets the sampling rate for the DSO-5200: | 330 | /// This command sets the sampling rate for the DSO-5200: |
| 314 | /// <table> | 331 | /// <table> |
| @@ -325,14 +342,27 @@ namespace Hantek { | @@ -325,14 +342,27 @@ namespace Hantek { | ||
| 325 | /// <p> | 342 | /// <p> |
| 326 | /// The values are similar to the ones used with ::BULK_SETTRIGGERANDSAMPLERATE. The formula is a bit different here:<br /> | 343 | /// The values are similar to the ones used with ::BULK_SETTRIGGERANDSAMPLERATE. The formula is a bit different here:<br /> |
| 327 | /// <i>Samplerate = SamplerateMax / (2comp(SamplerateSlow) * 2 + 4 - SamplerateFast)</i><br /> | 344 | /// <i>Samplerate = SamplerateMax / (2comp(SamplerateSlow) * 2 + 4 - SamplerateFast)</i><br /> |
| 328 | - /// SamplerateMax is 100 MS/s for the DSO-5200 in default configuration and 250 MS/s in fast rate mode though, the modifications regarding buffer size are the the same that apply for the DSO-2090. | 345 | + /// SamplerateMax is 100 MS/s for the DSO-5200 in default configuration and 250 MS/s in fast rate mode though, the modifications regarding record length are the the same that apply for the DSO-2090. |
| 329 | /// </p> | 346 | /// </p> |
| 330 | /// <p><br /></p> | 347 | /// <p><br /></p> |
| 331 | - BULK_SETSAMPLERATE5200, | ||
| 332 | - | ||
| 333 | - /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 348 | + BULK_CSETTRIGGERORSAMPLERATE, |
| 349 | + | ||
| 350 | + /// BulkSetRecordLength2250 [<em>::MODEL_DSO2250</em>] | ||
| 351 | + /// <p> | ||
| 352 | + /// This command sets the record length for the DSO-2250: | ||
| 353 | + /// <table> | ||
| 354 | + /// <tr> | ||
| 355 | + /// <td>0x0d</td> | ||
| 356 | + /// <td>0x00</td> | ||
| 357 | + /// <td>::RecordLengthId</td> | ||
| 358 | + /// <td>0x00</td> | ||
| 359 | + /// </tr> | ||
| 360 | + /// </table> | ||
| 361 | + /// </p> | ||
| 362 | + /// <p><br /></p> | ||
| 363 | + /// BulkSetBuffer5200 [<em>::MODEL_DSO5200, ::MODEL_DSO5200A</em>] | ||
| 334 | /// <p> | 364 | /// <p> |
| 335 | - /// This command sets the trigger position and buffer size for the DSO-5200: | 365 | + /// This command sets the trigger position and record length for the DSO-5200: |
| 336 | /// <table> | 366 | /// <table> |
| 337 | /// <tr> | 367 | /// <tr> |
| 338 | /// <td>0x0d</td> | 368 | /// <td>0x0d</td> |
| @@ -356,18 +386,40 @@ namespace Hantek { | @@ -356,18 +386,40 @@ namespace Hantek { | ||
| 356 | /// The TriggerPositionPre and TriggerPositionPost values set the pretrigger position. Both values have a range from 0xd7ff (0xc7ff for 14 kiS buffer) to 0xfffe. On the left side (0 %) the TriggerPositionPre value is minimal, on the right side (100 %) it is maximal. The TriggerPositionPost value is maximal for 0 % and minimal for 100%. | 386 | /// The TriggerPositionPre and TriggerPositionPost values set the pretrigger position. Both values have a range from 0xd7ff (0xc7ff for 14 kiS buffer) to 0xfffe. On the left side (0 %) the TriggerPositionPre value is minimal, on the right side (100 %) it is maximal. The TriggerPositionPost value is maximal for 0 % and minimal for 100%. |
| 357 | /// </p> | 387 | /// </p> |
| 358 | /// <p><br /></p> | 388 | /// <p><br /></p> |
| 359 | - BULK_SETBUFFER5200, | 389 | + BULK_DSETBUFFER, |
| 360 | 390 | ||
| 361 | - /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 391 | + /// BulkSetSamplerate2250 [<em>::MODEL_DSO2250</em>] |
| 392 | + /// <p> | ||
| 393 | + /// This command sets the samplerate: | ||
| 394 | + /// <table> | ||
| 395 | + /// <tr> | ||
| 396 | + /// <td>0x0e</td> | ||
| 397 | + /// <td>0x00</td> | ||
| 398 | + /// <td>ESamplerateBits</td> | ||
| 399 | + /// <td>0x00</td> | ||
| 400 | + /// <td>SamplerateSlow[0]</td> | ||
| 401 | + /// <td>SamplerateSlow[1]</td> | ||
| 402 | + /// <td>0x00</td> | ||
| 403 | + /// <td>0x00</td> | ||
| 404 | + /// </tr> | ||
| 405 | + /// </table> | ||
| 406 | + /// </p> | ||
| 362 | /// <p> | 407 | /// <p> |
| 363 | - /// This command sets the channel and trigger settings for the DSO-5200: | 408 | + /// The values are similar to the ones used with ::BULK_SETTRIGGERANDSAMPLERATE. The formula is a bit different here:<br /> |
| 409 | + /// <i>Samplerate = SamplerateMax / (2comp(SamplerateSlow) * 2 + ESamplerateBits.samplerateFast)</i><br /> | ||
| 410 | + /// SamplerateMax is 100 MS/s for the DSO-2250 in default configuration and 250 MS/s in fast rate mode though, the modifications regarding record length are the the same that apply for the DSO-2090. | ||
| 411 | + /// </p> | ||
| 412 | + /// <p><br /></p> | ||
| 413 | + /// BulkSetTrigger5200 [<em>::MODEL_DSO5200, ::MODEL_DSO5200A</em>] | ||
| 414 | + /// <p> | ||
| 415 | + /// This command sets the channel and trigger settings: | ||
| 364 | /// <table> | 416 | /// <table> |
| 365 | /// <tr> | 417 | /// <tr> |
| 366 | /// <td>0x0e</td> | 418 | /// <td>0x0e</td> |
| 367 | /// <td>0x00</td> | 419 | /// <td>0x00</td> |
| 368 | /// <td>ETsrBits</td> | 420 | /// <td>ETsrBits</td> |
| 369 | /// <td>0x00</td> | 421 | /// <td>0x00</td> |
| 370 | - /// <td>Unknown (0x02)</td> | 422 | + /// <td>0x00</td> |
| 371 | /// <td>0x00</td> | 423 | /// <td>0x00</td> |
| 372 | /// <td>0x00</td> | 424 | /// <td>0x00</td> |
| 373 | /// <td>0x00</td> | 425 | /// <td>0x00</td> |
| @@ -375,34 +427,37 @@ namespace Hantek { | @@ -375,34 +427,37 @@ namespace Hantek { | ||
| 375 | /// </table> | 427 | /// </table> |
| 376 | /// </p> | 428 | /// </p> |
| 377 | /// <p><br /></p> | 429 | /// <p><br /></p> |
| 378 | - BULK_SETTRIGGER5200, | 430 | + BULK_ESETTRIGGERORSAMPLERATE, |
| 379 | 431 | ||
| 380 | - /// <em>[::MODEL_DSO2250]</em> | 432 | + /// BulkSetBuffer2250 [<em>::MODEL_DSO2250</em>] |
| 381 | /// <p> | 433 | /// <p> |
| 382 | - /// This command is used for the DSO-2250: | 434 | + /// This command sets the trigger position and buffer configuration for the DSO-2250: |
| 383 | /// <table> | 435 | /// <table> |
| 384 | /// <tr> | 436 | /// <tr> |
| 385 | /// <td>0x0f</td> | 437 | /// <td>0x0f</td> |
| 386 | /// <td>0x00</td> | 438 | /// <td>0x00</td> |
| 387 | - /// <td>(unknown)</td> | ||
| 388 | - /// <td>(unknown)</td> | ||
| 389 | - /// <td>(unknown)</td> | ||
| 390 | - /// <td>(unknown)</td> | 439 | + /// <td>TriggerPositionPre[0]</td> |
| 440 | + /// <td>TriggerPositionPre[1]</td> | ||
| 441 | + /// <td>FBuffer1Bits</td> | ||
| 442 | + /// <td>0x00</td> | ||
| 391 | /// </tr> | 443 | /// </tr> |
| 392 | /// </table> | 444 | /// </table> |
| 393 | /// <table> | 445 | /// <table> |
| 394 | /// <tr> | 446 | /// <tr> |
| 395 | - /// <td>(unknown)</td> | ||
| 396 | - /// <td>(unknown)</td> | ||
| 397 | - /// <td>(unknown)</td> | ||
| 398 | - /// <td>(unknown)</td> | ||
| 399 | - /// <td>(unknown)</td> | ||
| 400 | - /// <td>(unknown)</td> | 447 | + /// <td>TriggerPositionPost[0]</td> |
| 448 | + /// <td>TriggerPositionPost[1]</td> | ||
| 449 | + /// <td>FBuffer1Bits</td> | ||
| 450 | + /// <td>0x00</td> | ||
| 451 | + /// <td>FBuffer2Bits</td> | ||
| 452 | + /// <td>0x00</td> | ||
| 401 | /// </tr> | 453 | /// </tr> |
| 402 | /// </table> | 454 | /// </table> |
| 403 | /// </p> | 455 | /// </p> |
| 456 | + /// <p> | ||
| 457 | + /// The TriggerPositionPre and TriggerPositionPost values set the pretrigger position. Both values have a range from 0xd7ff (0xc7ff for 14 kiS buffer) to 0xfffe. On the left side (0 %) the TriggerPositionPre value is minimal, on the right side (100 %) it is maximal. The TriggerPositionPost value is maximal for 0 % and minimal for 100%. | ||
| 458 | + /// </p> | ||
| 404 | /// <p><br /></p> | 459 | /// <p><br /></p> |
| 405 | - BULK_UNKNOWN_0F, | 460 | + BULK_FSETBUFFER, |
| 406 | 461 | ||
| 407 | BULK_COUNT | 462 | BULK_COUNT |
| 408 | }; | 463 | }; |
| @@ -556,14 +611,14 @@ namespace Hantek { | @@ -556,14 +611,14 @@ namespace Hantek { | ||
| 556 | /// Value 0x60 is the calibration data for the fast rate mode on the DSO-2250, DSO-5200 and DSO-5200A. It's used to correct the level differences between the two merged channels to avoid deterministic noise. | 611 | /// Value 0x60 is the calibration data for the fast rate mode on the DSO-2250, DSO-5200 and DSO-5200A. It's used to correct the level differences between the two merged channels to avoid deterministic noise. |
| 557 | /// </p> | 612 | /// </p> |
| 558 | /// <p><br /></p> | 613 | /// <p><br /></p> |
| 559 | - VALUE_CALIBRATIONDATA = 0x60, | 614 | + VALUE_FASTRATECALIBRATION = 0x60, |
| 560 | 615 | ||
| 561 | /// <em>[::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | 616 | /// <em>[::MODEL_DSO5200, ::MODEL_DSO5200A]</em> |
| 562 | /// <p> | 617 | /// <p> |
| 563 | /// Value 0x70 contains correction values for the ETS functionality of the DSO-5200 and DSO-5200A. | 618 | /// Value 0x70 contains correction values for the ETS functionality of the DSO-5200 and DSO-5200A. |
| 564 | /// </p> | 619 | /// </p> |
| 565 | /// <p><br /></p> | 620 | /// <p><br /></p> |
| 566 | - VALUE_VOLTAGELIMITS = 0x70 | 621 | + VALUE_ETSCORRECTION = 0x70 |
| 567 | }; | 622 | }; |
| 568 | 623 | ||
| 569 | ////////////////////////////////////////////////////////////////////////////// | 624 | ////////////////////////////////////////////////////////////////////////////// |
| @@ -591,8 +646,10 @@ namespace Hantek { | @@ -591,8 +646,10 @@ namespace Hantek { | ||
| 591 | /// \enum UsedChannels hantek/types.h | 646 | /// \enum UsedChannels hantek/types.h |
| 592 | /// \brief The enabled channels. | 647 | /// \brief The enabled channels. |
| 593 | enum UsedChannels { | 648 | enum UsedChannels { |
| 594 | - USED_CH1, USED_CH2, | ||
| 595 | - USED_CH1CH2 | 649 | + USED_CH1, ///< Only channel 1 is activated |
| 650 | + USED_CH2, ///< Only channel 2 is activated | ||
| 651 | + USED_CH1CH2, ///< Channel 1 and 2 are both activated | ||
| 652 | + USED_NONE ///< No channels are activated | ||
| 596 | }; | 653 | }; |
| 597 | 654 | ||
| 598 | ////////////////////////////////////////////////////////////////////////////// | 655 | ////////////////////////////////////////////////////////////////////////////// |
| @@ -605,21 +662,12 @@ namespace Hantek { | @@ -605,21 +662,12 @@ namespace Hantek { | ||
| 605 | }; | 662 | }; |
| 606 | 663 | ||
| 607 | ////////////////////////////////////////////////////////////////////////////// | 664 | ////////////////////////////////////////////////////////////////////////////// |
| 608 | - /// \enum BufferSize hantek/types.h | ||
| 609 | - /// \brief The size of the sample buffer. | ||
| 610 | - enum BufferSize { | ||
| 611 | - BUFFER_SMALL = 10240, | ||
| 612 | - BUFFER_LARGE5200 = 14336, | ||
| 613 | - BUFFER_LARGE = 32768 | ||
| 614 | - }; | ||
| 615 | - | ||
| 616 | - ////////////////////////////////////////////////////////////////////////////// | ||
| 617 | - /// \enum BufferSizeId hantek/types.h | 665 | + /// \enum RecordLengthId hantek/types.h |
| 618 | /// \brief The size id for CommandSetTriggerAndSamplerate. | 666 | /// \brief The size id for CommandSetTriggerAndSamplerate. |
| 619 | - enum BufferSizeId { | ||
| 620 | - BUFFERID_ROLL = 0, ///< Used for the roll mode | ||
| 621 | - BUFFERID_SMALL, ///< The standard buffer with 10240 samples | ||
| 622 | - BUFFERID_LARGE ///< The large buffer, 32768 samples (14336 for DSO-5200) | 667 | + enum RecordLengthId { |
| 668 | + RECORDLENGTHID_ROLL = 0, ///< Used for the roll mode | ||
| 669 | + RECORDLENGTHID_SMALL, ///< The standard buffer with 10240 samples | ||
| 670 | + RECORDLENGTHID_LARGE ///< The large buffer, 32768 samples (14336 for DSO-5200) | ||
| 623 | }; | 671 | }; |
| 624 | 672 | ||
| 625 | ////////////////////////////////////////////////////////////////////////////// | 673 | ////////////////////////////////////////////////////////////////////////////// |
| @@ -662,6 +710,14 @@ namespace Hantek { | @@ -662,6 +710,14 @@ namespace Hantek { | ||
| 662 | }; | 710 | }; |
| 663 | 711 | ||
| 664 | ////////////////////////////////////////////////////////////////////////////// | 712 | ////////////////////////////////////////////////////////////////////////////// |
| 713 | + /// \enum FTriggerPositionUsed hantek/types.h | ||
| 714 | + /// \brief The trigger position states for the 0x0f command. | ||
| 715 | + enum FTriggerPositionUsed { | ||
| 716 | + FTRIGGERPOSITION_OFF = 0, ///< Used for Roll mode | ||
| 717 | + FTRIGGERPOSITION_ON = 3 ///< Used for normal operation | ||
| 718 | + }; | ||
| 719 | + | ||
| 720 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 665 | /// \struct FilterBits hantek/types.h | 721 | /// \struct FilterBits hantek/types.h |
| 666 | /// \brief The bits for BULK_SETFILTER. | 722 | /// \brief The bits for BULK_SETFILTER. |
| 667 | struct FilterBits { | 723 | struct FilterBits { |
| @@ -685,7 +741,7 @@ namespace Hantek { | @@ -685,7 +741,7 @@ namespace Hantek { | ||
| 685 | /// \brief Trigger and samplerate bits (Byte 1). | 741 | /// \brief Trigger and samplerate bits (Byte 1). |
| 686 | struct Tsr1Bits { | 742 | struct Tsr1Bits { |
| 687 | unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource | 743 | unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource |
| 688 | - unsigned char bufferSize:3; ///< See ::BufferSizeId | 744 | + unsigned char recordLength:3; ///< See ::RecordLengthId |
| 689 | unsigned char samplerateFast:3; ///< samplerate value for fast sampling rates | 745 | unsigned char samplerateFast:3; ///< samplerate value for fast sampling rates |
| 690 | }; | 746 | }; |
| 691 | 747 | ||
| @@ -700,17 +756,35 @@ namespace Hantek { | @@ -700,17 +756,35 @@ namespace Hantek { | ||
| 700 | }; | 756 | }; |
| 701 | 757 | ||
| 702 | ////////////////////////////////////////////////////////////////////////////// | 758 | ////////////////////////////////////////////////////////////////////////////// |
| 759 | + /// \struct CTriggerBits hantek/types.h | ||
| 760 | + /// \brief Trigger bits for 0x0c command. | ||
| 761 | + struct CTriggerBits { | ||
| 762 | + unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource | ||
| 763 | + unsigned char triggerSlope:1; ///< The trigger slope, see Dso::Slope | ||
| 764 | + unsigned char reserved:5; ///< Unused bits | ||
| 765 | + }; | ||
| 766 | + | ||
| 767 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 703 | /// \struct DBufferBits hantek/types.h | 768 | /// \struct DBufferBits hantek/types.h |
| 704 | /// \brief Buffer mode bits for 0x0d command. | 769 | /// \brief Buffer mode bits for 0x0d command. |
| 705 | struct DBufferBits { | 770 | struct DBufferBits { |
| 706 | unsigned char triggerPositionUsed:3; ///< See ::DTriggerPositionUsed | 771 | unsigned char triggerPositionUsed:3; ///< See ::DTriggerPositionUsed |
| 707 | - unsigned char bufferSize:3; ///< See ::BufferSizeId | 772 | + unsigned char recordLength:3; ///< See ::RecordLengthId |
| 708 | unsigned char reserved:2; ///< Unused bits | 773 | unsigned char reserved:2; ///< Unused bits |
| 709 | }; | 774 | }; |
| 710 | 775 | ||
| 711 | ////////////////////////////////////////////////////////////////////////////// | 776 | ////////////////////////////////////////////////////////////////////////////// |
| 777 | + /// \struct ESamplerateBits hantek/types.h | ||
| 778 | + /// \brief Samplerate bits for DSO-2250 0x0e command. | ||
| 779 | + struct ESamplerateBits { | ||
| 780 | + unsigned char fastRate:1; ///< false, if one channels uses all buffers | ||
| 781 | + unsigned char samplerateFast:3; ///< samplerate value for fast sampling rates | ||
| 782 | + unsigned char reserved:4; ///< Unused bits | ||
| 783 | + }; | ||
| 784 | + | ||
| 785 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 712 | /// \struct ETsrBits hantek/types.h | 786 | /// \struct ETsrBits hantek/types.h |
| 713 | - /// \brief Trigger and samplerate bits for 0x0e command. | 787 | + /// \brief Trigger and samplerate bits for DSO-5200/DSO-5200A 0x0e command. |
| 714 | struct ETsrBits { | 788 | struct ETsrBits { |
| 715 | unsigned char fastRate:1; ///< false, if one channels uses all buffers | 789 | unsigned char fastRate:1; ///< false, if one channels uses all buffers |
| 716 | unsigned char usedChannels:2; ///< Used channels, see Hantek::UsedChannels | 790 | unsigned char usedChannels:2; ///< Used channels, see Hantek::UsedChannels |
| @@ -720,6 +794,23 @@ namespace Hantek { | @@ -720,6 +794,23 @@ namespace Hantek { | ||
| 720 | }; | 794 | }; |
| 721 | 795 | ||
| 722 | ////////////////////////////////////////////////////////////////////////////// | 796 | ////////////////////////////////////////////////////////////////////////////// |
| 797 | + /// \struct FBuffer1Bits hantek/types.h | ||
| 798 | + /// \brief Buffer mode bits for 0x0f command (Byte 1). | ||
| 799 | + struct FBuffer1Bits { | ||
| 800 | + unsigned char triggerPositionUsed:2; ///< See ::DTriggerPositionUsed | ||
| 801 | + unsigned char largeBuffer:1; ///< false, if ::RecordLengthId is ::RECORDLENGTHID_LARGE | ||
| 802 | + unsigned char reserved:5; ///< Unused bits | ||
| 803 | + }; | ||
| 804 | + | ||
| 805 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 806 | + /// \struct FBuffer2Bits hantek/types.h | ||
| 807 | + /// \brief Buffer mode bits for 0x0f command (Byte 2). | ||
| 808 | + struct FBuffer2Bits { | ||
| 809 | + unsigned char reserved:7; ///< Unused bits | ||
| 810 | + unsigned char slowBuffer:1; ///< false, if ::RecordLengthId is ::RECORDLENGTHID_SMALL | ||
| 811 | + }; | ||
| 812 | + | ||
| 813 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 723 | /// \class BulkSetFilter hantek/types.h | 814 | /// \class BulkSetFilter hantek/types.h |
| 724 | /// \brief The BULK_SETFILTER builder. | 815 | /// \brief The BULK_SETFILTER builder. |
| 725 | class BulkSetFilter : public Helper::DataArray<unsigned char> { | 816 | class BulkSetFilter : public Helper::DataArray<unsigned char> { |
| @@ -742,12 +833,12 @@ namespace Hantek { | @@ -742,12 +833,12 @@ namespace Hantek { | ||
| 742 | class BulkSetTriggerAndSamplerate : public Helper::DataArray<unsigned char> { | 833 | class BulkSetTriggerAndSamplerate : public Helper::DataArray<unsigned char> { |
| 743 | public: | 834 | public: |
| 744 | BulkSetTriggerAndSamplerate(); | 835 | BulkSetTriggerAndSamplerate(); |
| 745 | - BulkSetTriggerAndSamplerate(unsigned short int samplerateSlow, unsigned long int triggerPosition, unsigned char triggerSource = 0, unsigned char bufferSize = 0, unsigned char samplerateFast = 0, unsigned char usedChannels = 0, bool fastRate = false, unsigned char triggerSlope = 0); | 836 | + BulkSetTriggerAndSamplerate(unsigned short int samplerateSlow, unsigned long int triggerPosition, unsigned char triggerSource = 0, unsigned char recordLength = 0, unsigned char samplerateFast = 0, unsigned char usedChannels = 0, bool fastRate = false, unsigned char triggerSlope = 0); |
| 746 | 837 | ||
| 747 | unsigned char getTriggerSource(); | 838 | unsigned char getTriggerSource(); |
| 748 | void setTriggerSource(unsigned char value); | 839 | void setTriggerSource(unsigned char value); |
| 749 | - unsigned char getBufferSize(); | ||
| 750 | - void setBufferSize(unsigned char value); | 840 | + unsigned char getRecordLength(); |
| 841 | + void setRecordLength(unsigned char value); | ||
| 751 | unsigned char getSamplerateFast(); | 842 | unsigned char getSamplerateFast(); |
| 752 | void setSamplerateFast(unsigned char value); | 843 | void setSamplerateFast(unsigned char value); |
| 753 | unsigned char getUsedChannels(); | 844 | unsigned char getUsedChannels(); |
| @@ -855,8 +946,40 @@ namespace Hantek { | @@ -855,8 +946,40 @@ namespace Hantek { | ||
| 855 | }; | 946 | }; |
| 856 | 947 | ||
| 857 | ////////////////////////////////////////////////////////////////////////////// | 948 | ////////////////////////////////////////////////////////////////////////////// |
| 949 | + /// \class BulkSetFilter2250 hantek/types.h | ||
| 950 | + /// \brief The DSO-5200/DSO-5200A BULK_BSETFILTER builder. | ||
| 951 | + class BulkSetFilter2250 : public Helper::DataArray<unsigned char> { | ||
| 952 | + public: | ||
| 953 | + BulkSetFilter2250(); | ||
| 954 | + BulkSetFilter2250(bool channel1, bool channel2); | ||
| 955 | + | ||
| 956 | + bool getChannel(unsigned int channel); | ||
| 957 | + void setChannel(unsigned int channel, bool filtered); | ||
| 958 | + | ||
| 959 | + private: | ||
| 960 | + void init(); | ||
| 961 | + }; | ||
| 962 | + | ||
| 963 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 964 | + /// \class BulkSetTrigger2250 hantek/types.h | ||
| 965 | + /// \brief The DSO-2250 BULK_CSETTRIGGERORSAMPLERATE builder. | ||
| 966 | + class BulkSetTrigger2250 : public Helper::DataArray<unsigned char> { | ||
| 967 | + public: | ||
| 968 | + BulkSetTrigger2250(); | ||
| 969 | + BulkSetTrigger2250(unsigned char triggerSource, unsigned char triggerSlope); | ||
| 970 | + | ||
| 971 | + unsigned char getTriggerSource(); | ||
| 972 | + void setTriggerSource(unsigned char value); | ||
| 973 | + unsigned char getTriggerSlope(); | ||
| 974 | + void setTriggerSlope(unsigned char slope); | ||
| 975 | + | ||
| 976 | + private: | ||
| 977 | + void init(); | ||
| 978 | + }; | ||
| 979 | + | ||
| 980 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 858 | /// \class BulkSetSamplerate5200 hantek/types.h | 981 | /// \class BulkSetSamplerate5200 hantek/types.h |
| 859 | - /// \brief The BULK_SETSAMPLERATE5200 builder. | 982 | + /// \brief The DSO-5200/DSO-5200A BULK_CSETTRIGGERORSAMPLERATE builder. |
| 860 | class BulkSetSamplerate5200 : public Helper::DataArray<unsigned char> { | 983 | class BulkSetSamplerate5200 : public Helper::DataArray<unsigned char> { |
| 861 | public: | 984 | public: |
| 862 | BulkSetSamplerate5200(); | 985 | BulkSetSamplerate5200(); |
| @@ -872,12 +995,27 @@ namespace Hantek { | @@ -872,12 +995,27 @@ namespace Hantek { | ||
| 872 | }; | 995 | }; |
| 873 | 996 | ||
| 874 | ////////////////////////////////////////////////////////////////////////////// | 997 | ////////////////////////////////////////////////////////////////////////////// |
| 998 | + /// \class BulkSetRecordLength2250 hantek/types.h | ||
| 999 | + /// \brief The DSO-2250 BULK_DSETBUFFER builder. | ||
| 1000 | + class BulkSetRecordLength2250 : public Helper::DataArray<unsigned char> { | ||
| 1001 | + public: | ||
| 1002 | + BulkSetRecordLength2250(); | ||
| 1003 | + BulkSetRecordLength2250(unsigned char recordLength); | ||
| 1004 | + | ||
| 1005 | + unsigned char getRecordLength(); | ||
| 1006 | + void setRecordLength(unsigned char value); | ||
| 1007 | + | ||
| 1008 | + private: | ||
| 1009 | + void init(); | ||
| 1010 | + }; | ||
| 1011 | + | ||
| 1012 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 875 | /// \class BulkSetBuffer5200 hantek/types.h | 1013 | /// \class BulkSetBuffer5200 hantek/types.h |
| 876 | - /// \brief The BULK_SETBUFFER5200 builder. | 1014 | + /// \brief The DSO-5200/DSO-5200A BULK_DSETBUFFER builder. |
| 877 | class BulkSetBuffer5200 : public Helper::DataArray<unsigned char> { | 1015 | class BulkSetBuffer5200 : public Helper::DataArray<unsigned char> { |
| 878 | public: | 1016 | public: |
| 879 | BulkSetBuffer5200(); | 1017 | BulkSetBuffer5200(); |
| 880 | - BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre = 0, unsigned char usedPost = 0, unsigned char bufferSize = 0); | 1018 | + BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre = 0, unsigned char usedPost = 0, unsigned char recordLength = 0); |
| 881 | 1019 | ||
| 882 | unsigned short int getTriggerPositionPre(); | 1020 | unsigned short int getTriggerPositionPre(); |
| 883 | void setTriggerPositionPre(unsigned short int value); | 1021 | void setTriggerPositionPre(unsigned short int value); |
| @@ -887,8 +1025,27 @@ namespace Hantek { | @@ -887,8 +1025,27 @@ namespace Hantek { | ||
| 887 | void setUsedPre(unsigned char value); | 1025 | void setUsedPre(unsigned char value); |
| 888 | unsigned char getUsedPost(); | 1026 | unsigned char getUsedPost(); |
| 889 | void setUsedPost(unsigned char value); | 1027 | void setUsedPost(unsigned char value); |
| 890 | - unsigned char getBufferSize(); | ||
| 891 | - void setBufferSize(unsigned char value); | 1028 | + unsigned char getRecordLength(); |
| 1029 | + void setRecordLength(unsigned char value); | ||
| 1030 | + | ||
| 1031 | + private: | ||
| 1032 | + void init(); | ||
| 1033 | + }; | ||
| 1034 | + | ||
| 1035 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 1036 | + /// \class BulkSetSamplerate2250 hantek/types.h | ||
| 1037 | + /// \brief The DSO-2250 BULK_ESETTRIGGERORSAMPLERATE builder. | ||
| 1038 | + class BulkSetSamplerate2250 : public Helper::DataArray<unsigned char> { | ||
| 1039 | + public: | ||
| 1040 | + BulkSetSamplerate2250(); | ||
| 1041 | + BulkSetSamplerate2250(bool fastRate, unsigned char samplerateFast = 0, unsigned short int samplerateSlow = 0); | ||
| 1042 | + | ||
| 1043 | + bool getFastRate(); | ||
| 1044 | + void setFastRate(bool fastRate); | ||
| 1045 | + unsigned char getSamplerateFast(); | ||
| 1046 | + void setSamplerateFast(unsigned char value); | ||
| 1047 | + unsigned short int getSamplerateSlow(); | ||
| 1048 | + void setSamplerateSlow(unsigned short int samplerate); | ||
| 892 | 1049 | ||
| 893 | private: | 1050 | private: |
| 894 | void init(); | 1051 | void init(); |
| @@ -896,7 +1053,7 @@ namespace Hantek { | @@ -896,7 +1053,7 @@ namespace Hantek { | ||
| 896 | 1053 | ||
| 897 | ////////////////////////////////////////////////////////////////////////////// | 1054 | ////////////////////////////////////////////////////////////////////////////// |
| 898 | /// \class BulkSetTrigger5200 hantek/types.h | 1055 | /// \class BulkSetTrigger5200 hantek/types.h |
| 899 | - /// \brief The BULK_SETTRIGGER5200 builder. | 1056 | + /// \brief The DSO-5200/DSO-5200A BULK_ESETTRIGGERORSAMPLERATE builder. |
| 900 | class BulkSetTrigger5200 : public Helper::DataArray<unsigned char> { | 1057 | class BulkSetTrigger5200 : public Helper::DataArray<unsigned char> { |
| 901 | public: | 1058 | public: |
| 902 | BulkSetTrigger5200(); | 1059 | BulkSetTrigger5200(); |
| @@ -918,6 +1075,31 @@ namespace Hantek { | @@ -918,6 +1075,31 @@ namespace Hantek { | ||
| 918 | }; | 1075 | }; |
| 919 | 1076 | ||
| 920 | ////////////////////////////////////////////////////////////////////////////// | 1077 | ////////////////////////////////////////////////////////////////////////////// |
| 1078 | + /// \class BulkSetBuffer2250 hantek/types.h | ||
| 1079 | + /// \brief The DSO-2250 BULK_FSETBUFFER builder. | ||
| 1080 | + class BulkSetBuffer2250 : public Helper::DataArray<unsigned char> { | ||
| 1081 | + public: | ||
| 1082 | + BulkSetBuffer2250(); | ||
| 1083 | + BulkSetBuffer2250(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre = 0, unsigned char usedPost = 0, bool largeBuffer = false, bool slowBuffer = false); | ||
| 1084 | + | ||
| 1085 | + unsigned short int getTriggerPositionPre(); | ||
| 1086 | + void setTriggerPositionPre(unsigned short int value); | ||
| 1087 | + unsigned short int getTriggerPositionPost(); | ||
| 1088 | + void setTriggerPositionPost(unsigned short int value); | ||
| 1089 | + unsigned char getUsedPre(); | ||
| 1090 | + void setUsedPre(unsigned char value); | ||
| 1091 | + unsigned char getUsedPost(); | ||
| 1092 | + void setUsedPost(unsigned char value); | ||
| 1093 | + bool getLargeBuffer(); | ||
| 1094 | + void setLargeBuffer(bool largeBuffer); | ||
| 1095 | + bool getSlowBuffer(); | ||
| 1096 | + void setSlowBuffer(bool slowBuffer); | ||
| 1097 | + | ||
| 1098 | + private: | ||
| 1099 | + void init(); | ||
| 1100 | + }; | ||
| 1101 | + | ||
| 1102 | + ////////////////////////////////////////////////////////////////////////////// | ||
| 921 | /// \class ControlGetSpeed hantek/types.h | 1103 | /// \class ControlGetSpeed hantek/types.h |
| 922 | /// \brief The CONTROL_GETSPEED parser. | 1104 | /// \brief The CONTROL_GETSPEED parser. |
| 923 | class ControlGetSpeed : public Helper::DataArray<unsigned char> { | 1105 | class ControlGetSpeed : public Helper::DataArray<unsigned char> { |
openhantek/src/openhantek.cpp
| @@ -140,10 +140,10 @@ OpenHantekMainWindow::OpenHantekMainWindow(QWidget *parent, Qt::WindowFlags flag | @@ -140,10 +140,10 @@ OpenHantekMainWindow::OpenHantekMainWindow(QWidget *parent, Qt::WindowFlags flag | ||
| 140 | this->dsoControl->setTriggerLevel(channel, this->settings->scope.voltage[channel].trigger); | 140 | this->dsoControl->setTriggerLevel(channel, this->settings->scope.voltage[channel].trigger); |
| 141 | } | 141 | } |
| 142 | this->updateUsed(this->settings->scope.physicalChannels); | 142 | this->updateUsed(this->settings->scope.physicalChannels); |
| 143 | - this->dsoControl->setBufferSize(this->settings->scope.horizontal.samples); | 143 | + this->dsoControl->setRecordLength(this->settings->scope.horizontal.samples); |
| 144 | this->updateTimebase(); | 144 | this->updateTimebase(); |
| 145 | this->dsoControl->setTriggerMode(this->settings->scope.trigger.mode); | 145 | this->dsoControl->setTriggerMode(this->settings->scope.trigger.mode); |
| 146 | - this->dsoControl->setTriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME); | 146 | + this->dsoControl->setPretriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME); |
| 147 | this->dsoControl->setTriggerSlope(this->settings->scope.trigger.slope); | 147 | this->dsoControl->setTriggerSlope(this->settings->scope.trigger.slope); |
| 148 | this->dsoControl->setTriggerSource(this->settings->scope.trigger.special, this->settings->scope.trigger.source); | 148 | this->dsoControl->setTriggerSource(this->settings->scope.trigger.special, this->settings->scope.trigger.source); |
| 149 | 149 | ||
| @@ -203,20 +203,20 @@ void OpenHantekMainWindow::createActions() { | @@ -203,20 +203,20 @@ void OpenHantekMainWindow::createActions() { | ||
| 203 | this->startStopAction->setShortcut(tr("Space")); | 203 | this->startStopAction->setShortcut(tr("Space")); |
| 204 | this->stopped(); | 204 | this->stopped(); |
| 205 | 205 | ||
| 206 | - this->bufferSizeActionGroup = new QActionGroup(this); | ||
| 207 | - connect(this->bufferSizeActionGroup, SIGNAL(selected(QAction *)), this, SLOT(bufferSizeSelected(QAction *))); | 206 | + this->recordLengthActionGroup = new QActionGroup(this); |
| 207 | + connect(this->recordLengthActionGroup, SIGNAL(selected(QAction *)), this, SLOT(recordLengthSelected(QAction *))); | ||
| 208 | 208 | ||
| 209 | - this->bufferSizeSmallAction = new QAction(tr("&Small"), this); | ||
| 210 | - this->bufferSizeSmallAction->setActionGroup(this->bufferSizeActionGroup); | ||
| 211 | - this->bufferSizeSmallAction->setCheckable(true); | ||
| 212 | - this->bufferSizeSmallAction->setChecked(this->settings->scope.horizontal.samples == Hantek::BUFFER_SMALL); | ||
| 213 | - this->bufferSizeSmallAction->setStatusTip(tr("10240 Samples")); | 209 | + this->recordLengthSmallAction = new QAction(tr("&Small"), this); |
| 210 | + this->recordLengthSmallAction->setActionGroup(this->recordLengthActionGroup); | ||
| 211 | + this->recordLengthSmallAction->setCheckable(true); | ||
| 212 | + this->recordLengthSmallAction->setChecked(this->settings->scope.horizontal.samples == 10240); | ||
| 213 | + this->recordLengthSmallAction->setStatusTip(tr("10240 Samples")); | ||
| 214 | 214 | ||
| 215 | - this->bufferSizeLargeAction = new QAction(tr("&Large"), this); | ||
| 216 | - this->bufferSizeLargeAction->setActionGroup(this->bufferSizeActionGroup); | ||
| 217 | - this->bufferSizeLargeAction->setCheckable(true); | ||
| 218 | - this->bufferSizeLargeAction->setChecked(this->settings->scope.horizontal.samples == Hantek::BUFFER_LARGE); | ||
| 219 | - this->bufferSizeLargeAction->setStatusTip(tr("32768 Samples")); | 215 | + this->recordLengthLargeAction = new QAction(tr("&Large"), this); |
| 216 | + this->recordLengthLargeAction->setActionGroup(this->recordLengthActionGroup); | ||
| 217 | + this->recordLengthLargeAction->setCheckable(true); | ||
| 218 | + this->recordLengthLargeAction->setChecked(this->settings->scope.horizontal.samples != 10240); | ||
| 219 | + this->recordLengthLargeAction->setStatusTip(tr("32768 Samples")); | ||
| 220 | 220 | ||
| 221 | this->digitalPhosphorAction = new QAction(QIcon(":actions/digitalphosphor.png"), tr("Digital &phosphor"), this); | 221 | this->digitalPhosphorAction = new QAction(QIcon(":actions/digitalphosphor.png"), tr("Digital &phosphor"), this); |
| 222 | this->digitalPhosphorAction->setCheckable(true); | 222 | this->digitalPhosphorAction->setCheckable(true); |
| @@ -279,9 +279,9 @@ void OpenHantekMainWindow::createMenus() { | @@ -279,9 +279,9 @@ void OpenHantekMainWindow::createMenus() { | ||
| 279 | this->oscilloscopeMenu->addAction(this->commandAction); | 279 | this->oscilloscopeMenu->addAction(this->commandAction); |
| 280 | #endif | 280 | #endif |
| 281 | this->oscilloscopeMenu->addSeparator(); | 281 | this->oscilloscopeMenu->addSeparator(); |
| 282 | - this->bufferSizeMenu = this->oscilloscopeMenu->addMenu(tr("&Buffer size")); | ||
| 283 | - this->bufferSizeMenu->addAction(this->bufferSizeSmallAction); | ||
| 284 | - this->bufferSizeMenu->addAction(this->bufferSizeLargeAction); | 282 | + this->recordLengthMenu = this->oscilloscopeMenu->addMenu(tr("&Record length")); |
| 283 | + this->recordLengthMenu->addAction(this->recordLengthSmallAction); | ||
| 284 | + this->recordLengthMenu->addAction(this->recordLengthLargeAction); | ||
| 285 | 285 | ||
| 286 | this->menuBar()->addSeparator(); | 286 | this->menuBar()->addSeparator(); |
| 287 | 287 | ||
| @@ -598,11 +598,11 @@ void OpenHantekMainWindow::updateSettings() { | @@ -598,11 +598,11 @@ void OpenHantekMainWindow::updateSettings() { | ||
| 598 | } | 598 | } |
| 599 | } | 599 | } |
| 600 | 600 | ||
| 601 | -/// \brief Apply new buffer size to settings. | ||
| 602 | -/// \param action The selected buffer size menu item. | ||
| 603 | -void OpenHantekMainWindow::bufferSizeSelected(QAction *action) { | ||
| 604 | - this->settings->scope.horizontal.samples = (action == this->bufferSizeSmallAction) ? Hantek::BUFFER_SMALL : Hantek::BUFFER_LARGE; | ||
| 605 | - this->dsoControl->setBufferSize(this->settings->scope.horizontal.samples); | 601 | +/// \brief Apply new record length to settings. |
| 602 | +/// \param action The selected record length menu item. | ||
| 603 | +void OpenHantekMainWindow::recordLengthSelected(QAction *action) { | ||
| 604 | + this->settings->scope.horizontal.samples = (action == this->recordLengthSmallAction) ? 10240 : 32768; | ||
| 605 | + this->dsoControl->setRecordLength(this->settings->scope.horizontal.samples); | ||
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | /// \brief Sets the offset of the oscilloscope for the given channel. | 608 | /// \brief Sets the offset of the oscilloscope for the given channel. |
| @@ -620,7 +620,7 @@ void OpenHantekMainWindow::updateTimebase() { | @@ -620,7 +620,7 @@ void OpenHantekMainWindow::updateTimebase() { | ||
| 620 | this->dsoWidget->updateSamplerate(); | 620 | this->dsoWidget->updateSamplerate(); |
| 621 | 621 | ||
| 622 | // The trigger position should be kept at the same place but the timebase has changed | 622 | // The trigger position should be kept at the same place but the timebase has changed |
| 623 | - this->dsoControl->setTriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME); | 623 | + this->dsoControl->setPretriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME); |
| 624 | } | 624 | } |
| 625 | 625 | ||
| 626 | /// \brief Sets the state of the given oscilloscope channel. | 626 | /// \brief Sets the state of the given oscilloscope channel. |
openhantek/src/openhantek.h
| @@ -81,8 +81,8 @@ class OpenHantekMainWindow : public QMainWindow { | @@ -81,8 +81,8 @@ class OpenHantekMainWindow : public QMainWindow { | ||
| 81 | 81 | ||
| 82 | QAction *configAction; | 82 | QAction *configAction; |
| 83 | QAction *startStopAction; | 83 | QAction *startStopAction; |
| 84 | - QActionGroup *bufferSizeActionGroup; | ||
| 85 | - QAction *bufferSizeSmallAction, *bufferSizeLargeAction; | 84 | + QActionGroup *recordLengthActionGroup; |
| 85 | + QAction *recordLengthSmallAction, *recordLengthLargeAction; | ||
| 86 | QAction *digitalPhosphorAction, *zoomAction; | 86 | QAction *digitalPhosphorAction, *zoomAction; |
| 87 | 87 | ||
| 88 | QAction *aboutAction, *aboutQtAction; | 88 | QAction *aboutAction, *aboutQtAction; |
| @@ -94,7 +94,7 @@ class OpenHantekMainWindow : public QMainWindow { | @@ -94,7 +94,7 @@ class OpenHantekMainWindow : public QMainWindow { | ||
| 94 | // Menus | 94 | // Menus |
| 95 | QMenu *fileMenu; | 95 | QMenu *fileMenu; |
| 96 | QMenu *viewMenu, *dockMenu, *toolbarMenu; | 96 | QMenu *viewMenu, *dockMenu, *toolbarMenu; |
| 97 | - QMenu *oscilloscopeMenu, *bufferSizeMenu; | 97 | + QMenu *oscilloscopeMenu, *recordLengthMenu; |
| 98 | QMenu *helpMenu; | 98 | QMenu *helpMenu; |
| 99 | 99 | ||
| 100 | // Toolbars | 100 | // Toolbars |
| @@ -143,7 +143,7 @@ class OpenHantekMainWindow : public QMainWindow { | @@ -143,7 +143,7 @@ class OpenHantekMainWindow : public QMainWindow { | ||
| 143 | void applySettings(); | 143 | void applySettings(); |
| 144 | void updateSettings(); | 144 | void updateSettings(); |
| 145 | 145 | ||
| 146 | - void bufferSizeSelected(QAction *action); | 146 | + void recordLengthSelected(QAction *action); |
| 147 | void updateOffset(unsigned int channel); | 147 | void updateOffset(unsigned int channel); |
| 148 | void updateTimebase(); | 148 | void updateTimebase(); |
| 149 | void updateUsed(unsigned int channel); | 149 | void updateUsed(unsigned int channel); |