在 volttron 之外调用 @RPC 方法

Calling a @RPC method outside of volttron

假设我有一个 运行 volttron 代理,带有 @RPC 装饰方法(如果相关)。有什么方法可以从 volttron 平台外部调用该方法吗? (在我的例子中来自 django 网络服务器)

代理可以在 VOLTTRON 网络服务上注册端点。可以根据需要为端点设置回调。

必须启用 Web 服务,代理需要将 "enable_web=True" 传递给基本代理构造函数。

您可以在此处找到文档和示例:http://volttron.readthedocs.io/en/develop/specifications/webframework.html

除了 kyle-monson 提到的内容,您还必须 运行 Volttron 使用绑定参数。这将在给定的绑定 arg 上公开已注册的端点。 例如`volttron -vv --bind-web-address "https://127.0.0.1:7080"

在 ~/.volttron/config

中指定绑定网址
[volttron]
message-bus = rmq
bind-web-address = https://127.0.0.1:7080

然后你可以发送 HTTP POST 请求到 https://127.0.0.1:7080/rpc-method-name

请求中的

rpc-method-name URL 是使用 self.vip.web.register_endpoint("/rpc-method-name", self.call_back_method_for_endpoint)

注册的方法

回调方法接收两个参数“env”和“data”

有关这两个参数的更多详细信息,请查看文档 here