Implementation of generic measurements

Generic class for measurements and measurement frames

platform

Python 3.5.10 on Linux, OS X

synopsis

This module implements classes for generic measurements taken from a meter.

authors

Janus Bo Andersen, Jakob Aaboe Vestergaard

date

13 October 2020

Changelog: 03 Nov 2020: Added is_empty() method to MeterMeasurement. Janus.

The Measurement class

class meter.MeterMeasurement.Measurement(value: float, unit: str)[source]

Single physical measurement. A single measurement of a physical quantity pair, consisting of a value and a unit.

The MeterMeasurement class

class meter.MeterMeasurement.MeterMeasurement(meter_id: str, timestamp: datetime.datetime)[source]

A single measurement collection based on one frame from the meter. Will contain multiple measurements of physical quantities taken at the same time.

add_measurement(name: str, measurement: meter.MeterMeasurement.Measurement)None[source]

Store a new measurement in the collection.

as_dict()dict[source]

Serializes and outputs the Measurement frame as a structured dict.

is_empty()[source]

Must return True if no measurements have been added, otherwise False

json_dump()str[source]

Returns a JSON formatted string of all data in frame.