+ Added new alarm id and data
+ Added new library version (30) with pre and post power on data * Refactor
This commit is contained in:
Binary file not shown.
@@ -10,8 +10,6 @@ namespace Step.Database.Migrations
|
||||
|
||||
public sealed class Configuration : DbMigrationsConfiguration<DatabaseContext>
|
||||
{
|
||||
private readonly bool _pendingMigrations;
|
||||
|
||||
public Configuration()
|
||||
{
|
||||
AutomaticMigrationsEnabled = true;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Step.Model.DTOModels
|
||||
public DTOAlarmsModel IntersectModels(DTOAlarmsModel newAlarms)
|
||||
{
|
||||
DTOAlarmsModel result = new DTOAlarmsModel();
|
||||
// Get common data
|
||||
// Get common data from Obj1 and Obj2
|
||||
result.NcAlarms = NcAlarms.Where(x => newAlarms.NcAlarms.Contains(x as GenericAlarmModel)).ToList();
|
||||
// Concat common data + new data
|
||||
result.NcAlarms = result.NcAlarms.Concat(
|
||||
@@ -82,7 +82,9 @@ namespace Step.Model.DTOModels
|
||||
|
||||
public class GenericAlarmModel
|
||||
{
|
||||
public string alarmMessage;
|
||||
public uint id;
|
||||
public string message;
|
||||
public bool isWarning;
|
||||
public DateTime dateTime;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -92,7 +94,7 @@ namespace Step.Model.DTOModels
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
if (item.alarmMessage == alarmMessage)
|
||||
if (item.id == id)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -101,8 +103,10 @@ namespace Step.Model.DTOModels
|
||||
|
||||
public class ProcessAlarmModel
|
||||
{
|
||||
public string alarmMessage;
|
||||
public ushort process;
|
||||
public uint id;
|
||||
public string message;
|
||||
public int process;
|
||||
public bool isWarning;
|
||||
public DateTime dateTime;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -112,40 +116,10 @@ namespace Step.Model.DTOModels
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
if (item.process == process && item.alarmMessage == alarmMessage )
|
||||
if (item.process == process && item.id == id )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
class DTOAlarmsModelComparer : IEqualityComparer<DTOAlarmsModel>
|
||||
{
|
||||
public bool Equals(DTOAlarmsModel x, DTOAlarmsModel y)
|
||||
{
|
||||
if (x == null)
|
||||
return false;
|
||||
|
||||
if (x.NcAlarms.Count != y.NcAlarms.Count || x.PlcAlarms.Count != y.PlcAlarms.Count || x.ProcessAlarms.Count != y.ProcessAlarms.Count)
|
||||
return false;
|
||||
|
||||
bool isEqual = x.NcAlarms.All(y.NcAlarms.Contains);
|
||||
if (!isEqual)
|
||||
return false;
|
||||
|
||||
isEqual = x.PlcAlarms.All(y.PlcAlarms.Contains);
|
||||
if (!isEqual)
|
||||
return false;
|
||||
|
||||
isEqual = x.ProcessAlarms.All(y.ProcessAlarms.Contains);
|
||||
if (!isEqual)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode(DTOAlarmsModel obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Model.DTOModels
|
||||
{
|
||||
public class DTOPowerOnData
|
||||
{
|
||||
public PrePowerOnModel prePowerOn;
|
||||
|
||||
public DTOPowerOnData()
|
||||
{
|
||||
prePowerOn = new PrePowerOnModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,6 @@
|
||||
<LastGenOutput>DTOLanguageModel.cs.d.ts</LastGenOutput>
|
||||
</Compile>
|
||||
<Compile Include="DTOModels\DTONcGenericDataModel.cs" />
|
||||
<Compile Include="DTOModels\DTOPowerOnData.cs" />
|
||||
<Compile Include="DTOModels\DTORoleModel.cs" />
|
||||
<Compile Include="DTOModels\DTOStartupConfigurationModel.cs" />
|
||||
<Compile Include="DTOModels\DTOUserModel.cs" />
|
||||
|
||||
+19
-14
@@ -115,7 +115,7 @@ namespace Step.NC
|
||||
public CmsError GetNcAlarms(out DTOAlarmsModel alarms)
|
||||
{
|
||||
alarms = new DTOAlarmsModel();
|
||||
List<string> tmpAlarms = new List<string>();
|
||||
List<AlarmModel> tmpAlarms = new List<AlarmModel>();
|
||||
|
||||
// Read NC active alarms
|
||||
CmsError cmsError = numericalControl.NC_RActiveAlarms(ref tmpAlarms);
|
||||
@@ -123,11 +123,13 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
|
||||
// Create response list from strings
|
||||
foreach (string alarmMessage in tmpAlarms)
|
||||
foreach (AlarmModel ncAlarm in tmpAlarms)
|
||||
{
|
||||
alarms.NcAlarms.Add(new GenericAlarmModel()
|
||||
{
|
||||
alarmMessage = alarmMessage,
|
||||
id = ncAlarm.id,
|
||||
message = ncAlarm.message,
|
||||
isWarning = ncAlarm.isWarning,
|
||||
dateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
@@ -144,12 +146,14 @@ namespace Step.NC
|
||||
// Get process active alarms
|
||||
numericalControl.PROC_RActiveAlarms(i, ref tmpAlarms);
|
||||
// Create response list from strings
|
||||
foreach (string alarmMessage in tmpAlarms)
|
||||
foreach (AlarmModel processAlarm in tmpAlarms)
|
||||
{
|
||||
alarms.ProcessAlarms.Add(new ProcessAlarmModel()
|
||||
{
|
||||
alarmMessage = alarmMessage,
|
||||
process = i,
|
||||
id = processAlarm.id,
|
||||
message = processAlarm.message,
|
||||
process = processAlarm.process,
|
||||
isWarning = processAlarm.isWarning,
|
||||
dateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
@@ -160,12 +164,14 @@ namespace Step.NC
|
||||
if (cmsError.errorCode != 0)
|
||||
return cmsError;
|
||||
|
||||
// Formatting response list from strings
|
||||
foreach (string alarmMessage in tmpAlarms)
|
||||
// Formatting response list from library alarm model
|
||||
foreach (AlarmModel plcAlarm in tmpAlarms)
|
||||
{
|
||||
alarms.PlcAlarms.Add(new GenericAlarmModel()
|
||||
alarms.NcAlarms.Add(new GenericAlarmModel()
|
||||
{
|
||||
alarmMessage = alarmMessage,
|
||||
id = plcAlarm.id,
|
||||
message = plcAlarm.message,
|
||||
isWarning = plcAlarm.isWarning,
|
||||
dateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
@@ -199,7 +205,6 @@ namespace Step.NC
|
||||
|
||||
public CmsError GetAxesPositionsByProcess(ushort processNum, out DTOAxesModel axes)
|
||||
{
|
||||
|
||||
axes = new DTOAxesModel();
|
||||
|
||||
CmsError cmsError = numericalControl.AXES_RInterpPosition(processNum, ref axes.interpolated);
|
||||
@@ -223,10 +228,10 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public CmsError GetPowerOnData(out DTOPowerOnData powerOnData)
|
||||
public CmsError GetPowerOnData(out PreAndPostPowerOnModel powerOnData)
|
||||
{
|
||||
powerOnData = new DTOPowerOnData();
|
||||
CmsError cmsError = numericalControl.Nc_RWPrePowerOnFunctions(R, ref powerOnData.prePowerOn);
|
||||
powerOnData = new PreAndPostPowerOnModel();
|
||||
CmsError cmsError = numericalControl.Nc_RPowerOnData(ref powerOnData);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,9 @@ public static class ThreadsFunctions
|
||||
libraryError = ncHandler.GetNcAlarms(out DTOAlarmsModel alarms);
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_ALARMS, null, alarms);
|
||||
else
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_ALARMS, null, alarms);
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
@@ -121,8 +122,9 @@ public static class ThreadsFunctions
|
||||
libraryError = ncHandler.GetAxesPositions(out List<DTOAxesModel> genericData);
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_AXES, null, genericData);
|
||||
else
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_AXES, null, genericData);
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
@@ -157,11 +159,12 @@ public static class ThreadsFunctions
|
||||
if (ncHandler.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// Get Data from NC
|
||||
libraryError = ncHandler.GetPowerOnData(out DTOPowerOnData powerOnData);
|
||||
libraryError = ncHandler.GetPowerOnData(out PreAndPostPowerOnModel powerOnData);
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_POWER_ON_DATA, null, powerOnData);
|
||||
else
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_POWER_ON_DATA, null, powerOnData);
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
@@ -205,7 +208,7 @@ public static class ThreadsFunctions
|
||||
Thread.Sleep(1000);
|
||||
|
||||
// Send status to UI
|
||||
MessageServices.Current.Publish(MVVM_NC_STATUS, null, ncHandler.numericalControl.NC_IsConnected());
|
||||
MessageServices.Current.Publish(SEND_NC_STATUS, null, ncHandler.numericalControl.NC_IsConnected());
|
||||
}
|
||||
// Start/Restart NC threads
|
||||
ThreadsHandler.StartWorkers();
|
||||
@@ -292,7 +295,7 @@ public static class ThreadsFunctions
|
||||
ReadPowerOnTimes = 0;
|
||||
}
|
||||
|
||||
MessageServices.Current.Publish(MVVM_NC_THREADS, null, ThreadsHandler.RunningThreadStatus);
|
||||
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
|
||||
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Step.Core
|
||||
};
|
||||
private volatile static List<Thread> RunningThreadsList = new List<Thread>();
|
||||
internal volatile static Dictionary<String, String> RunningThreadStatus = new Dictionary<String, String>();
|
||||
private static Thread StatThread;
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
@@ -38,8 +37,8 @@ namespace Step.Core
|
||||
|
||||
public static void StartWorkers()
|
||||
{
|
||||
lock (RunningThreadStatus)
|
||||
RunningThreadStatus.Clear();
|
||||
|
||||
RunningThreadStatus.Clear();
|
||||
|
||||
// For each function run in the list a thread
|
||||
ThreadFunctionsList.ForEach(threadFunction =>
|
||||
@@ -53,12 +52,11 @@ namespace Step.Core
|
||||
lock (RunningThreadsList)
|
||||
RunningThreadsList.Add(t);
|
||||
|
||||
lock (RunningThreadStatus)
|
||||
if (!RunningThreadStatus.ContainsKey(threadFunction.Method.Name))
|
||||
RunningThreadStatus.Add(threadFunction.Method.Name, "---");
|
||||
|
||||
RunningThreadStatus.Add(threadFunction.Method.Name, "---");
|
||||
});
|
||||
|
||||
MessageServices.Current.Publish(MVVM_NC_THREADS, null, RunningThreadStatus);
|
||||
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, RunningThreadStatus);
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
@@ -75,12 +73,9 @@ namespace Step.Core
|
||||
lock (RunningThreadsList)
|
||||
RunningThreadsList.Clear();
|
||||
|
||||
lock (RunningThreadStatus)
|
||||
{
|
||||
RunningThreadStatus.Clear();
|
||||
RunningThreadStatus.Add("TryNcConnection", "---");
|
||||
}
|
||||
MessageServices.Current.Publish(MVVM_NC_THREADS, null, RunningThreadStatus);
|
||||
RunningThreadStatus.Clear();
|
||||
RunningThreadStatus.Add("TryNcConnection", "---");
|
||||
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, RunningThreadStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Step.UI
|
||||
private void StopServerButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Send message to listeners and close server
|
||||
MessageServices.Current.Publish(MVVM_STOP_SERVER);
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
}
|
||||
|
||||
private void NotifyIcon_Click(object sender, EventArgs e)
|
||||
@@ -123,7 +123,7 @@ namespace Step.UI
|
||||
|
||||
private void InitializeMessageListeners()
|
||||
{
|
||||
MessageServices.Current.Subscribe(MVVM_SEND_MESSAGE, (a, b) =>
|
||||
MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
|
||||
{
|
||||
// Cast object to ErrorMessageModel
|
||||
ErrorMessageModel message = (ErrorMessageModel)a;
|
||||
@@ -133,7 +133,7 @@ namespace Step.UI
|
||||
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel);
|
||||
});
|
||||
|
||||
MessageServices.Current.Subscribe(MVVM_NC_STATUS, (a, b) =>
|
||||
MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
|
||||
{
|
||||
bool newNcStatus = (bool)a;
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Step.UI
|
||||
|
||||
});
|
||||
|
||||
MessageServices.Current.Subscribe(MVVM_NC_THREADS, (a, b) =>
|
||||
MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
|
||||
{
|
||||
//Other type
|
||||
this.Invoke((MethodInvoker)delegate () {
|
||||
|
||||
@@ -61,13 +61,13 @@ namespace Step.Utils
|
||||
public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\";
|
||||
public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
|
||||
|
||||
// MVVM Messages names
|
||||
public const string MVVM_STOP_SERVER = "STOP_SERVER";
|
||||
public const string MVVM_SEND_MESSAGE = "SEND_MESSAGE";
|
||||
public const string MVVM_NC_STATUS = "NC_STATUS";
|
||||
public const string MVVM_NC_THREADS = "THREAD_STATUS";
|
||||
// MVVM Messages to server UI
|
||||
public const string SEND_STOP_SERVER = "STOP_SERVER";
|
||||
public const string SEND_MESSAGE = "SEND_MESSAGE";
|
||||
public const string SEND_NC_STATUS = "NC_STATUS";
|
||||
public const string SEND_THREADS_STATUS = "THREAD_STATUS";
|
||||
|
||||
// MVVM Messages tasks names
|
||||
// MVVM Messages to signalR tasks
|
||||
public const string SEND_ALARMS = "SEND_ALARMS";
|
||||
public const string SEND_POWER_ON_DATA = "SEND_POWER_ON_DATA";
|
||||
public const string SEND_GENERIC_DATA = "SEND_GENERIC_DATA";
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Step.Utils
|
||||
else
|
||||
{
|
||||
// Notify user
|
||||
MessageServices.Current.Publish(MVVM_SEND_MESSAGE, null, error);
|
||||
MessageServices.Current.Publish(SEND_MESSAGE, null, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ namespace Step
|
||||
string configuredUri = "http://*:" + ServerStartupConfig.ServerPort.ToString();
|
||||
|
||||
// Register listener to "close application" messages
|
||||
MessageServices.Current.Subscribe(MVVM_STOP_SERVER, (a, b) =>
|
||||
MessageServices.Current.Subscribe(SEND_STOP_SERVER, (a, b) =>
|
||||
{
|
||||
StopRequest.Set();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user