From 7ed87452a452c01a817759ff64b0cbeccbaa77f7 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Tue, 26 Mar 2019 17:01:29 +0100 Subject: [PATCH] Fix ACTIVE error management Fix tool table cancel buttons Removed deleted button in edit --- Step.Config/ServerConfigController.cs | 7 ++- Step.Core/ThreadsFunctions.cs | 60 +++---------------- Step.Model/ConfigModels/MessageModel.cs | 3 +- Step.UI/ServerControlWindow.cs | 55 +++++++++++------ Step.Utils/ExceptionManager.cs | 21 +++---- .../tooling/components/tooling-equipment.ts | 56 ++++++++--------- .../tooling/components/tooling-equipment.vue | 12 ++-- .../tooling/components/tooling-families.vue | 4 +- 8 files changed, 97 insertions(+), 121 deletions(-) diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index 2b684b6c..81e76ecb 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -134,13 +134,14 @@ namespace Step.Config { if (e.Severity == XmlSeverityType.Warning) { - ExceptionManager.Manage(ERROR_LEVEL.WARNING, e.Message); + ExceptionManager.Manage(ERROR_LEVEL.WARNING, e.Message, true); } else if (e.Severity == XmlSeverityType.Error) { ExceptionManager.Manage(ERROR_LEVEL.FATAL, // "Error while reading file: " + e.Exception.SourceUri + - "Error while reading configuration file: " + e.Message + "Error while reading configuration file: " + e.Message, + true ); } } @@ -193,7 +194,7 @@ namespace Step.Config { StreamReader sr = new StreamReader(SCADA_DIRECTORY + file.Name); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ScadaSchemaModel)); - ScadaSchemaModel schema = xmlSerializer.Deserialize(sr) as ScadaSchemaModel; + ScadaSchemaModel schema = xmlSerializer.Deserialize(sr) as ScadaSchemaModel; // Setup incremental ids schema.Id = i++; diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index aef8ba81..6e95ad69 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -1018,6 +1018,10 @@ public static class ThreadsFunctions case CMS_ERROR_CODES.INTERNAL_ERROR: Manage(ERROR_LEVEL.FATAL, cmsError.localizationKey); break; + case CMS_ERROR_CODES.SELECTED_PROCESS: + + Manage(ERROR_LEVEL.FATAL, cmsError.localizationKey); + break; //default: // Manage(ERROR_LEVEL.WARNING, cmsError.localizationKey); // break; @@ -1040,7 +1044,7 @@ public static class ThreadsFunctions ThreadsHandler.RunningThreadStatus["ReadAxesPositionsData"] = (ReadAxesTimer / ReadAxesTimes) + " mS"; ReadAxesTimer = 0; ReadAxesTimes = 0; - } + } if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadPowerOnData") && ReadPowerOnTimes != 0) { @@ -1086,6 +1090,7 @@ public static class ThreadsFunctions ReadAxesNamesTimer = 0; ReadAxesNamesTimes = 0; } + if (ThreadsHandler.RunningThreadStatus.ContainsKey("UpdateToolsData") && ReadAxesNamesTimer != 0) { ThreadsHandler.RunningThreadStatus["UpdateToolsData"] = (ReadToolDataTimer / ReadToolDataTimes) + " mS"; @@ -1134,55 +1139,4 @@ public static class ThreadsFunctions } #endregion SupportFunctions -} - -//public static void MonitorPanelPCResources() -//{ -// float sumRec, sumSen; -// Stopwatch sw = new Stopwatch(); -// DTONetworkMonitorModel Monitor = new DTONetworkMonitorModel(); -// int cardId = ServerConfig.ServerStartupConfig.NetworkCardId - 1; - -// PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface"); - -// if (cardId < 0 || cardId > performanceCounterCategory.GetInstanceNames().Length) -// { -// Monitor.Name = "No card to monitor"; -// MessageServices.Current.Publish(NETWORK_USAGE, null, Monitor); -// return; -// } - -// Monitor.Name = performanceCounterCategory.GetInstanceNames()[cardId]; - -// PerformanceCounter PC_Bandwith = new PerformanceCounter("Network Interface", "Current Bandwidth", Monitor.Name); -// PerformanceCounter PC_RecievedBytes = new PerformanceCounter("Network Interface", "Bytes Received/sec", Monitor.Name); -// PerformanceCounter PC_SentBytes = new PerformanceCounter("Network Interface", "Bytes Sent/sec", Monitor.Name); - -// Monitor.Bandwidth = PC_Bandwith.NextValue(); - -// try -// { -// while (true) -// { -// sw.Restart(); - -// sumRec = 0; -// sumSen = 0; -// for (int index = 0; index < 50; index++) -// { -// sumRec += PC_RecievedBytes.NextValue(); -// sumSen += PC_SentBytes.NextValue(); -// } -// Monitor.Value = Math.Round(((8 * (sumSen + sumRec)) / (Monitor.Bandwidth * 50) * 100), 2); -// MessageServices.Current.Publish(NETWORK_USAGE, null, Monitor); -// sw.Stop(); - -// // Wait -// Thread.Sleep(CalcSleepTime(2000, (int)sw.ElapsedMilliseconds)); -// } -// } -// catch (ThreadAbortException) -// { -// ExceptionManager.Manage(ERROR_LEVEL.FATAL, "Fatal error in Network Performance monitor Thread"); -// } -//} \ No newline at end of file +} \ No newline at end of file diff --git a/Step.Model/ConfigModels/MessageModel.cs b/Step.Model/ConfigModels/MessageModel.cs index 01111443..c3686213 100644 --- a/Step.Model/ConfigModels/MessageModel.cs +++ b/Step.Model/ConfigModels/MessageModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using static Step.Model.Constants; namespace Step.Model { @@ -10,6 +11,6 @@ namespace Step.Model { public string Title { get; set; } public string Message { get; set; } - public int ErrorLevel { get; set; } + public ERROR_LEVEL ErrorLevel { get; set; } } } diff --git a/Step.UI/ServerControlWindow.cs b/Step.UI/ServerControlWindow.cs index ea78e3ae..a4167629 100644 --- a/Step.UI/ServerControlWindow.cs +++ b/Step.UI/ServerControlWindow.cs @@ -1,5 +1,4 @@ using Step.Model; -using Step.Model.DTOModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -32,7 +31,7 @@ namespace Step.UI //End the update LISTThreadStatus.EndUpdate(); - if(NcConfig != null && NcConfig.NcVendor != null) + if (NcConfig != null && NcConfig.NcVendor != null) TXTType.Text = NcConfig.NcVendor; InitializeMessageListeners(); @@ -40,8 +39,7 @@ namespace Step.UI MessageServices.Current.Subscribe(SHOW_MSG_UI, (a, b) => { Invoke((MethodInvoker)delegate () { Focus(); MessageBox.Show(a.ToString()); }); - }); - + }); } private static ServerControlWindow ctrlwindow = null; @@ -135,23 +133,42 @@ namespace Step.UI private void InitializeMessageListeners() { MVVMListeners = new List - { + { MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) => - { - // Cast object to ErrorMessageModel - ErrorMessageModel message = (ErrorMessageModel)a; - // If error has a fatal level, icon must be error - message.ErrorLevel = message.ErrorLevel > (int)ERROR_LEVEL.ERROR ? (int)ERROR_LEVEL.ERROR : message.ErrorLevel; + { + // Cast object to ErrorMessageModel + ErrorMessageModel message = (ErrorMessageModel)a; + + if(message.ErrorLevel <= ERROR_LEVEL.ERROR) + { + // If error has a fatal level, icon must be error + message.ErrorLevel = message.ErrorLevel > ERROR_LEVEL.ERROR ? ERROR_LEVEL.ERROR : message.ErrorLevel; - if (!this.IsDisposed) - this.Invoke((MethodInvoker)delegate () - { - // Open BalloonTip with data - StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel); + if (!this.IsDisposed) + this.Invoke((MethodInvoker)delegate () + { + // Open BalloonTip with data + StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel); + + //ShowMessage on UI + TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message; + }); + } + else + { + if (!this.IsDisposed) + this.Invoke((MethodInvoker)delegate () + { + // Open BalloonTip with data + StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon.Error)); - //ShowMessage on UI - TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message; - }); + //ShowMessage on UI + TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message; + }); + // Notify user + if(MessageBox.Show(message.Message, message.Title, MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK) + MessageServices.Current.Publish(SEND_STOP_SERVER); + } }), // NC status handler MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) => @@ -225,7 +242,7 @@ namespace Step.UI private static bool ClientIsRunning() { Process[] p = Process.GetProcessesByName(CLIENT_EXE_NAME_NOEXT); - if (p.Length>0) + if (p.Length > 0) return true; return false; } diff --git a/Step.Utils/ExceptionManager.cs b/Step.Utils/ExceptionManager.cs index 3a74d0d6..1370da2e 100644 --- a/Step.Utils/ExceptionManager.cs +++ b/Step.Utils/ExceptionManager.cs @@ -45,7 +45,7 @@ namespace Step.Utils private static bool MessageBoxShow = false; - public static void Manage(ERROR_LEVEL errorLevel, string message) + public static void Manage(ERROR_LEVEL errorLevel, string message, bool beforeFormReady = false) { switch (errorLevel) { @@ -75,20 +75,21 @@ namespace Step.Utils if (!MessageBoxShow) { MessageBoxShow = true; - NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL)); - // Close the application - Environment.Exit(1); + NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL), beforeFormReady); + // Check if the server form is ready (if not i have to close manually) + if (beforeFormReady) + // Close the application + Environment.Exit(1); } }break; default: { + LogFatal(message); if (!MessageBoxShow) { MessageBoxShow = true; - NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL)); - // Close the application - Environment.Exit(1); + NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL), beforeFormReady); } } break; @@ -102,9 +103,9 @@ namespace Step.Utils NotifyUsers(error); } - private static void NotifyUsers(ErrorMessageModel error) + private static void NotifyUsers(ErrorMessageModel error, bool beforeFormReady = false) { - if (error.ErrorLevel > (int)ERROR_LEVEL.WARNING) + if (beforeFormReady) { // Notify user MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -122,7 +123,7 @@ namespace Step.Utils { Title = title, Message = message, - ErrorLevel = (int)level + ErrorLevel = level }; } } diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts index 65e94293..9794c631 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts @@ -301,6 +301,7 @@ export default class toolingEquipment extends Vue { let newTool = {}; if(!this.isSiemens){ this.selectedTool = Object.assign({}, newTool) + this.copySelectedTool = null this.enableToolCreation = true; this.enableToolModify = false this.enableOffsets = false @@ -417,6 +418,7 @@ export default class toolingEquipment extends Vue { } public cancel = function () { + console.log("CANCEL", this.selectedTool, this.copySelectedTool) if(this.isSiemens){ if (this.copySelectedTool) { this.selectedTool = Object.assign({},this.copySelectedTool); @@ -431,24 +433,24 @@ export default class toolingEquipment extends Vue { } - if (!this.selectedTool && !this.selectedTool.id) { - this.selectedTool = null; - }else { - for (let l in this.selectedTool.edgesData) { - if (this.selectedTool.edgesData[l].id <= 0) { - this.selectedTool.edgesData.splice(l, 1); - this.selectedEquipment = null; - this.enableEquipment = false; - this.enableParameters = true; + if (!this.selectedTool || !this.selectedTool.id) { + this.selectedTool = null; + } else { + for (let l in this.selectedTool.edgesData) { + if (this.selectedTool.edgesData[l].id <= 0) { + this.selectedTool.edgesData.splice(l, 1); + this.selectedEquipment = null; + this.enableEquipment = false; + this.enableParameters = true; + } } } - } - - this.enableAddOffsetToTool = false; - this.enableToolModify = false; - this.disableList = false; - - this.$forceUpdate(); + + this.enableAddOffsetToTool = false; + this.enableToolModify = false; + this.disableList = false; + + this.$forceUpdate(); } public isEquipmentSelected(offset){ @@ -461,13 +463,13 @@ public isEquipmentSelected(offset){ return false } - public cancelNc = function () { - if(this.copySelectedTool && this.selectedTool.id > 0){ + public cancelOffsetTab = function () { + if(this.copySelectedTool && this.selectedTool.id > 0){ // Useless? this.selectedTool = Object.assign({},this.copySelectedTool); toolingActions.updateNcTool(store, this.selectedTool); } - - if (this.selectedTool.id == null || this.selectedTool.id == 0) { + + if (!this.copySelectedEquipment || !this.copySelectedEquipment.id) { this.selectedTool = null; } else { @@ -814,17 +816,17 @@ public isEquipmentSelected(offset){ @Watch("newToolId") public canAddTool(){ + if(!this.offsetOptionActive && this.newToolId > this.maxOffsets){ + this.canAddNewTool = false; + return; + } + var tool = this.ncTools.find(k => k.id == this.newToolId); - + if(tool) this.canAddNewTool = false; else this.canAddNewTool = true; - } - - public toolMagLocked(id: number): boolean { - - - return true + } } diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue index c35bbbc0..eac3c77f 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue @@ -115,7 +115,7 @@ - +
{{'tooling_edgesdata_label_edit' | localize("Modifica Tagliente n. %d",selectedEquipment.id)}}
@@ -140,7 +140,7 @@
- +
{{'tooling_edgesdata_label_edit' | localize("Modifica Tagliente n. %d",selectedEquipment.id)}}
@@ -156,11 +156,11 @@
- +
{{'tooling_edgesdata_label_new' | localize("Scegliere posizione e id dell'Offset da aggiungere")}}
@@ -178,11 +178,11 @@
- +
{{'tooling_equipment_newlabel' | localize("Creazione Nuovo Utensile")}}
diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-families.vue b/Step/wwwroot/src/app_modules/tooling/components/tooling-families.vue index 85cdfc3b..52d5ceb1 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-families.vue +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-families.vue @@ -105,7 +105,7 @@
- +
@@ -114,7 +114,7 @@
- +
{{'tooling_families_boxright_editlabel' | localize("Modifica della famiglia %s", selectedTool.name)}}
{{'tooling_families_boxright_newlabel' | localize("Aggiunta nuova famiglia")}}