Dynamic Ports: Struct metadata can be generated automatically
The Dynamic Ports example lists the limitation that struct metadata is not generated automatically by the plcncli code generator.
It turns out that the //#typeinformation comment can be used to do just that.
The example should be updated to mention this.
Could you provide a little more detail? I'm looking into creating dynamic ports from config file and I'd like to be able to use structs.
I am unable to find any documentation on this annotation.
You're right, there is no documentation on this feature. I know that it's on the developer's list of things to do, but I don't know if/when it will be done.
Without testing it, something like this should work:
// Define the struct that will be used to declare port variables.
// The typeinformation attribute means that the plcncli will generate GDS metadata for this struct.
//#typeinformation
struct SampleStruct
{
float64 ElemA;
uint32 ElemB;
uint16 ElemC;
boolean ElemD;
};
You should then be able to create dynamic ports of this type, in a similar way to ports of elementary data types.
This is now mentioned in the latest README file in the Dynamic Ports example.