Is there any documentation or example how to access a parameter of type Any in a function block written in C++?
Hello Armali,
thank you for your request.
Unfortunately there is no documentation or example how to access a parameter of type Any in a function block written in C++.
For C# there is the following ANY example: https://github.com/PLCnext/CSharpExamples/blob/master/PLCnext_CSharpExamples/02_Any/Any.md
This could be converted according to the following instructions:
https://plcnext.help/te/Programming/Cplusplus/Function_blocks_in_Cpp.htm
Theoretically this should work, but is probably a lot of work.
You could try adding a separate method for each data type.
Our recommendation is to use C# for FB programming.
There is a template for this and the code generator makes problems easier to understand.
Hello, Tim,
thanks for the hints! I assume that by C+ you mean C#, right?
Unfortunately the C# examples cannot be converted to C++ without knowlegde of how the members and methods of the data structure Any are named there; this really ought to be documented in order to keep PLCnext’s advertised promise that it’s possible to program in C++. In fact we only started using PLCnext to be able to adapt existing code with as little effort as possible - a lot of work would be to port the code to C#.
Fortunately I found a definition of struct Any in …\Toolchain\eCLR\v…\include\pcoslib.h; therewith I can work for now since I only need the pointer to data.
Best regards