sunpeek.components.base.Component#

class sunpeek.components.base.Component(**kwargs)#

Bases: Base, AttrSetterMixin

Base class to be used for physical components of a Plant, also specifies a DB table to allow polymorpic references to any subclass (i.e. via FK on components.id)

Methods

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

add_component_attr(name[, unit, minimum, ...])

all_subclasses([c])

define_component_attrs()

get_component_attribute(name)

get_default_unit(name)

Return default unit of a class attribute defined as ComponentParam.

get_raw_sensor(str_map[, raise_if_not_found])

get_real_slots()

Get component's slot names for (possibly or always) real (not virtual) sensors

has_virtual_slot_named(slot_name)

Assert component has a (possibly or always) virtual sensor slot named slot_name.

is_attrib_missing(attrib_name)

Return True if component attribute is None or not a ComponentParam holding a Quantity.

is_real_sensor_missing(slot_name, check_mode)

Like is_sensor_missing, but additionally checks if sensor in named slot is real (not virtual).

is_sensor_missing(slot_name, check_mode)

Return True if component slot has no sensor mapped or sensor is not ready for calculations.

map_sensor(sensor, slot_name)

Maps sensor to slot_name of given component, including some sanity checks.

map_vsensor(slot_name, feedback)

Create virtual Sensor and map it to component.slot_name, or map None if it cannot be calculated.

register_callback(callback_type, func)

set_component_attribute(name, value, array_type)

set_sensors(**kwargs)

Maps one or multiple sensors (by calling map_sensor()) and handles configuring virtual sensors.

update_sensors(is_remove)

classmethod get_default_unit(name)#

Return default unit of a class attribute defined as ComponentParam.

Return type:

str

classmethod get_real_slots()#

Get component’s slot names for (possibly or always) real (not virtual) sensors

has_virtual_slot_named(slot_name)#

Assert component has a (possibly or always) virtual sensor slot named slot_name.

is_attrib_missing(attrib_name)#

Return True if component attribute is None or not a ComponentParam holding a Quantity.

Return type:

bool

is_real_sensor_missing(slot_name, check_mode)#

Like is_sensor_missing, but additionally checks if sensor in named slot is real (not virtual).

Return type:

bool

is_sensor_missing(slot_name, check_mode)#

Return True if component slot has no sensor mapped or sensor is not ready for calculations.

Return type:

bool

map_sensor(sensor, slot_name)#

Maps sensor to slot_name of given component, including some sanity checks.

map_vsensor(slot_name, feedback)#

Create virtual Sensor and map it to component.slot_name, or map None if it cannot be calculated.

Parameters:
  • slot_name (str, slot / channel name of the component self to which the virtual sensor will be mapped.)

  • feedback (CoreMethodFeedback, problems reported at config time, prior to vsensor calculation.)

set_sensors(**kwargs)#

Maps one or multiple sensors (by calling map_sensor()) and handles configuring virtual sensors.