From e77dd7b293d046594d8ec7598d1292cc3f3fcbe8 Mon Sep 17 00:00:00 2001 From: luciomaranta Date: Fri, 5 Jun 2020 13:03:26 +0200 Subject: [PATCH] Fix writing empty tablet status code Changed axes "IsSelectable" bit to "IsVisible" --- CMS_CORE_Library/Demo/Nc_Demo.cs | 2 +- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 29 +++++++++++++-------- CMS_CORE_Library/Models/DataStructures.cs | 2 +- CMS_CORE_Library/Nc.cs | 2 +- CMS_CORE_Library/Osai/Nc_Osai.cs | 29 +++++++++++---------- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 31 +++++++++++++++-------- 6 files changed, 57 insertions(+), 38 deletions(-) diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index c84a605..c0a5a5b 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -932,7 +932,7 @@ namespace CMS_CORE_Library.Demo return NO_ERROR; } - public override CmsError PLC_RM157Data(ref List value) + public override CmsError PLC_RM157Data(ref List value) { return NO_ERROR; } diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index f1b1c63..aa5e461 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1146,7 +1146,7 @@ namespace CMS_CORE_Library.Fanuc return PLC_WStrobe(M156_INPUT_ACK, M156_INPUT_STROBE, (uint)process); } - public override CmsError PLC_RM157Data(ref List value) + public override CmsError PLC_RM157Data(ref List value) { return NO_ERROR; } @@ -2363,18 +2363,27 @@ namespace CMS_CORE_Library.Fanuc if (cmsError.IsError()) return cmsError; - // Parse the data readed from PLC - foreach (byte id in ids) + // Remove not visible axes + axesData = axesData.Where(x => ids.Contains((byte)x.Id)).ToList(); + + // Set to true (old compatibility) + foreach (var axis in axesData) { - if (id != 0) - { - // If axis exists, set it as selectable - var tmpAxis = axesData.Where(x => x.Id == id).FirstOrDefault(); - if (tmpAxis != null) - tmpAxis.IsSelectable = true; - } + axis.IsSelectable = true; } + //// Parse the data readed from PLC + //foreach (byte id in ids) + //{ + // if (id != 0) + // { + // // If axis exists, set it as selectable + // var tmpAxis = axesData.Where(x => x.Id == id).FirstOrDefault(); + // if (tmpAxis != null) + // tmpAxis.IsSelectable = true; + // } + //} + return NO_ERROR; } diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index 764032d..ea484d1 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -330,7 +330,7 @@ namespace CMS_CORE_Library.Models public double Value; } - public class M157InputModel + public class M157DataModel { public uint Process; public ushort Timer; diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 66f62d6..5947215 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -583,7 +583,7 @@ namespace CMS_CORE_Library public abstract CmsError PLC_WM156Response(int process, double responseVal); - public abstract CmsError PLC_RM157Data(ref List value); + public abstract CmsError PLC_RM157Data(ref List value); public abstract CmsError PLC_WM157Timer(int process, ushort timerVal); diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index c266791..abf1807 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1146,7 +1146,7 @@ namespace CMS_CORE_Library.Osai - public override CmsError PLC_RM157Data(ref List value) + public override CmsError PLC_RM157Data(ref List value) { byte dataAreNeeded = 0; CmsError cmsError = MEM_RWByte(R, 0, M157_INPUT_NEEDED.MemType, M157_INPUT_NEEDED.Address, 0, ref dataAreNeeded); @@ -1172,18 +1172,18 @@ namespace CMS_CORE_Library.Osai // check if modal to choose date has to be shown if (dataNeededArray[processId - 1]) { - value.Add(new M157InputModel() + value.Add(new M157DataModel() { Process = (uint)processId, TimerInputNeeded = true, CountdownIsActive = false, Timer = 0 - }); ; + }); } else if (countdownActiveNeeded[processId - 1]) { // check if timeout modal has to be shown - value.Add(new M157InputModel() + value.Add(new M157DataModel() { Process = (uint)processId, TimerInputNeeded = false, @@ -1199,7 +1199,7 @@ namespace CMS_CORE_Library.Osai public override CmsError PLC_WM157Timer(int process, ushort timerVal) { - CmsError cmsError = MEM_RWWord(W, 0, MEMORY_TYPE.Osai_GD, M156_RESPONSE_MEMORY + (process - 1), ref timerVal); + CmsError cmsError = MEM_RWWord(W, 0, M157_TIMER.MemType, M157_TIMER.Address + (process - 1), ref timerVal); if (cmsError.IsError()) return cmsError; @@ -2461,13 +2461,14 @@ namespace CMS_CORE_Library.Osai if ((charName < 'a' || charName > 'z') && charName != 'S' && charName != '\0' && axesProcess[i] == process) { var isVisible = ids.Where(x => x == i + 1)?.FirstOrDefault() == 0 ? false : true; - // Add to returned value - axesData.Add(new AxisModel() - { - Id = i + 1, - Name = charName.ToString(), - IsSelectable = true - }); + if(isVisible) + // Add to returned value + axesData.Add(new AxisModel() + { + Id = i + 1, + Name = charName.ToString(), + IsSelectable = true + }); } } @@ -5153,8 +5154,8 @@ namespace CMS_CORE_Library.Osai internal static MEMORY_CELL M157_INPUT_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4343, 1); internal static MEMORY_CELL M157_INPUT_COUNTDOWN_ACTIVE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4345, 1); internal static MEMORY_CELL M157_INPUT_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4347, 1); - internal static MEMORY_CELL M157_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4337, 1); - internal static MEMORY_CELL M157_TIMER = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4338, 8); + internal static MEMORY_CELL M157_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4349, 1); + internal static MEMORY_CELL M157_TIMER = new MEMORY_CELL(MEMORY_TYPE.Osai_GW, 310, 8); internal static int M156_RESPONSE_MEMORY = 910; diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 4f5660b..a91f3c7 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1573,7 +1573,7 @@ namespace CMS_CORE_Library.Siemens return PLC_WStrobe(M156_INPUT_ACK, M156_INPUT_STROBE, (uint)process); } - public override CmsError PLC_RM157Data(ref List value) + public override CmsError PLC_RM157Data(ref List value) { return NO_ERROR; } @@ -2750,18 +2750,27 @@ namespace CMS_CORE_Library.Siemens if (cmsError.IsError()) return cmsError; - // Parse the data readed from PLC - foreach (byte id in ids) + // Remove not visible axes + axesData = axesData.Where(x => ids.Contains((byte)x.Id)).ToList(); + + // Set to true (old compatibility) + foreach (var axis in axesData) { - if (id != 0) - { - // If axis exists, set it as selectable - var tmpAxis = AxesData.Where(x => x.Id == id).FirstOrDefault(); - if (tmpAxis != null) - tmpAxis.IsSelectable = true; - } + axis.IsSelectable = true; } + //// Parse the data readed from PLC + //foreach (byte id in ids) + //{ + // if (id != 0) + // { + // // If axis exists, set it as selectable + // var tmpAxis = AxesData.Where(x => x.Id == id).FirstOrDefault(); + // if (tmpAxis != null) + // tmpAxis.IsSelectable = true; + // } + //} + axesData = AxesData; } catch (Exception ex) @@ -4835,7 +4844,7 @@ namespace CMS_CORE_Library.Siemens return ManageException(ex); } - return WBallufAction(SIEMENS_TDI_ACTION.ABORT); + return WBallufAction(SIEMENS_TDI_ACTION.NEW_DATA); } public override CmsError TOOLS_WAbortBallufTablet()