From c13e3c260b9f3f2a8078447ae6453fc95de2bb5c Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Wed, 9 Jan 2019 13:27:07 +0000 Subject: [PATCH] instrument/measurment_types: Add nanoseconds Add a 'nanosecond' measurement type and the appropriate conversions. Also update notion of existing conversions to make things clearer. --- devlib/instrument/__init__.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/devlib/instrument/__init__.py b/devlib/instrument/__init__.py index 9eaef7b..600b6b6 100644 --- a/devlib/instrument/__init__.py +++ b/devlib/instrument/__init__.py @@ -97,20 +97,30 @@ _measurement_types = [ # covert without being familar with individual instruments. MeasurementType('time', 'seconds', 'time', conversions={ - 'time_us': lambda x: x * 1000000, - 'time_ms': lambda x: x * 1000, + 'time_us': lambda x: x * 1e6, + 'time_ms': lambda x: x * 1e3, + 'time_ns': lambda x: x * 1e9, } ), MeasurementType('time_us', 'microseconds', 'time', conversions={ - 'time': lambda x: x / 1000000, - 'time_ms': lambda x: x / 1000, + 'time': lambda x: x / 1e6, + 'time_ms': lambda x: x / 1e3, + 'time_ns': lambda x: x * 1e3, } ), MeasurementType('time_ms', 'milliseconds', 'time', conversions={ - 'time': lambda x: x / 1000, - 'time_us': lambda x: x * 1000, + 'time': lambda x: x / 1e3, + 'time_us': lambda x: x * 1e3, + 'time_ns': lambda x: x * 1e6, + } + ), + MeasurementType('time_ns', 'nanoseconds', 'time', + conversions={ + 'time': lambda x: x / 1e9, + 'time_ms': lambda x: x / 1e6, + 'time_us': lambda x: x / 1e3, } ),