Can I get a tip on how to use the actuator agent set_multiple_points
?
In the actuator agent code, I can see the method:
def set_multiple_points(self, requester_id, topics_values, **kwargs):
"""RPC method
Set multiple points on multiple devices. Makes a single
RPC call to the platform driver per device.
:param requester_id: Ignored, VIP Identity used internally
:param topics_values: List of (topic, value) tuples
:param \*\*kwargs: Any driver specific parameters
:returns: Dictionary of points to exceptions raised.
If all points were set successfully an empty
dictionary will be returned.
.. warning:: calling without previously scheduling *all* devices
and not within the time allotted will raise a LockError
"""
In my CSV agent driver that I am experimenting with, I have 4 devices
defined in the init, as well as a point_topic
that is the same across all devices, and a change_setpoint
to apply to all of the devices.
def __init__(self, csv_topic="", **kwargs):
# Configure the base agent
super(Csvdriveragent, self).__init__(**kwargs)
_log.debug("vip_identity: " + self.core.identity)
# This agent is for testing purposes, so we'll default our ID
self.agent_id = "csv_actuation_agent"
# Get the topic that the Driver will publish to from the configuration file
devices = {device1:'201201',
device2:'201202',
device3:'201203',
device4:'201204'
}
self.point_topic = self.topic + "/" + "RmTmpSpt"
# This value will be used to send requests to the Driver to set a point on the device with an alternating value
self.change_setpoint = 85
Can I get a tip on what the rpc
call would look like for set_multiple_points
?
I know the comments state in a dictionary format, is this at all close below for how to put the rpc call together?
result = self.vip.rpc.call(
'platform.actuator', 'set_multiple_points', devices, point_topic, self.change_setpoint).get(
timeout=4)
Any tips for how to revert_multiple points back also greatly appreciated too. For example if a timer expires (gevent.sleep()
) how would I revert all the point back to prior values?
The
set_multiple_points
RPC call requires arequester_id
string and a list of tuples defining pairs of topic to value-to-set combinations (topic_values
).The basic form of an RPC call to the actuator is as follows:
Because we're working with devices, we need to know which devices we're interested in, and what their topics are.
Before setting one or more points, it is required that the requester establish a schedule period for sending control signals - this is done by creating a schedule data structure and sending that to the actuator along with some other metadata.
Now we can send our
set_multiple_points
request during the scheduled period - within the next 10 seconds.To revert a point, create a schedule for the point following the above examples but for a single point, then send an RPC request to the Actuator for the 'revert_point' method. This requires that you've set a default value in your driver's registry config.