fix: The dscope captured data and stoped

change the scale, but the measure information is error.
This commit is contained in:
dreamsourcelabTAI 2023-07-05 17:26:25 +08:00
parent a8b359d43f
commit d05af104e0
3 changed files with 19 additions and 18 deletions

View File

@ -111,20 +111,20 @@ public:
return _threshold; return _threshold;
} }
inline void set_measure_voltage_factor1(uint64_t v){ inline void set_measure_voltage_factor(uint64_t v, int index){
_measure_voltage_factor1 = v; index == 0 ? _measure_voltage_factor1 = v : _measure_voltage_factor2 = v;
} }
inline uint64_t get_measure_voltage_factor1(){ inline uint64_t get_measure_voltage_factor(int index){
return _measure_voltage_factor1; return index == 0 ? _measure_voltage_factor1 : _measure_voltage_factor2;
} }
inline void set_measure_voltage_factor2(uint64_t v){ inline void set_data_scale(float scale, int index){
_measure_voltage_factor2 = v; index == 0 ? _data_scale1 = scale : _data_scale2 = scale;
} }
inline uint64_t get_measure_voltage_factor2(){ inline float get_data_scale(int index){
return _measure_voltage_factor2; return index == 0 ? _data_scale1 : _data_scale2;
} }
private: private:
@ -144,6 +144,8 @@ private:
float _threshold; float _threshold;
uint64_t _measure_voltage_factor1; uint64_t _measure_voltage_factor1;
uint64_t _measure_voltage_factor2; uint64_t _measure_voltage_factor2;
float _data_scale1 = 0;
float _data_scale2 = 0;
friend class DsoSnapshotTest::Basic; friend class DsoSnapshotTest::Basic;
}; };

View File

@ -404,11 +404,8 @@ namespace pv
if (s->get_type() == SR_CHANNEL_DSO){ if (s->get_type() == SR_CHANNEL_DSO){
view::DsoSignal *ch = (view::DsoSignal*)s; view::DsoSignal *ch = (view::DsoSignal*)s;
uint64_t k = ch->get_vDial()->get_value(); uint64_t k = ch->get_vDial()->get_value();
_capture_data->get_dso()->set_measure_voltage_factor(k, ch->get_index());
if (ch->get_index() == 0) _capture_data->get_dso()->set_data_scale(ch->get_scale(), ch->get_index());
_capture_data->get_dso()->set_measure_voltage_factor1(k);
else
_capture_data->get_dso()->set_measure_voltage_factor2(k);
} }
} }
} }

View File

@ -1495,9 +1495,10 @@ double DsoSignal::get_voltage(uint64_t index)
const double value = *_data->get_samples(index, index, get_index()); const double value = *_data->get_samples(index, index, get_index());
const int hw_offset = get_hw_offset(); const int hw_offset = get_hw_offset();
uint64_t k = get_index() == 0 ? _data->get_measure_voltage_factor1() : _data->get_measure_voltage_factor2(); uint64_t k = _data->get_measure_voltage_factor(this->get_index());
float data_scale = _data->get_data_scale(this->get_index());
return (hw_offset - value) * _scale * return (hw_offset - value) * data_scale *
k *_vDial->get_factor() * k *_vDial->get_factor() *
DS_CONF_DSO_VDIVS / get_view_rect().height(); DS_CONF_DSO_VDIVS / get_view_rect().height();
} }
@ -1514,12 +1515,13 @@ QString DsoSignal::get_voltage(double v, int p, bool scaled)
assert(_data); assert(_data);
uint64_t k = get_index() == 0 ? _data->get_measure_voltage_factor1() : _data->get_measure_voltage_factor2(); uint64_t k = _data->get_measure_voltage_factor(this->get_index());
float data_scale = _data->get_data_scale(this->get_index());
if (scaled) if (scaled)
v = v * k * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height(); v = v * k * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
else else
v = v * _scale * k * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height(); v = v * data_scale * k * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
return abs(v) >= 1000 ? QString::number(v/1000.0, 'f', p) + "V" : QString::number(v, 'f', p) + "mV"; return abs(v) >= 1000 ? QString::number(v/1000.0, 'f', p) + "V" : QString::number(v, 'f', p) + "mV";
} }