Data Types for Logic, OPC, and ClearSCADA
Each Logic program has values that are of a specific data type, for example, the Name value of a point is a STRING data type. However, the name for the data type varies depending on whether you access the value via Logic, OPC, or ClearSCADA (access the value in the ClearSCADA database schema). For example, in Logic, the Name value of a point is a STRING data type, whereas the Name value in OPC is a VT_BSTR data type.
The following table shows the names of the data types in Logic, OPC (automation), and ClearSCADA:
Logic | OPC (Automation) |
ClearSCADA (shown on Database Schema) |
Range |
---|---|---|---|
BOOL |
VT_BOOL |
Boolean |
True or False |
SINT |
VT_I1 |
Byte |
-128 to 127 |
INT |
VT_I2 |
Word |
-32768 to 32767 |
DINT |
VT_I4 |
Long |
-2147483648 to 2147483647 |
USINT |
VT_UI1 |
0 to 255 |
|
UINT |
VT_UI2 |
Unsigned Word |
0 to 65535 |
UDINT |
VT_UI4 |
Unsigned Long |
0 to 4294967295 |
REAL |
VT_R4 |
Float |
32 bit precision floating point |
LREAL |
VT_R8 |
Double |
64 bit precision floating point |
TIME |
VT_DATE |
||
TIME_OF_DAY |
VT_DATE |
Time |
|
DATE |
VT_DATE |
||
DATE_AND_TIME |
VT_DATE |
Time |
|
STRING |
VT_BSTR |
Variant |
|
BYTE |
VT_UI1 |
0 to 255 |
|
WORD |
VT_I2 |
0 to 65535 |
|
DWORD |
VT_I4 |
Color |
0 to 4294967295 |
Internally, Logic uses:
- A FILETIME to represent DATE, and DATE_AND_TIME. Conversion to VT_DATE usually involves a small loss of precision, for example a VT_DATE is only accurate to a few uS, whereas a FILETIME is accurate to 100nS. In the conversion to VT_DATE, the FILETIME is rounded to the nearest 10uS. DATE and DATE_AND_TIME values can be mapped to VT_DATE and VT_BSTR variant types.
- A signed 64 bit integer to represent TIME types, where each increment represents 1mS. TIME types can be mapped to a number of VARIANT types including VT_BSTR, VT_UI1, VT_I2, VT_I4, VT_R4, VT_R8 and VT_VARIANT. For numeric values, the value is the number mS, for VT_BSTR, the time value is converted to a string. The format of the string is either day [-]hh:mm:ss.mmm, or an 61131 time constant T#XhYmZs depending on the configuration of the program.
- A FILETIME to represent TIME_OF_DAY. The actual value is offset to the unix epoch of 1-JAN-1970. Thus 1-JAN-1970 00:00:00.000 represents 00:00:00.000, and 1-JAN-1970 23:59:59.999 represents 23:59:59.999. Values outside of the range 1-JAN-1970 00:00:00.000 to 1-JAN-1970 23:59:59.999 are not strictly valid. TIME_OF_DAY values cannot be mapped to VARIANT types.
The data types that are available to a function, function block etc. are organized into a hierarchy. For more information, see Data Type Hierarchy.
For more information on the ClearSCADA Database Schema, see Working with the Database Schema in the ClearSCADA Guide to the Database.