Add try Catch over SystemControl write function
This commit is contained in:
parent
df0983e97e
commit
dafef572ab
|
@ -17,7 +17,7 @@ public class TruConvertAcDcDevices
|
||||||
|
|
||||||
public TruConvertAcDcDevices(Channel transport)
|
public TruConvertAcDcDevices(Channel transport)
|
||||||
{
|
{
|
||||||
var modbusClient = new ModbusTcpClient(transport, 0);
|
var modbusClient = new ModbusTcpClient(transport, slaveId: 0);
|
||||||
|
|
||||||
_SystemControl = new ModbusDevice<SystemControlRegisters>(modbusClient);
|
_SystemControl = new ModbusDevice<SystemControlRegisters>(modbusClient);
|
||||||
|
|
||||||
|
@ -57,20 +57,20 @@ public class TruConvertAcDcDevices
|
||||||
|
|
||||||
public void Write(AcDcDevicesRecord r)
|
public void Write(AcDcDevicesRecord r)
|
||||||
{
|
{
|
||||||
if (r.SystemControl is not null)
|
try
|
||||||
_SystemControl.Write(r.SystemControl); // must run BEFORE the attached devices
|
|
||||||
|
|
||||||
foreach (var (ctrl, device) in r.Devices.Zip(_AcDcs))
|
|
||||||
{
|
{
|
||||||
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))
|
||||||
{
|
{
|
||||||
device.Write(ctrl);
|
device.Write(ctrl);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
Console.WriteLine(e);
|
{
|
||||||
// TODO: log
|
Console.WriteLine(e);
|
||||||
}
|
// TODO: log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue