Tag

Module: thinkiq.model.tag

EN — Summary

  • Uses centralized DB helpers: database.Database.query_one / execute_non_query

  • No direct connect()/cursor() in the model code

  • Clean logging via a module-level logger

Tag

class thinkiq.model.tag.Tag(**kwargs)

A tag in the ThinkIQ system.

Tags are the interface between Attributes and time-series data.

The initialization of a tag 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.

Properties:

id: int
relative_name: str
display_name: str
part_of_id: int
fqn: list
data_type: str

Can be one of these options: bool, int, float, string, datetime

historized: bool

Methods:

__init__(**kwargs)

Construct a Tag object using keyword arguments.

This constructor is typically not called directly by users. Instead, use class methods like create() or get_from_id().

Parameters:

kwargs (dict) – Keyword arguments representing tag attributes.

static create(relative_name, data_type, measurement_unit=None)

Create a new tag under the system connector; return the created Tag object.

Parameters:
  • relative_name (str) – Tag name relative to the connector (unique within the connector).

  • data_type (str) – Data type: ‘bool’, ‘string’, ‘float’, ‘int’, ‘datetime’.

  • measurement_unit (MeasurementUnit, optional) – Optional measurement unit associated with the tag.

Return type:

Tag

Raises:

Exception – If connector not found or insert did not return a row.