diff --git a/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs b/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs index cf685de..d16885b 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs @@ -147,6 +147,32 @@ namespace MTC_Adapter parentForm.commPlcActive = false; return answ; } + /// + /// wrapper chiamata lettura/scrittura MULTI Float... + /// + /// + /// main address (1499/1500) + /// + /// + /// + public bool SIEMENSMemRW_Float(bool bWrite, int MemType, Int32 memIndex, ref float[] Value) + { + bool answ = false; + if (SIEMENS_ref.Connected) + { + try + { + parentForm.commPlcActive = true; + answ = SIEMENS_ref.S_RW_Real(bWrite, MemType, memIndex, ref Value); + } + catch (Exception exc) + { + lg.Error(string.Format("Eccezione in SIEMENSMemRW_DWord: {0}{1}", Environment.NewLine, exc)); + } + } + parentForm.commPlcActive = false; + return answ; + } /// /// struttura dati SIEMENS x ALL DYN DATA @@ -391,7 +417,7 @@ namespace MTC_Adapter if (utils.CRB("readAllTop")) { // copio la memoria allarmi dalla memoria top... - Buffer.BlockCopy(MemBlockTop, memIndexMST, MemBlock_MST, 0, MemBlock_MST.Length ); + Buffer.BlockCopy(MemBlockTop, memIndexMST, MemBlock_MST, 0, MemBlock_MST.Length); } else { @@ -976,9 +1002,13 @@ namespace MTC_Adapter // leggo le posizioni SINO ai 16 assi permessi... int memIndex = 0; - // leggo TUTTI i primi 284 byte... inizio = DateTime.Now; - SIEMENSMemRW_DWord(R, baseMemAx, memIndex, ref axisPosData); + + // !!!FARE!!! leggere un MACRO blocco di dati (multi) x dati assi.... + + // MODIFICA: leggo float direttamente x posizione assi... + float[] axisPosFloat = new float[axisPosData.Length]; + SIEMENSMemRW_Float(R, baseMemAx, memIndex, ref axisPosFloat); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-AXIS_POS", MemBlockTop.Length), DateTime.Now.Subtract(inizio).Ticks); for (int i = 0; i < currAdpConf.nAxis; i++) @@ -986,8 +1016,8 @@ namespace MTC_Adapter // per sicurezza try-catch try { - // popolo valori... ipotesi CENTESIMI di mm... - newPos = axisPosData[i] / 100; + // popolo valori... ipotesi MILLESIMI di mm... CONVERSIONE BigEndianness + newPos = axisPosFloat[i];// axisPosData[i] / 1000; // manca LOAD assi #if false