Added Siemens/Demo M155 SignalR
WIP fix alarm filters
This commit is contained in:
Binary file not shown.
@@ -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<DTOM155InputModel> 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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AlarmDescriptionsModel> descriptions)
|
||||
@@ -84,14 +85,14 @@ namespace Step.Database.Controllers
|
||||
dbCtx.AlarmDescriptions.Add(desc);
|
||||
}
|
||||
|
||||
dbCtx.SaveChangesAsync();
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public void InsertNewAlarmUser(List<AlarmUserModel> 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)
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-1
@@ -1442,7 +1442,7 @@ namespace Step.NC
|
||||
families = new List<FamilyModel>();
|
||||
return numericalControl.TOOLS_RFamilyData(ref families);
|
||||
}
|
||||
|
||||
|
||||
public CmsError GetMagazinesPositionsData(out List<PositionModel> magazinesPositions)
|
||||
{
|
||||
magazinesPositions = new List<PositionModel>();
|
||||
@@ -1464,6 +1464,26 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public CmsError GetM155Data(out List<DTOM155InputModel> data)
|
||||
{
|
||||
data = new List<DTOM155InputModel>();
|
||||
List<M155InputIsNeededModel> ncData = new List<M155InputIsNeededModel>();
|
||||
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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -232,6 +232,18 @@ namespace Step.Listeners.SignalR
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendM155Data(object data)
|
||||
{
|
||||
List<DTOM155InputModel> dtoM155Data = data as List<DTOM155InputModel>;
|
||||
|
||||
if (!LastM155Data.SequenceEqual(dtoM155Data))
|
||||
{
|
||||
LastM155Data = dtoM155Data;
|
||||
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
|
||||
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);
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Step.Listeners
|
||||
public static DTOActiveProgramDataModel LastProgramData = new DTOActiveProgramDataModel();
|
||||
public static Dictionary<int, bool> LastNcMagazineIsActive = new Dictionary<int, bool>();
|
||||
public static List<DTOQueueModel> LastPartProgramQueue = new List<DTOQueueModel>();
|
||||
public static List<DTOM155InputModel> LastM155Data = new List<DTOM155InputModel>();
|
||||
|
||||
public static bool LastIsNcConnected = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user