F_iecAddTableEntry
The function F_iecAddTableEntry configures the application objects (single points, double points, measured values...) in the application database as hash table entries. The function automatically searches for a free, unused table element (array element) and sets its configuration parameters.
Syntax
FUNCTION F_iecAddTableEntry: UDINT
VAR_INPUT
eType : E_IEC870_5_101TcTypeID := ASDU_TYPEUNDEF;
asduAddr : DWORD := 0;
objAddr : DWORD := 0;
group : DWORD := 0;
multiplier : BYTE := 0;
ioMapType : E_IEC870_5_101IOMappingType := MAP_AREA_NONE;
byteOffs : UXINT := 0;
bitOffs : UDINT := 0;
hUser : UXINT := 0;
END_VAR
VAR_IN_OUT
hTable : T_HAODBTable;
ENd_VAR
Inputs
eType: Application object type, ASDU identifier (e.g.: M_SP_NA_1 for single-point or M_DP_NA_1 for double point).
asduAddr: Common ASDU address.
objAddr: Object address, freely selectable.
group: Object group configuration flags. A description of all group flags can be found here. The flags can be combined with an OR operation. Not all combinations are meaningful!
multiplier: Basic cycle time multiplier for cyclic/periodic data transfer. 0 = deactivated. The basic cycle time can be configured via the tPerCyclicBase parameter in the system parameters.
ioMapType: TwinCAT PLC process data area. This parameter defines the mapping for the TwinCAT PLC and IEC application object process data.
byteOffs: TwinCAT PLC process data byte offset (x86 platform => 32 bit, x64 platform => 64 bit).
bitOffs: TwinCAT PLC process data bit offset.
hUser: Freely definable value, also pointer (x86 platform => 32 bit, x64 platform => 64 bit). This value is stored in the configuration data of the application object.
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.
Sample in ST
In the following sample, some data points are added to the application database as hash table entries:
eType | asduAddr | objAddr | group | multiplier | ioMapType | byteOffs | bitOffs | hUser |
---|---|---|---|---|---|---|---|---|
M_SP_NA_1 | 11 | 100 | IEC870_GRP_INRO1 | 0 | MAP_AREA_MEMORY | 100 | 0 | 16#00BECF01 |
M_SP_TB_1 | 11 | 101 | IEC870_GRP_INRO1 | 0 | MAP_AREA_MEMORY | 101 | 0 | 16#00BECF11 |
M_DP_NA_1 | 11 | 200 | IEC870_GRP_INROGEN | 0 | MAP_AREA_DATA | 200 | 0 | 16#00BECF02 |
M_IT_NA_1 | 11 | 800 | IEC870_GRP_REQCOGEN | 0 | MAP_AREA_MEMORY | 800 | 0 | 16#00BECF03 |
VAR_GLOBAL CONSTANT
MAX_TABLE_IDX : INT := 49;
END_VAR
PROGRAM P_iecAddTableEntry
VAR_IN_OUT
hTable : T_HAODBTable;
AODB : ARRAY[1..MAX_TABLE_IDX] OF ST_IEC870_5_101AODBEntry;
END_VAR
VAR
bAdd : BOOL := TRUE;
nError : UDINT;
END_VAR
IF bAdd THEN
bAdd := FALSE;
IF ( nError := F_iecCreateTableHnd( ADR( AODB ), SIZEOF( AODB ), hTable )) <> 0 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecCreateTableHnd() error: %s',
DWORD_TO_HEXSTR( nError, 8, FALSE ) );
RETURN;
END_IF
IF ( nError := F_iecAddTableEntry( eType := M_SP_NA_1,
asduAddr := 11,
objAddr := 100,
group := IEC870_GRP_INRO1,
multiplier := 0,
ioMapType := MAP_AREA_MEMORY,
byteOffs := 100,
bitOffs := 0,
hUser := 16#00BECF01,
hTable := hTable ) ) <> 0 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecAddTableEntry() error: %s',
DWORD_TO_HEXSTR( nError, 8, FALSE ) );
END_IF
IF ( nError := F_iecAddTableEntry( eType := M_SP_TB_1,
asduAddr := 11,
objAddr := 101,
group := IEC870_GRP_INRO1,
multiplier := 0,
ioMapType := MAP_AREA_MEMORY,
byteOffs := 101,
bitOffs := 0,
hUser := 16#00BECF11,
hTable := hTable ) ) <> 0 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecAddTableEntry() error: %s',
DWORD_TO_HEXSTR( nError, 8, FALSE ) );
END_IF
IF ( nError := F_iecAddTableEntry( eType := M_DP_NA_1,
asduAddr := 11,
objAddr := 200,
group := IEC870_GRP_INROGEN,
multiplier := 0,
ioMapType := MAP_AREA_DATA,
byteOffs := 200,
bitOffs := 0,
hUser := 16#00BECF02,
hTable := hTable ) ) <> 0 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecAddTableEntry() error: %s',
DWORD_TO_HEXSTR( nError, 8, FALSE ) );
END_IF
IF ( nError := F_iecAddTableEntry( eType := M_IT_NA_1,
asduAddr := 11,
objAddr := 800,
group := IEC870_GRP_REQCOGEN,
multiplier := 0,
ioMapType := MAP_AREA_MEMORY,
byteOffs := 800,
bitOffs := 0,
hUser := 16#00BECF03,
hTable := hTable ) ) <> 0 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG, 'F_iecAddTableEntry() error: %s',
DWORD_TO_HEXSTR( nError, 8, FALSE ) );
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) |