sgr_commhandler.api =================== .. py:module:: sgr_commhandler.api .. autoapi-nested-parse:: Contains the CommHandler API, which is intended to be utilized by the user. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/sgr_commhandler/api/configuration_parameter/index /autoapi/sgr_commhandler/api/data_point_api/index /autoapi/sgr_commhandler/api/data_types/index /autoapi/sgr_commhandler/api/device_api/index /autoapi/sgr_commhandler/api/dynamic_parameter/index /autoapi/sgr_commhandler/api/functional_profile_api/index Classes ------- .. autoapisummary:: sgr_commhandler.api.ConfigurationParameter sgr_commhandler.api.DynamicParameter sgr_commhandler.api.DataPoint sgr_commhandler.api.DataPointProtocol sgr_commhandler.api.DataPointValidator sgr_commhandler.api.DeviceInformation sgr_commhandler.api.SGrBaseInterface sgr_commhandler.api.FunctionalProfile Package Contents ---------------- .. py:class:: ConfigurationParameter(parameter) Implements an EID configuration parameter. .. py:attribute:: label .. py:attribute:: name .. py:attribute:: type .. py:attribute:: description .. py:attribute:: default_value .. py:method:: __str__() Converts to string. :returns: A string :rtype: str .. py:method:: __repr__() Gets an object description as string. :returns: A string :rtype: str .. py:class:: DynamicParameter(parameter) Implements a dynamic parameter of data points. .. py:attribute:: label .. py:attribute:: name .. py:attribute:: type .. py:attribute:: description .. py:attribute:: default_value .. py:method:: __str__() Converts to string. :returns: A string :rtype: str .. py:method:: __repr__() Gets an object description as string. :returns: A string :rtype: str .. py:class:: DataPoint(protocol, validator) Bases: :py:obj:`Generic`\ [\ :py:obj:`TFpSpec`\ , :py:obj:`TDpSpec`\ ] Implements a data point of a generic data type. .. py:attribute:: _protocol .. py:attribute:: _validator .. py:method:: name() Gets the data point name. :returns: the functional profile and data point name :rtype: tuple[str, str] .. py:method:: get_value_async(parameters = None, skip_cache = False) :async: Gets the data point value asynchronously. :returns: the data point value :rtype: Any :raises Exception: when read value is not compatible with data type .. py:method:: set_value_async(value) :async: Sets the data point value asynchronously. :param value: the data point value :type value: Any .. py:method:: subscribe(fn) Subscribes to data point value changes. :param fn: the handler method :type fn: Callable[[DataPointProtocol, Any], NoReturn] .. py:method:: unsubscribe() Unsubscribes from data point value changes. .. py:method:: direction() Gets the data point direction. :returns: the data point direction :rtype: DataDirectionProduct .. py:method:: data_type() Gets the data point data type. :returns: the data point data type :rtype: DataTypes .. py:method:: unit() Gets the unit of measurement of the data point. :returns: the unit :rtype: Units .. py:method:: describe() Describes the data point. :returns: the data point information :rtype: tuple[tuple[str, str], DataDirectionProduct, DataTypes, Units] .. py:method:: options() Describes the data point options. :returns: the data point options :rtype: list[Any] .. py:method:: dynamic_parameters() Gets the dynamic parameters of the data point. :returns: the dynamic parameters :rtype: list[DynamicParameter] .. py:method:: get_specification() Gets the data point specification. :returns: the data point specification :rtype: TDpSpec .. py:class:: DataPointProtocol(fp_spec, dp_spec) Bases: :py:obj:`abc.ABC`, :py:obj:`Generic`\ [\ :py:obj:`TFpSpec`\ , :py:obj:`TDpSpec`\ ] Implements a base class for data point protocols. .. py:attribute:: _fp_spec :type: TFpSpec .. py:attribute:: _dp_spec :type: TDpSpec .. py:attribute:: _fp_name :type: str .. py:attribute:: _dp_name :type: str .. py:attribute:: _dynamic_parameters :type: list[sgr_commhandler.api.dynamic_parameter.DynamicParameter] .. py:method:: get_specification() Gets the data point specification. :returns: the interface-specific specification :rtype: TDpSpec .. py:method:: set_val(value) :abstractmethod: :async: Writes the data point value. :param value: the data point value to write :type value: Any .. py:method:: get_val(parameters = None, skip_cache = False) :abstractmethod: :async: Reads the data point value. :param parameters: optional dynamic parameters of the request :type parameters: Optional[dict[str, str]] :param skip_cache: does not use cache if true :type skip_cache: bool :returns: the data point value :rtype: Any .. py:method:: name() Gets the functional profile and data point names. :returns: the functional profile and data point names as tuple :rtype: tuple[str, str] .. py:method:: direction() Gets the data direction of the data point. :returns: the data point direction :rtype: DataDirectionProduct .. py:method:: unit() Gets the unit of measurement of the data point. :returns: the unit :rtype: Units .. py:method:: dynamic_parameters() Gets the dynamic parameters of the data point. :returns: the dynamic parameters :rtype: list[DynamicParameter] .. py:method:: can_subscribe() Defines if subscribe() is allowed. :returns: True if allowed, False otherwise :rtype: bool .. py:method:: subscribe(fn) Subscribes to changes of the data point value. :param fn: the callback method :type fn: Callable[[DataPointProtocol, Any], NoReturn] .. py:method:: unsubscribe() Unsubscribes from changes of the data point value. .. py:class:: DataPointValidator(data_type) Bases: :py:obj:`object` Implements a base class for data point validators. .. py:attribute:: _data_type :type: sgr_commhandler.api.data_types.DataTypes .. py:method:: validate(value) Validates the compatibility of a value. :param value: the value to validate :type value: Any :returns: true if value is compatible, false otherwise :rtype: bool .. py:method:: data_type() Gets the validator's data type. :returns: the data type enumeration :rtype: DataTypes .. py:method:: options() Gets the validator's options. :returns: the options :rtype: list[Any] .. py:class:: DeviceInformation Implements a device information container. .. attribute:: name Defines the device name :type: str .. attribute:: manufacturer Defines the manufacturer's name :type: str .. attribute:: software_revision Defines the device software version :type: str .. attribute:: hardware_revision Defines the device hardware version :type: str .. attribute:: device_category Defines the device category :type: DeviceCategory .. attribute:: is_local Defines if the device is controlled locally or via cloud :type: bool .. py:attribute:: name :type: str .. py:attribute:: manufacturer :type: str .. py:attribute:: software_revision :type: str .. py:attribute:: hardware_revision :type: str .. py:attribute:: device_category :type: sgr_specification.v0.generic.DeviceCategory .. py:attribute:: is_local :type: bool .. py:class:: SGrBaseInterface(frame) Bases: :py:obj:`abc.ABC` Defines an abstract base class for all SGr device interfaces. .. attribute:: device_frame the device specification :type: DeviceFrame .. attribute:: configuration_parameters the configuration parameters with default values :type: list[ConfigurationParameter] .. attribute:: device_information the device information :type: DeviceInformation .. attribute:: functional_profiles the configured functional profiles :type: dict[str, FunctionalProfile] .. py:attribute:: device_frame :type: sgr_specification.v0.product.product.DeviceFrame .. py:attribute:: configuration_parameters :type: list[sgr_commhandler.api.configuration_parameter.ConfigurationParameter] .. py:attribute:: device_information :type: DeviceInformation .. py:attribute:: functional_profiles :type: dict[str, sgr_commhandler.api.functional_profile_api.FunctionalProfile] .. py:method:: connect_async() :abstractmethod: :async: Connects the device asynchronously. .. py:method:: disconnect_async() :abstractmethod: :async: Disconnects the device asynchronously. .. py:method:: is_connected() :abstractmethod: Gets the connection state. :returns: the connection state :rtype: bool .. py:method:: get_functional_profiles() Gets all functional profiles. :returns: all functional profiles :rtype: dict[str, FunctionalProfile] .. py:method:: get_functional_profile(functional_profile_name) Gets a functional profile. :param functional_profile_name: the functional profile name :type functional_profile_name: str :returns: a functional profile :rtype: FunctionalProfile .. py:method:: get_data_point(dp) Gets a data point. :param dp: the functional profile and data point name :type dp: tuple[str, str] :returns: a data point :rtype: DataPoint .. py:method:: get_data_points() Gets all data points. :returns: all data points :rtype: dict[tuple[str, str], DataPoint] .. py:method:: get_values_async(parameters = None) :async: Gets all data point values asynchronously. :returns: all data point values :rtype: dict[tuple[str, str], Any] .. py:method:: describe() Gets the device description and all data. :returns: a tuple of device name and all data point values :rtype: tuple[str, dict[str, dict[str, tuple[DataDirectionProduct, DataTypes]]]] .. py:method:: get_specification() Gets the complete SGr specification of the device. :returns: the device specification :rtype: DeviceFrame .. py:class:: FunctionalProfile(fp_spec) Bases: :py:obj:`Generic`\ [\ :py:obj:`TFpSpec`\ ] Implements a functional profile. .. py:attribute:: _fp_spec :type: TFpSpec .. py:method:: name() Gets the functional profile name. :returns: the functional profile name :rtype: str .. py:method:: get_data_points() Gets all data points. :returns: all data points :rtype: dict[tuple[str, str], DataPoint] .. py:method:: get_data_point(dp_name) Gets a data point. :param dp_name: the data point name :type dp_name: str :returns: a data point :rtype: DataPoint .. py:method:: get_values_async(parameters = None) :async: Gets all data point values of the functional profile asynchronously. :returns: all data point values by name :rtype: dict[str, Any] .. py:method:: describe() Describes the functional profile. :returns: the functional profile information :rtype: tuple[str, dict[str, tuple[DataDirectionProduct, DataTypes]]] .. py:method:: get_specification() Gets the functional profile specification. :returns: the functional profile specification :rtype: TFpSpec