2
0
forked from Ivasoft/DSView

fix: export error on DAQ mode

This commit is contained in:
DreamSourceLab
2023-09-21 19:00:28 -07:00
parent 40c0155fe5
commit 862462c1d6
3 changed files with 56 additions and 12 deletions

View File

@@ -1868,7 +1868,9 @@ namespace pv
}
_view->update_all_trace_postion();
_session->start_capture(true);
QTimer::singleShot(100, this, [this](){
_session->start_capture(true);
});
}
else if (_device_agent->is_demo())
{

View File

@@ -834,6 +834,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
p.payload = &meta;
p.bExportOriginalData = 0;
_outModule->receive(&output, &p, &data_out);
if(data_out){
out << QString::fromUtf8((char*) data_out->str);
g_string_free(data_out,TRUE);
@@ -975,21 +976,31 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
unsigned int usize = 8192;
unsigned int size = usize;
struct sr_datafeed_analog ap;
uint64_t unit_count = _unit_count;
int ch_count = snapshot->get_channel_num();
uint64_t i = 0;
for(uint64_t i = 0; !_canceled && i < _unit_count; i+=usize){
if(_unit_count - i < usize)
size = _unit_count - i;
ap.data = &datat[i*snapshot->get_channel_num()];
for(i = 0; i < unit_count; i+=usize){
if (_canceled)
break;
if(unit_count - i < usize)
size = unit_count - i;
ap.data = &datat[i*ch_count];
ap.num_samples = size;
p.type = SR_DF_ANALOG;
p.status = SR_PKT_OK;
p.payload = &ap;
p.bExportOriginalData = 0;
_outModule->receive(&output, &p, &data_out);
if(data_out){
out << (char*) data_out->str;
g_string_free(data_out,TRUE);
}
}
_units_stored += size;
progress_updated();

View File

@@ -205,6 +205,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
uint64_t i, j;
unsigned char *p, c;
double tmpv;
struct sr_channel *ch;
*out = NULL;
if (!o || !o->sdi)
@@ -291,14 +292,44 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
*out = g_string_sized_new(512);
}
int enalbe_channel_flags[8];
int ch_num = 0;
for (l = o->sdi->channels; l; l = l->next){
ch = l->data;
enalbe_channel_flags[ch_num++] = ch->enabled;
}
double max_min_ref = (double)(ctx->ref_max - ctx->ref_min);
double vf = 0;
int ch_cfg_dex = 0;
double hw_offset = 0;
double mapRange = 0;
for (i = 0; i < (uint64_t)analog->num_samples; i++) {
for (j = 0; j < ctx->num_enabled_channels; j++) {
idx = ctx->channel_index[j];
p = analog->data + i * ctx->num_enabled_channels + idx * ((ctx->num_enabled_channels > 1) ? 1 : 0);
g_string_append_printf(*out, "%0.5f", (ctx->channel_offset[j] - *p) *
(ctx->channel_mmax[j] - ctx->channel_mmin[j]) /
(ctx->ref_max - ctx->ref_min));
ch_cfg_dex = 0;
for (j = 0; j < ch_num; j++) {
// idx = ctx->channel_index[j];
// p = analog->data + i * ctx->num_enabled_channels + idx * ((ctx->num_enabled_channels > 1) ? 1 : 0);
// g_string_append_printf(*out, "%0.5f", (ctx->channel_offset[j] - *p) *
// (ctx->channel_mmax[j] - ctx->channel_mmin[j]) /
// (ctx->ref_max - ctx->ref_min));
if (enalbe_channel_flags[j] == 0){
continue;
}
p = analog->data + i * ch_num + j;
hw_offset = (double)ctx->channel_offset[ch_cfg_dex];
mapRange = (ctx->channel_mmax[ch_cfg_dex] - ctx->channel_mmin[ch_cfg_dex]);
vf = (hw_offset - (double)(*p)) * mapRange / max_min_ref;
g_string_append_printf(*out, "%0.5f", vf);
g_string_append_c(*out, ctx->separator);
ch_cfg_dex++;
}
/* Drop last separator. */