From the version D2000 V9.02.034, there is available both 32 and 64-bit version with modified header file for using in the projects with interpretation of text strings in 8-bit form (ANSI) or 16-bit form (wide character UNICODE), according to the parameter of project "Character Set" in MS Visual Studio.
UniVal contains all information about a value and status of given object of D2000 system.
Declaration in C language:
typedef struct _UniVal { GenValueType gvaltyp; unsigned int status; tLimitStatus limitStatus; tProcAlarmType procAlarmStatus; ValueType type; double valtime; double procAlarmTime; unsigned int Flags; VOBJ Indirect; union { tBVal Boval; int Intval; double Realval; StVal Stval; struct { AlVal Alval; double AlTimes[4]; } a; PrVal Prval; double TmAval; double TmRval; tQValue QVal; char *TxtVal; ArrayRecPtr ArrayValPtr; struct { ArrayRecPtr recordValPtr; HOBJ StructTypId; int ColsNr; } r; } v; } UniVal; |
Constant definition | Description |
#define VAL_Valid 1U | Object value is valid |
#define VAL_ProcAlarm 2U | Object has an active process alarm |
#define VAL_NoAckPAlarm 4U | Object had an active process alarm, that is not acknowledged |
#define VAL_PrAlSilent 8U | Process alarms of the object are not evaluated |
#define VAL_Weak 16U | Object value is suspicious – “weak” |
#define VAL_NoAckValue 32U | Object value is changed and is not acknowledged |
#define VAL_Transient 64U | Object value is in the transient status when is writing |
#define VAL_Default 128U | Value is in the default status |
#define VAL_Manual 256U | Object value modified manually |
#define VAL_PrAlCrit 512U | Object has an active critical process alarm |
typedef enum {InLimit,VL_Limit,L_Limit,H_Limit,VH_Limit,LimitsProblem} tLimitStatus; |
Value status | Status description |
InLimit | Object value is in limits |
L_Limit | Object value is below the low limit |
VL_Limit | Object value is below the lowest limit |
H_Limit | Object value is above the high limit |
VH_Limit | Object value is above the highest limit |
LimitsProblem | A problem with the evaluation of the limits (unknown value of active limit, crossing the values of the active limits) |
typedef enum {NoAlarm,ToOn,ToOff,On,Off,Err,Oscillate,ErrCmdOn,ErrCmdOff, SwToTrans,SwToOff,SwToOn,SwToErr,SwTrans,SwOff,SwOn,SwErr,ErrZalCmdOff, HL,VHL,LL,VLL,ToHL,ToVHL,ToLL,ToVLL,ErrWriteCmd,A28,A29,A30,A31,A32} tProcAlarmType; |
Variable part, holding an own object value:
Alarm status | Index |
Alarm | 0 |
NoKvit | 1 |
Kvit | 2 |
Norm | 3 |
Warning for some value types:
UniVal contains only references to values for objects of Text and Array types. Values are created dynamically and it is necessary to release them calling the function FreeData. Exceptions are asynchronous calling the function NewValueProc (ObjAPI releases the values after return from the callback) and the function ListOfObjects (values are released by calling the function FreeData that releases structures of ListObjData type).
Arrays and structures are represented by a value array of UniVal type, before which there are low (lowIndex) and high (hiIndex) indexes. Array items are indexed from 1. Before hiIndex, there are following individual values in rows in successive steps.
typedef struct _ArrayRec { int lowIndex; int hiIndex; } ArrayRec; typedef ArrayRec * ArrayRecPtr; |
Access to a structure item (row, column) is represented by the following function:
UniValPtr GetRecordItem(UniVal value, int row, int col) { UniValPtr uni_Ptr; int valueIdx; valueIdx = (row-1)*value.v.r.ColsNr+col - 1; // first value address uni_Ptr = (UniValPtr)((char *)value.v.r.recordValPtr + sizeof(*value.v.r.recordValPtr)); uni_Ptr = &(uni_Ptr[valueIdx]); return uni_Ptr; } |
When calling interface procedures, it is important to correctly enter the indexes !!!