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

Method ParseRangeRecord

lib/mdflib/mdflib/src/readcache.cpp:119–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool ReadCache::ParseRangeRecord(DgRange& range) {
120
121 if (dg4_block_ == nullptr || dg4_block_->Cg4().empty() ) {
122 return false;
123 }
124 if (data_count_ >= max_data_count_ || block_list_.empty()) {
125 return false;
126 }
127 bool continue_reading = true;
128 try {
129 const auto record_id = ParseRecordId();
130 auto *cg_range = range.GetCgRange(record_id);
131 Cg4Block* channel_group = dg4_block_->FindCgRecordId(record_id);
132
133 if (cg_range == nullptr || channel_group == nullptr) {
134 throw std::runtime_error("No channel group range found.");
135 }
136 const size_t sample = channel_group->Sample(); // Previous sample index
137 const size_t next_sample = sample + 1;
138
139 if (channel_group->Flags() & CgFlag::VlsdChannel) {
140 // This is normally used for string,
141 // and the CG block only includes one signal
142 std::vector<uint8_t> temp(4, 0);
143 GetArray(temp);
144 const LittleBuffer<uint32_t> length(temp, 0);
145 if (!cg_range->IsUsed() ||
146 next_sample < range.MinSample() ||
147 next_sample > range.MaxSample() ) {
148 // Skip this sample
149 SkipBytes(length.value());
150 if (sample < channel_group->NofSamples()) {
151 channel_group->IncrementSample();
152 }
153 if (next_sample > range.MaxSample()) {
154 // Mark this group as read
155 cg_range->IsUsed(false);
156 }
157 } else if (record_id_list_.find(record_id) == record_id_list_.cend()) {
158 // This block should be covered by the above code.
159 SkipBytes(length.value());
160 if (sample < channel_group->NofSamples()) {
161 channel_group->IncrementSample();
162 }
163 } else {
164 std::vector<uint8_t> record(length.value(), 0);
165 GetArray(record);
166 if (sample < channel_group->NofSamples()) {
167 continue_reading = dg4_block_->NotifySampleObservers(sample,
168 record_id, record);
169 channel_group->IncrementSample();
170 }
171 }
172 } else {
173 const size_t record_size = channel_group->NofDataBytes()
174 + channel_group->NofInvalidBytes();
175 // Normal fixed length records
176 if (!cg_range->IsUsed() ||

Callers 1

ReadRangeDataMethod · 0.80

Calls 15

emptyMethod · 0.80
GetCgRangeMethod · 0.80
SampleMethod · 0.80
MinSampleMethod · 0.80
MaxSampleMethod · 0.80
IncrementSampleMethod · 0.80
findMethod · 0.80
cendMethod · 0.80
NotifySampleObserversMethod · 0.80
NofDataBytesMethod · 0.80
NofInvalidBytesMethod · 0.80
IsReadyMethod · 0.80

Tested by

no test coverage detected