Field variablesΒΆ

Tag variables and field variables

To reference field variables (PLC tags or variables of an OPC UA server), UNIQO uses special project variables, Tags, that report their value.

When a Tag variable is read, UNIQO reads the field variable and updates the value of the project variable. When a Tag variable is written, UNIQO propagates the write on the field variable.

Reading/writing in Q Studio and in C#

While field variable reading/writing occurs automatically when a Tag variable is read/written in Q Studio, to reproduce the same behavior in C#, it is necessary to use specific APIs (see API for reading/writing of field variables), in these cases:

  • reading/writing of Tag variables synchronized with corresponding PLC tags

  • reading/writing of important variables with an OPC UA Client object from a OPC UA server, to synchronize them with the OPC UA server corresponding variables

  • reading/writing of a variable directly or indirectly connected (using dynamic links or converters) to a variable described in the two previous points.

Note

when a Tag variable is read using the Get method, UNIQO does not read the value on the field and therefore can return a value that has not been updated.

Value change events

To subscribe methods to the change value event of the field variables, it is necessary to use a RemoteVariableSynchronizer object (see IUAVariable.VariableChange and API for keeping field variables synchronized). In fact, this object keeps the project variables referring to field variables constantly updated, without the need to repeat readings through simple API reading (see API for reading/writing of field variables).

However, the RemoteVariableSynchronizer object is not required if a link to a Tag variable from a graphical object, Data logger object, alarm or Recipe Schema object already exists in Q Studio. In this case, in a NetLogic it is possible to subscribe the change value method directly to the linked Tag variable.

Management of communication delays with the field

If a field variable is read/written in NetLogic, it is first necessary to execute the instructions that follow, making sure that the current value is actually read or that any write has actually been performed.

Taking account of the delays due to the different communications protocols, the APIs for reading/writing field variables are synchronous, i. e. their execution must terminate before the next instruction can be executed.