0

I am trying to get agents talk to each other across remote platform instances. For example, Agent1 running on machine1 (192.168.1.10) wants to talk to Agent2 running on machine2 (192.168.1.11) with VOLTTRON environment. I think VOLTTRON Interconnect Protocol (VIP) may be a good choice to implement that, but how to set it? Can anyone show me an example?

Thanks.

Jason
  • 11
  • 1

1 Answers1

0

Are you trying to have two agents talk directly or is the goal for them to publish messages to a remote bus for the other agent to see? If it's the latter, you can see an example in the ForwardHistorian: https://github.com/VOLTTRON/volttron/blob/develop/services/core/ForwardHistorian/forwarder/agent.py

By default, agents can talk to their local message bus, in order to talk to a remote one they need to setup this connection (where "destination_vip" is the vip address of the remote VOLTTRON including the serverkey):

    agent = Agent(address=destination_vip)
    event = gevent.event.Event()
    agent.core.onstart.connect(lambda *a, **kw: event.set(), event)
    gevent.spawn(agent.core.run)
    event.wait()

Then later they can use it to publish or subscribe to that bus:

self._target_platform.vip.pubsub.publish(peer='pubsub',
                                    topic="MyTopic",
                                    message="Some message").get()

Using these methods agents can publish and subscribe to a remote message bus and interact with it in the same way they could with their local bus.

If you are looking for how to call another agent directly, then the SchedulerExample interacting with the ActuatorAgent provides an example: https://github.com/VOLTTRON/volttron/blob/develop/examples/SchedulerExample/schedule_example/agent.py

The call is similar to the above pub/sub example except that it uses the rpc subsystem. The calling agent uses the target agent's VIP identity, the method it wants to call, and the parameters. The ActuatorAgent has a set vip identity making it easier to call and it has the "@RPC.export" decorator over the "set_point" method.

            result =  self._target_platform.vip.rpc.call(
                                   'platform.actuator', 
                                   'set_point',
                                   agent_id, 
                                   'campus/building/unit3/some_point',
                                   '0.0').get(timeout=10)
  • Thanks for your answer! What I want to ask acturally is "the latter one": to publish messages to a remote bus for the other agent to see. I am setting the connection you give me. For the destination_vip, is the following format correct? "destination-vip": "ipc://192.168.1.246/home/volttron/.volttron/run/vip.socket" – Jason Sep 01 '16 at 14:28
  • Or "destination-vip": "tcp://192.168.1.246.116.246:29216?serverkey=RcbUt99IJk3J1nD101WfRrk7VYOwOICAtfHwJrZw1zs&publickey=6ZFlyV9w_RppG743NGM1ajFyiC3IMA_aCmacER_8OzE&secretkey=qTKwxXcUHPFCoSF2Fxf5iQyNOJTAg2IS4lOFnfbPvoA /home/volttron/.volttron/run/vip.socket"? – Jason Sep 01 '16 at 15:21
  • You don't need the VOLTTRON home in there, just: "destination-vip": "tcp://192.168.1.246.116.246:29216?serverkey=RcbUt99IJk3J1nD‌​101WfRrk7VYOwOICAtfH‌​wJrZw1zs&publickey=6‌​ZFlyV9w_RppG743NGM1a‌​jFyiC3IMA_aCmacER_8O‌​zE&secretkey=qTKwxXc‌​UHPFCoSF2Fxf5iQyNOJT‌​Ag2IS4lOFnfbPvoA – Jereme Haack Sep 06 '16 at 23:32
  • It works! Thank you!!! Now agent in platform A can publish/subscribe message to remote platform B! But I tried to register the platform in "VOLTTRON Management Central" using the "destination-vip", there is no response when I click the "register" button, do you know why? – Jason Sep 08 '16 at 01:01