From adcb2da51da426462847edc7668888553e891676 Mon Sep 17 00:00:00 2001 From: luciomaranta Date: Thu, 11 Jun 2020 13:26:59 +0200 Subject: [PATCH] Fix siemens balluf -> double writing --- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index a91f3c7..8ff5202 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1521,6 +1521,7 @@ namespace CMS_CORE_Library.Siemens public override CmsError PLC_RM156Data(ref List value) { + return NO_ERROR; byte val = 0; List vals = new List(); CmsError cmsError = MEM_RWByte(R, 0, M156_INPUT_NEEDED.MemType, M156_INPUT_NEEDED.Address, M156_INPUT_NEEDED.SubAddress, 0, ref val); @@ -4762,6 +4763,9 @@ namespace CMS_CORE_Library.Siemens // Setup dimensions byte ( byte is formed by nibble => left_size right_size 0001 0001 ) ushort dimensions = (ushort)((((tool.LeftSize << 4) + tool.RightSize) << 8) + 17); // 17 = 0001 0001 -> + + var maxSpeed = GetSiemensFormattedDouble(tool.MaxSpeed); + DataSvc dataSvc = new DataSvc(); // Main data byte[] familyName = Encoding.ASCII.GetBytes(tool.FamilyName); @@ -4772,7 +4776,7 @@ namespace CMS_CORE_Library.Siemens new Item(){ Path = string.Format("DB{0}.DBW36", BALLUF_EMPTY_TABLE.Address), Value = tool.MagazinePositionType }, new Item(){ Path = string.Format("DB{0}.DBW38", BALLUF_EMPTY_TABLE.Address), Value = statusArray[0] }, new Item(){ Path = string.Format("DB{0}.DBW40", BALLUF_EMPTY_TABLE.Address), Value = (int)tool.LifeType }, - new Item(){ Path = string.Format("DB{0}.DBD42", BALLUF_EMPTY_TABLE.Address), Value = tool.MaxSpeed }, + new Item(){ Path = string.Format("DB{0}.DBD42", BALLUF_EMPTY_TABLE.Address), Value = maxSpeed}, new Item(){ Path = string.Format("DB{0}.DBD46", BALLUF_EMPTY_TABLE.Address), Value = tool.Load }, new Item(){ Path = string.Format("DB{0}.DBD50", BALLUF_EMPTY_TABLE.Address), Value = tool.Gamma }, new Item(){ Path = string.Format("DB{0}.DBD54", BALLUF_EMPTY_TABLE.Address), Value = tool.MaxLoadPctAutoload }, @@ -4797,9 +4801,10 @@ namespace CMS_CORE_Library.Siemens { if (edge.EdgeAdditionalParams.ContainsKey(conf.Name) && toolEdgesConfig.TDIEdgeFields.ContainsKey(conf.Path)) { + var formattedValue = GetSiemensFormattedDouble(edge.EdgeAdditionalParams[conf.Name]); items.Add(new Item() { Path = string.Format(toolEdgesConfig.TDIEdgeFields[conf.Path], BALLUF_EMPTY_TABLE.Address), - Value = edge.EdgeAdditionalParams[conf.Name] + Value = formattedValue }); } } @@ -4846,6 +4851,13 @@ namespace CMS_CORE_Library.Siemens return WBallufAction(SIEMENS_TDI_ACTION.NEW_DATA); } + + private uint GetSiemensFormattedDouble(double value) + { + var byteVal = BitConverter.GetBytes((Single)value); + + return BitConverter.ToUInt32(byteVal, 0); + } public override CmsError TOOLS_WAbortBallufTablet() {