Commit cb11dd719d02fbc456c0d3685b269b1323610a1b
Committed by
David Gräff
1 parent
43a1bd67
fix segfault #183, improve SW trigger stability by less aggressive samplerate selection
Showing
5 changed files
with
23 additions
and
11 deletions
openhantek/src/docks/HorizontalDock.cpp
| ... | ... | @@ -164,9 +164,16 @@ void HorizontalDock::setSamplerateLimits(double minimum, double maximum) { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | void HorizontalDock::setSamplerateSteps(int mode, QList<double> steps) { |
| 167 | - QSignalBlocker blocker(samplerateSiSpinBox); | |
| 168 | - this->samplerateSiSpinBox->setMode(mode); | |
| 169 | - this->samplerateSiSpinBox->setSteps(steps); | |
| 167 | + // Assume that method is invoked for fixed samplerate devices only | |
| 168 | + QSignalBlocker samplerateBlocker(samplerateSiSpinBox); | |
| 169 | + samplerateSiSpinBox->setMode(mode); | |
| 170 | + samplerateSiSpinBox->setSteps(steps); | |
| 171 | + samplerateSiSpinBox->setMinimum(steps.first()); | |
| 172 | + samplerateSiSpinBox->setMaximum(steps.last()); | |
| 173 | + // Make reasonable adjustments to the timebase spinbox | |
| 174 | + QSignalBlocker timebaseBlocker(timebaseSiSpinBox); | |
| 175 | + timebaseSiSpinBox->setMinimum(pow(10, floor(log10(1.0 / steps.last())))); | |
| 176 | + timebaseSiSpinBox->setMaximum(pow(10, ceil(log10(8192.0 / (steps.first() * 10))))); | |
| 170 | 177 | } |
| 171 | 178 | |
| 172 | 179 | /// \brief Called when the frequencybase spinbox changes its value. | ... | ... |
openhantek/src/hantekdso/hantekdsocontrol.cpp
| ... | ... | @@ -583,9 +583,8 @@ void HantekDsoControl::restoreTargets() { |
| 583 | 583 | |
| 584 | 584 | void HantekDsoControl::updateSamplerateLimits() { |
| 585 | 585 | if (specification->isFixedSamplerateDevice) { |
| 586 | - // Convert to GUI presentable values (1e5 -> 1.0, 48e6 -> 480.0 etc) | |
| 587 | 586 | QList<double> sampleSteps; |
| 588 | - for (auto &v : specification->fixedSampleRates) { sampleSteps << v.samplerate / 1e5; } | |
| 587 | + for (auto &v : specification->fixedSampleRates) { sampleSteps << v.samplerate; } | |
| 589 | 588 | emit samplerateSet(1, sampleSteps); |
| 590 | 589 | } else { |
| 591 | 590 | // Works only if the minimum samplerate for normal mode is lower than for fast |
| ... | ... | @@ -691,10 +690,13 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { |
| 691 | 690 | // For now - we go for the 10240 size sampling - the other seems not to be supported |
| 692 | 691 | // Find highest samplerate using less than 10240 samples to obtain our duration. |
| 693 | 692 | unsigned sampleCount = 10240; |
| 694 | - if (specification->isSoftwareTriggerDevice) sampleCount -= controlsettings.swSampleMargin; | |
| 695 | - unsigned sampleId; | |
| 696 | - for (sampleId = 0; sampleId < specification->fixedSampleRates.size(); ++sampleId) { | |
| 697 | - if (specification->fixedSampleRates[sampleId].samplerate * duration < sampleCount) break; | |
| 693 | + // Ensure that at least 1/2 of remaining samples are available for SW trigger algorithm | |
| 694 | + if (specification->isSoftwareTriggerDevice) { | |
| 695 | + sampleCount = (sampleCount - controlsettings.swSampleMargin) / 2; | |
| 696 | + } | |
| 697 | + unsigned sampleId = 0; | |
| 698 | + for (unsigned id = 0; id < specification->fixedSampleRates.size(); ++id) { | |
| 699 | + if (specification->fixedSampleRates[id].samplerate * duration < sampleCount) sampleId = id; | |
| 698 | 700 | } |
| 699 | 701 | // Usable sample value |
| 700 | 702 | modifyCommand<ControlSetTimeDIV>(ControlCode::CONTROL_SETTIMEDIV) | ... | ... |
openhantek/src/post/ppresult.cpp
| ... | ... | @@ -19,6 +19,7 @@ unsigned int PPresult::sampleCount() const { return (unsigned)analyzedData[0].vo |
| 19 | 19 | unsigned int PPresult::channelCount() const { return (unsigned)analyzedData.size(); } |
| 20 | 20 | |
| 21 | 21 | double DataChannel::computeAmplitude() const { |
| 22 | + if (voltage.sample.empty()) return 0.0; | |
| 22 | 23 | double minimalVoltage, maximalVoltage; |
| 23 | 24 | minimalVoltage = maximalVoltage = voltage.sample[0]; |
| 24 | 25 | ... | ... |
openhantek/src/settings.cpp
| ... | ... | @@ -106,7 +106,8 @@ void DsoSettings::load() { |
| 106 | 106 | for (ChannelID channel = 0; channel < scope.voltage.size(); ++channel) { |
| 107 | 107 | store->beginGroup(QString("vertical%1").arg(channel)); |
| 108 | 108 | if (store->contains("gainStepIndex")) scope.voltage[channel].gainStepIndex = store->value("gainStepIndex").toUInt(); |
| 109 | - if (store->contains("couplingOrMathIndex")) scope.voltage[channel].couplingOrMathIndex = store->value("couplingIndex").toUInt(); | |
| 109 | + if (store->contains("couplingOrMathIndex")) scope.voltage[channel].couplingOrMathIndex = | |
| 110 | + store->value("couplingOrMathIndex").toUInt(); | |
| 110 | 111 | if (store->contains("inverted")) scope.voltage[channel].inverted = store->value("inverted").toBool(); |
| 111 | 112 | if (store->contains("offset")) scope.voltage[channel].offset = store->value("offset").toDouble(); |
| 112 | 113 | if (store->contains("trigger")) scope.voltage[channel].trigger = store->value("trigger").toDouble(); | ... | ... |
openhantek/src/widgets/sispinbox.cpp
| ... | ... | @@ -124,7 +124,8 @@ void SiSpinBox::stepBy(int steps) { |
| 124 | 124 | if (stepsId < 0) stepsId += stepsCount; |
| 125 | 125 | value = pow(stepsSpan, floor((double)this->stepId / stepsCount)) * this->steps[stepsId]; |
| 126 | 126 | } else { |
| 127 | - value = this->minimum() * this->steps[stepId]; | |
| 127 | + stepId = std::min(std::max(stepId, 0), stepsCount); | |
| 128 | + value = this->steps[stepId]; | |
| 128 | 129 | } |
| 129 | 130 | if (value <= this->minimum() || value >= this->maximum()) break; |
| 130 | 131 | } | ... | ... |