Update Amax register and put coils as writable as default.

new function to clear buffers.
Add old K2 variable as Tschireen have problem with Relay 23. Now its relay 22
This commit is contained in:
atef 2026-02-13 09:31:39 +01:00
parent 8c2a360ba3
commit bd572b4ed1
5 changed files with 21 additions and 7 deletions

View File

@ -31,6 +31,8 @@ public class CombinedAdamRelaysRecord : IRelaysRecord
set => _recordAdam6360D.K2ConnectIslandBusToGridBus = value;
}
public Boolean OldK2ConnectIslandBusToGridBus { get; set; }
public Boolean Inverter1WagoStatus => _recordAdam6360D.Inverter1WagoStatus;
public Boolean Inverter2WagoStatus => _recordAdam6360D.Inverter2WagoStatus;
public Boolean Inverter3WagoStatus => _recordAdam6360D.Inverter3WagoStatus;

View File

@ -32,8 +32,8 @@ namespace InnovEnergy.Lib.Devices.Amax5070
[Coil(25)] public Boolean Relay20 { get; set; } // Relay5060 2
[Coil(26)] public Boolean Relay21 { get; set; } // Relay5060 2
[Coil(27)] public Boolean Relay22 { get; set; } // Relay5060 2
[Coil(28)] public Boolean Relay23 { get; set; } // Relay5060 2
[Coil(27, writable: true)] public Boolean Relay22 { get; set; }
[Coil(28)] public Boolean Relay23 { get; set; }
[Coil(33)] public Boolean Relay30 { get; set; } // Relay5060 3
[Coil(34)] public Boolean Relay31 { get; set; } // Relay5060 3

View File

@ -15,5 +15,6 @@ namespace InnovEnergy.Lib.Protocols.Modbus.Channels
{
public abstract IReadOnlyList<byte> Read(int nBytes);
public abstract void Write(IReadOnlyList<byte> bytes);
public virtual void ClearBuffers() { }
}
}

View File

@ -4,7 +4,11 @@ namespace InnovEnergy.Lib.Protocols.Modbus.Reflection.Attributes;
public class Coil : ModbusBoolean
{
public Coil(UInt16 address) : base(address, ModbusKind.Coil)
public bool Writable { get; }
public Coil(ushort address, bool writable = true)
: base(address, ModbusKind.Coil)
{
Writable = writable;
}
}

View File

@ -37,7 +37,7 @@ public static class Batches
{
if (CloseBatch(member))
{
//PrintBatchStart(batchMembers);
PrintBatchStart(batchMembers);
yield return MakeBatch<R>(mb, batchMembers);
batchMembers = new List<ModbusMember>();
}
@ -47,7 +47,6 @@ public static class Batches
if (batchMembers.Count > 0)
{
//PrintBatchStart(batchMembers);
yield return MakeBatch<R>(mb, batchMembers);
}
@ -74,9 +73,17 @@ public static class Batches
: $"{first.StartAddress}-{last.EndAddress - 1}";
var writable = first.IsWritable ? "Writable" : "ReadOnly";
Console.WriteLine($"📦 New Batch: {first.Kind} [{range}] ({writable})");
foreach (var member in members)
{
if (member.Kind == ModbusKind.Coil)
{
Console.WriteLine($"👀 Coil: {member.StartAddress}, Name: {member.Member.Name}, Writable: {member.IsWritable}");
}
}
}
private static Batch<R> MakeBatch<R>(ModbusClient modbusClient, IReadOnlyList<ModbusMember> members)
{
var startAddress = members[0].StartAddress;
@ -86,7 +93,7 @@ public static class Batches
//var isWritable = kind is ModbusKind.HoldingRegister or ModbusKind.Coil;
var debugString = $"{kind}: {startAddress}" + (endAddress - 1 == startAddress ? "" : $"-{endAddress - 1}");
var isWritable = members.Any(m => m.IsWritable);
var isWritable = kind == ModbusKind.Coil || members.Any(m => m.IsWritable);
//foreach (var m in members)
// Console.WriteLine($"🧪 Address {m.StartAddress} Writable: {m.IsWritable}");