MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / save_dso

Method save_dso

DSView/pv/storesession.cpp:456–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456void StoreSession::save_dso(pv::data::DsoSnapshot *dso_snapshot)
457{
458 char chunk_name[20] = {0};
459 int ret = SR_ERR;
460
461 uint64_t size = dso_snapshot->get_sample_count();
462 int ch_num = dso_snapshot->get_channel_num();
463 _unit_count = size * ch_num;
464
465 for(auto s : _session->get_signals())
466 {
467 if (s->get_type() == SR_CHANNEL_DSO) {
468 int ch_index = s->get_index();
469
470 if (!dso_snapshot->has_data(ch_index))
471 continue;
472
473 if (_canceled)
474 break;
475
476 const uint8_t *data_buffer = dso_snapshot->get_samples(0, 0, ch_index);
477
478 snprintf(chunk_name, 19, "O-%d/0", ch_index);
479 ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)data_buffer, size) ? SR_OK : -1;
480
481 if (ret != SR_OK) {
482 if (!_has_error) {
483 _has_error = true;
484 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_SAVEPROC_ERROR2),
485 "Failed to create zip file. Please check write permission of this path.");
486 }
487 progress_updated();
488 if (_has_error)
489 QFile::remove(_file_name);
490 return;
491 }
492
493 _units_stored += size;
494 progress_updated();
495 }
496 }
497
498 progress_updated();
499
500 if (_canceled || size == 0 || ch_num == 0){
501 QFile::remove(_file_name);
502 }
503 else {
504 bool bret = m_zipDoc.Close();
505 m_zipDoc.Release();
506
507 if (!bret){
508 _has_error = true;
509 _error = m_zipDoc.GetError();
510 }
511 }
512}
513

Callers

nothing calls this directly

Calls 10

get_sample_countMethod · 0.80
get_channel_numMethod · 0.80
AddFromBufferMethod · 0.80
GetErrorMethod · 0.80
get_typeMethod · 0.45
get_indexMethod · 0.45
has_dataMethod · 0.45
get_samplesMethod · 0.45
CloseMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected