I have used the dynamic ports example in C++ from Github and I was able to run it successfully. However, I would like to expand the project and add more tags - Boolean and real tags. Does the attributes in the Json file provided in the example have a significance (I imagine 36 for output and 34 for input )? Is there a documentation or example that helps us expand the scope provided.
Here is the sample of what I am looking for. Need all these variables to do some logic in C++ and as well as have them in the GDS.
I copied the json file to plcnext controller and see the following message and no dynamic ports were created.
Not sure if the Json file format is incorrect or something else is wrong. Please help.
There’s nothing special about the JSON file used in that example - the JSON file is just an example of how to read attributes from a configuration file. You can use JSON, XML, or any other file format, or maybe you want to use a database or web service to store port configuration information. The example uses the nlohmann header-only JSON library for C++ to read the JSON (because it happens to be included in the SDK), but you can use any method you like to read the configuration information.
In the example, the configuration information is just passed to the AddPort method. The third parameter on this method is a StandardAttribute enum:
enum StandardAttribute : uint64 {
StandardAttribute::None = 0, StandardAttribute::Hidden = (1 << 0), StandardAttribute::Input = (1 << 1), StandardAttribute::Output = (1 << 2),
StandardAttribute::ReadOnly = (1 << 3), StandardAttribute::Retain = (1 << 4), StandardAttribute::Opc = (1 << 5), StandardAttribute::Ehmi = (1 << 6),
StandardAttribute::ProfiCloud = (1 << 7), StandardAttribute::Archive = (1 << 8), StandardAttribute::Invisible = (1 << 9), StandardAttribute::Assignable = (1 << 10),
StandardAttribute::Redundant = (1 << 11)
}
You can see from the enum values that 34 (decimal) = OPC and Input attributes, and 36 (decimal) = OPC and Output attributes.