Skip to content

Loading Custom Structs using Dynamic Type Loader with missing type_definition and non-Numeric NodeId #133

@porquey

Description

@porquey

Hello,
I have been experimenting with custom dynamic structures via the example code in the samples: https://github.com/FreeOpcUa/async-opcua/blob/master/samples/custom-structures-client/src/bin/dynamic_client.rs

In my example I have the following code to load in the dynamic structs:

        let type_tree = DataTypeTreeBuilder::new(|f| f.namespace <= 4)
            .values_per_read(100)
            .build(&session)
            .await?;
        println!("{:?}", type_tree);
        let loader = Arc::new(DynamicTypeLoader::new(Arc::new(type_tree)));
        session.add_type_loader(loader);

From my limited testing and debugging I see that it can load the types and encoders for dynamic types registered by the OPCUA server when the NodeId of the types (and perhaps the variables) are Numeric.
However in our CODESYS generated OPCUA Server, the custom types are created with NodeId Identifier: String.

The above code example prints the type_tree, and I can see that for the dynamic_client.rs example, it can populate the struct_types, enum_types and encoding_to_data_type fields correctly.
When I repeat the same code against the CODESYS server, it iterates through the data type nodes such as:

NodeId { namespace: 4, identifier: String(UAString { value: Some("|type|CODESYS Control for Linux SL.Application.extractionAPI") }) }

But the type_tree contains empty struct_types, enum_types and encoding_to_data_type fields.

I wonder if this is a known limitation of dynamic type loader, or is expected behaviour according to OPCUA spec, and whether CODESYS is doing something unique with their server.

At the minimum, it would be great if types that do not have a registered encoder can still return the raw binary, rather than panicking.

Originally posted by @porquey in #132

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions