refactored RTU response event to offload message processing to a single function

This commit is contained in:
nikzori
2024-12-12 15:14:13 +03:00
parent 4ee185b333
commit 330d943b5d
5 changed files with 372 additions and 224 deletions

21
Json.cs
View File

@@ -13,11 +13,12 @@ namespace Gidrolock_Modbus_Scanner
public string name;
public string description;
public List<Entry> entries;
public Device(string name, string description, List<Entry> entries)
public CheckEntry checkEntry;
public Device(string name, string description, CheckEntry checkEntry, List<Entry> entries)
{
this.name = name;
this.description = description;
this.checkEntry = checkEntry;
this.entries = entries;
}
}
@@ -40,5 +41,21 @@ namespace Gidrolock_Modbus_Scanner
this.readOnce = readOnce;
}
}
public struct CheckEntry
{
public RegisterType registerType;
public ushort address;
public ushort length;
public string dataType;
public string expectedValue;
public CheckEntry(RegisterType registerType, ushort address, ushort length, string dataType, string expectedValue)
{
this.registerType = registerType;
this.address = address;
this.length = length;
this.dataType = dataType;
this.expectedValue = expectedValue;
}
}
public enum RegisterType { Coil = 1, Discrete = 2, Holding = 3, Input = 4}
}