https://volttron.readthedocs.io/en/develop/platform-features/message-bus/vip/vip-json-rpc.html#remote-procedure-calls code example
Example: https://volttron.readthedocs.io/en/develop/platform-features/message-bus/vip/vip-json-rpc.html#remote-procedure-calls
from volttron.platform.vip import Agent, Core, RPC
def add(a, b):
'''Add two numbers and return the result'''
return a + b
class ExampleAgent(Agent):
@RPC.export
def say_hello(self, name):
'''Build and return a hello string'''
return 'Hello, %s!' % (name,)
@RPC.export('say_bye')
def bye(self, name):
'''Build and return a goodbye string'''
return 'Goodbye, %s.' % (name,)
@Core.receiver('setup')
def onsetup(self, sender, **kwargs):
self.vip.rpc.export('add')