{
int min_val = INT_MAX;
+ // Find the lowest common number of segments
for (shared_ptr<data::SignalData> data : all_signal_data_)
if (data->get_segment_count() < min_val)
min_val = data->get_segment_count();
- return min_val;
+ return (min_val != INT_MAX) ? min_val : 0;
}
const unordered_set< shared_ptr<data::SignalBase> > Session::signalbases() const
out_of_memory_ = false;
+ {
+ lock_guard<recursive_mutex> lock(data_mutex_);
+ cur_logic_segment_.reset();
+ cur_analog_segments_.clear();
+ }
+ highest_segment_id_ = -1;
+
try {
device_->start();
} catch (Error e) {
}
}
+void Session::signal_new_segment()
+{
+ int new_segment_id = 1;
+
+ if ((cur_logic_segment_ != nullptr) || !cur_analog_segments_.empty()) {
+
+ // Determine new frame/segment number, assuming that all
+ // signals have the same number of frames/segments
+ if (cur_logic_segment_) {
+ new_segment_id = logic_data_->get_segment_count();
+ } else {
+ shared_ptr<sigrok::Channel> any_channel =
+ (*cur_analog_segments_.begin()).first;
+
+ shared_ptr<data::SignalBase> base = signalbase_from_channel(any_channel);
+ assert(base);
+
+ shared_ptr<data::Analog> data(base->analog_data());
+ assert(data);
+
+ new_segment_id = data->get_segment_count();
+ }
+ }
+
+ if (new_segment_id > highest_segment_id_) {
+ highest_segment_id_ = new_segment_id;
+ new_segment(highest_segment_id_);
+ }
+}
+
void Session::feed_in_header()
{
// Nothing to do here for now
void Session::feed_in_frame_begin()
{
frame_began_ = true;
-
- if (cur_logic_segment_ || !cur_analog_segments_.empty())
- frame_began();
}
void Session::feed_in_frame_end()
cur_analog_segments_.clear();
}
- if (frame_began_) {
+ if (frame_began_)
frame_began_ = false;
- frame_ended();
- }
}
void Session::feed_in_logic(shared_ptr<Logic> logic)
*logic_data_, logic->unit_size(), cur_samplerate_);
logic_data_->push_segment(cur_logic_segment_);
- // @todo Putting this here means that only listeners querying
- // for logic will be notified. Currently the only user of
- // frame_began is DecoderStack, but in future we need to signal
- // this after both analog and logic sweeps have begun.
- frame_began();
+ signal_new_segment();
}
cur_logic_segment_->append_payload(logic);
// Push the segment into the analog data.
data->push_segment(segment);
+
+ signal_new_segment();
}
assert(segment);
void free_unused_memory();
+ void signal_new_segment();
+
void feed_in_header();
void feed_in_meta(shared_ptr<sigrok::Meta> meta);
shared_ptr<data::LogicSegment> cur_logic_segment_;
map< shared_ptr<sigrok::Channel>, shared_ptr<data::AnalogSegment> >
cur_analog_segments_;
+ int32_t highest_segment_id_;
std::thread sampling_thread_;
void trigger_event(util::Timestamp location);
- void frame_began();
+ void new_segment(int new_frame_id);
void data_received();
- void frame_ended();
-
void add_view(const QString &title, views::ViewType type,
Session *session);
segment_selector_->setMinimum(1);
segment_selector_->hide();
- connect(&session_, SIGNAL(frame_ended()),
- this, SLOT(on_segment_added()));
+ connect(&session_, SIGNAL(new_segment(int)),
+ this, SLOT(on_new_segment(int)));
connect(segment_selector_, SIGNAL(valueChanged(int)),
view_, SLOT(on_segment_changed(int)));
action_view_zoom_fit_->setChecked(state);
}
-void StandardBar::on_segment_added()
+void StandardBar::on_new_segment(int new_segment_id)
{
- const int segment_count = session_.get_segment_count();
-
- if (segment_count > 1) {
+ if (new_segment_id > 1) {
show_multi_segment_ui(true);
- segment_selector_->setMaximum(segment_count);
+ segment_selector_->setMaximum(new_segment_id);
} else
show_multi_segment_ui(false);
}
void on_always_zoom_to_fit_changed(bool state);
- void on_segment_added();
+ void on_new_segment(int new_segment_id);
private:
vector<QAction*> multi_segment_actions_;
}
}
+void View::on_new_segment(int new_segment_id)
+{
+ on_segment_changed(new_segment_id);
+}
+
void View::on_segment_changed(int segment)
{
current_segment_ = segment - 1;
void signals_changed();
void capture_state_updated(int state);
+ void on_new_segment(int new_segment_id);
void on_segment_changed(int segment);
virtual void perform_delayed_view_update();
this, SLOT(signals_changed()));
connect(&session_, SIGNAL(capture_state_changed(int)),
this, SLOT(capture_state_updated(int)));
+ connect(&session_, SIGNAL(new_segment(int)),
+ this, SLOT(on_new_segment(int)));
connect(&delayed_view_updater_, SIGNAL(timeout()),
this, SLOT(perform_delayed_view_update()));
{
}
+void ViewBase::on_new_segment(int new_segment_id)
+{
+ (void)new_segment_id;
+}
+
void ViewBase::capture_state_updated(int state)
{
(void)state;
virtual void trigger_event(util::Timestamp location);
virtual void signals_changed();
virtual void capture_state_updated(int state);
+ virtual void on_new_segment(int new_segment_id);
virtual void perform_delayed_view_update();
private Q_SLOTS: