Add try Catch over SystemControl write function

This commit is contained in:
atef 2023-07-13 09:50:40 +02:00
parent df0983e97e
commit dafef572ab
1 changed files with 11 additions and 11 deletions

View File

@ -17,7 +17,7 @@ public class TruConvertAcDcDevices
public TruConvertAcDcDevices(Channel transport)
{
var modbusClient = new ModbusTcpClient(transport, 0);
var modbusClient = new ModbusTcpClient(transport, slaveId: 0);
_SystemControl = new ModbusDevice<SystemControlRegisters>(modbusClient);
@ -56,22 +56,22 @@ public class TruConvertAcDcDevices
}
public void Write(AcDcDevicesRecord r)
{
try
{
if (r.SystemControl is not null)
_SystemControl.Write(r.SystemControl); // must run BEFORE the attached devices
foreach (var (ctrl, device) in r.Devices.Zip(_AcDcs))
{
try
{
device.Write(ctrl);
}
}
catch (Exception e)
{
Console.WriteLine(e);
// TODO: log
}
}
}
}