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

The Measurement class

class OmniPower.OmniPower.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 OmniPower.OmniPower.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: OmniPower.MeterMeasurement.Measurement)None[source]

Store a new measurement in the collection.

as_dict()dict[source]

Serializes and dumps the Measurement frame as a dict. Make an object similar to {

“Meter ID: “: “3232323”, “Timestamp:”: “2020-10-13T17:36:53”, “Measurements”: {

“A+”: {

“unit”: “kWh”, “value”: 7

}, “A-“: {

“unit”: “kWh”, “value”: 8

}, “P+”: {

“unit”: “kW”, “value”: 9

}, “P-“: {

“unit”: “kW”, “value”: 10

}

}

}

json_dump()str[source]

Returns a JSON formatted string of all data in frame.