min_value_(0),
max_value_(0)
{
- if (channel_)
+ if (channel_) {
internal_name_ = QString::fromStdString(channel_->name());
+ index_ = channel_->index();
+ }
connect(&delayed_conversion_starter_, SIGNAL(timeout()),
this, SLOT(on_delayed_conversion_start()));
return internal_name_;
}
+void SignalBase::set_internal_name(QString internal_name)
+{
+ internal_name_ = internal_name;
+}
+
QString SignalBase::display_name() const
{
if ((name() != internal_name_) && (!internal_name_.isEmpty()))
unsigned int SignalBase::index() const
{
- return (channel_) ? channel_->index() : 0;
+ return index_;
+}
+
+void SignalBase::set_index(unsigned int index)
+{
+ index_ = index;
}
unsigned int SignalBase::logic_bit_index() const
{
if (channel_type_ == LogicChannel)
- return channel_->index();
+ return index_;
else
return 0;
}
public:
/**
* Returns the underlying SR channel.
+ * Generated channels don't have a SR channel.
*/
shared_ptr<sigrok::Channel> channel() const;
*/
unsigned int index() const;
+ /**
+ * Sets the index number of this channel, i.e. a unique ID assigned by
+ * the device driver or the logic bit index (see below).
+ * Only use immediately after creating the signal and leave it untouched after.
+ */
+ void set_index(unsigned int index);
+
/**
* Returns which bit of a given sample for this signal represents the
* signal itself. This is relevant for compound signals like logic,
QString name() const;
/**
- * Gets the internal name of this signal, i.e. how the device calls it.
+ * Gets the internal name of this signal, i.e. how the device/generator calls it.
*/
QString internal_name() const;
+ /**
+ * Sets the internal name of this signal, i.e. how the device/generator calls it.
+ * Only use immediately after creating the signal and leave it untouched after.
+ */
+ void set_internal_name(QString internal_name);
+
/**
* Produces a string for this signal that can be used for display,
* i.e. it contains one or both of the signal/internal names.
QString internal_name_, name_;
QColor color_, bgcolor_;
+ unsigned int index_;
};
} // namespace data
return signalbases_;
}
+void Session::add_generated_signal(shared_ptr<data::SignalBase> signal)
+{
+ signalbases_.push_back(signal);
+
+ for (shared_ptr<views::ViewBase>& view : views_)
+ view->add_signalbase(signal);
+
+ update_signals();
+}
+
+void Session::remove_generated_signal(shared_ptr<data::SignalBase> signal)
+{
+ signalbases_.erase(std::remove_if(signalbases_.begin(), signalbases_.end(),
+ [&](shared_ptr<data::SignalBase> s) { return s == signal; }),
+ signalbases_.end());
+
+ for (shared_ptr<views::ViewBase>& view : views_)
+ view->remove_signalbase(signal);
+
+ update_signals();
+}
+
bool Session::all_segments_complete(uint32_t segment_id) const
{
bool all_complete = true;
lock_guard<recursive_mutex> lock(data_mutex_);
cur_logic_segment_.reset();
cur_analog_segments_.clear();
+ for (shared_ptr<data::SignalBase> sb : signalbases_)
+ sb->clear_sample_data();
}
highest_segment_id_ = -1;
frame_began_ = false;
signal_segment_completed();
}
-void Session::feed_in_logic(shared_ptr<Logic> logic)
+void Session::feed_in_logic(shared_ptr<sigrok::Logic> logic)
{
if (logic->data_length() == 0) {
qDebug() << "WARNING: Received logic packet with 0 samples.";
data_received();
}
-void Session::feed_in_analog(shared_ptr<Analog> analog)
+void Session::feed_in_analog(shared_ptr<sigrok::Analog> analog)
{
if (analog->num_samples() == 0) {
qDebug() << "WARNING: Received analog packet with 0 samples.";
bool has_view(shared_ptr<views::ViewBase> view);
const vector< shared_ptr<data::SignalBase> > signalbases() const;
+ void add_generated_signal(shared_ptr<data::SignalBase> signal);
+ void remove_generated_signal(shared_ptr<data::SignalBase> signal);
bool all_segments_complete(uint32_t segment_id) const;
this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t)));
}
+void ViewBase::remove_signalbase(const shared_ptr<data::SignalBase> signalbase)
+{
+ disconnect(signalbase.get(), SIGNAL(samples_cleared()),
+ this, SLOT(on_data_updated()));
+ disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
+ this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t)));
+
+ signalbases_.erase(std::remove_if(signalbases_.begin(), signalbases_.end(),
+ [&](shared_ptr<data::SignalBase> s) { return s == signalbase; }),
+ signalbases_.end());
+}
+
#ifdef ENABLE_DECODE
void ViewBase::clear_decode_signals()
{
virtual void clear_signalbases();
virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase);
+ virtual void remove_signalbase(const shared_ptr<data::SignalBase> signalbase);
#ifdef ENABLE_DECODE
virtual void clear_decode_signals();