F_iecLookupTableEntry

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

F_iecLookupTableEntry 1:

The function F_iecLookupTableEntry checks if an table entry already exists that matches to the key.

FUNCTION F_iecLookupTableEntry: UDINT

VAR_INPUT
    key : ST_IEC870_5_101HashTableKey;
END_VAR
VAR_IN_OUT
    hTable  : T_HAODBTable;
ENd_VAR

key: Lookup key.

hTable: Application object data base handle (hash table handle). The table handle has to be initialized once before using with the function F_iecCreateTableHnd.

Return parameter

Description

0

No error. A table entry that matches to the key exists.

<> 0

No table entry found. Error: IEC60870-5-10x error code

 

Example in ST:

It will be checked if three data points in the application data base exist. The searched data points have already been configured as hash table entries.
See description of: 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

PROGRAM P_LookupEntry
VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR
VAR
    key : ST_IEC870_5_101HashTableKey;
    bLookup : BOOL;
    nFound : BYTE;
    nError : UDINT;
END_VAR
IF bLookup THEN
    bLookup := 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;
    nError      := F_iecLookupTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    ELSE
        nFound := nFound + 1;
    END_IF

    key.eType       := M_DP_NA_1;
    key.asduAddr    := 11;
    key.objAddr     := 200;
    key.group       := IEC870_GRP_INROGEN;
    key.lookup      := IEC870_LOOKUP_KEY_ALL_ON;
    nError      := F_iecLookupTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    ELSE
        nFound := nFound + 1;
    END_IF

    key.eType       := M_IT_NA_1;
    key.asduAddr    := 11;
    key.objAddr     := 800;
    key.group       := IEC870_GRP_REQCOGEN;
    key.lookup      := IEC870_LOOKUP_KEY_ALL_ON;
    nError      := F_iecLookupTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    ELSE
        nFound := nFound + 1;
    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
( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib;  are included atomatically )