diff --git a/csharp/Lib/Protocols/Modbus/Reflection/Batch.cs b/csharp/Lib/Protocols/Modbus/Reflection/Batch.cs index 21542ba89..15be8c7d0 100644 --- a/csharp/Lib/Protocols/Modbus/Reflection/Batch.cs +++ b/csharp/Lib/Protocols/Modbus/Reflection/Batch.cs @@ -8,7 +8,10 @@ namespace InnovEnergy.Lib.Protocols.Modbus.Reflection; #pragma warning disable CS8509 #pragma warning disable CS8524 -internal record Batch(Action Read, Action Write); +internal record Batch(Action Read, Action Write, String DebugString) +{ + public override String ToString() => DebugString; +} public static class Batches { @@ -60,10 +63,16 @@ public static class Batches var count = (UInt16)(endAddress - startAddress); var kind = members[0].Kind; var isWritable = kind is ModbusKind.HoldingRegister or ModbusKind.Coil; - - return new Batch(Read(), Write()); + var debugString = $"{kind}: {startAddress}" + (endAddress - 1 == startAddress ? "" : $"-{endAddress - 1}"); - Action Read() + + // var modPoll = $"{kind}: {startAddress}-{endAddress}"; // TODO + var read = MakeRead(); + var write = MakeWrite(); + + return new Batch(read, write, debugString); + + Action MakeRead() { Func readModbus = kind switch { @@ -85,7 +94,7 @@ public static class Batches }; } - Action Write() + Action MakeWrite() { if (!isWritable) return _ => { }; // nop