独自のエンドポイントを登録しようとしているエージェントがいる場合は、オンスタート信号中にそれを行う必要があります。以下は、ボルトトロン中央剤から抽出されたものである。動的(エンドポイントとしてvolttron rpcを使用)と静的(htmlが単に提供される)のエンドポイントを登録する方法を示します。私はこの例の不要なビットを削除しました。透明度MASTER_WEBとVOLTTRON_CENTRALについては
onstart volttron central code
volttronインスタンス上で実行されているそれらの特定の薬剤のためのユニークな識別子です。
@Core.receiver('onstart')
def _starting(self, sender, **kwargs):
""" Starting of the platform
:param sender:
:param kwargs:
:return:
"""
...
# Registers dynamic route.
self.vip.rpc.call(MASTER_WEB, 'register_agent_route',
r'^/jsonrpc.*',
self.core.identity,
'jsonrpc').get(timeout=30)
# Registers static route.
self.vip.rpc.call(MASTER_WEB, 'register_path_route', VOLTTRON_CENTRAL,
r'^/.*', self._webroot).get(timeout=30)
ルートを追加したので、エージェントが停止しているときにも削除する必要があります。 onstop referenced code
@Core.receiver("onstop")
def stopping(self, sender, **kwargs):
'''
Release subscription to the message bus because we are no longer able
to respond to messages now.
'''
try:
# unsubscribes to all topics that we are subscribed to.
self.vip.pubsub.unsubscribe(peer='pubsub', prefix=None, callback=None)
except KeyError:
# means that the agent didn't start up properly so the pubsub
# subscriptions never got finished.
pass
ありがとうCraig。私はそれを試み、これに後で戻ってきます。 – HNGO
10種類の異なるUIを持つ10種類のアプリがある場合、このアプローチはあまりに多くのバックエンドエージェント、ルート、フロントエンドリソースをどこで作成するのですか? – HNGO
このルートの登録は、標準的な方法です。それは新しいものではありません。フロントエンドのリソースは、クライアント側にある必要があります。 – Craig