python: Add Analog class.
This commit is contained in:
parent
624f5b4c1e
commit
15574a3cec
|
@ -225,6 +225,9 @@ class Packet(object):
|
|||
if self.struct.type == SR_DF_LOGIC:
|
||||
self._payload = Logic(self,
|
||||
void_ptr_to_sr_datafeed_logic_ptr(pointer))
|
||||
elif self.struct.type == SR_DF_ANALOG:
|
||||
self._payload = Analog(self,
|
||||
void_ptr_to_sr_datafeed_analog_ptr(pointer))
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
"No Python mapping for packet type %ѕ" % self.struct.type)
|
||||
|
@ -243,6 +246,23 @@ class Logic(object):
|
|||
self._data = cdata(self.struct.data, self.struct.length)
|
||||
return self._data
|
||||
|
||||
class Analog(object):
|
||||
|
||||
def __init__(self, packet, struct):
|
||||
self.packet = packet
|
||||
self.struct = struct
|
||||
self._data = None
|
||||
|
||||
@property
|
||||
def num_samples(self):
|
||||
return self.struct.num_samples
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
if self._data is None:
|
||||
self._data = float_array.frompointer(self.struct.data)
|
||||
return self._data
|
||||
|
||||
for symbol_name in dir(lowlevel):
|
||||
prefix = 'SR_DF_'
|
||||
if symbol_name.startswith(prefix):
|
||||
|
|
|
@ -56,9 +56,11 @@ GVariant *g_variant_get_child_value(GVariant *value, unsigned long index);
|
|||
%include "libsigrok/proto.h"
|
||||
%include "libsigrok/version.h"
|
||||
|
||||
%array_class(float, float_array);
|
||||
%pointer_functions(GVariant *, gvariant_ptr_ptr);
|
||||
%array_functions(GVariant *, gvariant_ptr_array);
|
||||
%pointer_functions(struct sr_context *, sr_context_ptr_ptr);
|
||||
%array_functions(struct sr_dev_driver *, sr_dev_driver_ptr_array);
|
||||
%pointer_cast(gpointer, struct sr_dev_inst *, gpointer_to_sr_dev_inst_ptr);
|
||||
%pointer_cast(void *, struct sr_datafeed_logic *, void_ptr_to_sr_datafeed_logic_ptr)
|
||||
%pointer_cast(void *, struct sr_datafeed_analog *, void_ptr_to_sr_datafeed_analog_ptr)
|
||||
|
|
Loading…
Reference in New Issue