CVTEngine API¶
The CVTEngine manages the thread-safe operations on the Current Value Table. It handles tag creation, updates, deletion, and observer notifications.
automation.tags.cvt.CVTEngine(*args, **kwargs)Current Value Table (CVT) Engine class for a tag-based, thread-safe repository.
This class is designed to hold in-memory tag-based values and manage observers for the required tags. It is implemented as a singleton, ensuring that each sub-thread within the PyAutomation application can access and modify tags in a thread-safe manner.
It acts as a thread-safe wrapper around the CVT class, using a query-based mechanism (request/response) to handle operations.
Usage Example:
.. code-block:: python
>>> from automation.tags import CVTEngine
>>> tag_engine = CVTEngine()
set_tag(self, name, unit, data_type, variable, description, display_unit='', display_name='', opcua_address='', node_namespace='', scan_time=0, dead_band=0.0, process_filter=False, gaussian_filter=False, gaussian_filter_threshold=1.0, gaussian_filter_r_value=0.0, outlier_detection=False, out_of_range_detection=False, frozen_data_detection=False, manufacturer='', segment='', kp=None, id='', user=None)Thread-safe method to create a new tag.
See CVT.set_tag for parameters.
update_tag(self, id, user=None, **kwargs)Thread-safe method to update a tag.
See CVT.update_tag for parameters.
delete_tag(self, id, user=None)Thread-safe method to delete a tag.
See CVT.delete_tag for parameters.
get_tag(self, id=None)Thread-safe method to get a tag object.
get_tags(self)Thread-safe method to get all tags.
get_tags_by_names(self, names)Thread-safe method to get tags by names.
get_tag_by_name(self, name)Thread-safe method to get a tag by name.
get_tag_by_display_name(self, display_name)Thread-safe method to get a tag by display name.
get_tag_by_node_namespace(self, node_namespace)Thread-safe method to get a tag by node namespace.
get_value(self, id)Thread-safe method to get a tag value by ID.
get_value_by_name(self, tag_name)Thread-safe method to get a tag value by name.
get_values_by_name(self, tag_names)Thread-safe method to get multiple tag values.
get_scan_time(self, id)Thread-safe method to get scan time.
get_dead_band(self, id)Thread-safe method to get deadband.
get_display_unit_by_tag(self, tag)Thread-safe method to get display unit.
set_value(self, id, value, timestamp)Thread-safe method to set a tag value.
set_data_type(self, data_type)Thread-safe method to set data type.
is_tag_defined(self, name)Thread-safe method to check if tag is defined.
attach(self, name, observer)Attaches an observer to a Tag in a thread-safe way.
detach(self, name, observer)Detaches an observer from a Tag in a thread-safe way.
serialize(self, id)Thread-safe serialization by ID.
serialize_by_tag_name(self, name)Thread-safe serialization by name.
request(self, query)Executes a request to the CVT in a thread-safe mechanism using locks.
Parameters:
- query (dict): Dictionary defining the action and parameters.
response(self)Retrieves the response from the last request, handling thread synchronization.