When you want to use source properties to change the IP address or unit ID of equipment at run time, use the [Equipment] operation to commit the change.
saveEquipment(EQUIPMENT);
1
1: Equipment
You can use a single equipment block to save both the IP address and unit ID. Success or failure of each operation is recorded in the operation log.
The following example shows how you can change the IP address for equipment in the project.
The equipment’s current IP address is 192.168.0.1.
onClick($GraphicObject.Switch1, ()=>{
$Device.ModbusTCPDriver1.SchneiderModbusTCPIPEquipment1.IPAddress.OverwriteValue = address('192.168.0.2');
saveEquipment($Device.ModbusTCPDriver1.SchneiderModbusTCPIPEquipment1);
});
Run the script to:
Set a new IP address (192.168.0.2) to IPAddress.OverwriteValue.
Run the [Equipment] operation.
Equipment1.IPAddress.CurrentValue (192.168.0.2) is now equal to Equipment1.IPAddress.OverwriteValue (192.168.0.2).
You can use 32-bit data (Int) to change the IP address value. The IP address value is changed as shown in the figure below. In 32-bit data, each octet in the IP address is saved in 8-bit units.
You need to execute the [Equipment] operation to update the equipment IP address and unit ID.