modifica decodifica UT x gestione bigendianness

This commit is contained in:
Samuele E. Locatelli
2017-06-07 14:18:14 +02:00
parent 913242b2c1
commit 9a85d32099
+31 -7
View File
@@ -3622,12 +3622,12 @@ namespace MTC_Adapter
byte[] tabFam_FamUt = new byte[2 * maxMemAddr];
// altre variabili
int[] idUtMontato = new int[maxNumOp];
int[] idFamUt = new int[maxNumOp];
int[] idTipoVitaUt = new int[maxNumOp];
int[] valVitaUtRes = new int[maxNumOp];
int[] tabUt = new int[maxMemAddr];
int[] tabFamUt = new int[maxMemAddr];
ushort[] idUtMontato = new ushort[maxNumOp];
ushort[] idFamUt = new ushort[maxNumOp];
ushort[] idTipoVitaUt = new ushort[maxNumOp];
uint[] valVitaUtRes = new uint[maxNumOp];
ushort[] tabUt = new ushort[maxMemAddr];
ushort[] tabFamUt = new ushort[maxMemAddr];
int memIndex = 0;
byte[] int32Mem = new byte[4];
byte[] int16Mem = new byte[2];
@@ -3640,6 +3640,10 @@ namespace MTC_Adapter
for (int i = 0; i < maxNumOp; i++)
{
idUtMontato[i] = BitConverter.ToUInt16(elencoUtMem, 2 * i);
if (hasBigEndian)
{
idUtMontato[i] = Endian.SwapUInt16(idUtMontato[i]);
}
}
// step 2a: leggo vettore memoria dei maxMemAddr(200) UT in Tabella Utensili
@@ -3648,6 +3652,10 @@ namespace MTC_Adapter
for (int i = 0; i < maxMemAddr; i++)
{
tabUt[i] = BitConverter.ToUInt16(tabUt_UT, 2 * i);
if (hasBigEndian)
{
tabUt[i] = Endian.SwapUInt16(tabUt[i]);
}
}
// step 2b: devo cercare l'UT di ogni UnOp nella Tabella Utensili
for (int i = 0; i < maxNumOp; i++)
@@ -3664,6 +3672,10 @@ namespace MTC_Adapter
memIndex = getDatiUt_step2b(ref int16Mem, j);
// step 2b: leggo puntualmente la FamUt dal suo indice...
idFamUt[i] = BitConverter.ToUInt16(int16Mem, 0);
if (hasBigEndian)
{
idFamUt[i] = Endian.SwapUInt16(idFamUt[i]);
}
found = true;
}
}
@@ -3676,6 +3688,10 @@ namespace MTC_Adapter
for (int i = 0; i < maxMemAddr; i++)
{
tabFamUt[i] = BitConverter.ToUInt16(tabFam_FamUt, 2 * i);
if (hasBigEndian)
{
tabFamUt[i] = Endian.SwapUInt16(tabFamUt[i]);
}
}
// step 3b: devo cercare la famiglia dell'UT di ogni UnOp nella Tabella Famiglie
for (int i = 0; i < maxNumOp; i++)
@@ -3692,6 +3708,10 @@ namespace MTC_Adapter
memIndex = getDatiUt_step3b(ref int8Mem, j);
// step 3b: leggo puntualmente il TIPO DI vita UT dal suo indice...
idTipoVitaUt[i] = int8Mem;
if (hasBigEndian)
{
idTipoVitaUt[i] = Endian.SwapUInt16(idTipoVitaUt[i]);
}
found = true;
}
}
@@ -3711,7 +3731,11 @@ namespace MTC_Adapter
// leggo FamUt puntuale..
memIndex = getDatiUt_step4(ref int32Mem, j);
// leggo puntualmente valore della vita ut residua da indice utensile...
valVitaUtRes[i] = BitConverter.ToInt32(int32Mem, 0);
valVitaUtRes[i] = BitConverter.ToUInt32(int32Mem, 0);
if (hasBigEndian)
{
valVitaUtRes[i] = Endian.SwapUInt32(valVitaUtRes[i]);
}
found = true;
}
}