diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 6eba5a3..d5c3350 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -119,6 +119,8 @@ namespace CMS_CORE_Application Stopwatch st = new Stopwatch(); sw.Restart(); N.NC_Connect(); + Dictionary b = new Dictionary(); + N.AXES_RInterpPosition(1, ref b); List ints = new List(); N.MEM_RWIntegerList(false, 1, Nc.MEMORY_TYPE.Siemens_DB, 258, 0, 256, ref ints); diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 7501bf6..0fca71f 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1960,7 +1960,6 @@ namespace CMS_CORE_Library.Osai nReturn = OpenNC.GetAxesPosition(process, 0, OSAI_INTERPOLPOS, ref nAxis, out GETINTDATAC4array Pos, out uint errorClass, out uint errorNum); - // if (errorClass != 0 || errorNum != 0 || nReturn == 0) return GetNCError(errorClass, errorNum); @@ -2265,13 +2264,19 @@ namespace CMS_CORE_Library.Osai axesData.Clear(); - ushort nReturn, axesNumber = 64; + ushort nReturn, axesNumber = 20; //Try to get information try { - // Read axes info from NC - nReturn = OpenNC.GetAxesInfo3(ushort.MaxValue, ref axesNumber, out unsignedshortarray axesProcess, out byte[] axesName, out unsignedshortarray axesType, out unsignedshortarray axesInterface, out uint errorClass, out uint errorNum); + //nReturn = OpenNC.GetAxesInfo3(ushort.MaxValue, ref axesNumber, out unsignedshortarray axesProcess, out byte[] axesName, out unsignedshortarray axesType, out unsignedshortarray axesInterface, out uint errorClass, out uint errorNum); + //if (errorClass != 0 || errorNum != 0 || nReturn == 0) + // return GetNCError(errorClass, errorNum); + + // Read axes info from NC (use GetAxesPosition because GetAxesInfo3 returns useless data and axes order is not coerent with OsaiBootController) + nReturn = OpenNC.GetAxesPosition(process, 0, OSAI_INTERPOLPOS, ref axesNumber, out GETINTDATAC4array axesName, out uint errorClass, out uint errorNum); + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); // Get from PLC which axis can be selected List ids = new List(); @@ -2284,9 +2289,9 @@ namespace CMS_CORE_Library.Osai for (int i = 0; i < axesNumber; i++) { - var charName = Convert.ToChar(axesName[i]); + var charName = Convert.ToChar(axesName[i].AxisName); // Filter per master axes and process - if ((charName < 'a' || charName > 'z') && charName != 'S' && charName != '\0' && axesProcess[i] == process) + if ((charName < 'a' || charName > 'z') && charName != 'S' && charName != '\0') { // Add to returned value axesData.Add(new AxisModel() diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 979500d..f063130 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1663,7 +1663,7 @@ namespace CMS_CORE_Library.Siemens if (!ok) { // Reset strobe - cmsError = MEM_RWBoolean(W, 0, memType, strobeByte, bitId, ref writeValue); + cmsError = MEM_RWBoolean(W, 0, memType, TABLE, strobeByte, bitId, ref writeValue); if (cmsError.IsError()) return cmsError; } @@ -4476,7 +4476,7 @@ namespace CMS_CORE_Library.Siemens ushort dimensions = (ushort)(((tool.LeftSize << 4) + tool.RightSize) << 8); DataSvc dataSvc = new DataSvc(); // Data - Item[] items = new Item[] { + List items = new List { new Item(){ Path = string.Format("DB{0}.DBB10", BALLUF_EMPTY_TABLE.Address), Value = 0 }, new Item(){ Path = string.Format("DB{0}.DBB12", BALLUF_EMPTY_TABLE.Address), Value = 0 }, new Item(){ Path = string.Format("DB{0}.DBW44", BALLUF_EMPTY_TABLE.Address), Value = dimensions }, @@ -4486,14 +4486,65 @@ namespace CMS_CORE_Library.Siemens new Item(){ Path = string.Format("DB{0}.DBW52", BALLUF_EMPTY_TABLE.Address), Value = tool.MaxSpeed }, new Item(){ Path = string.Format("DB{0}.DBD56", BALLUF_EMPTY_TABLE.Address), Value = tool.Load }, new Item(){ Path = string.Format("DB{0}.DBD60", BALLUF_EMPTY_TABLE.Address), Value = tool.Gamma }, + + // EDGE new Item(){ Path = string.Format("DB{0}.DBW96", BALLUF_EMPTY_TABLE.Address), Value = tool.ToolType }, new Item(){ Path = string.Format("DB{0}.DBW98", BALLUF_EMPTY_TABLE.Address), Value = 9 }, - new Item(){ Path = string.Format("DB{0}.DBW80", BALLUF_EMPTY_TABLE.Address), Value = 1} + new Item(){ Path = string.Format("DB{0}.DBW80", BALLUF_EMPTY_TABLE.Address), Value = 1}, }; + EdgeModel edge = tool.EdgesData[0]; + + SiemensEdgesConfiguration toolEdgesConfig = new SiemensEdgesConfiguration(); + // Get config for current tool type + List toolTypeConfig = toolEdgesConfig.EdgesConfig[tool.ToolType]; + // Set edge additional params, read by configuration + foreach (EdgeConfigModel conf in toolTypeConfig) + { + if (edge.EdgeAdditionalParams.ContainsKey(conf.Name)) + { + items.Add(new Item() { + Path = string.Format(toolEdgesConfig.TDIEdgeFields[conf.Path], BALLUF_EMPTY_TABLE.Address), + Value = edge.EdgeAdditionalParams[conf.Name] + }); + } + } + + + // Life Parameters + switch (tool.LifeType) + { + case SIEMENS_LIFE_TYPE.TIME: + { + items.AddRange(new List() + { + new Item() { Path = string.Format("DB{0}.DBD196", BALLUF_EMPTY_TABLE.Address), Value = edge.ResidualLife }, // MOP2 + new Item() { Path = string.Format("DB{0}.DBD204", BALLUF_EMPTY_TABLE.Address), Value = edge.NominalLife }, // MOP11 + new Item() { Path = string.Format("DB{0}.DBD192", BALLUF_EMPTY_TABLE.Address), Value = edge.PreAlmLife } // MOP1 + }); + } + break; + + case SIEMENS_LIFE_TYPE.COUNT: + { + items.Add(new Item() { Path = string.Format("DB{0}.DBW202", BALLUF_EMPTY_TABLE.Address), Value = edge.ResidualLife }); // MOP4 + items.Add(new Item() { Path = string.Format("DB{0}.DBW208", BALLUF_EMPTY_TABLE.Address), Value = edge.NominalLife }); // MOP13 + items.Add(new Item() { Path = string.Format("DB{0}.DBW200", BALLUF_EMPTY_TABLE.Address), Value = edge.PreAlmLife }); // MOP3 + } + break; + + case SIEMENS_LIFE_TYPE.WEAR: + { + items.Add(new Item() { Path = string.Format("DB{0}.DBD214", BALLUF_EMPTY_TABLE.Address), Value = edge.ResidualLife }); // MOP6 + items.Add(new Item() { Path = string.Format("DB{0}.DBD218", BALLUF_EMPTY_TABLE.Address), Value = edge.NominalLife }); // MOP15 + items.Add(new Item() { Path = string.Format("DB{0}.DBD210", BALLUF_EMPTY_TABLE.Address), Value = edge.PreAlmLife }); // MOP5 + } + break; + } + try { - dataSvc.Write(items); + //dataSvc.Write(items.ToArray()); } catch (Exception ex) { @@ -6044,7 +6095,7 @@ namespace CMS_CORE_Library.Siemens private void ActionsHandler(ToolInfo toolInfo) { - switch (toolInfo.action) + switch (toolInfo.action) { case ToolAction.TOOL_DELETED: { diff --git a/CMS_CORE_Library/Siemens/SiemensEdgesConfigurations.cs b/CMS_CORE_Library/Siemens/SiemensEdgesConfigurations.cs index ad21bd4..563be0f 100644 --- a/CMS_CORE_Library/Siemens/SiemensEdgesConfigurations.cs +++ b/CMS_CORE_Library/Siemens/SiemensEdgesConfigurations.cs @@ -446,5 +446,32 @@ namespace CMS_CORE_Library.Siemens } }, }; + + public Dictionary TDIEdgeFields = new Dictionary() + { + { "$TC_DP3[", "DB{0}.DBD100"}, + { "$TC_DP4[", "DB{0}.DBD104"}, + { "$TC_DP5[", "DB{0}.DBD108"}, + { "$TC_DP6[", "DB{0}.DBD112"}, + { "$TC_DP7[", "DB{0}.DBD116"}, + { "$TC_DP8[", "DB{0}.DBD120"}, + { "$TC_DP9[", "DB{0}.DBD124"}, + { "$TC_DP10[", "DB{0}.DBD128"}, + { "$TC_DP11[", "DB{0}.DBD132"}, + { "$TC_DP12[", "DB{0}.DBD136"}, + { "$TC_DP13[", "DB{0}.DBD140"}, + { "$TC_DP14[", "DB{0}.DBD144"}, + { "$TC_DP15[", "DB{0}.DBD148"}, + { "$TC_DP16[", "DB{0}.DBD152"}, + { "$TC_DP17[", "DB{0}.DBD156"}, + { "$TC_DP18[", "DB{0}.DBD160"}, + { "$TC_DP19[", "DB{0}.DBD164"}, + { "$TC_DP20[", "DB{0}.DBD168"}, + { "$TC_DP21[", "DB{0}.DBD172"}, + { "$TC_DP22[", "DB{0}.DBD176"}, + { "$TC_DP23[", "DB{0}.DBD180"}, + { "$TC_DP24[", "DB{0}.DBD184"}, + { "$TC_DP25[", "DB{0}.DBD188"}, + }; } } \ No newline at end of file