F_iecGetPosOfTableEntry

F_iecGetPosOfTableEntry 1:

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).

Syntax

FUNCTION F_iecGetPosOfTableEntry: UDINT
VAR_INPUT
    key    : ST_IEC870_5_101HashTableKey;
END_VAR
VAR_IN_OUT
    hTable : T_HAODBTable;
ENd_VAR

F_iecGetPosOfTableEntry 2: Inputs

key: Lookup key.

Inputs/outputs

hTable: Application object database handle (hash table handle). The table handle must be initialized once with the function F_iecCreateTableHnd before it can be used.

F_iecGetPosOfTableEntry 3: Return value

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).

Sample 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_SP_TB_1

101

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
    MAX_TABLE_IDX : INT := 49;
END_VAR
VAR_IN_OUT
    hTable  : T_HAODBTable;
    AODB    : ARRAY[1..MAX_TABLE_IDX] OF ST_IEC870_5_101AODBEntry;
END_VAR
VAR
    bGet : BOOL := TRUE;
    key1 : ST_IEC870_5_101HashTableKey := ( eType := M_SP_NA_1, asduAddr := 11, objAddr := 100, group := IEC870_GRP_INRO1, lookup := IEC870_LOOKUP_KEY_ALL_ON );
    key2 : ST_IEC870_5_101HashTableKey := ( eType := M_SP_TB_1, asduAddr := 11, objAddr := 101, group := IEC870_GRP_INRO1, lookup := IEC870_LOOKUP_KEY_ALL_ON );
    key3 : ST_IEC870_5_101HashTableKey := ( eType := M_DP_NA_1, asduAddr := 11, objAddr := 200, group := IEC870_GRP_INROGEN, lookup := IEC870_LOOKUP_KEY_ALL_ON );
    key4 : ST_IEC870_5_101HashTableKey := ( eType := M_IT_NA_1, asduAddr := 11, objAddr := 800, group := IEC870_GRP_REQCOGEN, lookup := IEC870_LOOKUP_KEY_ALL_ON );

    nPosition : UDINT;
    hUser1  : UXINT;
    hUser2  : UXINT;
    hUser3  : UXINT;
    hUser4  : UXINT;
END_VAR
IF bGet    THEN
    bGet := FALSE;

    IF ( nPosition := F_iecGetPosOfTableEntry( key := key1, hTable := hTable ) ) = 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecGetPosOfTableEntry(key1) failed! %s', '' );
    ELSE
        hUser1 := AODB[nPosition].aObj.cfg.hUser;
    END_IF

    IF ( nPosition := F_iecGetPosOfTableEntry( key := key2, hTable := hTable ) ) = 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecGetPosOfTableEntry(key2) failed! %s', '' );
    ELSE
        hUser2 := AODB[nPosition].aObj.cfg.hUser;
    END_IF

    IF ( nPosition := F_iecGetPosOfTableEntry( key := key3, hTable := hTable ) ) = 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecGetPosOfTableEntry(key3) failed! %s', '' );
    ELSE
        hUser3 := AODB[nPosition].aObj.cfg.hUser;
    END_IF

    IF ( nPosition := F_iecGetPosOfTableEntry( key := key4, hTable := hTable ) ) = 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecGetPosOfTableEntry(key4) failed! %s', '' );
    ELSE
        hUser4 := AODB[nPosition].aObj.cfg.hUser;
    END_IF
END_IF

Requirements

Development environment

Target system type

PLC libraries to be linked (category group)

TwinCAT v3.1.4012.0

PC oder CX (x86, x64, ARM)

Tc2_IEC60870_5_10x (Communication->IEC60870)
Tc2_SerialCom (Communication->Serial)
Tc2_TcpIp (Communication->TcpIp)
Tc2_Utilities (System)