I want to define a few similar GDS-structs with small variances in the actual datatype.
Instead of copy-pasting the declaration I created a template class in C++, and created explicit instantiations for the needed types and created ports for those.
That all seems to compile OK, but the types don’t show up in PLCnext Engineer, after importing the updated .plcwx
The datatypes are listed in the .compmeta-file, generated in the build.
Something like this:
template <class T>
class TagValue {
T value;
// .. more fields
}
// IEC 61131-3 datatype aliases
using MyDINT = TagValue<Arp::int32>; // 32-bit signed integer
using MyLINT = TagValue<Arp::int64>; // 64-bit signed integer
using MyREAL = TagValue<Arp::float32>; // 32-bit floating point
using MyLREAL = TagValue<Arp::float64>; // 64-bit floating point
// Explicit template instantiations
template class TagValue<Arp::int32>; // DINT
template class TagValue<Arp::int64>; // LINT
template class TagValue<Arp::float32>; // REAL
template class TagValue<Arp::float64>; // LREAL
Port declaration in the Component itself:
// #port
// #attributes(Output|Retain)
// #name(dintTag)
MyNameSpace::MyDINT dintTag;
Is this not possible?