bindings: Use SR_DF_ANALOG, drop SR_DF_ANALOG_OLD support.
All SR_DF_ANALOG_OLD packets are automatically converted to SR_DF_ANALOG in the session already.
This commit is contained in:
parent
edb691fced
commit
dd13d47a9e
|
@ -319,21 +319,25 @@ shared_ptr<Packet> Context::create_logic_packet(
|
||||||
return shared_ptr<Packet>(new Packet(nullptr, packet), Packet::Deleter());
|
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,
|
vector<shared_ptr<Channel> > channels,
|
||||||
float *data_pointer, unsigned int num_samples, const Quantity *mq,
|
float *data_pointer, unsigned int num_samples, const Quantity *mq,
|
||||||
const Unit *unit, vector<const QuantityFlag *> mqflags)
|
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)
|
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->num_samples = num_samples;
|
||||||
analog->mq = mq->id();
|
meaning->mq = (sr_mq)mq->id();
|
||||||
analog->unit = unit->id();
|
meaning->unit = (sr_unit)unit->id();
|
||||||
analog->mqflags = QuantityFlag::mask_from_flags(mqflags);
|
meaning->mqflags = (sr_mqflag)QuantityFlag::mask_from_flags(mqflags);
|
||||||
analog->data = data_pointer;
|
analog->data = data_pointer;
|
||||||
auto packet = g_new(struct sr_datafeed_packet, 1);
|
auto packet = g_new(struct sr_datafeed_packet, 1);
|
||||||
packet->type = SR_DF_ANALOG_OLD;
|
packet->type = SR_DF_ANALOG;
|
||||||
packet->payload = analog;
|
packet->payload = analog;
|
||||||
return shared_ptr<Packet>(new Packet(nullptr, packet), Packet::Deleter());
|
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 *>(
|
static_cast<const struct sr_datafeed_logic *>(
|
||||||
structure->payload));
|
structure->payload));
|
||||||
break;
|
break;
|
||||||
case SR_DF_ANALOG_OLD:
|
case SR_DF_ANALOG:
|
||||||
_payload = new AnalogOld(
|
_payload = new Analog(
|
||||||
static_cast<const struct sr_datafeed_analog_old *>(
|
static_cast<const struct sr_datafeed_analog *>(
|
||||||
structure->payload));
|
structure->payload));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1192,54 +1196,54 @@ unsigned int Logic::unit_size()
|
||||||
return _structure->unitsize;
|
return _structure->unitsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalogOld::AnalogOld(const struct sr_datafeed_analog_old *structure) :
|
Analog::Analog(const struct sr_datafeed_analog *structure) :
|
||||||
ParentOwned(structure),
|
ParentOwned(structure),
|
||||||
PacketPayload()
|
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>(
|
return static_pointer_cast<PacketPayload>(
|
||||||
ParentOwned::get_shared_pointer(_parent));
|
ParentOwned::get_shared_pointer(_parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
float *AnalogOld::data_pointer()
|
void *Analog::data_pointer()
|
||||||
{
|
{
|
||||||
return _structure->data;
|
return _structure->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int AnalogOld::num_samples()
|
unsigned int Analog::num_samples()
|
||||||
{
|
{
|
||||||
return _structure->num_samples;
|
return _structure->num_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<shared_ptr<Channel>> AnalogOld::channels()
|
vector<shared_ptr<Channel>> Analog::channels()
|
||||||
{
|
{
|
||||||
vector<shared_ptr<Channel>> result;
|
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(
|
result.push_back(_parent->_device->get_channel(
|
||||||
(struct sr_channel *)l->data));
|
(struct sr_channel *)l->data));
|
||||||
return result;
|
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) :
|
InputFormat::InputFormat(const struct sr_input_module *structure) :
|
||||||
|
|
|
@ -297,7 +297,7 @@ public:
|
||||||
shared_ptr<Packet> create_logic_packet(
|
shared_ptr<Packet> create_logic_packet(
|
||||||
void *data_pointer, size_t data_length, unsigned int unit_size);
|
void *data_pointer, size_t data_length, unsigned int unit_size);
|
||||||
/** Create an analog packet. */
|
/** Create an analog packet. */
|
||||||
shared_ptr<Packet> create_analog_old_packet(
|
shared_ptr<Packet> create_analog_packet(
|
||||||
vector<shared_ptr<Channel> > channels,
|
vector<shared_ptr<Channel> > channels,
|
||||||
float *data_pointer, unsigned int num_samples, const Quantity *mq,
|
float *data_pointer, unsigned int num_samples, const Quantity *mq,
|
||||||
const Unit *unit, vector<const QuantityFlag *> mqflags);
|
const Unit *unit, vector<const QuantityFlag *> mqflags);
|
||||||
|
@ -428,7 +428,7 @@ protected:
|
||||||
friend class Channel;
|
friend class Channel;
|
||||||
friend class ChannelGroup;
|
friend class ChannelGroup;
|
||||||
friend class Output;
|
friend class Output;
|
||||||
friend class AnalogOld;
|
friend class Analog;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A real hardware device, connected via a driver */
|
/** A real hardware device, connected via a driver */
|
||||||
|
@ -702,7 +702,7 @@ protected:
|
||||||
friend class Header;
|
friend class Header;
|
||||||
friend class Meta;
|
friend class Meta;
|
||||||
friend class Logic;
|
friend class Logic;
|
||||||
friend class AnalogOld;
|
friend class Analog;
|
||||||
friend class Context;
|
friend class Context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -777,15 +777,15 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Payload of a datafeed packet with analog data */
|
/** Payload of a datafeed packet with analog data */
|
||||||
class SR_API AnalogOld :
|
class SR_API Analog :
|
||||||
public ParentOwned<AnalogOld, Packet, const struct sr_datafeed_analog_old>,
|
public ParentOwned<Analog, Packet, const struct sr_datafeed_analog>,
|
||||||
public PacketPayload
|
public PacketPayload
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Pointer to data. */
|
/** Pointer to data. */
|
||||||
float *data_pointer();
|
void *data_pointer();
|
||||||
/** Number of samples in this packet. */
|
/** Number of samples in this packet. */
|
||||||
unsigned int num_samples();
|
uint32_t num_samples();
|
||||||
/** Channels for which this packet contains data. */
|
/** Channels for which this packet contains data. */
|
||||||
vector<shared_ptr<Channel> > channels();
|
vector<shared_ptr<Channel> > channels();
|
||||||
/** Measured quantity of the samples in this packet. */
|
/** Measured quantity of the samples in this packet. */
|
||||||
|
@ -795,8 +795,8 @@ public:
|
||||||
/** Measurement flags associated with the samples in this packet. */
|
/** Measurement flags associated with the samples in this packet. */
|
||||||
vector<const QuantityFlag *> mq_flags();
|
vector<const QuantityFlag *> mq_flags();
|
||||||
protected:
|
protected:
|
||||||
AnalogOld(const struct sr_datafeed_analog_old *structure);
|
Analog(const struct sr_datafeed_analog *structure);
|
||||||
~AnalogOld();
|
~Analog();
|
||||||
shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
|
shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
|
||||||
friend class Packet;
|
friend class Packet;
|
||||||
};
|
};
|
||||||
|
|
|
@ -385,7 +385,7 @@ typedef jobject jdatafeedcallback;
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
/* Ignore this for now, needs a fix. */
|
/* 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"
|
%include "bindings/swig/classes.i"
|
||||||
|
|
||||||
|
|
|
@ -250,9 +250,9 @@ typedef guint pyg_flags_type;
|
||||||
{
|
{
|
||||||
return dynamic_pointer_cast<sigrok::Meta>($self->payload());
|
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()
|
std::shared_ptr<sigrok::Logic> _payload_logic()
|
||||||
{
|
{
|
||||||
|
@ -271,8 +271,8 @@ typedef guint pyg_flags_type;
|
||||||
return self._payload_meta()
|
return self._payload_meta()
|
||||||
elif self.type == PacketType.LOGIC:
|
elif self.type == PacketType.LOGIC:
|
||||||
return self._payload_logic()
|
return self._payload_logic()
|
||||||
elif self.type == PacketType.ANALOG_OLD:
|
elif self.type == PacketType.ANALOG:
|
||||||
return self._payload_analog_old()
|
return self._payload_analog()
|
||||||
else:
|
else:
|
||||||
return None
|
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 these methods, we will override them below. */
|
||||||
%ignore sigrok::AnalogOld::data;
|
%ignore sigrok::Analog::data;
|
||||||
%ignore sigrok::Driver::scan;
|
%ignore sigrok::Driver::scan;
|
||||||
%ignore sigrok::InputFormat::create_input;
|
%ignore sigrok::InputFormat::create_input;
|
||||||
%ignore sigrok::OutputFormat::create_output;
|
%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(). */
|
/* Return NumPy array from Analog::data(). */
|
||||||
%extend sigrok::AnalogOld
|
%extend sigrok::Analog
|
||||||
{
|
{
|
||||||
PyObject * _data()
|
PyObject * _data()
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ template< class T > class enable_shared_from_this;
|
||||||
%shared_ptr(sigrok::PacketPayload);
|
%shared_ptr(sigrok::PacketPayload);
|
||||||
%shared_ptr(sigrok::Header);
|
%shared_ptr(sigrok::Header);
|
||||||
%shared_ptr(sigrok::Meta);
|
%shared_ptr(sigrok::Meta);
|
||||||
%shared_ptr(sigrok::AnalogOld);
|
%shared_ptr(sigrok::Analog);
|
||||||
%shared_ptr(sigrok::Logic);
|
%shared_ptr(sigrok::Logic);
|
||||||
%shared_ptr(sigrok::InputFormat);
|
%shared_ptr(sigrok::InputFormat);
|
||||||
%shared_ptr(sigrok::Input);
|
%shared_ptr(sigrok::Input);
|
||||||
|
@ -259,12 +259,12 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
|
||||||
|
|
||||||
%attributemap(Meta, map_ConfigKey_Variant, config, config);
|
%attributemap(Meta, map_ConfigKey_Variant, config, config);
|
||||||
|
|
||||||
%attributevector(AnalogOld,
|
%attributevector(Analog,
|
||||||
std::vector<std::shared_ptr<sigrok::Channel> >, channels, channels);
|
std::vector<std::shared_ptr<sigrok::Channel> >, channels, channels);
|
||||||
%attribute(sigrok::AnalogOld, int, num_samples, num_samples);
|
%attribute(sigrok::Analog, int, num_samples, num_samples);
|
||||||
%attribute(sigrok::AnalogOld, const sigrok::Quantity *, mq, mq);
|
%attribute(sigrok::Analog, const sigrok::Quantity *, mq, mq);
|
||||||
%attribute(sigrok::AnalogOld, const sigrok::Unit *, unit, unit);
|
%attribute(sigrok::Analog, const sigrok::Unit *, unit, unit);
|
||||||
%attributevector(AnalogOld, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
|
%attributevector(Analog, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
|
||||||
|
|
||||||
%include <libsigrokcxx/libsigrokcxx.hpp>
|
%include <libsigrokcxx/libsigrokcxx.hpp>
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ enum sr_packettype {
|
||||||
SR_DF_TRIGGER,
|
SR_DF_TRIGGER,
|
||||||
/** Payload is struct sr_datafeed_logic. */
|
/** Payload is struct sr_datafeed_logic. */
|
||||||
SR_DF_LOGIC,
|
SR_DF_LOGIC,
|
||||||
/** Payload is struct sr_datafeed_analog_old. */
|
/** DEPRECATED! Use SR_DF_ANALOG instead. */
|
||||||
SR_DF_ANALOG_OLD,
|
SR_DF_ANALOG_OLD,
|
||||||
/** Beginning of frame. No payload. */
|
/** Beginning of frame. No payload. */
|
||||||
SR_DF_FRAME_BEGIN,
|
SR_DF_FRAME_BEGIN,
|
||||||
|
|
Loading…
Reference in New Issue