ControllerConfigUtil.UpdateDataRecord (METH)ΒΆ
METHOD UpdateDataRecord : ConfigError
Update the value of a data record parameter of a submodule.
By using this method together with GetDataRecord(), the settings / parameters of a module or device can be updated at the runtime of an application.
The device first has to be deactivated (DED.Reconfigure function block), then update the setting and re-activate it again. The updated parameters will be used, when the new connection is established.
Example: Reconfigure a single slave
PROGRAM PLC_PRG
VAR
util : IoDrvProfinetBase.ControllerConfigUtil;
moduleID : UDINT;
error : IoDrvProfinetBase.ConfigError;
byteData : ProfinetCommon.ProfinetByteData;
buffer : ARRAY[0..15] OF BYTE;
recordLen : UDINT;
anyValue : UDINT;
reconf : DED.Reconfigure;
enabled : BOOL;
END_VAR
//read a data item of type Unsigned32 from one of the submodule's record data parameters (each has an unique INDEX):
moduleID := IoDrvProfinetBase.GetID(Module_with_Parameters); // here we access the module directly by the device object's name
error := util.GetDataRecord(ID := moduleID, INDEX := 10 , MLEN := SIZEOF(buffer), RECORD := ADR(buffer), LEN => recordLen); // read the complete data record
//read a specific value item from the data record paramter;
byteData.InitData(ADR(buffer), SIZEOF(buffer));
anyValue := byteData.GetUnsigned32(2); //within the data record, the value is at offset 2.
//update the value - only possible while device is disabled (see below)
byteData.PutUnsigned32(2, 2000);
error := util.UpdateDataRecord(ID := moduleID, INDEX := 10 , LEN := recordLen, RECORD := ADR(buffer));
//enable / disable device which is parent of this module
pn_device.Enable := enabled;
reconf(itfNode := pn_device); //start reconfigure (set xExecute := TRUE) to enable / disable PROFINET device that owns this module
- InOut:
Scope
Name
Type
Comment
Return
UpdateDataRecordInput
IDDWORDID of the submodule that is owner of the data record
INDEXUINTIndex of the data record
LENUDINTLength to write
RECORDPOINTER TO BYTE
Data record