commit 21/11/2024
This commit is contained in:
51
FSM.cs
51
FSM.cs
@@ -4,6 +4,7 @@ using FSM5000FSIAPI.Version3;
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Infrastructure.Interception;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -47,7 +48,6 @@ namespace FAtoPA
|
||||
config.PNA = pna;
|
||||
config.LocalIPAddress = localip;
|
||||
config.RepositoryLocation = ".\\repository";
|
||||
config.AdvancedFSIConfig = new AdvancedFSIConfig();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +82,7 @@ namespace FAtoPA
|
||||
TraceConsoleWritter outputter = new TraceConsoleWritter();
|
||||
controller.SetTraceLevel(SourceLevels.Warning); //for support issues please set the level to SourceLevels.Verbose
|
||||
Result result = controller.Startup(config);
|
||||
//Debug.WriteLine("[FSM] Start result = "+result.ToString());
|
||||
Debug.WriteLine("[FSM] Start result = "+result.ToString());
|
||||
if (result==Result.SUCCESS)
|
||||
{
|
||||
Started = true;
|
||||
@@ -110,7 +110,7 @@ namespace FAtoPA
|
||||
try
|
||||
{
|
||||
Result result = controller.Shutdown();
|
||||
//Console.WriteLine("[FSM] Shutdown result = " + result.ToString());
|
||||
Debug.WriteLine("[FSM] Shutdown result = " + result.ToString());
|
||||
if (_event!=null) _event.ConnectStatus(false, "FSM Stopped");
|
||||
} catch (Exception e)
|
||||
{
|
||||
@@ -149,12 +149,16 @@ namespace FAtoPA
|
||||
/// <param name="devItemType"></param>
|
||||
public void SetItemType(ItemType devItemType)
|
||||
{
|
||||
Debug.WriteLine($"Item type {devItemType.FunctionalType} ({devItemType.Description})");
|
||||
//Debug.WriteLine($"Item type {devItemType.FunctionalType} ({devItemType.Description})");
|
||||
if (type_dictionary != null)
|
||||
{
|
||||
int type = int.Parse(devItemType.FunctionalType.ToString());
|
||||
if (!type_dictionary.ContainsKey(type)) type_dictionary.Add(type, devItemType.Description);
|
||||
|
||||
if (!type_dictionary.ContainsKey(type))
|
||||
{
|
||||
Debug.WriteLine($"Adding key={type}, value={devItemType.Description} to type_dictionary");
|
||||
type_dictionary.Add(type, devItemType.Description);
|
||||
}
|
||||
else Debug.WriteLine($"type_dictionary already have key={type}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -178,12 +182,14 @@ namespace FAtoPA
|
||||
nodeData.Label = devItem.Label;
|
||||
nodeData.Description = type_dictionary.ContainsKey(type) ? type_dictionary[type] : "Unknown";
|
||||
node_data.Add(SIID, nodeData);
|
||||
Debug.WriteLine($"Adding SIID={nodeData.SIID} Label={nodeData.Label} Description={nodeData.Description} to node_data");
|
||||
// notify all listeners
|
||||
if (listeners != null)
|
||||
foreach (var item in listeners)
|
||||
if (listeners != null)
|
||||
foreach (var item in listeners)
|
||||
item.DiscoveredSIID(SIID, nodeData);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else Debug.WriteLine($"node_data already have SIID={SIID}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -235,22 +241,23 @@ namespace FAtoPA
|
||||
{
|
||||
NodeState prev = nd.State;
|
||||
nd.State = new NodeState(devItemState);
|
||||
//if (prev != null)
|
||||
//{
|
||||
// Debug.WriteLine($"SIID={SIID} Change LogicalState from {prev.LogicalState} to {nd.State.LogicalState}");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Debug.WriteLine($"SIID={SIID} New LogicalState {nd.State.LogicalState}");
|
||||
//}
|
||||
|
||||
// notify all listeners
|
||||
if (listeners != null)
|
||||
foreach (var item in listeners)
|
||||
item.NewState(SIID, prev, nd.State);
|
||||
|
||||
if (prev != null)
|
||||
{
|
||||
Debug.WriteLine("SIID=" + SIID + " Change LogicalState from " + prev.LogicalState + " to " + nd.State.LogicalState);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("New State for SIID=" + SIID + " LogicalState=" + nd.State.LogicalState);
|
||||
}
|
||||
} else Debug.WriteLine("NodeData with SIID " + SIID + " is null");
|
||||
} else Debug.WriteLine("node_data doesn't contain SIID " + SIID);
|
||||
|
||||
} else Debug.WriteLine($"NodeData with SIID {SIID} is null");
|
||||
} else Debug.WriteLine($"node_data doesn't contain SIID {SIID}");
|
||||
|
||||
} else Debug.WriteLine("node_data is null");
|
||||
|
||||
@@ -263,7 +270,7 @@ namespace FAtoPA
|
||||
/// <param name="mpNetTime"></param>
|
||||
public void SetMPNetTime(DateTime mpNetTime)
|
||||
{
|
||||
Debug.WriteLine("Time is " + mpNetTime + ".");
|
||||
Debug.WriteLine($"Time is {mpNetTime}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +283,7 @@ namespace FAtoPA
|
||||
{
|
||||
public override void Write(string message)
|
||||
{
|
||||
if (message!=null && message.Length>0) Debug.Write(message);
|
||||
if (message!=null && message.Length>0) Debug.WriteLine(message);
|
||||
}
|
||||
|
||||
public override void WriteLine(string message)
|
||||
|
||||
Reference in New Issue
Block a user