From e52875fe56652b59c6aac825e546f3f6fa731696 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Tue, 23 Apr 2019 13:33:02 +0000 Subject: [PATCH] --- CMS_CORE_Application/Form1.cs | 6 ++++-- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 223938d..77f74ef 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -120,9 +120,11 @@ namespace CMS_CORE_Application sw.Restart(); SelectedProcessData selected = new SelectedProcessData(); - + double d = 0; + (N as Nc_Fanuc).ReadMacroValue(1, 955, true, ref d); //cmsError = N.PROC_RSelectedProcessData(1, ref selected); - + List m155 = new List(); + N.PLC_ROperatorInputIsNeeded(ref m155); //cmsError = N.PLC_WAssistedToolingCmd(1, 1, 1, 1, 1, ASSISTED_TOOLING_ACTION.UNLOAD); //AssistedToolingModel ass = new AssistedToolingModel(); //cmsError = N.PLC_RAssistedToolingData(ref ass); diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 57445f3..c0ea0f1 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -941,7 +941,7 @@ namespace CMS_CORE_Library.Fanuc MEMORY_CELL currentStrobeCell = sign == HEAD_OVERRIDE_SIGN.PLUS ? HEADS_STROBE_INCREMENT : HEADS_STROBE_DECREMENT; // Write strobe into memory - CmsError cmsError = PLC_WStrobe(HEADS_ACK, currentStrobeCell, id); + CmsError cmsError = PLC_WStrobe(HEADS_ACK, currentStrobeCell, id); if (cmsError.IsError()) return cmsError; @@ -1036,15 +1036,23 @@ namespace CMS_CORE_Library.Fanuc return NO_ERROR; } - private CmsError ReadMacroValue(int processId, int memIndex, bool isCustom, ref double val) + public CmsError ReadMacroValue(int processId, int memIndex, bool isCustom, ref double val) { - if (isCustom) + if (isCustom) { // Read custom machine variable - int num = 1; - short nReturn = Focas1.cnc_rdmacror2(nLibHandle[processId - 1], memIndex, ref num, val); + IODBMR readVal = new IODBMR() + { + datano_s = (short)memIndex, + datano_e = (short)(memIndex) + }; + // Fanuc standard length + short length = 8 + 8; + short nReturn = Focas1.cnc_rdmacror(nLibHandle[processId - 1], readVal.datano_s, readVal.datano_e, length, readVal); if (nReturn != 0) return GetNcError(nReturn); + + val = readVal.data.data1.mcr_val * Math.Pow(10, (-1 * readVal.data.data1.dec_val)); } else { @@ -3643,9 +3651,9 @@ namespace CMS_CORE_Library.Fanuc // return cmsError; // Set reload command - cmsError = PLC_WStrobe(TOOL_MANAGER_STATUS, TOOL_MANAGER_COMMAND, 1); - if (cmsError.IsError()) - return cmsError; + //cmsError = PLC_WStrobe(TOOL_MANAGER_STATUS, TOOL_MANAGER_COMMAND, 1); + //if (cmsError.IsError()) + // return cmsError; return NO_ERROR; }