本文整理汇总了Python中opcua.Server.historize_node_event方法的典型用法代码示例。如果您正苦于以下问题:Python Server.historize_node_event方法的具体用法?Python Server.historize_node_event怎么用?Python Server.historize_node_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opcua.Server
的用法示例。
在下文中一共展示了Server.historize_node_event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: database
# 需要导入模块: from opcua import Server [as 别名]
# 或者: from opcua.Server import historize_node_event [as 别名]
# get an event generator for the server node which generates BaseEventType
serverevgen = server.get_event_generator()
serverevgen.event.Severity = 111
# Configure server to use sqlite as history database (default is a simple in memory dict)
server.iserver.history_manager.set_storage(HistorySQLite("my_event_history.sql"))
# starting!
server.start()
# enable history for myobj events; must be called after start since it uses subscription
server.iserver.enable_history_event(myobj, period=None)
# enable history for server events; must be called after start since it uses subscription
server_node = server.get_node(ua.ObjectIds.Server)
server.historize_node_event(server_node, period=None)
try:
count = 0
while True:
time.sleep(1)
count += 0.1
# generate events for subscribed clients and history
myevgen.trigger(message="This is MyFirstEvent " + str(count))
myevgen2.trigger(message="This is MySecondEvent " + str(count))
serverevgen.trigger(message="Server Event Message")
# read event history from sql
end_time = datetime.utcnow()
server_event_history = server_node.read_event_history(None, end_time, 0)