diff --git a/devlib/instrument/__init__.py b/devlib/instrument/__init__.py index 5b056c0..9d898c4 100644 --- a/devlib/instrument/__init__.py +++ b/devlib/instrument/__init__.py @@ -170,6 +170,7 @@ class Instrument(object): self.logger = logging.getLogger(self.__class__.__name__) self.channels = collections.OrderedDict() self.active_channels = [] + self.sample_rate_hz = None # channel management diff --git a/devlib/instrument/daq.py b/devlib/instrument/daq.py index 3120480..40269c0 100644 --- a/devlib/instrument/daq.py +++ b/devlib/instrument/daq.py @@ -55,6 +55,7 @@ class DaqInstrument(Instrument): resistor_values=resistor_values, channel_map=channel_map, labels=labels) + self.sample_rate_hz = sampling_rate for label in labels: for kind in ['power', 'voltage']: diff --git a/devlib/instrument/energy_probe.py b/devlib/instrument/energy_probe.py index b7ad832..3f7506a 100644 --- a/devlib/instrument/energy_probe.py +++ b/devlib/instrument/energy_probe.py @@ -51,6 +51,7 @@ class EnergyProbeInstrument(Instrument): self.command = None self.raw_output_directory = None self.process = None + self.sample_rate_hz = 10000 # Determined empirically for label in self.labels: for kind in self.attributes: diff --git a/devlib/platform/arm.py b/devlib/platform/arm.py index 43320ad..e760eaf 100644 --- a/devlib/platform/arm.py +++ b/devlib/platform/arm.py @@ -236,6 +236,7 @@ class JunoEnergyInstrument(Instrument): for chan in self._channels: self.channels[chan.name] = chan self.on_target_file = self.target.tempfile('energy', '.csv') + self.sample_rate_hz = 10 # DEFAULT_PERIOD is 100[ms] in readenergy.c self.command = '{} -o {}'.format(self.binary, self.on_target_file) self.command2 = '{}'.format(self.binary) diff --git a/doc/instrumentation.rst b/doc/instrumentation.rst index 6d5b16d..c475cae 100644 --- a/doc/instrumentation.rst +++ b/doc/instrumentation.rst @@ -146,6 +146,12 @@ Instrument .. note:: This method is only implemented by :class:`Instrument`\ s that support ``CONTINUOUS`` measurment. +.. attribute:: Instrument.sample_rate_hz + + Sample rate of the instrument in Hz. Assumed to be the same for all channels. + + .. note:: This attribute is only provided by :class:`Instrument`\ s that + support ``CONTINUOUS`` measurment. Instrument Channel ~~~~~~~~~~~~~~~~~~