+ return Unit::get(_structure->meaning->unit);
+}
+
+vector<const QuantityFlag *> Analog::mq_flags() const
+{
+ return QuantityFlag::flags_from_mask(_structure->meaning->mqflags);
+}
+
+shared_ptr<Logic> Analog::get_logic_via_threshold(float threshold,
+ uint8_t *data_ptr) const
+{
+ auto datafeed = g_new(struct sr_datafeed_logic, 1);
+ datafeed->length = num_samples();
+ datafeed->unitsize = 1;
+
+ if (data_ptr)
+ datafeed->data = data_ptr;
+ else
+ datafeed->data = g_malloc(datafeed->length);
+
+ shared_ptr<Logic> logic =
+ shared_ptr<Logic>{new Logic{datafeed}, default_delete<Logic>{}};
+
+ check(sr_a2l_threshold(_structure, threshold,
+ (uint8_t*)datafeed->data, datafeed->length));
+
+ return logic;
+}
+
+shared_ptr<Logic> Analog::get_logic_via_schmitt_trigger(float lo_thr,
+ float hi_thr, uint8_t *state, uint8_t *data_ptr) const
+{
+ auto datafeed = g_new(struct sr_datafeed_logic, 1);
+ datafeed->length = num_samples();
+ datafeed->unitsize = 1;
+
+ if (data_ptr)
+ datafeed->data = data_ptr;
+ else
+ datafeed->data = g_malloc(datafeed->length);
+
+ shared_ptr<Logic> logic =
+ shared_ptr<Logic>{new Logic{datafeed}, default_delete<Logic>{}};
+
+ check(sr_a2l_schmitt_trigger(_structure, lo_thr, hi_thr, state,
+ (uint8_t*)datafeed->data, datafeed->length));
+
+ return logic;
+}
+
+Rational::Rational(const struct sr_rational *structure) :
+ _structure(structure)
+{
+}
+
+Rational::~Rational()
+{
+}
+
+shared_ptr<Rational> Rational::share_owned_by(shared_ptr<Analog> _parent)
+{
+ return static_pointer_cast<Rational>(
+ ParentOwned::share_owned_by(_parent));
+}
+
+int64_t Rational::numerator() const
+{
+ return _structure->p;
+}
+
+uint64_t Rational::denominator() const
+{
+ return _structure->q;
+}
+
+float Rational::value() const
+{
+ return (float)(_structure->p) / (float)(_structure->q);