MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / ReadPartialData

Method ReadPartialData

lib/mdflib/mdflib/src/mdfreader.cpp:540–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

538}
539
540bool MdfReader::ReadPartialData(IDataGroup &data_group, size_t min_sample,
541 size_t max_sample) {
542 if (!instance_ || !file_) {
543 MDF_ERROR() << "No instance created. File: " << filename_;
544 return false;
545 }
546 if (max_sample < min_sample) {
547 max_sample = min_sample;
548 }
549 bool shall_close = !IsOpen() && Open();
550 if (!IsOpen()) {
551 MDF_ERROR() << "Failed to open file. File: " << filename_;
552 return false;
553 }
554
555 bool error = false;
556 try {
557 if (instance_->IsMdf4()) {
558
559 auto &dg4 = dynamic_cast<detail::Dg4Block &>(data_group);
560 DgRange range(dg4, min_sample, max_sample);
561 dg4.ReadRangeData(*file_, range);
562 } else {
563 auto &dg3 = dynamic_cast<detail::Dg3Block &>(data_group);
564 DgRange range(dg3, min_sample, max_sample);
565 dg3.ReadRangeData(*file_, range);
566 }
567 } catch (const std::exception &err) {
568 MDF_ERROR() << "Failed to read the file information blocks. Error: "
569 << err.what();
570 error = true;
571 }
572
573 if (shall_close) {
574 Close();
575 }
576 return !error;
577}
578
579bool MdfReader::ReadSrData(ISampleReduction &sr_group) {
580 if (!instance_ || !file_) {

Callers 2

TEST_FFunction · 0.80
MdfReader.cppFile · 0.80

Calls 2

IsMdf4Method · 0.45
ReadRangeDataMethod · 0.45

Tested by 1

TEST_FFunction · 0.64