F_iecGetPosOfTableEntry
From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.
The function F_iecGetPosOfTableEntry supplies the table index (array index) for a hash table entry that matches the lookup key. The first array element has position number one (non-zero-based array position).
FUNCTION F_iecGetPosOfTableEntry: UDINT
VAR_INPUT
key : ST_IEC870_5_101HashTableKey;
END_VAR
VAR_IN_OUT
hTable : T_HAODBTable;
ENd_VAR
key: Lookup key.
hTable: Application object database handle (hash table handle). The table handle must be initialised once with the function F_iecCreateTableHnd before it can be used.
Return parameter | Description |
---|---|
0 | No table entry matching the key was found. |
<> 0 | No error. The return parameter supplies the required table index (non-zero-based array position). |
Example in ST:
The system searches for the linear table index for three data points. The associated data points have already been configured as hash table entries. See function description: F_iecAddTableEntry.
eType | objAddr | asduAddr | group |
---|---|---|---|
M_SP_NA_1 | 100 | 11 | IEC870_GRP_INRO1 |
M_DP_NA_1 | 200 | 11 | IEC870_GRP_INROGEN |
M_IT_NA_1 | 800 | 11 | IEC870_GRP_REQCOGEN |
VAR_GLOBAL CONSTANT
MIN_TABLE_IDX : INT := 0;
MAX_TABLE_IDX : INT := 49;
END_VAR
PROGRAM P_GetPosOfTableEntry
VAR_IN_OUT
hTable : T_HAODBTable;
AODB : ARRAY[MIN_TABLE_IDX..MAX_TABLE_IDX] OF ST_IEC870_5_101AODBEntry;
END_VAR
VAR
bGetPos : BOOL;
position : UDINT;
key : ST_IEC870_5_101HashTableKey;
hUser : UDINT;
END_VAR
IF bGetPos THEN
bGetPos := FALSE;
key.eType := M_SP_NA_1;
key.asduAddr := 11;
key.objAddr := 100;
key.group := IEC870_GRP_INRO1;
key.lookup := IEC870_LOOKUP_KEY_ALL_ON;
position := F_iecGetPosOfTableEntry( key := key, hTable := hTable );
IF position <> 0 THEN
hUser := AODB[MIN_TABLE_IDX+position-1].aObj.cfg.hUser;
ELSE
ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
'F_iecGetPosOfTableEntry() error: %s', '' );
END_IF
key.eType := M_DP_NA_1;
key.objAddr := 200;
key.group := IEC870_GRP_INROGEN;
key.lookup := IEC870_LOOKUP_KEY_ALL_ON;
position := F_iecGetPosOfTableEntry( key := key, hTable := hTable );
IF position <> 0 THEN
hUser := AODB[MIN_TABLE_IDX+position-1].aObj.cfg.hUser;
ELSE
ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
'F_iecGetPosOfTableEntry() error: %s', '' );
END_IF
key.eType := M_IT_NA_1;
key.objAddr := 800;
key.group := IEC870_GRP_REQCOGEN;
key.lookup := IEC870_LOOKUP_KEY_ALL_ON;
position := F_iecGetPosOfTableEntry( key := key, hTable := hTable );
IF position <> 0 THEN
hUser := AODB[MIN_TABLE_IDX+position-1].aObj.cfg.hUser;
ELSE
ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
'F_iecGetPosOfTableEntry() error: %s', '' );
END_IF
END_IF
Requirements
Development Environment | Target System | PLC Libraries to include |
---|---|---|
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib |