diff --git a/Thermo.Active.CmsConnectGateway/CMSConnectConstants.cs b/Thermo.Active.CmsConnectGateway/CMSConnectConstants.cs index ce9d6434..b32aabb2 100644 --- a/Thermo.Active.CmsConnectGateway/CMSConnectConstants.cs +++ b/Thermo.Active.CmsConnectGateway/CMSConnectConstants.cs @@ -113,7 +113,7 @@ namespace Thermo.Active.CmsConnectGateway List alms = new List(); foreach (DTOPlcAlarmModel alarm in alarms.PlcAlarms) { int severity = alarm.IsWarning ? 500 : 900; - alms.Add(alarm.Id + "|" + severity); + alms.Add(alarm.Id.ToString("D6") + "|" + severity); } return string.Join(",", alms); } diff --git a/Thermo.Active.Config/Config/DataModel.xml b/Thermo.Active.Config/Config/DataModel.xml index aecba01e..cb0abf08 100644 --- a/Thermo.Active.Config/Config/DataModel.xml +++ b/Thermo.Active.Config/Config/DataModel.xml @@ -1,107 +1,112 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 2580263f..3b29808b 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -310,7 +310,12 @@ namespace Thermo.Active.Config else if(elem.Name.LocalName == "Property") Paths.Add(Parent + ":" + elem.Attribute("SymbolicName").Value, elem.Attribute("Value").Value); else - Paths.Add(Parent + ":" + elem.Attribute("SymbolicName").Value, "UNAVAILABLE"); + { + if(elem.Attribute("SymbolicName") != null && elem.Attribute("SymbolicName").Value == "Condition") + Paths.Add(Parent + ":" + elem.Attribute("SymbolicName").Value, ""); + else + Paths.Add(Parent + ":" + elem.Attribute("SymbolicName").Value, "UNAVAILABLE"); + } } } diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 44566643..f38965a8 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -1140,7 +1140,7 @@ public static class ThreadsFunctions NcAdapter ncAdapter = new NcAdapter(); try { - + //Write all the datamodel if (!RedisController.WriteDatamodel(CMSConnectDataModel)) ManageError(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); @@ -1153,6 +1153,14 @@ public static class ThreadsFunctions if (!RedisController.WriteActiveVersion(SupportFunctions.GetSoftwareVersionAndBuildDate())) ManageError(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + //Write the Overrides + if (!RedisController.WriteFakeOverrides(1)) + ManageError(ERROR_LEVEL.FATAL, CMS_CONNECT_SETUP_ALARM_MESSAGE); + + var ts = DateTime.UtcNow.ToString("o"); + var a = "{\"v\": { \"PART_COUNT\": 0}\"ts\": " + ts + "}"; + RedisController.WriteMachineEventKpis(a); + List availableLanguages = LanguageController.GetLanguageListFromDirectory(); if (availableLanguages == null) return; diff --git a/Thermo.Active.Database/Controllers/RedisController.cs b/Thermo.Active.Database/Controllers/RedisController.cs index 01e13fa1..2eeed753 100644 --- a/Thermo.Active.Database/Controllers/RedisController.cs +++ b/Thermo.Active.Database/Controllers/RedisController.cs @@ -23,12 +23,17 @@ namespace Thermo.Active.Database.Controllers private const string alarmsPath = "Machine:Plc:Condition"; private const string processStatusPath = "Machine:Cnc:CncProcesses:%NN%:Status"; private const string processModePath = "Machine:Cnc:CncProcesses:%NN%:Mode"; + private const string processFeedOverridePath = "Machine:Cnc:CncProcesses:%NN%:FeedOverride"; + private const string processRapidOverridePath = "Machine:Cnc:CncProcesses:%NN%:RapidOverride"; + private const string processSpeedOverridePath = "Machine:Cnc:CncProcesses:%NN%:SpeedOverride"; + private const string datamodelPath = "AdpConf:DataModel"; private const string currentActiveVersionPath = "Machine:Hmi:Version"; private const string machineAxisPosition = "Machine:Axes:%NN%:CurrentPos"; private const string machineAxisSpeed = "Machine:Axes:%NN%:FeedRate"; private const string machineAxisLoad = "Machine:Axes:%NN%:Load"; private const string machineAxisName = "Machine:Axes:%NN%:Name"; + private const string machineEventKpis = "Machine:Events:Kpis"; public static void WriteProductionNotification(uint ProductionProcess, string Notification) { @@ -122,6 +127,21 @@ namespace Thermo.Active.Database.Controllers return redUtil.man.setRSV(redisHash, status.ToString()); } + public static bool WriteFakeOverrides(uint ProductionProcess) + { + string redisHash = redUtil.man.redHash(processFeedOverridePath).Replace("%NN%", ProductionProcess.ToString("00")); + if (!redUtil.man.setRSV(redisHash, "100")) + return false; + redisHash = redUtil.man.redHash(processRapidOverridePath).Replace("%NN%", ProductionProcess.ToString("00")); + if (!redUtil.man.setRSV(redisHash, "100")) + return false; + redisHash = redUtil.man.redHash(processSpeedOverridePath).Replace("%NN%", ProductionProcess.ToString("00")); + if(!redUtil.man.setRSV(redisHash, "100")) + return false; + return true; + } + + public static bool WriteCurrentMachinePowerPath(bool status) { string redisHash = redUtil.man.redHash(machinePowerPath); @@ -155,6 +175,14 @@ namespace Thermo.Active.Database.Controllers return redUtil.man.setRSV(redisHash, alarms); } + public static bool WriteMachineEventKpis(string alarms) + { + string redisHash = redUtil.man.redHash(machineEventKpis); + redUtil.man.ListPush(redisHash, alarms); + return true; + } + + public static bool WriteCurrentAxisStatus(Dictionary axis) { foreach(KeyValuePair asse in axis) diff --git a/Thermo.Active.Database/Redis/redUtil.cs b/Thermo.Active.Database/Redis/redUtil.cs index 9b988cf8..35345558 100644 --- a/Thermo.Active.Database/Redis/redUtil.cs +++ b/Thermo.Active.Database/Redis/redUtil.cs @@ -826,5 +826,70 @@ namespace Thermo.Active.Database.Redis #endregion + + #region gestione Stack / List + + /// + /// Lunghezza Stack + /// + /// + /// + public long StackLen(string stackName) + { + return connRedis.GetDatabase().ListLength((RedisKey)stackName); + } + + /// + /// Mette in Stack un valore (F.I.L.O.) + /// + /// + /// + public void StackPush(string stackName, string value) + { + connRedis.GetDatabase().ListRightPush((RedisKey)stackName, (RedisValue)value); + } + + /// + /// Recupera valore da Stack (F.I.L.O.) + /// + /// + /// + public string StackPop(string stackName) + { + return connRedis.GetDatabase().ListRightPop((RedisKey)stackName).ToString(); + } + + /// + /// Lunghezza List + /// + /// + /// + public long ListLen(string queueName) + { + return connRedis.GetDatabase().ListLength((RedisKey)queueName); + } + + /// + /// Mette un valore in List (F.I.F.O.) + /// + /// + /// + public void ListPush(string queueName, string value) + { + connRedis.GetDatabase().ListRightPush((RedisKey)queueName, (RedisValue)value); + } + + /// + /// Recupera valore da List (F.I.F.O.) + /// + /// + /// + public string ListPop(string queueName) + { + return connRedis.GetDatabase().ListLeftPop((RedisKey)queueName).ToString(); + } + + #endregion gestione Stack / List + } } diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index fb67ae73..02820ec5 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -459,7 +459,9 @@ namespace Thermo.Active.Listeners.SignalR if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady && currProdPanel.NumDone > 0 && currProdPanel.NumDone != LastProdPanelData.NumDone) { - //TODO + var ts = DateTime.UtcNow.ToString("o"); + var a = "{\"v\": { \"PART_COUNT\": 1}\"ts\": " + ts + "}"; + RedisController.WriteMachineEventKpis(a); } } @@ -612,6 +614,16 @@ namespace Thermo.Active.Listeners.SignalR // THERMO prod cycle data group.prodCycleData(LastProdCycleData); + if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady) + { + RedisController.WriteCurrentAlarms(CMSConnectConstants.ConvertThermoToConnectAlarms(LastAlarms)); + RedisController.WriteCurrentMachineAlarmPath(CMSConnectConstants.ConvertThermoToConnectMachineAlarm(LastAlarms)); + RedisController.WriteCurrentMachineStatus(CMSConnectConstants.ConvertThermoToConnectStatus(LastProdCycleData.Status)); + RedisController.WriteCurrentMachinePowerPath(CMSConnectConstants.ConvertThermoToConnectPower(LastProdCycleData.Status)); + RedisController.WriteCurrentProcessStatus(1, CMSConnectConstants.ConvertThermoToConnectProcessStatus(LastProdCycleData.Status)); + RedisController.WriteCurrentProcessMode(1, CMSConnectConstants.ConvertThermoToConnectProcessMode(LastProdCycleData.Mode)); + } + Debug.WriteLine(string.Format("{0} {1} Broadcast..completed", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), DateTime.Now.Millisecond)); Monitor.Exit(_broadcastlock); }