diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index c9cfeedc..6144b486 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index d1c77d33..ec62977e 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -40,7 +40,8 @@ namespace Step.Config { ExceptionManager.Manage(ERROR_LEVEL.FATAL, "Error while reading file: " + ex.SourceUri + - "\n Error: " + ex.Message + "\n Error: " + ex.Message, + true ); } catch (Exception ex) @@ -48,7 +49,7 @@ namespace Step.Config var message = ex.Message; if (ex.InnerException != null) message += "\n"+ex.InnerException.Message; - ExceptionManager.Manage(ERROR_LEVEL.FATAL, message); + ExceptionManager.Manage(ERROR_LEVEL.FATAL, message, true); } } diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 123c3a6d..4583c07a 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -514,9 +514,9 @@ public static class ThreadsFunctions try { // Try connection - CmsError libraryError = ncHandler.Connect(); + CmsError libraryError = ncHandler.Connect(); if (libraryError.errorCode != 0) - ManageLibraryError(libraryError); + ManageLibraryError(libraryError); while (true) { @@ -988,9 +988,10 @@ public static class ThreadsFunctions { toolTable.Connect(); // After reconecction write option - cmsError = toolTable.WriteOption(); - // Check if there are blocked magazines - cmsError = toolTable.RestoreTableLock(); + cmsError = toolTable.SetupNcToolManager(); + if (cmsError.IsError()) + ManageLibraryError(cmsError); + // cmsError = toolTable.RestoreTableLock(); } } @@ -1043,6 +1044,7 @@ public static class ThreadsFunctions break; case CMS_ERROR_CODES.INTERNAL_ERROR: + case CMS_ERROR_CODES.OPTION_NOT_CONSISTENT: Manage(ERROR_LEVEL.FATAL, cmsError.localizationKey); break; diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 915cf881..8115092a 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -194,6 +194,7 @@ namespace Step.Model public const string SEND_STOP_SERVER = "STOP_SERVER"; public const string SEND_MESSAGE = "SEND_MESSAGE"; + public const string SEND_STOP_THREADS = "SEND_STOP_THREADS"; public const string SEND_NC_STATUS = "NC_STATUS"; public const string SEND_THREADS_STATUS = "THREAD_STATUS"; public const string SHOW_MSG_UI = "SHOW_MSG_UI"; @@ -257,7 +258,6 @@ namespace Step.Model public const string ID_ALREADY_EXIST = "error_id_already_exist"; public const string PASSWORD_IS_INVALID = "error_password_is_invalid"; public const string IMPORT_FILE_NOT_VALID = "error_import_file_not_valid"; - public const string OPTION_NOT_CONSISTENT = "error_option_not_consistent"; } // File paths diff --git a/Step.NC/NcToolTableHandler.cs b/Step.NC/NcToolTableHandler.cs index 488fbf56..9205c3da 100644 --- a/Step.NC/NcToolTableHandler.cs +++ b/Step.NC/NcToolTableHandler.cs @@ -193,7 +193,7 @@ namespace Step.NC return numericalControl.TOOLS_WOffset(offsetId, offsetData); } - public CmsError UpdateToolOffsetId(int toolId, int positionId, short offsetId, out DTONcToolModel toolWithOffsets) + public CmsError UpdateToolOffsetId(int toolId, int positionId, short offsetId, out DTONcToolModel toolWithOffsets) { toolWithOffsets = new DTONcToolModel(); @@ -590,18 +590,22 @@ namespace Step.NC toolManager.ImportData(exp); } } + + List databaseTool = toolManager.GetTools(); + // Check options consistency with database data + bool exist = databaseTool.Exists(x => + (!ToolManagerConfig.FamilyOpt && x.FamilyId != x.Id) || // Check family + (!ToolManagerConfig.ShankOpt && x.ShankId != x.Id) || // Check shanks + (!ToolManagerConfig.OffsetOpt && x.OffsetId1 != x.Id && x.OffsetId2 != null && x.OffsetId3 != null) // Check offsets + ); + if (exist) + return OPTION_NOT_CONSISTENT_ERROR; - //List databaseTool = toolManager.GetTools(); - - //// Check option consistency - //bool exist = databaseTool.Exists(x => - // (!ToolManagerConfig.FamilyOpt && x.FamilyId != x.Id) || // Check family - // (!ToolManagerConfig.ShankOpt && x.ShankId != x.Id) || // Check shanks - // (!ToolManagerConfig.OffsetOpt && x.OffsetId1 != x.Id && x.OffsetId2 != null && x.OffsetId3 != null) // Check offsets - //); - //if (exist) - // ExceptionManager.Manage(ERROR_LEVEL., ); + // Check if there are blocked magazines, and release them + cmsError = RestoreTableLock(); + if (cmsError.IsError()) + return cmsError; } diff --git a/Step.UI/ServerControlWindow.cs b/Step.UI/ServerControlWindow.cs index 87d45424..b27ebacb 100644 --- a/Step.UI/ServerControlWindow.cs +++ b/Step.UI/ServerControlWindow.cs @@ -206,11 +206,11 @@ namespace Step.UI if (!this.IsDisposed) this.Invoke((MethodInvoker)delegate () { - // Open BalloonTip with data - StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon.Error)); + // 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) diff --git a/Step.Utils/ExceptionManager.cs b/Step.Utils/ExceptionManager.cs index 1370da2e..0c4b8ff1 100644 --- a/Step.Utils/ExceptionManager.cs +++ b/Step.Utils/ExceptionManager.cs @@ -66,7 +66,7 @@ namespace Step.Utils case ERROR_LEVEL.ERROR: { LogError(message); - NotifyUsers(CreateMessageModel("Error!", message, ERROR_LEVEL.ERROR)); + NotifyUsersAndClose(CreateMessageModel("Error!", message, ERROR_LEVEL.ERROR)); } break; case ERROR_LEVEL.FATAL: @@ -75,7 +75,7 @@ namespace Step.Utils if (!MessageBoxShow) { MessageBoxShow = true; - NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL), beforeFormReady); + NotifyUsersAndClose(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 @@ -89,7 +89,7 @@ namespace Step.Utils if (!MessageBoxShow) { MessageBoxShow = true; - NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL), beforeFormReady); + NotifyUsersAndClose(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL), beforeFormReady); } } break; @@ -99,20 +99,35 @@ namespace Step.Utils private static void LogAndNotifyUsers(ErrorMessageModel error) { // Log - LogMessage(error.Message, (ERROR_LEVEL)error.ErrorLevel); - NotifyUsers(error); + LogMessage(error.Message, (ERROR_LEVEL)error.ErrorLevel); + NotifyUsersAndClose(error); } private static void NotifyUsers(ErrorMessageModel error, bool beforeFormReady = false) { if (beforeFormReady) { - // Notify user MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } else + { + MessageServices.Current.Publish(SEND_MESSAGE, null, error); + } + } + + private static void NotifyUsersAndClose(ErrorMessageModel error, bool beforeFormReady = false) + { + if (beforeFormReady) { // Notify user + MessageServices.Current.Publish(SEND_STOP_THREADS); + MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageServices.Current.Publish(SEND_STOP_SERVER); + } + else + { + // Notify user + MessageServices.Current.Publish(SEND_STOP_THREADS); MessageServices.Current.Publish(SEND_MESSAGE, null, error); } } diff --git a/Step/program.cs b/Step/program.cs index ab0dc96e..2efb28aa 100644 --- a/Step/program.cs +++ b/Step/program.cs @@ -53,17 +53,19 @@ namespace Step StopRequest.Set(); if (NcConfig.NcVendor.ToUpper() == NC_VENDOR.SIEMENS) ThreadSiemensHmi.StopThread(); - }); - - if(NcConfig.NcVendor.ToUpper() != NC_VENDOR.SIEMENS) + }); + + // Stop threads and disconnect from NC + MessageServices.Current.Subscribe(SEND_STOP_THREADS, (a, b) => { - // Setup Osai/fanuc toolManager - using (NcToolTableHandler handler = new NcToolTableHandler()) - { - handler.Connect(); - handler.SetupNcToolManager(); - } - } + using (NcHandler ncHandler = new NcHandler()) + ncHandler.Disconnect(); + + // Stop Threads + ThreadsHandler.Close(); + // Stop messageservice listeners + ListenersHandler.Stop(); + }); // Start server services if (!ValidateAddress(ServerStartupConfig.ServerAddress)) @@ -98,7 +100,7 @@ namespace Step // Stop messageservice listeners ListenersHandler.Stop(); // Close WinForm - ServerControlWindow.Stop(); + ServerControlWindow.Stop(); } private static bool ValidateAddress(string Addr) diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts index 3b6f23e7..78f52157 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts @@ -219,6 +219,7 @@ export default class depot extends Vue { public typeNc: string = "Osai"; public toolMountedInSpindle = null + public needReload = false @Watch("searchText") public applyFilter(n) { @@ -231,6 +232,12 @@ export default class depot extends Vue { public modalBlockMagazine() { if (this.magazineStatusModel.action == 1) { ModalHelper.HideModal("modal-internal"); + + // Load data only if needed + if(this.needReload) { + this.loadData() + this.needReload = false + } } else if (this.magazineStatusModel.action == 0) { ModalHelper.ShowModal(DepotActionGeneric, "modal-internal"); @@ -250,6 +257,10 @@ export default class depot extends Vue { else if (this.magazineStatusModel.action == 7) { ModalHelper.ShowModal(DepotActionStartNeeded, "modal-internal") } + + // If one action occurred, i need to reload data when action return to 1 + if(this.magazineStatusModel.action != 1) + this.needReload = true } // Ottengo il tool alla posizione corrente diff --git a/Step/wwwroot/src/store/machineStatus.store.ts b/Step/wwwroot/src/store/machineStatus.store.ts index 002ce968..e716cf91 100644 --- a/Step/wwwroot/src/store/machineStatus.store.ts +++ b/Step/wwwroot/src/store/machineStatus.store.ts @@ -287,9 +287,10 @@ export const machineStatusStore = { return false; }, setSecurityFunction(context, securityFunctions: Array) { - securityFunctions.forEach(element => { - context.commit("SetSecurityFunction", element); - }); + if(securityFunctions) + securityFunctions.forEach(element => { + context.commit("SetSecurityFunction", element); + }); }, updateSecurityFunction(context, securityFunctions: Array) { securityFunctions.forEach(element => {