Closed eoursel closed 3 years ago
The ModelCompiler does not support Structures with Optional fields at this time.
Hi @opcfoundation-org, @randy-armstrong. Do you a plan to support that in the near future ? Thanks
It is not likely to happen before December.
Option fields have been supported for awhile.
Hi @opcfoundation-org, I don't see in the code where the C# Modelcompiler generated code is fixed.
When I run this description through ModelCompiler:
<opc:DataType SymbolicName="ComplexTypeWithOptionsType" BaseType="ua:Structure">
<opc:Fields>
<opc:Field Name="X" DataType="ua:Double" IsOptional="true" />
<opc:Field Name="Y" DataType="ua:Double" IsOptional="true" />
<opc:Field Name="Z" DataType="ua:Double" IsOptional="true" />
</opc:Fields>
</opc:DataType>
the generated C# code:
/// <summary cref="IEncodeable.Encode(IEncoder)" />
public virtual void Encode(IEncoder encoder)
{
encoder.PushNamespace(ComplexTypesInterop.Namespaces.ComplexTypesInterop);
encoder.WriteDouble("X", X);
encoder.WriteDouble("Y", Y);
encoder.WriteDouble("Z", Z);
encoder.PopNamespace();
}
I'd expect generated code like this for structure with optional fields:
/// <summary cref="IEncodeable.Encode(IEncoder)" />
public virtual void Encode(IEncoder encoder)
{
encoder.PushNamespace(ComplexTypesInterop.Namespaces.ComplexTypesInterop);
encoder.WriteUInt32("EncodingMask", m_bitMask);
if ((m_bitMask & 1)!=0) encoder.WriteDouble("X", X);
if ((m_bitMask & 2)!=0) encoder.WriteDouble("Y", Y);
if ((m_bitMask & 4)!=0) encoder.WriteDouble("Z", Z);
encoder.PopNamespace();
}
Hi
How is it possible to describe in ModelDesign format a DataTypes which contains Optional Fields. So for instance in in the NodeSet2 format i have something like that (from the VDMA Machine Vision companion specification
So in the model design format do we have something to describe that fields are optional. The problem is that the encoders/decoders are not generated correctly in C# since it is written in part 6 we should generate a 4 bytes (UInt32) at the beginning of the encoding.
Is there something missing in the modelcompiler?
Thanks