public static void DecodeCAT01I042(byte[] Data)
{
// Get an instance of bit ops
Bit_Ops BO = new Bit_Ops();
double Result = 0.0;
CAT01I042Types.CAT01I042CalculatedPositionInCartesianCoordinates MyCAT01I042 = new CAT01I042Types.CAT01I042CalculatedPositionInCartesianCoordinates();
BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT01.CurrentDataBufferOctalIndex + 4];
BO.DWord[Bit_Ops.Bits8_15_Of_DWord] = Data[CAT01.CurrentDataBufferOctalIndex + 3];
BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT01.CurrentDataBufferOctalIndex + 2];
BO.DWord[Bit_Ops.Bits24_31_Of_DWord] = Data[CAT01.CurrentDataBufferOctalIndex + 1];
// Decode first X component
// Check if this is a negative altitude.
// and then handle it properly
if (BO.DWord[Bit_Ops.Bit31] == true)
{
BO.DWord[Bit_Ops.Bit16] = !BO.DWord[Bit_Ops.Bit16];
BO.DWord[Bit_Ops.Bit17] = !BO.DWord[Bit_Ops.Bit17];
BO.DWord[Bit_Ops.Bit18] = !BO.DWord[Bit_Ops.Bit18];
BO.DWord[Bit_Ops.Bit19] = !BO.DWord[Bit_Ops.Bit19];
BO.DWord[Bit_Ops.Bit20] = !BO.DWord[Bit_Ops.Bit20];
BO.DWord[Bit_Ops.Bit21] = !BO.DWord[Bit_Ops.Bit21];
BO.DWord[Bit_Ops.Bit22] = !BO.DWord[Bit_Ops.Bit22];
BO.DWord[Bit_Ops.Bit23] = !BO.DWord[Bit_Ops.Bit23];
BO.DWord[Bit_Ops.Bit24] = !BO.DWord[Bit_Ops.Bit24];
BO.DWord[Bit_Ops.Bit25] = !BO.DWord[Bit_Ops.Bit25];
BO.DWord[Bit_Ops.Bit26] = !BO.DWord[Bit_Ops.Bit26];
BO.DWord[Bit_Ops.Bit27] = !BO.DWord[Bit_Ops.Bit27];
BO.DWord[Bit_Ops.Bit28] = !BO.DWord[Bit_Ops.Bit28];
BO.DWord[Bit_Ops.Bit29] = !BO.DWord[Bit_Ops.Bit29];
BO.DWord[Bit_Ops.Bit30] = !BO.DWord[Bit_Ops.Bit30];
BO.DWord[Bit_Ops.Bit31] = !BO.DWord[Bit_Ops.Bit31];
BO.DWord[Bit_Ops.Bits0_15_Of_DWord] = BO.DWord[Bit_Ops.Bits0_15_Of_DWord] + 1;
if (BO.DWord[Bit_Ops.Bit16] == true)
Result = Result + XY_1;
if (BO.DWord[Bit_Ops.Bit17] == true)
Result = Result + XY_2;
if (BO.DWord[Bit_Ops.Bit18] == true)
Result = Result + XY_3;
if (BO.DWord[Bit_Ops.Bit19] == true)
Result = Result + XY_4;
if (BO.DWord[Bit_Ops.Bit20] == true)
Result = Result + XY_5;
if (BO.DWord[Bit_Ops.Bit21] == true)
Result = Result + XY_6;
if (BO.DWord[Bit_Ops.Bit22] == true)
Result = Result + XY_7;
if (BO.DWord[Bit_Ops.Bit23] == true)
Result = Result + XY_8;
if (BO.DWord[Bit_Ops.Bit24] == true)
Result = Result + XY_9;
if (BO.DWord[Bit_Ops.Bit25] == true)
Result = Result + XY_10;
if (BO.DWord[Bit_Ops.Bit26] == true)
Result = Result + XY_11;
if (BO.DWord[Bit_Ops.Bit27] == true)
Result = Result + XY_12;
if (BO.DWord[Bit_Ops.Bit28] == true)
Result = Result + XY_13;
if (BO.DWord[Bit_Ops.Bit29] == true)
Result = Result + XY_14;
if (BO.DWord[Bit_Ops.Bit30] == true)
Result = Result + XY_15;
Result = -Result;
}
else
{
if (BO.DWord[Bit_Ops.Bit16] == true)
Result = Result + XY_1;
if (BO.DWord[Bit_Ops.Bit17] == true)
Result = Result + XY_2;
if (BO.DWord[Bit_Ops.Bit18] == true)
Result = Result + XY_3;
if (BO.DWord[Bit_Ops.Bit19] == true)
Result = Result + XY_4;
if (BO.DWord[Bit_Ops.Bit20] == true)
Result = Result + XY_5;
if (BO.DWord[Bit_Ops.Bit21] == true)
Result = Result + XY_6;
if (BO.DWord[Bit_Ops.Bit22] == true)
Result = Result + XY_7;
if (BO.DWord[Bit_Ops.Bit23] == true)
Result = Result + XY_8;
if (BO.DWord[Bit_Ops.Bit24] == true)
Result = Result + XY_9;
if (BO.DWord[Bit_Ops.Bit25] == true)
Result = Result + XY_10;
if (BO.DWord[Bit_Ops.Bit26] == true)
Result = Result + XY_11;
if (BO.DWord[Bit_Ops.Bit27] == true)
Result = Result + XY_12;
if (BO.DWord[Bit_Ops.Bit28] == true)
Result = Result + XY_13;
if (BO.DWord[Bit_Ops.Bit29] == true)
Result = Result + XY_14;
if (BO.DWord[Bit_Ops.Bit30] == true)
Result = Result + XY_15;
if (BO.DWord[Bit_Ops.Bit31] == true)
Result = Result + XY_16;
}
MyCAT01I042.X = Result;
Result = 0.0;
// Decode first Y component
// Check if this is a negative altitude.
// and then handle it properly
if (BO.DWord[Bit_Ops.Bit15] == true)
{
BO.DWord[Bit_Ops.Bit0] = !BO.DWord[Bit_Ops.Bit0];
BO.DWord[Bit_Ops.Bit1] = !BO.DWord[Bit_Ops.Bit1];
BO.DWord[Bit_Ops.Bit2] = !BO.DWord[Bit_Ops.Bit2];
BO.DWord[Bit_Ops.Bit3] = !BO.DWord[Bit_Ops.Bit3];
BO.DWord[Bit_Ops.Bit4] = !BO.DWord[Bit_Ops.Bit4];
BO.DWord[Bit_Ops.Bit5] = !BO.DWord[Bit_Ops.Bit5];
BO.DWord[Bit_Ops.Bit6] = !BO.DWord[Bit_Ops.Bit6];
BO.DWord[Bit_Ops.Bit7] = !BO.DWord[Bit_Ops.Bit7];
BO.DWord[Bit_Ops.Bit8] = !BO.DWord[Bit_Ops.Bit8];
BO.DWord[Bit_Ops.Bit9] = !BO.DWord[Bit_Ops.Bit9];
BO.DWord[Bit_Ops.Bit10] = !BO.DWord[Bit_Ops.Bit10];
BO.DWord[Bit_Ops.Bit11] = !BO.DWord[Bit_Ops.Bit11];
BO.DWord[Bit_Ops.Bit12] = !BO.DWord[Bit_Ops.Bit12];
BO.DWord[Bit_Ops.Bit13] = !BO.DWord[Bit_Ops.Bit13];
BO.DWord[Bit_Ops.Bit14] = !BO.DWord[Bit_Ops.Bit14];
BO.DWord[Bit_Ops.Bit15] = !BO.DWord[Bit_Ops.Bit15];
BO.DWord[Bit_Ops.Bits16_31_Of_DWord] = BO.DWord[Bit_Ops.Bits16_31_Of_DWord] + 1;
if (BO.DWord[Bit_Ops.Bit0] == true)
Result = Result + XY_1;
if (BO.DWord[Bit_Ops.Bit1] == true)
Result = Result + XY_2;
if (BO.DWord[Bit_Ops.Bit2] == true)
Result = Result + XY_3;
if (BO.DWord[Bit_Ops.Bit3] == true)
Result = Result + XY_4;
if (BO.DWord[Bit_Ops.Bit4] == true)
Result = Result + XY_5;
if (BO.DWord[Bit_Ops.Bit5] == true)
Result = Result + XY_6;
if (BO.DWord[Bit_Ops.Bit6] == true)
Result = Result + XY_7;
if (BO.DWord[Bit_Ops.Bit7] == true)
Result = Result + XY_8;
if (BO.DWord[Bit_Ops.Bit8] == true)
Result = Result + XY_9;
if (BO.DWord[Bit_Ops.Bit9] == true)
Result = Result + XY_10;
if (BO.DWord[Bit_Ops.Bit10] == true)
Result = Result + XY_11;
if (BO.DWord[Bit_Ops.Bit11] == true)
Result = Result + XY_12;
if (BO.DWord[Bit_Ops.Bit12] == true)
Result = Result + XY_13;
if (BO.DWord[Bit_Ops.Bit13] == true)
Result = Result + XY_14;
if (BO.DWord[Bit_Ops.Bit14] == true)
Result = Result + XY_15;
Result = -Result;
}
else
{
if (BO.DWord[Bit_Ops.Bit0] == true)
Result = Result + XY_1;
if (BO.DWord[Bit_Ops.Bit1] == true)
Result = Result + XY_2;
if (BO.DWord[Bit_Ops.Bit2] == true)
Result = Result + XY_3;
if (BO.DWord[Bit_Ops.Bit3] == true)
Result = Result + XY_4;
if (BO.DWord[Bit_Ops.Bit4] == true)
Result = Result + XY_5;
if (BO.DWord[Bit_Ops.Bit5] == true)
Result = Result + XY_6;
if (BO.DWord[Bit_Ops.Bit6] == true)
Result = Result + XY_7;
if (BO.DWord[Bit_Ops.Bit7] == true)
Result = Result + XY_8;
if (BO.DWord[Bit_Ops.Bit8] == true)
Result = Result + XY_9;
if (BO.DWord[Bit_Ops.Bit9] == true)
Result = Result + XY_10;
if (BO.DWord[Bit_Ops.Bit10] == true)
Result = Result + XY_11;
if (BO.DWord[Bit_Ops.Bit11] == true)
Result = Result + XY_12;
if (BO.DWord[Bit_Ops.Bit12] == true)
Result = Result + XY_13;
if (BO.DWord[Bit_Ops.Bit13] == true)
Result = Result + XY_14;
if (BO.DWord[Bit_Ops.Bit14] == true)
Result = Result + XY_15;
if (BO.DWord[Bit_Ops.Bit15] == true)
Result = Result + XY_16;
}
MyCAT01I042.Y = Result;
Azimuth_And_Distance_Type CalculatedGSPDandHDG = ToPolarFromCarteisan(MyCAT01I042.X, MyCAT01I042.Y);
DecodeAzimuthAndDistance(ref MyCAT01I042.LatLong, CalculatedGSPDandHDG.Distance, CalculatedGSPDandHDG.Azimuth);
//////////////////////////////////////////////////////////////////////////////////
// Now assign it to the generic list
CAT01.I001DataItems[CAT01.ItemIDToIndex("042")].value = MyCAT01I042;
//////////////////////////////////////////////////////////////////////////////////
CAT01.CurrentDataBufferOctalIndex = CAT01.CurrentDataBufferOctalIndex + 4;
}