diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index b858103c..bacfa06a 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 16eafe95..df221279 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -146,10 +146,19 @@ public static class ThreadsFunctions ManageLibraryError(libraryError); else { - // Send processes through signalR - MessageServices.Current.Publish(SEND_PROCESSES_DATA, null, processesPPData); - // Send ncSoftKeys through signalR - MessageServices.Current.Publish(SEND_NC_SOFTKEYS_DATA, null, ncSoftKeys); + libraryError = ncHandler.GetM155Data(out List m155Data); + if (libraryError.errorCode != 0) + ManageLibraryError(libraryError); + else + { + // Send processes through signalR + MessageServices.Current.Publish(SEND_PROCESSES_DATA, null, processesPPData); + // Send ncSoftKeys through signalR + MessageServices.Current.Publish(SEND_NC_SOFTKEYS_DATA, null, ncSoftKeys); + // Send m155 through signalR + MessageServices.Current.Publish(SEND_M155_DATA, null, m155Data); + + } } } } diff --git a/Step.Database/Controllers/AlarmsController.cs b/Step.Database/Controllers/AlarmsController.cs index a16ef0f5..29b0f86a 100644 --- a/Step.Database/Controllers/AlarmsController.cs +++ b/Step.Database/Controllers/AlarmsController.cs @@ -50,7 +50,8 @@ namespace Step.Database.Controllers x.TimeStamp >= startDate && x.TimeStamp <= endDate && types.Contains(x.Type) && x.Users.Any(y => userIds.Any(z => z == y.UserId)) - && ((x.Source == ALARM_SOURCE.NC && ncAlarmDescIds.Contains(x.AlarmDescriptionId.Value)) + && + ((x.Source == ALARM_SOURCE.NC && ncAlarmDescIds.Contains(x.AlarmDescriptionId.Value)) || (x.Source == ALARM_SOURCE.PLC && plcAlarmDescIds.Contains(x.PlcMessageId.Value))) ); @@ -69,7 +70,7 @@ namespace Step.Database.Controllers { dbCtx.AlarmOccurrences.AddRange(alarms); - dbCtx.SaveChangesAsync(); + dbCtx.SaveChanges(); } public void InsertNewNcAlarmDescriptions(List descriptions) @@ -84,14 +85,14 @@ namespace Step.Database.Controllers dbCtx.AlarmDescriptions.Add(desc); } - dbCtx.SaveChangesAsync(); + dbCtx.SaveChanges(); } public void InsertNewAlarmUser(List loggedUser) { dbCtx.AlarmUsers.AddRange(loggedUser); - dbCtx.SaveChangesAsync(); // TODO check if it is the best solutions + dbCtx.SaveChanges(); // TODO check if it is the best solutions } public DTOAlarmsData GetAlarmsData(int pageSize) diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 01a735d9..94d630dd 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -185,6 +185,7 @@ namespace Step.Model public const string UPDATE_TOOLS_DATA = "UPDATE_TOOLS_DATA"; public const string NC_MAGAZINE_IS_ACTIVE = "UPDATE_NC_MAGAZINE_STATUS"; public const string SEND_QUEUE_DATA = "SEND_QUEUE_DATA"; + public const string SEND_M155_DATA = "SEND_M155_DATA"; public const string BROADCAST_DATA = "BROADCAST_DATA"; diff --git a/Step.Model/DTOModels/DTOProcessDataModel.cs b/Step.Model/DTOModels/DTOProcessDataModel.cs index 592ce9fa..9bbde251 100644 --- a/Step.Model/DTOModels/DTOProcessDataModel.cs +++ b/Step.Model/DTOModels/DTOProcessDataModel.cs @@ -60,7 +60,7 @@ namespace Step.Model.DTOModels { public override bool Equals(object obj) { - var item = obj as ProcessModel; + ProcessModel item = obj as ProcessModel; if (item == null) return false; @@ -84,4 +84,24 @@ namespace Step.Model.DTOModels return base.GetHashCode(); } } + + public class DTOM155InputModel : M155InputIsNeededModel + { + public new string Type; + public override bool Equals(object obj) + { + DTOM155InputModel item = obj as DTOM155InputModel; + + if (item == null) + return false; + + if (Process != item.Process) + return false; + + if (Type != item.Type) + return false; + + return true; + } + } } \ No newline at end of file diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index e3b3c19d..32251874 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -1442,7 +1442,7 @@ namespace Step.NC families = new List(); return numericalControl.TOOLS_RFamilyData(ref families); } - + public CmsError GetMagazinesPositionsData(out List magazinesPositions) { magazinesPositions = new List(); @@ -1464,6 +1464,26 @@ namespace Step.NC return cmsError; } + public CmsError GetM155Data(out List data) + { + data = new List(); + List ncData = new List(); + CmsError cmsError = numericalControl.PLC_ROperatorInputIsNeeded(ref ncData); + if (cmsError.IsError()) + return cmsError; + + data = ncData.Select(x => new DTOM155InputModel() + { + Buttons = x.Buttons, + IsNeeded = x.IsNeeded, + Message = x.Message, + Process = x.Process, + Type = x.Type.ToString() + }).ToList(); + + return NO_ERROR; + } + #endregion Read Data #region Write data diff --git a/Step/Listeners/ListenersHandler.cs b/Step/Listeners/ListenersHandler.cs index 51c15a8c..498292b4 100644 --- a/Step/Listeners/ListenersHandler.cs +++ b/Step/Listeners/ListenersHandler.cs @@ -86,7 +86,10 @@ namespace Step.Listeners SignalRListener.SendPartProgramQueue(a); SignalRDatabaseHandler.UpdateQueue(a); })); - + infos.Add(MessageServices.Current.Subscribe(SEND_M155_DATA, (a, b) => + { + SignalRListener.SendM155Data(a); + })); // Database infos.Add(MessageServices.Current.Subscribe(UPDATE_TOOLS_DATA, (a, b) => @@ -100,6 +103,7 @@ namespace Step.Listeners SignalRListener.BroadcastData(); })); } + public static void Stop() { diff --git a/Step/Listeners/SignalR/SignalRListener.cs b/Step/Listeners/SignalR/SignalRListener.cs index 7c55ae3b..3d636350 100644 --- a/Step/Listeners/SignalR/SignalRListener.cs +++ b/Step/Listeners/SignalR/SignalRListener.cs @@ -232,6 +232,18 @@ namespace Step.Listeners.SignalR } } + public static void SendM155Data(object data) + { + List dtoM155Data = data as List; + + if (!LastM155Data.SequenceEqual(dtoM155Data)) + { + LastM155Data = dtoM155Data; + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.Group("ncData").m155Data(dtoM155Data); + } + } + private volatile static object _broadcastlock = new Object(); public static void BroadcastData() @@ -282,6 +294,8 @@ namespace Step.Listeners.SignalR context.Clients.Group("ncData").magazineIsActive(LastNcMagazineIsActive); // Send PP Queue context.Clients.Group("ncData").partProgramQueue(LastPartProgramQueue); + // Send m155 data + context.Clients.Group("ncData").m155Data(LastM155Data); Debug.WriteLine(string.Format("{0} {1} Broadcast..completed", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), DateTime.Now.Millisecond)); Monitor.Exit(_broadcastlock); diff --git a/Step/Listeners/SignalRStaticObjects.cs b/Step/Listeners/SignalRStaticObjects.cs index fdd2363c..dfa6669c 100644 --- a/Step/Listeners/SignalRStaticObjects.cs +++ b/Step/Listeners/SignalRStaticObjects.cs @@ -21,6 +21,7 @@ namespace Step.Listeners public static DTOActiveProgramDataModel LastProgramData = new DTOActiveProgramDataModel(); public static Dictionary LastNcMagazineIsActive = new Dictionary(); public static List LastPartProgramQueue = new List(); + public static List LastM155Data = new List(); public static bool LastIsNcConnected = false; }