BAC0.core.devices.mixins package
Submodules
BAC0.core.devices.mixins.read_mixin module
read_mixin.py - Add ReadProperty and ReadPropertyMultiple to a device
- class BAC0.core.devices.mixins.read_mixin.DiscoveryUtilsMixin[source]
Bases:
objectThose functions are used in the process of discovering points in a device
- class BAC0.core.devices.mixins.read_mixin.ReadProperty[source]
Bases:
ReadUtilsMixin,DiscoveryUtilsMixin,RPObjectsProcessing- poll(command='start', *, delay=120)[source]
Poll a point every x seconds (delay=x sec) Can be stopped by using point.poll(‘stop’) or .poll(0) or .poll(False) or by setting a delay = 0
- Parameters:
command (str) – (str) start or stop polling
delay (int) – (int) time delay between polls in seconds
- Example:
device.poll() device.poll(‘stop’) device.poll(delay = 5)
- async read_multiple(points_list, *, points_per_request=1, discover_request=(None, 6))[source]
Functions to read points from a device using the ReadPropertyMultiple request. Using readProperty request can be very slow to read a lot of data.
- Parameters:
points_list – (list) a list of all point_name as str
points_per_request – (int) number of points in the request
Using too many points will create big requests needing segmentation. It’s better to use just enough request so the message will not require segmentation.
- Example:
device.read_multiple([‘point1’, ‘point2’, ‘point3’], points_per_request = 10)
- class BAC0.core.devices.mixins.read_mixin.ReadPropertyMultiple[source]
Bases:
ReadUtilsMixin,DiscoveryUtilsMixin,RPMObjectsProcessing- poll(command='start', *, delay=10)[source]
Poll a point every x seconds (delay=x sec) Can be stopped by using point.poll(‘stop’) or .poll(0) or .poll(False) or by setting a delay = 0
- Parameters:
command (str) – (str) start or stop polling
delay (int) – (int) time delay between polls in seconds
- Example:
device.poll() device.poll(‘stop’) device.poll(delay = 5)
- async read_multiple(points_list, *, points_per_request=25, discover_request=(None, 6), force_single=False, property_identifier='presentValue')[source]
Read points from a device using a ReadPropertyMultiple request. [ReadProperty requests are very slow in comparison].
- Parameters:
points_list – (list) a list of all point_name as str
points_per_request – (int) number of points in the request
Requesting many points results big requests that need segmentation. Aim to request just the ‘right amount’ so segmentation can be avoided. Determining the ‘right amount’ is often trial-&-error.
- Example:
device.read_multiple([‘point1’, ‘point2’, ‘point3’], points_per_request = 10)
- class BAC0.core.devices.mixins.read_mixin.ReadUtilsMixin[source]
Bases:
objectHandle ReadPropertyMultiple for a device
- BAC0.core.devices.mixins.read_mixin.batch_requests(request, points_per_request)[source]
Generator for creating ‘request batches’. Each batch contains a maximum of “points_per_request” points to read. :params: request a list of point_name as a list :params: (int) points_per_request :returns: (iter) list of point_name of size <= points_per_request