ControllerConfigUtil (FB)

FUNCTION_BLOCK ControllerConfigUtil

This function block can be used to adapt some parameters of the initially downloaded profinet controller config-structure (device tree).

For example this way the IP-adresses of the slaves that are configured for this controller can be adapted at runtime.

The FB is typically used with the Reconfigure-feature (see DED.Reconfigure function block).

Example: Reconfigure a single slave

PROGRAM PLC_PRG
VAR
    ip : ProfinetCommon.IPParameterValue := (IPAddress := [192, 168, 0, 2], Subnetmask := [255, 255, 255, 0]);

    i : DINT;
    enable : BOOL := FALSE;
    moduleDevice : DED.IDevice;
    reconf : DED.Reconfigure;

    configUtil : IoDrvProfinetBase.ControllerConfigUtil;
    updateIP : IoDrvProfinetBase.ConfigError;
END_VAR

//note: pn_device is some (initially disabled) profinet slave in the device-tree of the application
IF(enable AND NOT pn_device.Enable) THEN
    updateIP := configUtil.UpdateIPSettings(pn_device, ip);         // change configured ip-address

    //enable device and modules
    pn_device.Enable := enable;
    FOR i := 0 TO TO_DINT(pn_device.ChildNodeCount) - 1 DO
        moduleDevice := INode_To_IDevice(pn_device.GetChild(TO_UDINT(i)));
        configUtil.UpdateSlotNumber(moduleDevice, TO_UINT(i + 1));  // change configured slot number
        moduleDevice.Enable := enable;
    END_FOR

    reconf.xExecute := TRUE;
END_IF

reconf(itfNode := pn_device);         //start reconfigure