namespace data {
Analog::Analog() :
- SignalData()
+ SignalData(),
+ samplerate_(1) // Default is 1 Hz to prevent division-by-zero errors
{
}
samples_cleared();
}
-double Analog::get_samplerate() const
+void Analog::set_samplerate(double value)
{
- if (segments_.empty())
- return 1.0;
+ samplerate_ = value;
+}
- return segments_.front()->samplerate();
+double Analog::get_samplerate() const
+{
+ return samplerate_;
}
uint64_t Analog::max_sample_count() const
void clear();
+ void set_samplerate(double value);
+
double get_samplerate() const;
uint64_t max_sample_count() const;
void min_max_changed(float min, float max);
private:
+ double samplerate_;
deque< shared_ptr<AnalogSegment> > segments_;
};
Logic::Logic(unsigned int num_channels) :
SignalData(),
+ samplerate_(1), // Default is 1 Hz to prevent division-by-zero errors
num_channels_(num_channels)
{
assert(num_channels_ > 0);
samples_cleared();
}
-double Logic::get_samplerate() const
+void Logic::set_samplerate(double value)
{
- if (segments_.empty())
- return 1.0;
+ samplerate_ = value;
+}
- return segments_.front()->samplerate();
+double Logic::get_samplerate() const
+{
+ return samplerate_;
}
uint64_t Logic::max_sample_count() const
void clear();
+ void set_samplerate(double value);
+
double get_samplerate() const;
uint64_t max_sample_count() const;
uint64_t end_sample);
private:
+ double samplerate_;
const unsigned int num_channels_;
deque< shared_ptr<LogicSegment> > segments_;
};
}
}
+void SignalBase::clear_sample_data()
+{
+ if (analog_data())
+ analog_data()->clear();
+
+ if (logic_data())
+ logic_data()->clear();
+}
+
shared_ptr<data::Analog> SignalBase::analog_data() const
{
shared_ptr<Analog> result = nullptr;
*/
void set_data(shared_ptr<pv::data::SignalData> data);
+ /**
+ * Clears all sample data and removes all associated segments.
+ */
+ void clear_sample_data();
+
/**
* Get the internal data as analog data object in case of analog type.
*/
virtual uint64_t max_sample_count() const = 0;
+ virtual void set_samplerate(double value) = 0;
+
virtual double get_samplerate() const = 0;
};