forked from Ivasoft/DSView
fix: The math data calculate error!
This commit is contained in:
@@ -265,7 +265,7 @@ void DsoSnapshot::enable_envelope(bool enable)
|
||||
_envelope_en = enable;
|
||||
}
|
||||
|
||||
const uint8_t *DsoSnapshot::get_samples(int64_t start_sample, int64_t end_sample, uint16_t index)
|
||||
const uint8_t *DsoSnapshot::get_samples(int64_t start_sample, int64_t end_sample, uint16_t ch_index)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
@@ -275,10 +275,10 @@ const uint8_t *DsoSnapshot::get_samples(int64_t start_sample, int64_t end_sample
|
||||
assert(end_sample < (int64_t)_sample_count);
|
||||
assert(start_sample <= end_sample);
|
||||
|
||||
int order = get_ch_order(index);
|
||||
int order = get_ch_order(ch_index);
|
||||
|
||||
if (order == -1){
|
||||
dsv_err("The channel index is not exist:%d", index);
|
||||
dsv_err("The channel index is not exist:%d", ch_index);
|
||||
assert(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
GSList *channels, bool instant, bool isFile);
|
||||
|
||||
void append_payload(const sr_datafeed_dso &dso);
|
||||
const uint8_t* get_samples(int64_t start_sample, int64_t end_sample, uint16_t index);
|
||||
const uint8_t* get_samples(int64_t start_sample, int64_t end_sample, uint16_t ch_index);
|
||||
|
||||
void get_envelope_section(EnvelopeSection &s,
|
||||
uint64_t start, uint64_t end, float min_length, int probe_index);
|
||||
|
||||
@@ -325,6 +325,9 @@ void MathStack::calc_math()
|
||||
if (!_dsoSig1->enabled() || !_dsoSig2->enabled())
|
||||
return;
|
||||
|
||||
if (data->get_channel_num() < 2)
|
||||
return;
|
||||
|
||||
const double scale1 = _dsoSig1->get_vDialValue() / 1000.0 * _dsoSig1->get_factor() * DS_CONF_DSO_VDIVS *
|
||||
_dsoSig1->get_scale() / _dsoSig1->get_view_rect().height();
|
||||
const double delta1 = _dsoSig1->get_hw_offset() * scale1;
|
||||
@@ -333,18 +336,19 @@ void MathStack::calc_math()
|
||||
_dsoSig2->get_scale() / _dsoSig2->get_view_rect().height();
|
||||
const double delta2 = _dsoSig2->get_hw_offset() * scale2;
|
||||
|
||||
const int index1 = _dsoSig1->get_index();
|
||||
const int index2 = _dsoSig2->get_index();
|
||||
|
||||
const int num_channels = data->get_channel_num();
|
||||
const uint8_t* value = data->get_samples(0, 0, 0);
|
||||
_sample_num = data->get_sample_count();
|
||||
assert(_sample_num <= _total_sample_num);
|
||||
|
||||
const int index1 = _dsoSig1->get_index();
|
||||
const int index2 = _dsoSig2->get_index();
|
||||
const uint8_t* value_buffer1 = data->get_samples(0, 0, index1);
|
||||
const uint8_t* value_buffer2 = data->get_samples(0, 0, index2);
|
||||
double value1, value2;
|
||||
|
||||
for (uint64_t sample = 0; sample < _sample_num; sample++) {
|
||||
value1 = value[sample * num_channels + index1];
|
||||
value2 = value[sample * num_channels + index2];
|
||||
value1 = *(value_buffer1 + sample);
|
||||
value2 = *(value_buffer2 + sample);
|
||||
|
||||
switch(_type) {
|
||||
case MATH_ADD:
|
||||
_math[sample] = (delta1 - scale1 * value1) + (delta2 - scale2 * value2);
|
||||
|
||||
Reference in New Issue
Block a user