public static DecodeCAT01I042 ( byte Data ) : void | ||
Data | byte | |
return | void |
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;
}
// This method will accept a buffer of data with the assumption that // category has been determined. It will then decode the data and save // it in the shared buffer. Every time a message is passed in the data // will be appended to the buffer. This means that each line will contain // data for one message. For data items which are not in the message, // indicated by the FSPEC field, N/A will be inserted instead. The shared // buffer is loacted in the SharedData and will not be saved. It is responsibility // of the user to save the data in a file if desired. public static void Do(byte[] Data) { // First check what type of data is received? if (CAT01.Type_Of_Report == CAT01I020Types.Type_Of_Report_Type.Plot) { /////////////////////////////////////////////////////////////////////// // PLOT DATA // /////////////////////////////////////////////////////////////////////// // I001/010 Data Source Identifier 2 // NO NEED to do anything this is handled in CAT01 // I001/020 Target Report Descriptor +1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("020")].CurrentlyPresent == true) { CAT01I020UserData.DecodeCAT01I002(Data); } // I001/040 Measured Position in Polar Coordinates 4 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("040")].CurrentlyPresent == true) { CAT01I040UserData.DecodeCAT01I040(Data); } // I001/070 Mode-3/A Code in Octal Representation 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("070")].CurrentlyPresent == true) { CAT01I070UserData.DecodeCAT01I070(Data); } // I001/090 Mode-C Code in Binary Representation 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("090")].CurrentlyPresent == true) { CAT01I090UserData.DecodeCAT01I090(Data); } // I001/130 Radar Plot Characteristics 1+ if (CAT01.I001DataItems[CAT01.ItemIDToIndex("130")].CurrentlyPresent == true) { CAT01I130UserData.DecodeCAT01I130(Data); } // I001/141 Truncated Time of Day 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("141")].CurrentlyPresent == true) { CAT01I141UserData.DecodeCAT01I141(Data); } // FX -------- Field Extension Indicator - // I001/050 Mode-2 Code in Octal Representation 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("050")].CurrentlyPresent == true) { CAT01I050UserData.DecodeCAT01I050(Data); } // I001/120 Measured Radial Doppler Speed 1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("120")].CurrentlyPresent == true) { CAT01I120UserData.DecodeCAT01I120(Data); } // I001/131 Received Power 1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("131")].CurrentlyPresent == true) { CAT01I131UserData.DecodeCAT01I131(Data); } // I001/080 Mode-3/A Code Confidence Indicator 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("080")].CurrentlyPresent == true) { CAT01I080UserData.DecodeCAT01I080(Data); } // I001/100 Mode-C Code and Code Confidence Indicator 4 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("100")].CurrentlyPresent == true) { CAT01I100UserData.DecodeCAT01I100(Data); } // I001/060 Mode-2 Code Confidence Indicator 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("060")].CurrentlyPresent == true) { CAT01I060UserData.DecodeCAT01I060(Data); } // I001/030 Warning/Error Conditions 1+ if (CAT01.I001DataItems[CAT01.ItemIDToIndex("030")].CurrentlyPresent == true) { CAT01I030UserData.DecodeCAT01I030(Data); } // FX -------- Field Extension Indicator - // I001/150 Presence of X-Pulse 1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("150")].CurrentlyPresent == true) { CAT01I150UserData.DecodeCAT01I150(Data); } StoreDecodedData(); } else { /////////////////////////////////////////////////////////////////////// // TRACK DATA // /////////////////////////////////////////////////////////////////////// // I001/010 Data Source Identifier // NO NEED to do anything this is handled in CAT01 // I001/020 Target Report Descriptor +1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("020")].CurrentlyPresent == true) { CAT01I020UserData.DecodeCAT01I002(Data); } // I001/161 Track/Plot Number 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("161")].CurrentlyPresent == true) { CAT01I161UserData.DecodeCAT01I161(Data); } // I001/040 Measured Position in Polar Coordinates 4 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("040")].CurrentlyPresent == true) { CAT01I040UserData.DecodeCAT01I040(Data); } // I001/042 Calculated Position in Cartesian Coordinates 4 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("042")].CurrentlyPresent == true) { CAT01I042UserData.DecodeCAT01I042(Data); } // I001/200 Calculated Track Velocity in polar Coordinates 4 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("200")].CurrentlyPresent == true) { CAT01I200UserData.DecodeCAT01I200(Data); } // I001/070 Mode-3/A Code in Octal Representation 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("070")].CurrentlyPresent == true) { CAT01I070UserData.DecodeCAT01I070(Data); } // I001/090 Mode-C Code in Binary Representation 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("090")].CurrentlyPresent == true) { CAT01I090UserData.DecodeCAT01I090(Data); } // I001/141 Truncated Time of Day 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("141")].CurrentlyPresent == true) { CAT01I141UserData.DecodeCAT01I141(Data); } // I001/130 Radar Plot Characteristics 1+ if (CAT01.I001DataItems[CAT01.ItemIDToIndex("130")].CurrentlyPresent == true) { CAT01I130UserData.DecodeCAT01I130(Data); } // I001/131 Received Power 1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("131")].CurrentlyPresent == true) { CAT01I131UserData.DecodeCAT01I131(Data); } // I001/120 Measured Radial Doppler Speed 1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("120")].CurrentlyPresent == true) { CAT01I120UserData.DecodeCAT01I120(Data); } // I001/170 Track Status 1+ if (CAT01.I001DataItems[CAT01.ItemIDToIndex("170")].CurrentlyPresent == true) { CAT01I170UserData.DecodeCAT01I170(Data); } // I001/210 Track Quality 1+ if (CAT01.I001DataItems[CAT01.ItemIDToIndex("210")].CurrentlyPresent == true) { CAT01I210UserData.DecodeCAT01I210(Data); } // FX Field Extension Indicator // I001/050 Mode-2 Code in Octal Representation 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("050")].CurrentlyPresent == true) { CAT01I050UserData.DecodeCAT01I050(Data); } // I001/080 Mode-3/A Code Confidence Indicator 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("080")].CurrentlyPresent == true) { CAT01I080UserData.DecodeCAT01I080(Data); } // I001/100 Mode-C Code and Code Confidence Indicator 4 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("100")].CurrentlyPresent == true) { CAT01I100UserData.DecodeCAT01I100(Data); } // I001/060 Mode-2 Code Confidence Indicator 2 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("060")].CurrentlyPresent == true) { CAT01I060UserData.DecodeCAT01I060(Data); } // I001/030 Warning/Error Conditions 1+ if (CAT01.I001DataItems[CAT01.ItemIDToIndex("030")].CurrentlyPresent == true) { CAT01I030UserData.DecodeCAT01I030(Data); } // Reserved for Special Purpose Indicator (SP) // Reserved for RFS Indicator (RS-bit) // FX Field Extension Indicator // I001/150 Presence of X-Pulse 1 if (CAT01.I001DataItems[CAT01.ItemIDToIndex("150")].CurrentlyPresent == true) { CAT01I150UserData.DecodeCAT01I150(Data); } StoreDecodedData(); } }