fix scompattamento memorie lette x ACK/STROBES...

This commit is contained in:
Samuele E. Locatelli
2017-03-27 10:46:58 +02:00
parent 087efa1bc2
commit ee2c552ed9
+29 -15
View File
@@ -194,10 +194,8 @@ namespace MTC_Adapter
tryConnect();
lg.Info("End init Adapter OSAI");
// !!!CHECK!!! aggiunto banco ack/strobe del 2 processo IN CODA... 5DW!!!
// !!!HARD CODED!!! aggiunto banco STATUS del 2 processo IN CODA... (4+1)DW=20byte x strobes...!!!
Strobes = new byte[20];
Acknowl = new byte[20];
}
/// <summary>
/// Override disconnessione
@@ -277,19 +275,36 @@ namespace MTC_Adapter
base.getStrobeAndAckStatus();
if (connectionOk)
{
int numByte = Acknowl.Length + Strobes.Length;
// leggo TUTTO ack e strobe...
ushort[] MemBlock_W = new ushort[numByte / 2];
int memIndex = 19018;
// leggo TUTTO ack e strobe... in blocco di 16 WORD (32 byte) + altre 2 in coda...
ushort[] MemBlock_A = new ushort[16];
ushort[] MemBlock_B = new ushort[2];
// LEGGO a WORD 16bit (+ veloce...)
int memIndexA = 19018;
int memIndexB = 19698;
// LEGGO SEMPRE a WORD 16bit (+ veloce...)
// leggo blocco dati + grande...
inizio = DateTime.Now;
OsaiMemRW_Word(R, OSAI.MemTypeWord.MW_CODE, memIndex, ref MemBlock_W);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R-{0}-WW", MemBlock_W.Length * 2), DateTime.Now.Subtract(inizio).Ticks);
OsaiMemRW_Word(R, OSAI.MemTypeWord.MW_CODE, memIndexA, ref MemBlock_A);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R-{0}-W4", MemBlock_A.Length * 2), DateTime.Now.Subtract(inizio).Ticks);
// suddivido!
Buffer.BlockCopy(MemBlock_W, 0, Acknowl, 0, Acknowl.Length);
Buffer.BlockCopy(MemBlock_W, Acknowl.Length, Strobes, 0, Strobes.Length);
// leggo blocco dati + piccolo
inizio = DateTime.Now;
OsaiMemRW_Word(R, OSAI.MemTypeWord.MW_CODE, memIndexB, ref MemBlock_B);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R-{0}-W1", MemBlock_B.Length * 2), DateTime.Now.Subtract(inizio).Ticks);
// suddivido blocco a blocco... da file di conf x OSAI!!!
//Buffer.BlockCopy(MemBlock_A, 0, Acknowl, 0, Acknowl.Length);
//Buffer.BlockCopy(MemBlock_A, Acknowl.Length, Strobes, 0, Strobes.Length);
// primi 12 byte ad ACK
Buffer.BlockCopy(MemBlock_A, 0, Acknowl, 0, Acknowl.Length - 4);
// altri 4 byte ad ACK blocco secondario
Buffer.BlockCopy(MemBlock_B, 0, Acknowl, Acknowl.Length - 4, 4);
// tutti i 16+4 byte a strobe/status
Buffer.BlockCopy(MemBlock_A, Acknowl.Length - 4, Strobes, 0, Strobes.Length);
}
else
{
@@ -304,8 +319,7 @@ namespace MTC_Adapter
{
base.processStrobe();
// gestione multipath: inizializzo al primo (poi verifico da config SE ci sia il secondo...)
// cicl su path
// gestione multipath: ciclo
for (int i = 1; i <= currAdpConf.nPath; i++)
{
processPath(i);