diff --git a/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs b/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs index 3c67dba..64f8bf4 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs @@ -241,7 +241,7 @@ namespace MTC_Adapter // check COD_S bitNum = 1; gestStrobeCodMST(bitNum, ref retACK_DW1, 11, MemBlock, "S"); - + // check COD_T bitNum = 2; gestStrobeCodMST(bitNum, ref retACK_DW1, 17, MemBlock, "T"); @@ -439,11 +439,11 @@ namespace MTC_Adapter // da rivedere: se sono N+1 file (N=path + generale) deve essere ad esempio nomeComune_*.mtc --> ciclo per leggerne N string fileName = string.Format(@"{0}\{1}", utils.dataDir, utils.CRS("GeneralStatusFilePath")); string linea; - totRighe = File.ReadLines(fileName).Count(); // creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco... generalStatus = new Dictionary(); try { + totRighe = File.ReadLines(fileName).Count(); // carica da file... System.IO.StreamReader file = new System.IO.StreamReader(fileName); if (file != null) diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index cc999d9..95217ab 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -2401,7 +2401,14 @@ namespace MTC_Adapter /// private uint getStoredValUInt(string keyVal) { - return Convert.ToUInt32(getStoredVal(keyVal)); + uint answ = 0; + try + { + answ = Convert.ToUInt32(getStoredVal(keyVal)); + } + catch + { } + return answ; } /// /// recupera valore salvato in persistence layer (se non c'è crea...) come INT @@ -2410,7 +2417,14 @@ namespace MTC_Adapter /// private long getStoredValLong(string keyVal) { - return Convert.ToInt64(getStoredVal(keyVal)); + long answ = 0; + try + { + answ = Convert.ToInt64(getStoredVal(keyVal)); + } + catch + { } + return answ; } /// /// recupera valore salvato in persistence layer (se non c'è crea...) come double @@ -2419,7 +2433,14 @@ namespace MTC_Adapter /// private double getStoredValDouble(string keyVal) { - return Convert.ToDouble(getStoredVal(keyVal)); + double answ = 0; + try + { + answ = Convert.ToDouble(getStoredVal(keyVal)); + } + catch + { } + return answ; } /// diff --git a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs index afd04dc..a2670b1 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs @@ -194,12 +194,14 @@ namespace MTC_Adapter tryConnect(); lg.Info("End init Adapter OSAI"); - // !!!FARE!!! per ora aggiunto banco ack/strobe del 2 processo IN CODA... 5DW!!! + // !!!CHECK!!! aggiunto banco ack/strobe del 2 processo IN CODA... 5DW!!! Strobes = new byte[20]; Acknowl = new byte[20]; } - + /// + /// Override disconnessione + /// public override void tryDisconnect() { if (connectionOk) @@ -222,7 +224,9 @@ namespace MTC_Adapter lg.Error("IMPOSSIBILE effettuare disconnessione: Connessione non disponibile..."); } } - + /// + /// OVerride connessione + /// public override void tryConnect() { if (!connectionOk) @@ -254,7 +258,6 @@ namespace MTC_Adapter } } } - /// /// Verifico connessione OSAI... /// @@ -266,7 +269,6 @@ namespace MTC_Adapter return OSAI_ref.Connected; } } - /// /// Effettuo lettura dei 16 byte di strobe/status /// @@ -275,14 +277,14 @@ namespace MTC_Adapter base.getStrobeAndAckStatus(); if (connectionOk) { - int numByte = Acknowl.Length+Strobes.Length; + int numByte = Acknowl.Length + Strobes.Length; // leggo TUTTO ack e strobe, - uint[] MemBlock_DW = new uint[numByte/4]; - ushort[] MemBlock_W = new ushort[numByte/2]; + uint[] MemBlock_DW = new uint[numByte / 4]; + ushort[] MemBlock_W = new ushort[numByte / 2]; byte[] MemBlock = new byte[numByte]; int memIndex = 19018; - // !!!FARE!!! verifica tipo memoria + // !!!CHECK!!! test tempo lettura x tipo memoria inizio = DateTime.Now; OsaiMemRW_DWord(R, OSAI.MemTypeWord.MW_CODE, memIndex, ref MemBlock_DW); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R-{0}-DW", MemBlock_DW.Length * 32), DateTime.Now.Subtract(inizio).Ticks); @@ -294,7 +296,7 @@ namespace MTC_Adapter inizio = DateTime.Now; OsaiMemRW_Byte(R, OSAI.MemTypeWord.MW_CODE, memIndex, 0, ref MemBlock); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R-{0}-BYTE", MemBlock.Length * 8), DateTime.Now.Subtract(inizio).Ticks); - + // suddivido! Buffer.BlockCopy(MemBlock, 0, Acknowl, 0, Acknowl.Length); Buffer.BlockCopy(MemBlock, Acknowl.Length, Strobes, 0, Strobes.Length); @@ -550,11 +552,11 @@ namespace MTC_Adapter // da rivedere: se sono N+1 file (N=path + generale) deve essere ad esempio nomeComune_*.mtc --> ciclo per leggerne N string fileName = string.Format(@"{0}\{1}", utils.dataDir, utils.CRS("GeneralStatusFilePath")); string linea; - totRighe = File.ReadLines(fileName).Count(); // creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco... generalStatus = new Dictionary(); try { + totRighe = File.ReadLines(fileName).Count(); // carica da file... System.IO.StreamReader file = new System.IO.StreamReader(fileName); if (file != null) @@ -798,6 +800,7 @@ namespace MTC_Adapter // HARD CODE: forzo path 1 (indice 0...) int idxPath = 0; + // switch su run mode... if (STRB_DW2.HasFlag(StFlag32.B01)) { @@ -912,7 +915,7 @@ namespace MTC_Adapter { // INVIO SEMPRE (x prendere il reset/fronte discesa)... vettPath[idxPath].mPathSubMode.Value = SubMode.Trim(); - } + } } public override void getConfigParam()