saleae.measurements package
AnalogMeasurer is the base class of all custom measurer classes.
A measurer processes a span of contiguous analog samples and produces:
Measures (See
measure.Measure
)Annotations (See
annotation.Annotation
)
To implement a custom measurer:
Subclass
AnalogMeasurer
Declare measures and annotation as class members
Implement the
measure_range()
method
The measure_range method is passed a range of analog samples to process and is where it does its work. The declared measures and annotations should be set within this method.
from saleae.data import AnalogSpan
from saleae.measurements import AnalogMeasurer, Annotation, HorizontalRule, Measure
class MyMeasurer(AnalogMeasurer):
min_measure = Measure('min', description='Minimum Value')
max_measure = Measure('max', description='Maximum Value')
mid_measure = Measure('mid', description='Mid-point')
# This annotation will only be shown if the user has enabled `mid_measure`
mid_annotation = Annotation(measures=[mid_measure])
def measure_range(self, data: AnalogSpan):
self.min_measure.value = data.min
self.max_measure.value = data.max
self.mid_measure.value = (data.max + data.min) / 2
self.mid_annotation.value = HorizontalRule(value=self.mid_measure.value)
- class saleae.measurements.analog_measurer.AnalogMeasurer
AnalogMeasurer base class.
measure_range must be implemented.
- measure_range(data)
This method is called when running a measurement over a span of analog data.
This must be overridden by subclasses.
- Parameters
data (
AnalogSpan
) – The span of data to run the measurement on.
- class saleae.measurements.measure.Measure
Measure declaration that appears as a class property of an
analog_measurer.AnalogMeasurer
- __init__(label, *, type=<class 'float'>, description='', units='')
- class saleae.measurements.annotation.Annotation
Annotation declaration that appears as a class property of an
analog_measurer.AnalogMeasurer
- class saleae.measurements.annotation.HorizontalRule
An annotation value represented as a horizontal rule.
This can be assigned to an annotation value while processing data in
saleae.measurements.analog_measurer.AnalogMeasurer.measure_range()
.
- class saleae.measurements.annotation.VerticalRule
An annotation value represented as a vertical rule, as an absolute time.
This can be assigned to an annotation value while processing data in
saleae.measurements.analog_measurer.AnalogMeasurer.measure_range()
.- __init__(*, time)
- Parameters
value – The time value of the rule.