1

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 ?

Craig
  • 949
  • 1
  • 5
  • 13
Priyank Kapadia
  • 203
  • 4
  • 14

1 Answers1

2

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.

Kyle Monson
  • 471
  • 1
  • 3
  • 6
  • So I just have to subscribe to devices/actuators/schedule/announce/ and then my callback function will be triggered ? – Priyank Kapadia Jul 11 '16 at 20:25
  • And also in my callback if i have performed my task for the event then i need to cancel the schedule right ? – Priyank Kapadia Jul 11 '16 at 20:27
  • @PriyankKapadia You'll want to look at the ExampleSubscriber example agent to see how subscriptions and callbacks are setup. – Kyle Monson Jul 12 '16 at 20:56
  • @PriyankKapadia You should cancel the scheduled block of time when you are done with the device(s). Typically you would estimate the amount of time all actions would require and schedule that plus some padding. If the task is to set a few points, that can usually be done in less than a few seconds (usually faster) a 1 minute block is considered good practice. If the task is a series of actions (set points) spread out over 15 minutes than a 18-20 minute block is probably appropriate. – Kyle Monson Jul 12 '16 at 21:11