]> sigrok.org Git - libsigrok.git/commitdiff
bindings: Use SR_DF_ANALOG, drop SR_DF_ANALOG_OLD support.
authorUwe Hermann <redacted>
Fri, 2 Oct 2015 14:18:35 +0000 (16:18 +0200)
committerUwe Hermann <redacted>
Tue, 20 Oct 2015 22:29:29 +0000 (00:29 +0200)
All SR_DF_ANALOG_OLD packets are automatically converted to SR_DF_ANALOG
in the session already.

bindings/cxx/classes.cpp
bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp
bindings/java/org/sigrok/core/classes/classes.i
bindings/python/sigrok/core/classes.i
bindings/swig/classes.i
include/libsigrok/libsigrok.h

index 3e441f72252c2e4a34ebe30c303cd7a0e4b07a1c..d7ba79177033bbee9ea164c20d787066fb7330a2 100644 (file)
@@ -319,21 +319,25 @@ shared_ptr<Packet> Context::create_logic_packet(
        return shared_ptr<Packet>(new Packet(nullptr, packet), Packet::Deleter());
 }
 
-shared_ptr<Packet> Context::create_analog_old_packet(
+shared_ptr<Packet> Context::create_analog_packet(
        vector<shared_ptr<Channel> > channels,
        float *data_pointer, unsigned int num_samples, const Quantity *mq,
        const Unit *unit, vector<const QuantityFlag *> mqflags)
 {
-       auto analog = g_new0(struct sr_datafeed_analog_old, 1);
+       auto analog = g_new0(struct sr_datafeed_analog, 1);
+       auto meaning = g_new0(struct sr_analog_meaning, 1);
+
+       analog->meaning = meaning;
+
        for (auto channel : channels)
-               analog->channels = g_slist_append(analog->channels, channel->_structure);
+               meaning->channels = g_slist_append(meaning->channels, channel->_structure);
        analog->num_samples = num_samples;
-       analog->mq = mq->id();
-       analog->unit = unit->id();
-       analog->mqflags = QuantityFlag::mask_from_flags(mqflags);
+       meaning->mq = (sr_mq)mq->id();
+       meaning->unit = (sr_unit)unit->id();
+       meaning->mqflags = (sr_mqflag)QuantityFlag::mask_from_flags(mqflags);
        analog->data = data_pointer;
        auto packet = g_new(struct sr_datafeed_packet, 1);
-       packet->type = SR_DF_ANALOG_OLD;
+       packet->type = SR_DF_ANALOG;
        packet->payload = analog;
        return shared_ptr<Packet>(new Packet(nullptr, packet), Packet::Deleter());
 }
@@ -1068,9 +1072,9 @@ Packet::Packet(shared_ptr<Device> device,
                                static_cast<const struct sr_datafeed_logic *>(
                                        structure->payload));
                        break;
-               case SR_DF_ANALOG_OLD:
-                       _payload = new AnalogOld(
-                               static_cast<const struct sr_datafeed_analog_old *>(
+               case SR_DF_ANALOG:
+                       _payload = new Analog(
+                               static_cast<const struct sr_datafeed_analog *>(
                                        structure->payload));
                        break;
                default:
@@ -1192,54 +1196,54 @@ unsigned int Logic::unit_size()
        return _structure->unitsize;
 }
 
-AnalogOld::AnalogOld(const struct sr_datafeed_analog_old *structure) :
+Analog::Analog(const struct sr_datafeed_analog *structure) :
        ParentOwned(structure),
        PacketPayload()
 {
 }
 
-AnalogOld::~AnalogOld()
+Analog::~Analog()
 {
 }
 
-shared_ptr<PacketPayload> AnalogOld::get_shared_pointer(Packet *_parent)
+shared_ptr<PacketPayload> Analog::get_shared_pointer(Packet *_parent)
 {
        return static_pointer_cast<PacketPayload>(
                ParentOwned::get_shared_pointer(_parent));
 }
 
-float *AnalogOld::data_pointer()
+void *Analog::data_pointer()
 {
        return _structure->data;
 }
 
-unsigned int AnalogOld::num_samples()
+unsigned int Analog::num_samples()
 {
        return _structure->num_samples;
 }
 
-vector<shared_ptr<Channel>> AnalogOld::channels()
+vector<shared_ptr<Channel>> Analog::channels()
 {
        vector<shared_ptr<Channel>> result;
-       for (auto l = _structure->channels; l; l = l->next)
+       for (auto l = _structure->meaning->channels; l; l = l->next)
                result.push_back(_parent->_device->get_channel(
                        (struct sr_channel *)l->data));
        return result;
 }
 
-const Quantity *AnalogOld::mq()
+const Quantity *Analog::mq()
 {
-       return Quantity::get(_structure->mq);
+       return Quantity::get(_structure->meaning->mq);
 }
 
-const Unit *AnalogOld::unit()
+const Unit *Analog::unit()
 {
-       return Unit::get(_structure->unit);
+       return Unit::get(_structure->meaning->unit);
 }
 
-vector<const QuantityFlag *> AnalogOld::mq_flags()
+vector<const QuantityFlag *> Analog::mq_flags()
 {
-       return QuantityFlag::flags_from_mask(_structure->mqflags);
+       return QuantityFlag::flags_from_mask(_structure->meaning->mqflags);
 }
 
 InputFormat::InputFormat(const struct sr_input_module *structure) :
index 3c8e7276b13a6b7a563eaf7fc265f829a1d56384..d76f9b8758023cd015a14a553fa7d809eb77e78a 100644 (file)
@@ -297,7 +297,7 @@ public:
        shared_ptr<Packet> create_logic_packet(
                void *data_pointer, size_t data_length, unsigned int unit_size);
        /** Create an analog packet. */
-       shared_ptr<Packet> create_analog_old_packet(
+       shared_ptr<Packet> create_analog_packet(
                vector<shared_ptr<Channel> > channels,
                float *data_pointer, unsigned int num_samples, const Quantity *mq,
                const Unit *unit, vector<const QuantityFlag *> mqflags);
@@ -428,7 +428,7 @@ protected:
        friend class Channel;
        friend class ChannelGroup;
        friend class Output;
-       friend class AnalogOld;
+       friend class Analog;
 };
 
 /** A real hardware device, connected via a driver */
@@ -702,7 +702,7 @@ protected:
        friend class Header;
        friend class Meta;
        friend class Logic;
-       friend class AnalogOld;
+       friend class Analog;
        friend class Context;
 };
 
@@ -777,15 +777,15 @@ protected:
 };
 
 /** Payload of a datafeed packet with analog data */
-class SR_API AnalogOld :
-       public ParentOwned<AnalogOld, Packet, const struct sr_datafeed_analog_old>,
+class SR_API Analog :
+       public ParentOwned<Analog, Packet, const struct sr_datafeed_analog>,
        public PacketPayload
 {
 public:
        /** Pointer to data. */
-       float *data_pointer();
+       void *data_pointer();
        /** Number of samples in this packet. */
-       unsigned int num_samples();
+       uint32_t num_samples();
        /** Channels for which this packet contains data. */
        vector<shared_ptr<Channel> > channels();
        /** Measured quantity of the samples in this packet. */
@@ -795,8 +795,8 @@ public:
        /** Measurement flags associated with the samples in this packet. */
        vector<const QuantityFlag *> mq_flags();
 protected:
-       AnalogOld(const struct sr_datafeed_analog_old *structure);
-       ~AnalogOld();
+       Analog(const struct sr_datafeed_analog *structure);
+       ~Analog();
        shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
        friend class Packet;
 };
index 44efc1c51e43f396c327e84b2710af2f292e3f5d..34323b16a8df7f24131cde337b38360f3aba1a69 100644 (file)
@@ -385,7 +385,7 @@ typedef jobject jdatafeedcallback;
 %enddef
 
 /* Ignore this for now, needs a fix. */
-%ignore sigrok::Context::create_analog_old_packet;
+%ignore sigrok::Context::create_analog_packet;
 
 %include "bindings/swig/classes.i"
 
index 07b13715964a699ee685f77084bdabd658e49ce5..49cfba98791443e48c7b0f4fe8d7eec246d7a873 100644 (file)
@@ -250,9 +250,9 @@ typedef guint pyg_flags_type;
     {
         return dynamic_pointer_cast<sigrok::Meta>($self->payload());
     }
-    std::shared_ptr<sigrok::AnalogOld> _payload_analog_old()
+    std::shared_ptr<sigrok::Analog> _payload_analog()
     {
-        return dynamic_pointer_cast<sigrok::AnalogOld>($self->payload());
+        return dynamic_pointer_cast<sigrok::Analog>($self->payload());
     }
     std::shared_ptr<sigrok::Logic> _payload_logic()
     {
@@ -271,8 +271,8 @@ typedef guint pyg_flags_type;
             return self._payload_meta()
         elif self.type == PacketType.LOGIC:
             return self._payload_logic()
-        elif self.type == PacketType.ANALOG_OLD:
-            return self._payload_analog_old()
+        elif self.type == PacketType.ANALOG:
+            return self._payload_analog()
         else:
             return None
 
@@ -377,7 +377,7 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
 %}
 
 /* Ignore these methods, we will override them below. */
-%ignore sigrok::AnalogOld::data;
+%ignore sigrok::Analog::data;
 %ignore sigrok::Driver::scan;
 %ignore sigrok::InputFormat::create_input;
 %ignore sigrok::OutputFormat::create_output;
@@ -506,8 +506,8 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
     }
 }
 
-/* Return NumPy array from AnalogOld::data(). */
-%extend sigrok::AnalogOld
+/* Return NumPy array from Analog::data(). */
+%extend sigrok::Analog
 {
     PyObject * _data()
     {
index 443d77b5e78578c82555303d689a1d80622c6eaa..309bd34057f78eed5fd3b376b1b4571224176baa 100644 (file)
@@ -72,7 +72,7 @@ template< class T > class enable_shared_from_this;
 %shared_ptr(sigrok::PacketPayload);
 %shared_ptr(sigrok::Header);
 %shared_ptr(sigrok::Meta);
-%shared_ptr(sigrok::AnalogOld);
+%shared_ptr(sigrok::Analog);
 %shared_ptr(sigrok::Logic);
 %shared_ptr(sigrok::InputFormat);
 %shared_ptr(sigrok::Input);
@@ -259,12 +259,12 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
 
 %attributemap(Meta, map_ConfigKey_Variant, config, config);
 
-%attributevector(AnalogOld,
+%attributevector(Analog,
     std::vector<std::shared_ptr<sigrok::Channel> >, channels, channels);
-%attribute(sigrok::AnalogOld, int, num_samples, num_samples);
-%attribute(sigrok::AnalogOld, const sigrok::Quantity *, mq, mq);
-%attribute(sigrok::AnalogOld, const sigrok::Unit *, unit, unit);
-%attributevector(AnalogOld, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
+%attribute(sigrok::Analog, int, num_samples, num_samples);
+%attribute(sigrok::Analog, const sigrok::Quantity *, mq, mq);
+%attribute(sigrok::Analog, const sigrok::Unit *, unit, unit);
+%attributevector(Analog, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
 
 %include <libsigrokcxx/libsigrokcxx.hpp>
 
index 69d88d19d7b8505bbc660dbdb904b68e4b8daf19..12bbb171a7fde5564b5bd548a6c2af1bc1429edc 100644 (file)
@@ -162,7 +162,7 @@ enum sr_packettype {
        SR_DF_TRIGGER,
        /** Payload is struct sr_datafeed_logic. */
        SR_DF_LOGIC,
-       /** Payload is struct sr_datafeed_analog_old. */
+       /** DEPRECATED! Use SR_DF_ANALOG instead. */
        SR_DF_ANALOG_OLD,
        /** Beginning of frame. No payload. */
        SR_DF_FRAME_BEGIN,