MockGenesis: - bit mask reset

This commit is contained in:
Thomas Wiedebusch
2025-07-11 11:14:27 +02:00
parent eaff7b7230
commit 552a5e510b
2 changed files with 65 additions and 41 deletions
@@ -716,47 +716,52 @@
},
"statictype": "dynamic"
},
{
"type": "uint32_t",
"privilege": {
"lvl1": "RO",
"lvl2": "RO",
"lvl3": "RW",
"lvl4": "RO",
"lvl5": "RW",
"lvl6": "RW",
"lvl7": "RW",
"lvl8": "RW"
{
"type": "uint32_t",
"privilege": {
"lvl1": "RO",
"lvl2": "RO",
"lvl3": "RW",
"lvl4": "RO",
"lvl5": "RW",
"lvl6": "RW",
"lvl7": "RW",
"lvl8": "RW"
},
"description": "Any set bits manually clear the corresponding alarm.",
"version": {
"first": 111,
"last": 164
},
"values": {
"default": 4294967295,
"minimum": 0,
"maximum": 4294967295
},
"statictype": "dynamic",
"production": {
"required": true,
"kitron": false,
"csd": null,
"vako": false,
"operation_calibration": true,
"runtime_ignore": false,
"responsible": [],
"remarks": "Cancel all alarms at the end of production.",
"region": {
"emea": {
"values": {
"default": 4294967295
}
},
"description": "Any set bits manually clear the corresponding alarm.",
"version": {
"first": 111,
"last": 164
},
"statictype": "dynamic",
"production": {
"required": true,
"kitron": false,
"csd": null,
"vako": false,
"operation_calibration": true,
"runtime_ignore": false,
"responsible": [],
"remarks": "Cancel all alarms at the end of production.",
"region": {
"emea": {
"values": {
"default": 4294967295
}
},
"na": {
"values": {
"default": 4294967295
}
}
}
"na": {
"values": {
"default": 4294967295
}
}
}
}
}
]
},
"AlarmStatus2": {
@@ -876,16 +876,35 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.MockGenesis
/// <remarks date="2025-Jul-11" author="Thomas Wiedebusch">
/// - Simulation of reset bits.
/// </remarks>
private static void CheckAndModifySpecialReplies(String regName, Byte[] data)
private void CheckAndModifySpecialReplies(String regName, Byte[] data)
{
// Reset a bit mask
if (SpecialRegisterResetBits.Any(n => regName.Contains(n.RegisterIdent)))
{
for ( var c = 0 ; c < data.Length; c++)
var readValue = ReadRegister(regName);
if (readValue != null)
{
data[c] ^= data[c];
for (var c = 0; c < data.Length; c++)
{
if (c < readValue.Length)
{
data[c] = (Byte)(readValue[c] & (Byte)~data[c]);
}
else
{
data[c] = 0;
}
}
}
else
{
for (var c = 0; c < data.Length; c++)
{
data[c] = 0x00;
}
}
}
// Input value forces a constant reply if the input matches
if (SpecialRegisterReplies.Any(n => regName.Contains(n.RegisterIdent)))
{