You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently failing to decode the ExtensionObject into the expected UDT using the following code
varsession=Session.Create(config,newConfiguredEndpoint(null,selectedEndpoint,EndpointConfiguration.Create(config)),false,"",60000,null,null).GetAwaiter().GetResult();varcomplexTypeSystem=InitializeComplexTypeSystem(session);foreach(vartypeincomplexTypeSystem.GetDefinedTypes()){Console.WriteLine($"Type Loaded: {type}");}varresult=session.ReadValue("ns=3;s=\"H35dispenser\".\"ID\".\"ElectricalVersion\"");Console.WriteLine(result);if(result.ValueisExtensionObjectextObject){Console.WriteLine(extObject.Body.ToString());varcustomType=extObject.BodyasUDT_SemVer;if(customType!=null){Console.WriteLine($"Successfully read custom UDT: {customType}");}else{Console.WriteLine("Failed to decode ExtensionObject into the expected UDT.");}}else{Console.WriteLine("The result is not an ExtensionObject.");}
I have the defined the UDT_SemVer as follows:
[DataContract(Namespace="http://www.siemens.com/simatic-s7-opcua")]publicclassUDT_SemVer:IEncodeable,IJsonEncodeable{
#region Constructors
publicUDT_SemVer(){Initialize();}[OnDeserializing]privatevoidInitialize(StreamingContextcontext){Initialize();}privatevoidInitialize(){Major=0;Minor=0;Patch=0;}
#endregion
#region Public Properties
[DataMember(Name="Major",IsRequired=true,Order=1)]publicbyteMajor{get;set;}[DataMember(Name="Minor",IsRequired=true,Order=2)]publicbyteMinor{get;set;}[DataMember(Name="Patch",IsRequired=true,Order=3)]publicbytePatch{get;set;}
#endregion
#region IEncodeable Members
publicExpandedNodeIdTypeId=>newExpandedNodeId("nsu=http://www.siemens.com/simatic-s7-opcua;s=DT_\"UDT_SemVer\"");publicExpandedNodeIdBinaryEncodingId=>newExpandedNodeId("nsu=http://www.siemens.com/simatic-s7-opcua;s=TE_\"UDT_SemVer\"");publicExpandedNodeIdXmlEncodingId=>newExpandedNodeId(0);publicvoidEncode(IEncoderencoder){encoder.WriteByte("Major",Major);encoder.WriteByte("Minor",Minor);encoder.WriteByte("Patch",Patch);}publicvoidDecode(IDecoderdecoder){Major=decoder.ReadByte("Major");Minor=decoder.ReadByte("Minor");Patch=decoder.ReadByte("Patch");}publicboolIsEqual(IEncodeableencodeable){if(encodeableisUDT_SemVerother){returnMajor==other.Major&&Minor==other.Minor&&Patch==other.Patch;}returnfalse;}publicvoidEncodeJson(IJsonEncoderencoder){encoder.WriteByte("Major",Major);encoder.WriteByte("Minor",Minor);encoder.WriteByte("Patch",Patch);}publicvoidDecodeJson(IJsonDecoderdecoder){Major=decoder.ReadByte("Major");Minor=decoder.ReadByte("Minor");Patch=decoder.ReadByte("Patch");}publicobjectClone(){return(UDT_SemVer)this.MemberwiseClone();}publicXmlQualifiedNameXmlEncodingNamespace=>newXmlQualifiedName("http://www.siemens.com/simatic-s7-opcua");publicExpandedNodeIdJsonEncodingId=>thrownewNotImplementedException();
#endregion
}
The structure looks as follows on the PLC:
And the type that got loaded from the complexTypeSystem = Opc.Ua.ComplexTypes.simatic-s7-opcua.3.UDT_SemVer
I hope this is enough info in order to help me out
Expected Behavior
I expect the extObject.Body to be able to be cast to a UDT_SemVer
Steps To Reproduce
No response
Environment
- OS: Windows 10
- Environment: Visual Studio 2022
- Runtime: .NET 8.0 LTS
- Nuget Version: Latest Stable
- Component: Opc.Ua.Client.ComplexTypes
- Server: Custom Server
Anything else?
No response
The text was updated successfully, but these errors were encountered:
@JessevGool To my understanding the Complex type system builds the types at runtime (and uses OPC UA Type BaseComplexType) using the information returned from the OPC UA Server and has no way to know about your implementation of UDT_SemVer. Feel free to propose an extension to allow the loading of own provided types.
Type of issue
Current Behavior
Currently failing to decode the ExtensionObject into the expected UDT using the following code
I have the defined the UDT_SemVer as follows:
The structure looks as follows on the PLC:

And the type that got loaded from the complexTypeSystem = Opc.Ua.ComplexTypes.simatic-s7-opcua.3.UDT_SemVer
I hope this is enough info in order to help me out
Expected Behavior
I expect the extObject.Body to be able to be cast to a UDT_SemVer
Steps To Reproduce
No response
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: