I read the documentation of VOLTTRON and I still have doubts understanding the RPC mechanism in connection with pubsub mechanism of the actuator agent in volttron.
For example I have a device with the topic : "campus/building/unit" and I reserve the device for one hour on monday between 5PM to 6PM. Then how do i run my code for this event ? Do i need to subscribe to some topic from the actuator agent in order to catch the event or do i need to periodically try using setpoint via rpc and see that if the exception is not thrown then we do have our exclusive lock on the device and hence now we can call getpoint/setpoint on the device ?
When a reserved block of time for a device starts the Actuator Agent will start publishing that fact on the pubsub.
The topic used is
devices/actuators/schedule/announce/<full device path>
or in your case
devices/actuators/schedule/announce/campus/building/unit
The publish has no message and a header with the following format:
{
'requesterID': <Agent with access>,
'taskID': <Task associated with the time slot>
'window': <Seconds remaining in the time slot>
}
(If the fact that this is all in the header seems weird it's because this hearkens back to the VOLTTRON Lite days where we were still deciding what belonged in the header and what went in the message.)
Ideally an agent would schedule a block of time then subscribe to the announce topic. The handler for that topic would trigger the start of activity during the allotted block of time.
It's important to remember that the Actuator Agent will republish the same information with an updated window value at set intervals. (By default this is once a minute and is configurable) You can use the window value to trigger actions over the course of the allotted block of time.