const shared_ptr<Decoder> dec = make_shared<Decoder>(decoder, stack_.size());
stack_.push_back(dec);
+ connect(dec.get(), SIGNAL(annotation_visibility_changed()),
+ this, SLOT(on_annotation_visibility_changed()));
+
// Include the newly created decode channels in the channel lists
update_channel_list();
assert(index < (int)stack_.size());
// Find the decoder in the stack
- auto iter = stack_.begin();
- for (int i = 0; i < index; i++, iter++)
- assert(iter != stack_.end());
+ auto iter = stack_.begin() + index;
+ assert(iter != stack_.end());
+
+ shared_ptr<Decoder> dec = *iter;
- decoder_removed(iter->get());
+ decoder_removed(dec.get());
// Delete the element
stack_.erase(iter);
for (const decode::DecodeChannel& ch : channels_)
if (ch.assigned_signal) {
+ if (!ch.assigned_signal->logic_data())
+ return 0;
+
no_signals_assigned = false;
const shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
- if (!logic_data || logic_data->logic_segments().empty())
+ if (logic_data->logic_segments().empty())
return 0;
- try {
- const shared_ptr<LogicSegment> segment = logic_data->logic_segments().at(segment_id);
- count = min(count, (int64_t)segment->get_sample_count());
- } catch (out_of_range&) {
+ if (segment_id >= logic_data->logic_segments().size())
return 0;
- }
+
+ const shared_ptr<LogicSegment> segment = logic_data->logic_segments()[segment_id];
+ count = min(count, (int64_t)segment->get_sample_count());
}
return (no_signals_assigned ? 0 : count);
uint32_t DecodeSignal::get_binary_data_chunk_count(uint32_t segment_id,
const Decoder* dec, uint32_t bin_class_id) const
{
- if (segments_.size() == 0)
+ if ((segments_.size() == 0) || (segment_id >= segments_.size()))
return 0;
- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
+ const DecodeSegment *segment = &(segments_[segment_id]);
- for (const DecodeBinaryClass& bc : segment->binary_classes)
- if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
- return bc.chunks.size();
- } catch (out_of_range&) {
- // Do nothing
- }
+ for (const DecodeBinaryClass& bc : segment->binary_classes)
+ if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
+ return bc.chunks.size();
return 0;
}
const Decoder* dec, uint32_t bin_class_id, uint32_t chunk_id,
const vector<uint8_t> **dest, uint64_t *size)
{
- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
+ if (segment_id >= segments_.size())
+ return;
- for (const DecodeBinaryClass& bc : segment->binary_classes)
- if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id)) {
- if (dest) *dest = &(bc.chunks.at(chunk_id).data);
- if (size) *size = bc.chunks.at(chunk_id).data.size();
- return;
- }
- } catch (out_of_range&) {
- // Do nothing
- }
+ const DecodeSegment *segment = &(segments_[segment_id]);
+
+ for (const DecodeBinaryClass& bc : segment->binary_classes)
+ if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id)) {
+ if (dest) *dest = &(bc.chunks.at(chunk_id).data);
+ if (size) *size = bc.chunks.at(chunk_id).data.size();
+ return;
+ }
}
void DecodeSignal::get_merged_binary_data_chunks_by_sample(uint32_t segment_id,
{
assert(dest != nullptr);
- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
-
- const DecodeBinaryClass* bin_class = nullptr;
- for (const DecodeBinaryClass& bc : segment->binary_classes)
- if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
- bin_class = &bc;
-
- // Determine overall size before copying to resize dest vector only once
- uint64_t size = 0;
- uint64_t matches = 0;
- for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
- if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
- size += chunk.data.size();
- matches++;
- }
- dest->resize(size);
-
- uint64_t offset = 0;
- uint64_t matches2 = 0;
- for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
- if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
- memcpy(dest->data() + offset, chunk.data.data(), chunk.data.size());
- offset += chunk.data.size();
- matches2++;
-
- // Make sure we don't overwrite memory if the array grew in the meanwhile
- if (matches2 == matches)
- break;
- }
- } catch (out_of_range&) {
- // Do nothing
- }
+ if (segment_id >= segments_.size())
+ return;
+
+ const DecodeSegment *segment = &(segments_[segment_id]);
+
+ const DecodeBinaryClass* bin_class = nullptr;
+ for (const DecodeBinaryClass& bc : segment->binary_classes)
+ if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
+ bin_class = &bc;
+
+ // Determine overall size before copying to resize dest vector only once
+ uint64_t size = 0;
+ uint64_t matches = 0;
+ for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
+ if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
+ size += chunk.data.size();
+ matches++;
+ }
+ dest->resize(size);
+
+ uint64_t offset = 0;
+ uint64_t matches2 = 0;
+ for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
+ if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
+ memcpy(dest->data() + offset, chunk.data.data(), chunk.data.size());
+ offset += chunk.data.size();
+ matches2++;
+
+ // Make sure we don't overwrite memory if the array grew in the meanwhile
+ if (matches2 == matches)
+ break;
+ }
}
void DecodeSignal::get_merged_binary_data_chunks_by_offset(uint32_t segment_id,
{
assert(dest != nullptr);
- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
-
- const DecodeBinaryClass* bin_class = nullptr;
- for (const DecodeBinaryClass& bc : segment->binary_classes)
- if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
- bin_class = &bc;
-
- // Determine overall size before copying to resize dest vector only once
- uint64_t size = 0;
- uint64_t offset = 0;
- for (const DecodeBinaryDataChunk& chunk : bin_class->chunks) {
- if (offset >= start)
- size += chunk.data.size();
- offset += chunk.data.size();
- if (offset >= end)
- break;
- }
- dest->resize(size);
-
- offset = 0;
- uint64_t dest_offset = 0;
- for (const DecodeBinaryDataChunk& chunk : bin_class->chunks) {
- if (offset >= start) {
- memcpy(dest->data() + dest_offset, chunk.data.data(), chunk.data.size());
- dest_offset += chunk.data.size();
- }
- offset += chunk.data.size();
- if (offset >= end)
- break;
+ if (segment_id >= segments_.size())
+ return;
+
+ const DecodeSegment *segment = &(segments_[segment_id]);
+
+ const DecodeBinaryClass* bin_class = nullptr;
+ for (const DecodeBinaryClass& bc : segment->binary_classes)
+ if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
+ bin_class = &bc;
+
+ // Determine overall size before copying to resize dest vector only once
+ uint64_t size = 0;
+ uint64_t offset = 0;
+ for (const DecodeBinaryDataChunk& chunk : bin_class->chunks) {
+ if (offset >= start)
+ size += chunk.data.size();
+ offset += chunk.data.size();
+ if (offset >= end)
+ break;
+ }
+ dest->resize(size);
+
+ offset = 0;
+ uint64_t dest_offset = 0;
+ for (const DecodeBinaryDataChunk& chunk : bin_class->chunks) {
+ if (offset >= start) {
+ memcpy(dest->data() + dest_offset, chunk.data.data(), chunk.data.size());
+ dest_offset += chunk.data.size();
}
- } catch (out_of_range&) {
- // Do nothing
+ offset += chunk.data.size();
+ if (offset >= end)
+ break;
}
}
const DecodeBinaryClass* DecodeSignal::get_binary_data_class(uint32_t segment_id,
const Decoder* dec, uint32_t bin_class_id) const
{
- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
+ if (segment_id >= segments_.size())
+ return nullptr;
- for (const DecodeBinaryClass& bc : segment->binary_classes)
- if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
- return &bc;
- } catch (out_of_range&) {
- // Do nothing
- }
+ const DecodeSegment *segment = &(segments_[segment_id]);
+
+ for (const DecodeBinaryClass& bc : segment->binary_classes)
+ if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
+ return &bc;
return nullptr;
}
const deque<const Annotation*>* DecodeSignal::get_all_annotations_by_segment(
uint32_t segment_id) const
{
- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
- return &(segment->all_annotations);
- } catch (out_of_range&) {
- // Do nothing
- }
+ if (segment_id >= segments_.size())
+ return nullptr;
- return nullptr;
+ const DecodeSegment *segment = &(segments_[segment_id]);
+
+ return &(segment->all_annotations);
}
void DecodeSignal::save_settings(QSettings &settings) const
i = 0;
for (const AnnotationClass* ann_class : decoder->ann_classes()) {
settings.beginGroup("ann_class" + QString::number(i));
- settings.setValue("visible", ann_class->visible);
+ settings.setValue("visible", ann_class->visible());
settings.endGroup();
i++;
}
if (QString::fromUtf8(dec->id) == id) {
shared_ptr<Decoder> decoder = make_shared<Decoder>(dec, stack_.size());
+ connect(decoder.get(), SIGNAL(annotation_visibility_changed()),
+ this, SLOT(on_annotation_visibility_changed()));
+
stack_.push_back(decoder);
decoder->set_visible(settings.value("visible", true).toBool());
i = 0;
for (AnnotationClass* ann_class : decoder->ann_classes()) {
settings.beginGroup("ann_class" + QString::number(i));
- ann_class->visible = settings.value("visible", true).toBool();
+ ann_class->set_visible(settings.value("visible", true).toBool());
settings.endGroup();
i++;
}
QString assigned_signal_name = settings.value("assigned_signal_name").toString();
for (const shared_ptr<data::SignalBase>& signal : signalbases)
- if (signal->name() == assigned_signal_name)
+ if ((signal->name() == assigned_signal_name) && (signal->type() != SignalBase::DecodeChannel))
channel->assigned_signal = signal.get();
channel->initial_pin_state = settings.value("initial_pin_state").toInt();
logic_mux_cond_.notify_one();
}
+void DecodeSignal::on_annotation_visibility_changed()
+{
+ annotation_visibility_changed();
+}
+
} // namespace data
} // namespace pv