Write
This method creates a record in the standard table structure specified by Beckhoff.
Syntax
METHOD Write : BOOL
VAR_INPUT
hDBID: UDINT;
sTableName: T_MaxString;
pValue: POINTER TO BYTE;
cbValue: UDINT;
sDBSymbolName: T_MaxString;
eDBWriteMode: E_WriteMode := E_WriteMode.eADS_TO_DB_Append;
nRingBuffParameter: UDINT;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
hDBID | UDINT | Indicates the ID of the database to be used. |
sTableName | T_MaxString | Name of the table that is to be read. |
pValue | POINTER TO BYTE | Address of the variable to be logged in the standard table structure. |
cbValue | UDINT | Length of the variable to be logged. |
sDBSymbolName | T_MaxString | Name that is logged in the table. |
eDBWriteMode | E_WriteMode | Indicates the write mode. (append, update, ring buffer) |
nRingBuffParameter | UDINT | Additional parameter(s) for the "ring buffer" write mode. |
Return value
Name | Type | Description |
---|---|---|
Write | BOOL | Displays the status of the method. Returns TRUE as soon as the method execution is finished, even in the event of an error. |
Sample
This sample shows how to use the FB_PLCDBWriteEvt.Write method:
VAR
fbPLCDBWrite : FB_PLCDBWriteEvt(sNetID := '', tTimeout := T#5S);
myValue : LREAL := 43.23;
tcMessage : I_TcMessage;
END_VAR
IF fbPLCDBWrite.Write(
hDBID:= 1,
sTableName:= 'myTable_WithLReal',
pValue:= ADR(myValue),
cbValue:= SIZEOF(myValue),
sDBSymbolName:= 'MyValue',
eDBWriteMode:= E_WriteMode.eADS_TO_DB_RingBuff_Count,
nRingBuffParameter:= 3)
THEN
IF fbPLCDBWrite.bError THEN
tcMessage := fbPLCDBWrite.ipTcResult;
nState := 255;
ELSE
nState := 0;
END_IF
END_IF
Result in the database:
ID | Timestamp | Name | Value |
---|---|---|---|
27 | Has been dropped | ||
28 | '2018-01-30 14:04:19' | 'MyValue' | 41.23 |
29 | '2018-01-30 14:04:29' | 'MyValue' | 42.23 |
30 | '2018-01-30 14:04:39' | 'MyValue' | 43.23 |
With the ring buffer option, only three entries of this name are in the database at any one time. Older entries are deleted.