add translation table from FSM LogicalState to Modbus Register Value

This commit is contained in:
2024-11-25 15:55:47 +07:00
parent 44daa44b6d
commit 5e28088303
6 changed files with 323 additions and 93 deletions

23
FSM.cs
View File

@@ -12,6 +12,9 @@ using System.Threading.Tasks;
namespace FAtoPA
{
/// <summary>
/// Class to handle Fire Alarm System Monitoring
/// </summary>
class FSM
{
public static bool Started = false;
@@ -21,6 +24,11 @@ namespace FAtoPA
public Dictionary<int, String> ItemTypeDictionary { get; }
public Dictionary<String, NodeData> AvailableNodes { get; }
private EventInterface _event;
/// <summary>
/// to count the incoming event, then update at _event;
/// </summary>
public static long eventcounter = 0;
public FSM(EventInterface callback)
{
_event = callback;
@@ -75,6 +83,7 @@ namespace FAtoPA
/// </summary>
public void Start()
{
eventcounter = 0;
controller = FSIController.GetInstance();
// internal Listeners
controller.AddListener(new ConfigListener(ItemTypeDictionary, AvailableNodes, listenerlist));
@@ -150,6 +159,7 @@ namespace FAtoPA
public void SetItemType(ItemType devItemType)
{
//Debug.WriteLine($"Item type {devItemType.FunctionalType} ({devItemType.Description})");
if (type_dictionary != null)
{
int type = int.Parse(devItemType.FunctionalType.ToString());
@@ -160,7 +170,10 @@ namespace FAtoPA
}
else Debug.WriteLine($"type_dictionary already have key={type}");
}
FSM.eventcounter++;
}
/// <summary>
@@ -191,7 +204,8 @@ namespace FAtoPA
}
else Debug.WriteLine($"node_data already have SIID={SIID}");
}
FSM.eventcounter++;
}
/// <summary>
@@ -207,7 +221,8 @@ namespace FAtoPA
if (node_data.ContainsKey(SIID)) node_data.Remove(SIID);
}
FSM.eventcounter++;
}
}
@@ -260,7 +275,8 @@ namespace FAtoPA
} else Debug.WriteLine($"node_data doesn't contain SIID {SIID}");
} else Debug.WriteLine("node_data is null");
FSM.eventcounter++;
}
@@ -271,6 +287,7 @@ namespace FAtoPA
public void SetMPNetTime(DateTime mpNetTime)
{
Debug.WriteLine($"Time is {mpNetTime}");
FSM.eventcounter++;
}
}