Da-Wei Huang
Da-Wei Huang

Reputation: 11

Can I schedule an agent in VOLTTRON to start at certain time?

Is it possible to start and then stop an agent by schedule, say run at 12 PM and then stop at 1 PM everyday. Thanks.

Upvotes: 1

Views: 90

Answers (2)

Kyle Monson
Kyle Monson

Reputation: 571

You have several options.

  1. You can do as Craig suggests and start and stop it with a cron job. I don't like this idea as it goes against the purpose of an agent which should be always on.
  2. Your agent can watch for device publishes to start appearing with timestamps that fall within the desired block of time (this is a common method).
  3. Your agent can schedule devices for the desired block of time (if you are going to be sending control signals) and then subscribe to the schedule announce topic and watch for your schedule start.
  4. You can schedule a periodic function call to be triggered at the start of the block.
  5. Like 4 you can use schedule instead of periodic. You have to schedule the next event as schedule will only call the callback once, but it is useful for events that change dynamically during run time. The actuator agent uses this for publishing schedule states.

In 2-5 the agent will remain dormant for most of the time and only be become active during the allotted time.

Upvotes: 2

Craig
Craig

Reputation: 949

One way is to set up a cron job that executes volttron-ctl start agent_uuid to start it...then another one that stops it.

The other way would involve just leaving the agent running and adding a periodic that can run every 24 hours, which would execute 24 hours from when you started the agent.

Upvotes: 1

Related Questions