Measurement Unit
Module: thinkiq.model.measurement_unit
Logic and classes for measurement units (conversion/lookup).
MeasurementUnit
- class thinkiq.model.measurement_unit.MeasurementUnit(**kwargs)
A measurement unit in the ThinkIQ system.
Measurement units are used to compare and calculate quantities in the ThinkIQ system. Measurement units are stored as metadata of attributes that reflect tag data in the ThinkIQ model.
The initialization of a measurement unit has multiple creational methods that allow for an array of arguments. Options included:
- classmethod get_from_id(id)
Retrieve a ThinkIQ object from the database using its id.
- Parameters:
id (int)
- classmethod get_from_fqn(fqn)
Retrieve a ThinkIQ object from the database using its fully qualified name, referred to as its fqn.
- Parameters:
fqn (str, list)
Notes
Supported strings are as follows: ‘plant_1.area_1.eq_1’ ‘plant_1,area_1,eq_1’
Fqn’s supplied as a list should be as follows: [ ‘plant_1’, ‘area_1’, ‘eq_1’ ]
- classmethod get_from_parent_id(part_of_id, relative_name)
Retrieve a ThinkIQ object from the database using its part_of_id (its parents id) and its relative_name.
- Parameters:
part_of_id (int) – The id of the parent object.
relative_name (str) – The requested objects relative_name as stored in the database. Not the display_name as shown in ThinkIQ.
- classmethod get_from_parent(parent, relative_name)
Retrieve a ThinkIQ object from the database using its parent python object and its relative_name.
- Parameters:
parent (thinkiq.model.node.Node) – The parent object
relative_name (str) – The requested objects relative_name as stored in the database. Not the display_name as shown in ThinkIQ.
- __init__(**kwargs)
Construct a MeasurementUnit object using keyword arguments that will become properties of the returned object.
- classmethod get_by_library_and_relative_name(library_relative_name, measurement_unit_relative_name)
Get a measurement unit object by specifying its relative_name and its parent library.
- Parameters:
library_relative_name (str)
measurement_unit_relative_name (str)
- Return type:
Properties:
- id: int
- relative_name: str
- display_name: str
- part_of_id: int
- fqn: list
- quantity_id: int
- symbol: str
MeasurementUnits
- class thinkiq.model.measurement_unit.MeasurementUnits(library_name)
Collection of measurement units under a given library (lightweight registry).
On initialization, it queries the database for all measurement units associated with the given library name and sets them as dynamic attributes on the object. Options included:
- __init__(library_name)
Load all measurement units under the given library (relative_name). Creates an attribute on this object for each unit (by relative_name).