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());
}
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:
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) :
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);
friend class Channel;
friend class ChannelGroup;
friend class Output;
- friend class AnalogOld;
+ friend class Analog;
};
/** A real hardware device, connected via a driver */
friend class Header;
friend class Meta;
friend class Logic;
- friend class AnalogOld;
+ friend class Analog;
friend class Context;
};
};
/** 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. */
/** 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;
};
%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"
{
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()
{
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
%}
/* 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;
}
}
-/* Return NumPy array from AnalogOld::data(). */
-%extend sigrok::AnalogOld
+/* Return NumPy array from Analog::data(). */
+%extend sigrok::Analog
{
PyObject * _data()
{
%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);
%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>
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,