Problem
The TIME datatype is a basic-datatype (see Automation studio help)
This data type primarily offers the advantage that times can be written more readable (e.g. T#2s_100ms)
If a variable of type TIME is released in OpcUa, it is assigned as an Int32 value in milliseconds and no unit can be assigned accordingly.
Node binding is therefore not possible.
The display and manipulation in mappView involves some difficulties:
- Since the variable cannot be assigned a unit, node binding is not possible. The conversion from milliseconds to seconds is not possible as the conversion is not known due to the missing unit.
- No limits can be assigned to the data type in the OpcUa view.
- The DateTimeInput widget only offers the option of adjusting times up to seconds. It is not possible to set milliseconds.
In this case, the widget looks as follows.
Milliseconds cannot be set and the display of the buttons is unsatisfactory.
The problem can be solved in different ways:
Variant 1 - Change to integer data type and use NumericInput
A simple variant is to change the variable in the code from the TIME data type to an integer data type. This then still displays milliseconds, but can be provided with a unit. Node binding to a NumericInput is then possible.
Disadvantage
In this variant, the advantage is lost that the values in the application can be written in the style T#2s_200ms. All values must be specified as integers in milliseconds (e.g. 2200).
Variant 2 - NumericInput in a Compound-Widget
Another variant is to place a NumericInput in a compound widget.
However, the value of the application is then not bound directly to the widget, but to a local property.
If the value of the widget changes, this can be recognized in the event action system and the value of the local property multiplied by 1000 can be set.
Conversely, if the local property changes, the value of the widget is divided by 1000.
In this variant, a TIME data type can be bound directly to the compound widget and the value can be specified in milliseconds.
Disadvantages
Although the implementation works in this way, the following disadvantage must be taken into account.
If the value cannot be changed due to the permissions of the variable, the widget accepts the value anyway. This must be prevented by the permissions on the compound widget (PermissionOperate).