From cee2bcb72936ec2532ae6bb690f07591ed05bb89 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 17 Mar 2017 09:52:06 +0100 Subject: [PATCH] continuo bonifica aree V, allarmi (rimaste) e command... --- MTC_Adapter/MTC_Adapter/AdapterESA.cs | 129 +----------------- .../MTC_Adapter/DATA/CONF/EsaKvara.ini | 12 -- .../Resources/SCM/EsaKvara_PROD.ini | 12 -- .../Resources/SCM/EsaKvara_SIM.ini | 12 -- MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs | 39 +----- 5 files changed, 3 insertions(+), 201 deletions(-) diff --git a/MTC_Adapter/MTC_Adapter/AdapterESA.cs b/MTC_Adapter/MTC_Adapter/AdapterESA.cs index eaab4b8..5782286 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterESA.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterESA.cs @@ -834,33 +834,7 @@ namespace MTC_Adapter { lg.Error("Errore connessione mancante in getGlobalData"); } - - // dati override feed/speed... - Byte v82 = ncDevice.PLC_MemoryAreaV[14]; - Byte v83 = ncDevice.PLC_MemoryAreaV[15]; - // 2 byte x speed da copiare... - byte[] tmpByte = new byte[2]; - Buffer.BlockCopy(ncDevice.PLC_MemoryAreaV, 16, tmpByte, 0, 2); - short v84 = BitConverter.ToInt16(tmpByte, 0); - // lista allarmi PLC/CNC - Byte v87 = ncDevice.PLC_MemoryAreaV[19]; // Allarme CN (almeno 1?!?) - - // ------------------------------------------- - // recupero dati Feed/Speed/override - // FeedOver: 100% = 213 (il pannello è 0-120 --> 0-255, quindi 100% è 100/120*255=213) - FeedRateOver = Convert.ToInt16((decimal)(v82 * 100) / 213); - sb.AppendLine(string.Format("FeedRateOver: {0} %", FeedRateOver)); - // SpeedOver: 50% = 128 - SpeedRateOver = Convert.ToInt16((decimal)(v83 * 100) / 255); - sb.AppendLine(string.Format("SpeedRateOver: {0} %", SpeedRateOver)); - // Speed S5000 OK!!! - SpeedRate = v84; - sb.AppendLine(string.Format("SpeedRate: {0} rpm", SpeedRate)); - // ------------------------------------------- - - // da recuperare da qualche parte?!? - UnOpLoad = 0; - sb.AppendLine(string.Format("Load: {0}", UnOpLoad)); + // ------------------------------------------- bool needSave = false; @@ -888,10 +862,6 @@ namespace MTC_Adapter // salvo se necessario! if (needSave) parentForm.persistData(); // ------------------------------------------- - - - // copio allarmi in vettore generale AlarFlags (dove lo gestisce)... - Buffer.BlockCopy(ncDevice.PLC_MemoryAreaAllarmi, 0, AlarmFlags, 0, ncDevice.PLC_MemoryAreaAllarmi.Length); parentForm.dataMonitor = sb.ToString(); } @@ -1060,102 +1030,7 @@ namespace MTC_Adapter getAxis(); lg.Info("DONE processAllMemory"); } - - /// - /// Processo stti macchina... - /// - public override void processStatus() - { - - // HARD CODE: forzo path 1 (indice 0...) - int idxPath = 0; - // accodo dati path in DataMonitor...... - StringBuilder sb = new StringBuilder(); - - // verifica macchina accesa... - Byte V73 = ncDevice.PLC_MemoryAreaV[5]; - - if (((StFlag8)V73).HasFlag(StFlag8.B2)) - { - mPower.Value = "ON"; - } - else - { - mPower.Value = "OFF"; - } - - // switch su EXE mode... - /* - * MODO_X V[70/71] --> byte (2-3) - * V70.2 = Modo RUN  - * V70.3 = Modo FeedHold - * V71.5 = Ready - * */ - Byte V70 = ncDevice.PLC_MemoryAreaV[2]; - Byte V71 = ncDevice.PLC_MemoryAreaV[3]; - - if (((StFlag8)V70).HasFlag(StFlag8.B3)) - { - vettPath[idxPath].mPathExeMode.Value = "FEED_HOLD"; //"FEEDHOLD"; - } - else if (((StFlag8)V70).HasFlag(StFlag8.B2)) - { - vettPath[idxPath].mPathExeMode.Value = "ACTIVE"; - } - else if (((StFlag8)V71).HasFlag(StFlag8.B5)) - { - vettPath[idxPath].mPathExeMode.Value = "READY"; - } - //// appunto: modi da creare - //STOPPED/HOLD(da creare) - //INTERRUPTED(da creare) - //OPTIONAL_STOP(da creare) - //PROGRAM_STOPPED(da creare) - //PROGRAM_COMPLETED(da creare) - - - // switch su run mode... - /* - * MODO_X V[74].W --> byte (6) - * 0 = Modo NESSUNO  - * 1 = Modo MANUALE  - * 2 = Modo AUTOMATICO  - * 3 = Modo POM  - * 4 = Modo MDI  - * 5 = Modo SEMIAUTOMATICO  - * 6 = Modo RAP  - * 7 = Modo TES - * */ - uint V74 = ncDevice.PLC_MemoryAreaV[6]; - switch (V74) - { - case 1: - vettPath[idxPath].mPathRunMode.Value = "EDIT"; - break; - case 2: - vettPath[idxPath].mPathRunMode.Value = "AUTOMATIC"; - break; - case 3: - vettPath[idxPath].mPathRunMode.Value = "MANUAL"; - break; - case 4: - vettPath[idxPath].mPathRunMode.Value = "MANUAL_DATA_INPUT"; - break; - case 5: - vettPath[idxPath].mPathRunMode.Value = "SEMI_AUTOMATIC"; //"SEMIAUTO"; - break; - case 6: - vettPath[idxPath].mPathRunMode.Value = "MANUAL"; //"RAP"; - break; - case 7: - vettPath[idxPath].mPathRunMode.Value = "MANUAL"; //"TES"; - break; - case 0: - default: - vettPath[idxPath].mPathRunMode.Value = "NA"; - break; - } - } + /// /// Recupera la speed override x i mandrini (UnOp) /// diff --git a/MTC_Adapter/MTC_Adapter/DATA/CONF/EsaKvara.ini b/MTC_Adapter/MTC_Adapter/DATA/CONF/EsaKvara.ini index 15f91a7..fb1538a 100644 --- a/MTC_Adapter/MTC_Adapter/DATA/CONF/EsaKvara.ini +++ b/MTC_Adapter/MTC_Adapter/DATA/CONF/EsaKvara.ini @@ -53,18 +53,6 @@ StatusNumber=401 ; indirizzo di memoria del primo byte di scrittura dati CommandsAddress=SIMREAD[0] CommandsNumber=10 -; indirizzo di memoria AreaV -VAreaAddress=V -VAreaNumber=10 -; area EOK -EOKAreaAddress=EOK -EOKAreaNumber=10 -; area ETK -ETKAreaAddress=ETK -ETKAreaNumber=10 -; indirizzo di memoria AreaV -PlcErrAreaAddress=V -PlcErrAreaNumber=10 ; offset del registro per l'indice di collisione CollisionIndex=6.L ; ritardo nella lettura dal plc diff --git a/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_PROD.ini b/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_PROD.ini index 4297de2..ca0afb7 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_PROD.ini +++ b/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_PROD.ini @@ -53,18 +53,6 @@ StatusNumber=401 ; indirizzo di memoria del primo byte di scrittura dati CommandsAddress=SIMREAD[0] CommandsNumber=10 -; indirizzo di memoria AreaV -VAreaAddress=V -VAreaNumber=10 -; area EOK -EOKAreaAddress=EOK -EOKAreaNumber=10 -; area ETK -ETKAreaAddress=ETK -ETKAreaNumber=10 -; indirizzo di memoria AreaV -PlcErrAreaAddress=V -PlcErrAreaNumber=10 ; offset del registro per l'indice di collisione CollisionIndex=6.L ; ritardo nella lettura dal plc diff --git a/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_SIM.ini b/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_SIM.ini index 15f91a7..fb1538a 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_SIM.ini +++ b/MTC_Adapter/MTC_Adapter/Resources/SCM/EsaKvara_SIM.ini @@ -53,18 +53,6 @@ StatusNumber=401 ; indirizzo di memoria del primo byte di scrittura dati CommandsAddress=SIMREAD[0] CommandsNumber=10 -; indirizzo di memoria AreaV -VAreaAddress=V -VAreaNumber=10 -; area EOK -EOKAreaAddress=EOK -EOKAreaNumber=10 -; area ETK -ETKAreaAddress=ETK -ETKAreaNumber=10 -; indirizzo di memoria AreaV -PlcErrAreaAddress=V -PlcErrAreaNumber=10 ; offset del registro per l'indice di collisione CollisionIndex=6.L ; ritardo nella lettura dal plc diff --git a/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs b/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs index ec20da0..14a0512 100644 --- a/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs +++ b/MTC_Adapter/SCMCncLib/thdNcEsaGvKvara.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -//using System.Windows.Threading; using System.Threading; using System.Runtime.InteropServices; using System.Linq; @@ -33,7 +32,6 @@ namespace SCMCncLib { private UInt16 ReadNumber; private UInt16 WriteNumber; - private UInt16 AlarmByteSize; private UInt16 IOT_ByteAreaByteSize; private UInt16 IOT_WordAreaByteSize; @@ -53,10 +51,6 @@ namespace SCMCncLib private string CommandsAddressName; private TS_REG CommandsAddress; - private string PlcErrAreaAddressName; - private TS_REG PlcErrAreaAddress; - - private string IOT_ByteAreaAddressName; private TS_REG IOT_ByteAreaAddress; @@ -81,19 +75,6 @@ namespace SCMCncLib public UInt32[] PLC_MemoryRead; public UInt32[] PLC_MemoryWrite; - /// - /// Area Allarmi: memoria temp di UINT di 4 byte (32 bit) - /// - public UInt32[] PLC_MemAreaAlarm_tmp; - /// - /// memorie a 4 byte (32 bit) x area V (status e valori vari) - /// - public Byte[] PLC_MemoryAreaV; - /// - /// memorie a 1 byte (8 bit) x area Allarmi (V[300] - 256 bit) - /// - public Byte[] PLC_MemoryAreaAllarmi; - #region memorie IOT NUOVE /// @@ -210,7 +191,6 @@ namespace SCMCncLib ReadNumber = 265; WriteNumber = 265; - AlarmByteSize = 32; // nuove aree: da init mi passa le dimensioni delle memorie IOT_ByteAreaByteSize = Convert.ToUInt16(IAS_Byte); @@ -219,7 +199,6 @@ namespace SCMCncLib IOT_String_AreaByteSize = Convert.ToUInt16(IAS_String); CommandsAddressName = fIni.ReadString("NC", "CommandsAddress", "SIMREAD[0]"); - PlcErrAreaAddressName = fIni.ReadString("NC", "PlcErrAreaAddress", "V"); StatusAddressName = fIni.ReadString("NC", "StatusAddress", "SIMWRITE[0]"); // indirizzo area IOT... @@ -242,11 +221,6 @@ namespace SCMCncLib // creazione buffers a 32bit - PLC_MemAreaAlarm_tmp = new UInt32[(int)Math.Ceiling((decimal)AlarmByteSize / 4)]; - - // creo array duali in bytes... - PLC_MemoryAreaAllarmi = new Byte[AlarmByteSize]; - // creo array x aree memoria IOT... PLC_MemoryAreaIOT_Byte_tmp = new UInt32[(int)Math.Ceiling((decimal)IOT_ByteAreaByteSize / 4)]; PLC_MemoryAreaIOT_Byte = new Byte[IOT_ByteAreaByteSize]; @@ -385,18 +359,9 @@ namespace SCMCncLib /// public void ReadBuffer() { - // leggo da posizione memorie V/allarmi come TS_REG - iError = read_regbuffer(ref PlcErrAreaAddress, 300, AlarmByteSize, PLC_MemAreaAlarm_tmp); - + // lettura buffer dal CN iError = read_regbuffer(ref StatusAddress, 0, ReadNumber, PLC_MemoryRead); - - try - { - Buffer.BlockCopy(PLC_MemAreaAlarm_tmp, 0, PLC_MemoryAreaAllarmi, 0, AlarmByteSize); - } - catch - { } } /// @@ -411,8 +376,6 @@ namespace SCMCncLib // inizializzo i registri di lettura e scrittura if (iError == 0) iError = get_reg_by_name(CommandsAddressName, ref CommandsAddress); - if (iError == 0) - iError = get_reg_by_name(PlcErrAreaAddressName, ref PlcErrAreaAddress); if (iError == 0) iError = get_reg_by_name(StatusAddressName, ref StatusAddress);