From 60347a55bec06d08e6bbd94e736b9fb102cb2ad3 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Tue, 9 Jan 2018 07:46:10 +0000 Subject: [PATCH] Fixed Osai-Messages Reading --- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 16 +++++++--------- CMS_CORE_Library/Nc.cs | 15 ++++++++++----- CMS_CORE_Library/Osai/Nc_Osai.cs | 6 +++--- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 10 +++++----- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 53fe6c9..e19fa04 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -104,15 +104,13 @@ namespace CMS_CORE.Fanuc public override void NC_Disconnect() { short nReturn; - - //Check if the NC is Connected - CheckConnection(); - - //If is connected -> Disconncet - foreach (ushort handle in nLibHandle) - { - nReturn = Focas1.cnc_freelibhndl(handle); - } + + if(Connected) + //If is connected -> Disconncet + foreach (ushort handle in nLibHandle) + { + nReturn = Focas1.cnc_freelibhndl(handle); + } //Setup the "Connected" value to FALSE Connected = false; diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 2289c41..842b8c8 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1163,23 +1163,28 @@ namespace CMS_CORE public readonly MEMORY_Type MemType; public readonly int Address; public readonly int SubAddress; //Only for Siemens + public readonly int Size; - public MEMORY_Cell(MEMORY_Type MType, int Addr, int SubAddr) + public MEMORY_Cell(MEMORY_Type MType, int Addr, int SubAddr,int Sz) { MemType = MType; Address = Addr; SubAddress = SubAddr; + Size = Sz; } } //Lingua CN - internal MEMORY_Cell PARAM_LING_FANUC = new MEMORY_Cell(MEMORY_Type.Null, 3281, 0); + internal MEMORY_Cell PARAM_LING_FANUC = new MEMORY_Cell(MEMORY_Type.Null, 3281, 0, 1); //Matricola Macchina - internal MEMORY_Cell MATR_MACCH_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW , 3403, 0); - internal MEMORY_Cell MATR_MACCH_FANUC = new MEMORY_Cell(MEMORY_Type.Fanuc_D , 4018, 0); - internal MEMORY_Cell MATR_MACCH_SIEMENS = new MEMORY_Cell(MEMORY_Type.Siemens_DB, 255 , 0); + internal MEMORY_Cell MATR_MACCH_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW , 3403, 0, 1); + internal MEMORY_Cell MATR_MACCH_FANUC = new MEMORY_Cell(MEMORY_Type.Fanuc_D , 4018, 0, 1); + internal MEMORY_Cell MATR_MACCH_SIEMENS = new MEMORY_Cell(MEMORY_Type.Siemens_DB, 255 , 0, 1); + + //Messaggi PLC + internal MEMORY_Cell PLC_MESS_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW, 12000, 0, 64); #endregion diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index d43851f..13bef94 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -240,7 +240,7 @@ namespace CMS_CORE.Osai CheckConnection(); //Execute the method - MEM_RWWordList(R, 0, MEMORY_Type.Osai_MW, 12000, 47, ref lista); + MEM_RWWordList(R, 0, PLC_MESS_OSAI.MemType, PLC_MESS_OSAI.Address, PLC_MESS_OSAI.Size, ref lista); //Elaborates the Messages for (int i=0; i Axes) { - throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC"); + Axes.Clear(); } @@ -389,7 +389,7 @@ namespace CMS_CORE.Siemens //Get a dictionary with the Machine position of the axes in Process public override void AXES_RMachinePosition(ushort ProcNumber, ref Dictionary Axes) { - throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC"); + Axes.Clear(); } @@ -397,7 +397,7 @@ namespace CMS_CORE.Siemens //Get a dictionary with the Programmed position of the axes in Process public override void AXES_RProgrPosition(ushort ProcNumber, ref Dictionary Axes) { - throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC"); + Axes.Clear(); } @@ -405,7 +405,7 @@ namespace CMS_CORE.Siemens //Get a dictionary with the Following Error of the axes in Process public override void AXES_RFollowingError(ushort ProcNumber, ref Dictionary Axes) { - throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC"); + Axes.Clear(); } @@ -413,7 +413,7 @@ namespace CMS_CORE.Siemens //Get a dictionary with the Distance To Go of the axes in Process public override void AXES_RDistanceToGo(ushort ProcNumber, ref Dictionary Axes) { - throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC"); + Axes.Clear(); } #endregion