Commit 8ba94e58 authored by Koseng's avatar Koseng Committed by oroulet

Add variables to generated event filter and event object

Event types can not only contain properties, but also variables. For example the ConditionType, which is the foundation of Alarms and Conditions, contains variables. Add the variables to the generated event filter and event object.
parent 020f3a17
......@@ -125,8 +125,10 @@ async def select_clauses_from_evtype(evtypes):
clauses = []
selected_paths = []
for evtype in evtypes:
for prop in await get_event_properties_from_type_node(evtype):
browse_name = await prop.read_browse_name()
event_props_and_vars = await get_event_properties_from_type_node(evtype)
event_props_and_vars.extend(await get_event_variables_from_type_node(evtype))
for node in event_props_and_vars:
browse_name = await node.read_browse_name()
if browse_name not in selected_paths:
op = ua.SimpleAttributeOperand()
op.AttributeId = ua.AttributeIds.Value
......@@ -180,6 +182,22 @@ async def get_event_properties_from_type_node(node):
return properties
async def get_event_variables_from_type_node(node):
variables = []
curr_node = node
while True:
variables.extend(await curr_node.get_variables())
if curr_node.nodeid.Identifier == ua.ObjectIds.BaseEventType:
break
parents = await curr_node.get_referenced_nodes(
refs=ua.ObjectIds.HasSubtype, direction=ua.BrowseDirection.Inverse, includesubtypes=True
)
if len(parents) != 1: # Something went wrong
return None
curr_node = parents[0]
return variables
async def get_event_obj_from_type_node(node):
"""
return an Event object from an event type node
......@@ -198,9 +216,11 @@ async def get_event_obj_from_type_node(node):
async def init(self):
curr_node = node
while curr_node.nodeid.Identifier != parent_identifier:
for prop in await curr_node.get_properties():
name = (await prop.read_browse_name()).Name
val = await prop.read_data_value()
node_props_and_vars = await curr_node.get_properties()
node_props_and_vars.extend(await curr_node.get_variables())
for field in node_props_and_vars:
name = (await field.read_browse_name()).Name
val = await field.read_data_value()
self.add_property(name, val.Value.Value, val.Value.VariantType)
parents = await curr_node.get_referenced_nodes(refs=ua.ObjectIds.HasSubtype,
direction=ua.BrowseDirection.Inverse,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment