========= Equipment ========= Module: `thinkiq.model.equipment` ================================= .. automodule:: thinkiq.model.equipment .. currentmodule:: thinkiq.model.equipment :class:`Equipment` ------------------ .. autoclass:: Equipment The initialization of an equipment has multiple creational methods that allow for an array of arguments. **Options included:** .. automethod:: get_from_id .. automethod:: get_from_fqn .. automethod:: get_from_parent_id .. automethod:: get_from_parent **Properties:** .. py:attribute:: id :type: int .. py:attribute:: part_of_id :type: int .. py:attribute:: fqn :type: list .. py:attribute:: attributes A list of ThinkIQ attributes that are children of the Equipment object. :type: List[thinkiq.model.Attribute] :value: None **Attributes** .. autoattribute:: pgsql_table_schema The schema in the PostgreSQL database where equipment data resides. .. autoattribute:: pgsql_table_name The name of the table in the PostgreSQL database for equipment. **Methods** .. automethod:: __init__ Constructs an Equipment object and loads its attributes. .. automethod:: _load_attributes Loads attribute data (including tag and measurement unit) from the database and attaches it to the Equipment instance. .. automethod:: _set_attributes Sets Python-accessible attributes for each model attribute found in the database. .. automethod:: load_node_details Placeholder for loading extra details from a database row. .. automethod:: get_attribute Retrieves an attribute by relative or display name. .. automethod:: create_attribute Programmatically creates an attribute for the equipment in the database. **Examples** Lets work with an example piece of plant equipment, *Peeler*. 1. **Get by fqn**: Locate the fully qualified name(fqn) of an equipment in ThinkIQ. For example, equipment with the name *Peeler* may have a fqn of *plant_1,site_1,area_1,peeler*. To retrieve the *Peeler* into an object, pass the *fqn* as a string to the **Equipment** class method *get_from_fqn*. .. code-block:: python peeler_eq = Equipment.get_from_fqn('plant_1,site_1,area_1,peeler') The **Equipment** class method *get_from_fqn* can also handle the *fqn* being passed as a *list* object. .. code:: python >>> from thinkiq.model.equipment import Equipment >>> peeler_eq = Equipment.get_from_fqn(['plant_1', 'site_1', 'area_1', 'peeler']) >>> print(peeler_eq.display_name) Peeler .. note:: The fqn str or list of strings requires the **relative_name** of the ThinkIQ object. **Display names are not currently supported.** 2. **Get by id**: Locate the id of an equipment in ThinkIQ. The *Peeler* equipment before could have an *id* of 233. To retrieve the *Peeler* into an object, pass the *id* as an integer to the **Equipment** class method *get_from_id*. .. code-block:: python >>> from thinkiq.model.equipment import Equipment >>> peeler_eq = Equipment.get_from_id(233) >>> print(peeler_eq.display_name) Peeler 3. **List the equipments attributes** Using the *Peeler* example from earlier, we can now access the attributes directly using the **attributes** property. .. code-block:: python >>> print(peeler_eq.attributes.list) [ 'Attribute object, name: Speed Setpoint, id: 456', ... ]