You need to use a variable in a code to have it created in the B&R world. It is not enough to declare it in the *.var file.
If you enable a variable in the OPC UA server, it is a different story:
- a local variable:
- It is ENOUGH to enable the variable in the OPC UA server to create it.
- Without using the variable in the code, you still get the warning 5874 - “variable is declared but not used.”
- a global variable:
- The variable must be used in the code to be created; it is NOT ENOUGH to enable it in the OPC UA server.
With that said, if you declare a global variable, use it in an I/O mapping, and enable it for OPC UA communication, you will get the BadResourceUnavailable (0x80040000) in the client. The name of the variable is known, but it is not created.