diff --git a/MTC_Sim/MTC_Sim/AdapterESA.cs b/MTC_Sim/MTC_Sim/AdapterESA.cs index 7822425..ad86393 100644 --- a/MTC_Sim/MTC_Sim/AdapterESA.cs +++ b/MTC_Sim/MTC_Sim/AdapterESA.cs @@ -152,7 +152,7 @@ namespace MTC_Adapter // switch su run mode... /* - * MODO_X V[74].W + * MODO_X V[74].W --> byte (6) * 0 = Modo NESSUNO  * 1 = Modo MANUALE  * 2 = Modo AUTOMATICO  @@ -162,43 +162,35 @@ namespace MTC_Adapter * 6 = Modo RAP  * 7 = Modo TES * */ - - uint Modo_X = ncDevice.PLC_MemoryAreaV[6]; + uint Modo_X = ncDevice.PLC_MemoryAreaV_bytes[6]; switch (Modo_X) { + case 1: + vettPath[idxPath].mPathRunMode.Value = "EDIT"; + break; + case 2: + vettPath[idxPath].mPathRunMode.Value = "AUTO"; + break; + case 3: + vettPath[idxPath].mPathRunMode.Value = "REF"; + break; + case 4: + vettPath[idxPath].mPathRunMode.Value = "MDI"; + break; + case 5: + vettPath[idxPath].mPathRunMode.Value = "SEMIAUTO"; // JOG/JOGINC/HANDLE ? + break; + case 6: + vettPath[idxPath].mPathRunMode.Value = "RAP"; // JOG/JOGINC/HANDLE ? + break; + case 7: + vettPath[idxPath].mPathRunMode.Value = "TES"; // JOG/JOGINC/HANDLE ? + break; + case 0: default: + vettPath[idxPath].mPathRunMode.Value = "ND"; // JOG/JOGINC/HANDLE ? break; } -#if false - if (STRB_DW2.HasFlag(StFlag32.B01)) - { - vettPath[idxPath].mPathRunMode.Value = "AUTO"; - } - else if (STRB_DW2.HasFlag(StFlag32.B02)) - { - vettPath[idxPath].mPathRunMode.Value = "EDIT"; - } - else if (STRB_DW2.HasFlag(StFlag32.B03)) - { - vettPath[idxPath].mPathRunMode.Value = "MDI"; - } - else if (STRB_DW2.HasFlag(StFlag32.B04)) - { - vettPath[idxPath].mPathRunMode.Value = "REF"; - } - else if (STRB_DW2.HasFlag(StFlag32.B05)) - { - vettPath[idxPath].mPathRunMode.Value = "JOG"; - } - else if (STRB_DW2.HasFlag(StFlag32.B07)) - { - vettPath[idxPath].mPathRunMode.Value = "JOGINC"; - } - else if (STRB_DW2.HasFlag(StFlag32.B07)) - { - vettPath[idxPath].mPathRunMode.Value = "HANDLE"; - } -#endif } public override void getUnOp() diff --git a/MTC_Sim/SCMCncLib/thdNcEsaGvKvara.cs b/MTC_Sim/SCMCncLib/thdNcEsaGvKvara.cs index 9a93dcb..b37c973 100644 --- a/MTC_Sim/SCMCncLib/thdNcEsaGvKvara.cs +++ b/MTC_Sim/SCMCncLib/thdNcEsaGvKvara.cs @@ -50,12 +50,22 @@ namespace SCMCncLib private string VAreaAddressName; private TS_REG VAreaAddress; - + /// + /// Memorie a 4 byte (32 bit) + /// public UInt32[] PLC_MemoryRead; public UInt32[] PLC_MemoryWrite; + /// + /// memorie a 4 byte (32 bit) + /// public UInt32[] PLC_MemoryAreaV; public UInt32[] PLC_MemoryAreaETK; + /// + /// memorie a 1 byte (8 bit) + /// + public Byte[] PLC_MemoryAreaV_bytes; + public Byte[] PLC_MemoryAreaETK_bytes; // esa constants #region ESA_PLC_CONSTANTS @@ -145,10 +155,11 @@ namespace SCMCncLib // !!! 2016.05.25 inutile forse? riguarda l'engine 3d... - //hack: metto fisso... + //hack: metto fisso... OCCHIO son 4 byte... ReadNumber = 265; WriteNumber = 265; - WriteNumber = 265; + VAreaNumber = 8; + ETKAreaNumber = 8; #if false // store read and write number of bytes ReadNumber = Convert.ToUInt16(mwEngine.MemoryManager.NrByteToRead / 4); @@ -168,9 +179,13 @@ namespace SCMCncLib PLC_MemoryWrite = new UInt32[WriteNumber]; // create VArea buffer - PLC_MemoryAreaV = new UInt32[32]; + PLC_MemoryAreaV = new UInt32[VAreaNumber]; // create ETKArea buffer - PLC_MemoryAreaETK = new UInt32[32]; + PLC_MemoryAreaETK = new UInt32[ETKAreaNumber]; + // creo array duali in bytes... + PLC_MemoryAreaV_bytes = new Byte[4 * VAreaNumber]; + PLC_MemoryAreaETK_bytes = new Byte[4 * ETKAreaNumber]; + if (!Connect()) Disconnect(); @@ -311,6 +326,14 @@ namespace SCMCncLib // devo definire posizione memorie Vcome TS_REG iError = read_regbuffer(ref VAreaAddress, 68, 32, PLC_MemoryAreaV); + + // !!!FARE!!! leggere ETK + + // copio in array a byte... + Buffer.BlockCopy(PLC_MemoryAreaV, 0, PLC_MemoryAreaV_bytes, 0, 4 * VAreaNumber); + Buffer.BlockCopy(PLC_MemoryAreaETK, 0, PLC_MemoryAreaETK_bytes, 0, 4 * ETKAreaNumber); + + #if false // se tutto ok leggo anche buffer V if (iError == 0)