2
0
forked from Ivasoft/DSView

Show the dso data out off range warnning

This commit is contained in:
dreamsourcelabTAI
2024-01-09 18:04:33 +08:00
parent 2db3fc1e9f
commit bb22f36b66
8 changed files with 62 additions and 1 deletions

View File

@@ -54,6 +54,9 @@ DsoSnapshot::DsoSnapshot() :
_data_scale1 = 0;
_data_scale2 = 0;
_is_file = false;
_ref_min = 0;
_ref_max = 0;
_data_out_off_range = false;
memset(_envelope_levels, 0, sizeof(_envelope_levels));
}
@@ -233,6 +236,8 @@ void DsoSnapshot::append_data(void *data, uint64_t samples, bool instant)
{
uint64_t old_sample_count = _sample_count;
_data_out_off_range = false;
if (instant) {
if(_sample_count + samples > _total_sample_count)
samples = _total_sample_count - _sample_count;
@@ -256,6 +261,11 @@ void DsoSnapshot::append_data(void *data, uint64_t samples, bool instant)
for (uint64_t i = 0; i < samples; i++)
{
*dest++ = *src;
if (*src > _ref_max || *src < _ref_min){
_data_out_off_range = true;
}
src += _channel_num;
}
}

View File

@@ -131,6 +131,15 @@ public:
return _is_file;
}
inline void set_ref_range(uint32_t ref_max, uint32_t ref_min){
_ref_max = ref_max;
_ref_min = ref_min;
}
inline bool data_is_out_off_range(){
return _data_out_off_range;
}
private:
void append_data(void *data, uint64_t samples, bool instant);
void free_envelop();
@@ -151,6 +160,9 @@ private:
float _data_scale1 = 0;
float _data_scale2 = 0;
bool _is_file;
uint32_t _ref_min;
uint32_t _ref_max;
bool _data_out_off_range;
friend class DsoSnapshotTest::Basic;
};

View File

@@ -578,6 +578,14 @@ namespace pv
_device_agent.set_config_bool(SR_CONF_LOOP_MODE, bv);
}
}
if (mode == DSO && _device_agent.is_hardware()){
uint32_t ref_max = 0;
uint32_t ref_min = 0;
_device_agent.get_config_uint32(SR_CONF_REF_MIN, ref_min);
_device_agent.get_config_uint32(SR_CONF_REF_MAX, ref_max);
_view_data->get_dso()->set_ref_range(ref_max, ref_min);
}
update_view();

View File

@@ -443,6 +443,10 @@ public:
int64_t get_ring_sample_count();
inline bool dso_data_is_out_off_range(){
return _view_data->get_dso()->data_is_out_off_range();
}
private:
void set_cur_samplelimits(uint64_t samplelimits);
void set_cur_snap_samplerate(uint64_t samplerate);

View File

@@ -463,6 +463,17 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
}
p.setPen(fore);
p.drawText(_view.get_view_rect(), Qt::AlignLeft | Qt::AlignTop, type_str);
if (_view.session().get_device()->is_hardware())
{
if (_view.session().dso_data_is_out_off_range()){
QString data_status = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DATA_OUT_OFF_RANGE), "Out off range");
data_status += "! ";
p.setPen(QColor(255,0,0,200));
p.drawText(_view.get_view_rect(), Qt::AlignRight | Qt::AlignTop, data_status);
p.setPen(fore);
}
}
}
}
}

View File

@@ -718,5 +718,9 @@
{
"id": "IDS_DLG_AUTO_SCROLL_LATEAST_DATA",
"text": "自动滚动到最新数据"
}
},
{
"id": "IDS_DLG_DATA_OUT_OFF_RANGE",
"text": "数据超出量程"
}
]

View File

@@ -718,5 +718,9 @@
{
"id": "IDS_DLG_AUTO_SCROLL_LATEAST_DATA",
"text": "Auto scroll to latest data"
},
{
"id": "IDS_DLG_DATA_OUT_OFF_RANGE",
"text": "Data out off range"
}
]

View File

@@ -1491,6 +1491,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
__func__, ch->index, ch->enabled);
} else if (id == SR_CONF_PROBE_OFFSET) {
ch->offset = g_variant_get_uint16(data);
if (ch->offset > devc->profile->dev_caps.ref_max){
ch->offset = devc->profile->dev_caps.ref_max;
}
if (ch->offset < devc->profile->dev_caps.ref_min){
ch->offset = devc->profile->dev_caps.ref_min;
}
if (devc->status != DSL_FINISH)
ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_PROBE_OFFSET));
else