Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event support for nested objects (NodeClass.Object) #905

Closed
deeTEEcee opened this issue Jun 3, 2022 · 6 comments · Fixed by #906
Closed

Add event support for nested objects (NodeClass.Object) #905

deeTEEcee opened this issue Jun 3, 2022 · 6 comments · Fixed by #906

Comments

@deeTEEcee
Copy link

I see that in #415 we added support for variables with properties but it looks like we're still missing NodeClass.Object in that filter. These can then contain their own properties, variables, or nested objects.

@deeTEEcee
Copy link
Author

Thanks for making the change. A side note is we're calling get_browse_name() quite a bit with the Node class. I wonder if it makes sense just to cache browse name as part of the node.

For example, I was subscribed to 1 event which contained about 400 nodes and that took 10 minutes to load. In cases like https://github.com/sightmachine/opcua-asyncio/blob/master/asyncua/common/node.py#L414-L425, we already have the browse name available and passing that into Node ahead of time, the time cut in half.

@schroeder-
Copy link
Contributor

There are a lot room of optimization in this code, but you are correct we have the browse_names already. I can look into using the low level api and speed up the code.

For your use case you could execute the code once and pickle the EventFilter that is created and reuse it for the next time.

I don't know if a event with 400 nodes something that you want to have. Sounds like something that should't be an event.

@deeTEEcee
Copy link
Author

deeTEEcee commented Jun 6, 2022

I don't know if a event with 400 nodes something that you want to have. Sounds like something that should't be an event.

🤔 Not sure. From a data perspective, 400 data points doesn't seem like that much in the large scope of a manufacturing plant. Whether doing that setup with an event actually makes sense, that would be something I'd have to ask our customer about. (I have no eyes into what happens with the setup on the server side)

@deeTEEcee
Copy link
Author

deeTEEcee commented Jun 6, 2022

It's definitely overkill for us right now because I setup application-side filtering after fetching the default subscribe_events call and we currently do only need a few nodes. The opcua lib was new to me and the interface is not very straightforward so I ended up doing it this way to start.

@schroeder-
Copy link
Contributor

filter = get_filter_from_event_type([NodeOfTheEvent])
# pickle filter
sub.subscribe_events(... evfilter=filter)

It's definitely overkill for us right now because I setup application-side filtering after fetching the default subscribe_events call and we currently do only need a few nodes.

Then create your own filter (Example is for AlarmConditionEvents):

content_filter = ContentFilter(
    [
        ContentFilterElement(
            FilterOperator.OfType,
            [LiteralOperand(Variant(NodeId(ObjectIds.AlarmConditionType)))],
        )
    ]
)
filter = EventFilter(
    [
        SimpleAttributeOperand(
            BrowsePath=[QualifiedName("EventType")],
            AttributeId=AttributeIds.Value,
            TypeDefinitionId=NodeId(ObjectIds.BaseEventType),
        ),
        SimpleAttributeOperand(
            BrowsePath=[QualifiedName("Message")],
            AttributeId=AttributeIds.Value,
            TypeDefinitionId=NodeId(ObjectIds.BaseEventType),
        ),
        SimpleAttributeOperand(
            BrowsePath=[QualifiedName("ActiveState"), QualifiedName("Id")],
            AttributeId=AttributeIds.Value,
            TypeDefinitionId=NodeId(ObjectIds.BaseEventType),
        ),
        SimpleAttributeOperand(
            BrowsePath=[QualifiedName("ConditionName")],
            AttributeId=AttributeIds.Value,
            TypeDefinitionId=NodeId(ObjectIds.BaseEventType),
        ),
    ],
    WhereClause=content_filter,
)

@schroeder-
Copy link
Contributor

See: #919 for improved version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants