locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
475 stars 128 forks source link

Cannot easily instantiate objects/create objects of specified type #310

Open evanjs opened 5 months ago

evanjs commented 5 months ago

Problem

As originally mentioned in https://github.com/locka99/opcua/discussions/297

I am trying to instantiate nodes (esp. objects) based on other node types.

As mentioned in the linked discussion, I am currently unable to do so using this library.

While I can create e.g. two distinct empty objects named Machine One and Machine Two, when I try to assign them to a type via has_type_definition, not even mandatory properties are created for me.

If I use has_component, the properties are created, but share the same instance across the objects with those components, which is not what I want.

If I understand the behavior of has_component correctly, I figure it is not what I should be using here. In addition, it sounds like has_type_definition is closer to what I want, but it will not create any properties for me on the new object.


I wanted to verify whether:

If I understand correctly, and this library does not currently have an instantiate function, then I would need to populate all properties by hand each time I instantiate an object.


Existing functions in other libraries

Python

python-opcua(DEPRECATED)

~instantiate: function, usage~

opcua-asyncio (ACTIVE)

instantiate: function, usage


.NET

UA-.NETStandard

CreateInstance


Node

Node-OPCUA

Instantiate: function, usage

hirschenberger commented 1 month ago

I would also need a recursive create_instance function.