38 lines
871 B
C#
38 lines
871 B
C#
using InnovEnergy.Lib.Devices.Amax5070;
|
|
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
|
using InnovEnergy.Lib.Utils;
|
|
|
|
namespace InnovEnergy.App.DeligreenBatteryCommunication;
|
|
|
|
public class RelaysDeviceAmax
|
|
{
|
|
private Amax5070Device AmaxDevice { get; }
|
|
|
|
public RelaysDeviceAmax(Channel channel) => AmaxDevice = new Amax5070Device(channel);
|
|
|
|
public RelaysRecordAmax? Read()
|
|
{
|
|
|
|
try
|
|
{
|
|
return AmaxDevice.Read();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
$"Failed to read from {nameof(RelaysDeviceAmax)}\n{e}".WriteLine();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void Write(RelaysRecordAmax r)
|
|
{
|
|
try
|
|
{
|
|
AmaxDevice.Write(r);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
$"Failed to write to {nameof(RelaysDeviceAmax)}\n{e}".WriteLine();
|
|
}
|
|
}
|
|
} |