From 2533be1e62ec6b80dea80a0ed521195a77e8a0b9 Mon Sep 17 00:00:00 2001 From: luciomaranta Date: Thu, 25 Jun 2020 13:01:49 +0200 Subject: [PATCH] Fix balluf double writing Added baluff option Added balluf cleat tablet --- CMS_CORE_Library/Demo/Nc_Demo.cs | 6 +++ CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 5 +++ CMS_CORE_Library/Models/DataStructures.cs | 1 + CMS_CORE_Library/Models/SiemensToolModels.cs | 2 + CMS_CORE_Library/Nc.cs | 3 ++ CMS_CORE_Library/Osai/Nc_Osai.cs | 6 +++ CMS_CORE_Library/Siemens/Nc_Siemens.cs | 45 ++++++++++++++++---- 7 files changed, 59 insertions(+), 9 deletions(-) diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index c0a5a5b..04a1de0 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -3412,6 +3412,12 @@ namespace CMS_CORE_Library.Demo return FUNCTION_NOT_ALLOWED_ERROR; } + public override CmsError TOOLS_WClearBallufTablet(ushort magazineId, ushort positionId, ushort toolId) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion ToolTable /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index aa5e461..d66d6d0 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -3807,6 +3807,11 @@ namespace CMS_CORE_Library.Fanuc return FUNCTION_NOT_ALLOWED_ERROR; } + public override CmsError TOOLS_WClearBallufTablet(ushort magazineId, ushort positionId, ushort toolId) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + #endregion Siemens Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index fecec47..0be5f91 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -516,6 +516,7 @@ namespace CMS_CORE_Library.Models LOAD = 1, UNLOAD = 2, NEW_DATA = 3, + DELETE_TABLET = 90, ABORT = 99 } diff --git a/CMS_CORE_Library/Models/SiemensToolModels.cs b/CMS_CORE_Library/Models/SiemensToolModels.cs index de22aa0..8fc21e2 100644 --- a/CMS_CORE_Library/Models/SiemensToolModels.cs +++ b/CMS_CORE_Library/Models/SiemensToolModels.cs @@ -233,6 +233,8 @@ namespace CMS_CORE_Library.Models public bool RadiusMetricType; public bool LifeOption; + public bool SiemensBallufOption; + public List Magazines; public List ToolsConfiguration; public FamiliesConfiguration FamiliesConfiguration; diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 5947215..62516c0 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1835,6 +1835,9 @@ namespace CMS_CORE_Library public abstract CmsError TOOLS_WAbortBallufTablet(); + public abstract CmsError TOOLS_WClearBallufTablet(ushort magazineId, ushort positionId, ushort toolId); + + #endregion Tool Table Siemens /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index abf1807..fe0d640 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -3663,6 +3663,12 @@ namespace CMS_CORE_Library.Osai return FUNCTION_NOT_ALLOWED_ERROR; } + public override CmsError TOOLS_WClearBallufTablet(ushort magazineId, ushort positionId, ushort toolId) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion Siemens Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 8ff5202..cc95d54 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -96,6 +96,7 @@ namespace CMS_CORE_Library.Siemens private static bool LIFE_OPTION_ACTIVE; private static bool MULTITOOL_OPTION_ACTIVE; + private static bool BALLUF_OPTION_IS_ACTIVE; private const string PLC_MESSAGES_FILE_PATH = "C:\\Program Files (x86)\\Siemens\\MotionControl\\oem\\sinumerik\\hmi\\lng\\"; private static readonly string AXES_FILE_PATH = AppDomain.CurrentDomain.BaseDirectory + "\\Config\\axesConfig.xml"; @@ -424,6 +425,9 @@ namespace CMS_CORE_Library.Siemens Array.Clear(toolsStrings, 0, toolsStrings.Count()); + itemToRead = new Item("/NC/_N_CH_TEA_ACX/$MCS_TM_FUNCTION_MASK"); + dataSvc.Read(itemToRead); + BALLUF_OPTION_IS_ACTIVE = Convert.ToInt32(itemToRead.Value) == 0x30D ? false : true; //// Subscribe to multitools number //DataSvc d = new DataSvc(); //Item i = new Item() { Path = "/Tool/MTCatalogue/numMultiTools[u1]" }; @@ -3760,6 +3764,8 @@ namespace CMS_CORE_Library.Siemens config.MagazinePosConfiguration = SiemensMagazinePosFieldsConfig; config.EdgesConfiguration = SiemensEdgesFieldsConfiguration; + config.SiemensBallufOption = BALLUF_OPTION_IS_ACTIVE; + config.EdgesConfiguration.EdgesAdditionalParamsConfiguration = new Dictionary>(); // Remove path and set only names as additionalParams foreach (int key in Add_Edges_Param_Config.EdgesConfig.Keys) @@ -4816,26 +4822,26 @@ namespace CMS_CORE_Library.Siemens { items.AddRange(new List() { - new Item() { Path = string.Format("DB{0}.DBD186", BALLUF_EMPTY_TABLE.Address), Value = edge.ResidualLife }, // MOP2 - new Item() { Path = string.Format("DB{0}.DBD194", BALLUF_EMPTY_TABLE.Address), Value = edge.NominalLife }, // MOP11 - new Item() { Path = string.Format("DB{0}.DBD182", BALLUF_EMPTY_TABLE.Address), Value = edge.PreAlmLife } // MOP1 + new Item() { Path = string.Format("DB{0}.DBD186", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.ResidualLife) }, // MOP2 + new Item() { Path = string.Format("DB{0}.DBD194", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.NominalLife) }, // MOP11 + new Item() { Path = string.Format("DB{0}.DBD182", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.PreAlmLife) } // MOP1 }); } break; case SIEMENS_LIFE_TYPE.COUNT: { - items.Add(new Item() { Path = string.Format("DB{0}.DBW192", BALLUF_EMPTY_TABLE.Address), Value = edge.ResidualLife }); // MOP4 - items.Add(new Item() { Path = string.Format("DB{0}.DBW198", BALLUF_EMPTY_TABLE.Address), Value = edge.NominalLife }); // MOP13 - items.Add(new Item() { Path = string.Format("DB{0}.DBW190", BALLUF_EMPTY_TABLE.Address), Value = edge.PreAlmLife }); // MOP3 + items.Add(new Item() { Path = string.Format("DB{0}.DBW192", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.ResidualLife) }); // MOP4 + items.Add(new Item() { Path = string.Format("DB{0}.DBW198", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.NominalLife) }); // MOP13 + items.Add(new Item() { Path = string.Format("DB{0}.DBW190", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.PreAlmLife) }); // MOP3 } break; case SIEMENS_LIFE_TYPE.WEAR: { - items.Add(new Item() { Path = string.Format("DB{0}.DBD204", BALLUF_EMPTY_TABLE.Address), Value = edge.ResidualLife }); // MOP6 - items.Add(new Item() { Path = string.Format("DB{0}.DBD208", BALLUF_EMPTY_TABLE.Address), Value = edge.NominalLife }); // MOP15 - items.Add(new Item() { Path = string.Format("DB{0}.DBD200", BALLUF_EMPTY_TABLE.Address), Value = edge.PreAlmLife }); // MOP5 + items.Add(new Item() { Path = string.Format("DB{0}.DBD204", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.ResidualLife) }); // MOP6 + items.Add(new Item() { Path = string.Format("DB{0}.DBD208", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.NominalLife) }); // MOP15 + items.Add(new Item() { Path = string.Format("DB{0}.DBD200", BALLUF_EMPTY_TABLE.Address), Value = GetSiemensFormattedDouble(edge.PreAlmLife) }); // MOP5 } break; } @@ -4864,6 +4870,27 @@ namespace CMS_CORE_Library.Siemens return WBallufAction(SIEMENS_TDI_ACTION.ABORT); } + public override CmsError TOOLS_WClearBallufTablet(ushort magazineId, ushort positionId, ushort toolId) + { + var mountedTool = MagazineMountedTools.Where(x => x.ToolId == toolId).FirstOrDefault(); + if (mountedTool == null || (mountedTool.ToolId != toolId && mountedTool.PositionId != positionId)) + return INCORRECT_PARAMETERS_ERROR; + + List words = new List() + { + (ushort)(((int)SIEMENS_TDI_ACTION.UNLOAD << 8) + positionId), + magazineId, + toolId + }; + + CmsError cmsError = MEM_RWWordList(W, 1, BALLUF_ACTION_DATA.MemType, BALLUF_ACTION_DATA.Address, BALLUF_ACTION_DATA.SubAddress, 2, ref words); + if (cmsError.IsError()) + return cmsError; + + return WBallufAction(SIEMENS_TDI_ACTION.DELETE_TABLET); + } + + private CmsError WBallufAction(SIEMENS_TDI_ACTION action) { byte act = (byte)action;