volttron CSV Agent onstart 添加时间延迟
volttron CSV Agent onstart add in time delay
在 CSV 驱动程序代理脚本中,如何向 onstart
函数添加 300 秒的延迟?我希望在安装代理时将 self.actuate_point
method/function 启动时仅延迟一次 300 秒。
#csv driver start
@Core.receiver("onstart")
def onstart(self, sender, **kwargs):
"""
This is method is called once the Agent has successfully connected to the platform.
This is a good place to setup subscriptions if they are not dynamic or
do any other startup activities that require a connection to the message bus.
Called after any configurations methods that are called at startup.
Usually not needed if using the configuration store.
"""
# ADD time.sleep?
time.sleep(300)
# Every time_delay_normal seconds, ask the core agent loop to run the actuate point method with no parameters
self.core.periodic(self.time_delay_normal, self.actuate_point)
@HenryHub 你不应该在大多数 volttron 中使用主时间库。相反,您应该使用 gevent.sleep(0.3)
导入 gevent
gevent.sleep(秒)
在 CSV 驱动程序代理脚本中,如何向 onstart
函数添加 300 秒的延迟?我希望在安装代理时将 self.actuate_point
method/function 启动时仅延迟一次 300 秒。
#csv driver start
@Core.receiver("onstart")
def onstart(self, sender, **kwargs):
"""
This is method is called once the Agent has successfully connected to the platform.
This is a good place to setup subscriptions if they are not dynamic or
do any other startup activities that require a connection to the message bus.
Called after any configurations methods that are called at startup.
Usually not needed if using the configuration store.
"""
# ADD time.sleep?
time.sleep(300)
# Every time_delay_normal seconds, ask the core agent loop to run the actuate point method with no parameters
self.core.periodic(self.time_delay_normal, self.actuate_point)
@HenryHub 你不应该在大多数 volttron 中使用主时间库。相反,您应该使用 gevent.sleep(0.3)
导入 gevent
gevent.sleep(秒)