public static void DecodeCAT02I020(byte[] Data) { // Get an instance of bit ops Bit_Ops BO = new Bit_Ops(); //Extract the first octet BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT02.CurrentDataBufferOctalIndex + 1]; double Result = 0.0; if (BO.DWord[Bit_Ops.Bit0] == true) { Result = LSB_1; } if (BO.DWord[Bit_Ops.Bit1] == true) { Result = Result + LSB_2; } if (BO.DWord[Bit_Ops.Bit2] == true) { Result = Result + LSB_3; } if (BO.DWord[Bit_Ops.Bit3] == true) { Result = Result + LSB_4; } if (BO.DWord[Bit_Ops.Bit4] == true) { Result = Result + LSB_5; } if (BO.DWord[Bit_Ops.Bit5] == true) { Result = Result + LSB_6; } if (BO.DWord[Bit_Ops.Bit6] == true) { Result = Result + LSB_7; } if (BO.DWord[Bit_Ops.Bit7] == true) { Result = Result + LSB_8; } ////////////////////////////////////////////////////////////////////////////////// // Now assign it to the generic list CAT02.I002DataItems[CAT02.ItemIDToIndex("020")].value = Result; ////////////////////////////////////////////////////////////////////////////////// // Leave it at the current index for the next decode CAT02.CurrentDataBufferOctalIndex = CAT02.CurrentDataBufferOctalIndex + 1; }
public static void DecodeCAT02I000(byte[] Data) { // First define CAT01I002 class CAT02I000UserData MyI002UserData = new CAT02I000UserData(); // Get an instance of bit ops Bit_Ops BO = new Bit_Ops(); //Extract the first octet BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT02.CurrentDataBufferOctalIndex]; int result = BO.DWord[Bit_Ops.Bits0_7_Of_DWord]; switch (result) { case 1: MyI002UserData.Message_Type = CAT02I000Types.Message_Type.North_Marker_Msg; FormMain MainFrame = Application.OpenForms[0] as FormMain; MainFrame.HandleNorthMarkMessage(); break; case 2: MyI002UserData.Message_Type = CAT02I000Types.Message_Type.Sector_Crossing_Msg; break; case 3: MyI002UserData.Message_Type = CAT02I000Types.Message_Type.South_Marker_Msg; break; case 8: MyI002UserData.Message_Type = CAT02I000Types.Message_Type.Activation_Of_Blind_Zone_Filtering; break; case 9: MyI002UserData.Message_Type = CAT02I000Types.Message_Type.Stop_Of_Blind_Zone_Filtering; break; default: break; } ////////////////////////////////////////////////////////////////////////////////// // Now assign it to the generic list CAT02.I002DataItems[CAT02.ItemIDToIndex("000")].value = MyI002UserData.Message_Type; ////////////////////////////////////////////////////////////////////////////////// }
// 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 it desired. public static void Do(byte[] Data) { // BitExtractor BE = new BitExtractor(); // I002/000, Message Type 1 if (CAT02.I002DataItems[CAT02.ItemIDToIndex("000")].CurrentlyPresent == true) { CAT02I000UserData.DecodeCAT02I000(Data); } // I002/020 Sector Number 1 if (CAT02.I002DataItems[CAT02.ItemIDToIndex("020")].CurrentlyPresent == true) { CAT02I020UserData.DecodeCAT02I020(Data); } // I002/030 Time of Day 3 if (CAT02.I002DataItems[CAT02.ItemIDToIndex("030")].CurrentlyPresent == true) { CAT02I030UserData.DecodeCAT02I030(Data); } // I002/041 Antenna Rotation Period 2 if (CAT02.I002DataItems[CAT02.ItemIDToIndex("041")].CurrentlyPresent == true) { CAT02I041UserData.DecodeCAT02I041(Data); } // I002/050 Station Configuration Status 1+ if (CAT02.I002DataItems[CAT02.ItemIDToIndex("050")].CurrentlyPresent == true) { CAT02I050UserData.DecodeCAT02I050(Data); } // I002/060 Station Processing Mode 1+ if (CAT02.I002DataItems[CAT02.ItemIDToIndex("060")].CurrentlyPresent == true) { CAT02I060UserData.DecodeCAT02I060(Data); } // FX Field Extension Indicator // I002/070 Plot Count Values (1 + 2 X N) if (CAT02.I002DataItems[CAT02.ItemIDToIndex("070")].CurrentlyPresent == true) { CAT02I070UserData.DecodeCAT02I070(Data); } // I002/100 Dynamic Window - Type 1 8 if (CAT02.I002DataItems[CAT02.ItemIDToIndex("100")].CurrentlyPresent == true) { CAT02I100UserData.DecodeCAT02I100(Data); } // I002/090 Collimation Error 2 if (CAT02.I002DataItems[CAT02.ItemIDToIndex("090")].CurrentlyPresent == true) { CAT02I090UserData.DecodeCAT02I090(Data); } // I002/080 Warning/Error Conditions 1+ if (CAT02.I002DataItems[CAT02.ItemIDToIndex("080")].CurrentlyPresent == true) { CAT02I080UserData.DecodeCAT02I080(Data); } //////////////////////////////////////////////////////////////////////////////////// // All CAT02 data has been decoded, so lets save off the message data to the global // storage for latter usage MainASTERIXDataStorage.CAT02Data CAT02MessageData = new MainASTERIXDataStorage.CAT02Data(); foreach (CAT02.CAT02DataItem Item in CAT02.I002DataItems) { CAT02.CAT02DataItem MyItem = new CAT02.CAT02DataItem(); MyItem.CurrentlyPresent = Item.CurrentlyPresent; MyItem.Description = Item.Description; MyItem.HasBeenPresent = Item.HasBeenPresent; MyItem.ID = Item.ID; MyItem.value = Item.value; CAT02MessageData.CAT02DataItems.Add(MyItem); } MainASTERIXDataStorage.CAT02Message.Add(CAT02MessageData); CAT02.Intitialize(false); }
public static void DecodeCAT02I030(byte[] Data) { CAT02I030Types.CAT02I030_Time_Of_The_Day_User_Type MyCAT02I030 = new CAT02I030Types.CAT02I030_Time_Of_The_Day_User_Type(); // Get an instance of bit ops Bit_Ops BO = new Bit_Ops(); //Extract the first octet BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT02.CurrentDataBufferOctalIndex + 3]; BO.DWord[Bit_Ops.Bits8_15_Of_DWord] = Data[CAT02.CurrentDataBufferOctalIndex + 2]; BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT02.CurrentDataBufferOctalIndex + 1]; double Result = 0.0; if (BO.DWord[Bit_Ops.Bit0] == true) { Result = LSB_1; } if (BO.DWord[Bit_Ops.Bit1] == true) { Result = Result + LSB_2; } if (BO.DWord[Bit_Ops.Bit2] == true) { Result = Result + LSB_3; } if (BO.DWord[Bit_Ops.Bit3] == true) { Result = Result + LSB_4; } if (BO.DWord[Bit_Ops.Bit4] == true) { Result = Result + LSB_5; } if (BO.DWord[Bit_Ops.Bit5] == true) { Result = Result + LSB_6; } if (BO.DWord[Bit_Ops.Bit6] == true) { Result = Result + LSB_7; } if (BO.DWord[Bit_Ops.Bit7] == true) { Result = Result + LSB_8; } if (BO.DWord[Bit_Ops.Bit8] == true) { Result = Result + LSB_9; } if (BO.DWord[Bit_Ops.Bit9] == true) { Result = Result + LSB_10; } if (BO.DWord[Bit_Ops.Bit10] == true) { Result = Result + LSB_11; } if (BO.DWord[Bit_Ops.Bit11] == true) { Result = Result + LSB_12; } if (BO.DWord[Bit_Ops.Bit12] == true) { Result = Result + LSB_13; } if (BO.DWord[Bit_Ops.Bit13] == true) { Result = Result + LSB_14; } if (BO.DWord[Bit_Ops.Bit14] == true) { Result = Result + LSB_15; } if (BO.DWord[Bit_Ops.Bit15] == true) { Result = Result + LSB_16; } if (BO.DWord[Bit_Ops.Bit16] == true) { Result = Result + LSB_17; } if (BO.DWord[Bit_Ops.Bit17] == true) { Result = Result + LSB_18; } if (BO.DWord[Bit_Ops.Bit18] == true) { Result = Result + LSB_19; } if (BO.DWord[Bit_Ops.Bit19] == true) { Result = Result + LSB_20; } if (BO.DWord[Bit_Ops.Bit20] == true) { Result = Result + LSB_21; } if (BO.DWord[Bit_Ops.Bit21] == true) { Result = Result + LSB_22; } if (BO.DWord[Bit_Ops.Bit22] == true) { Result = Result + LSB_23; } if (BO.DWord[Bit_Ops.Bit23] == true) { Result = Result + LSB_24; } MyCAT02I030.Time_Of_The_Day_In_Sec_Since_Midnight_UTC = Result; // Compute the time in a human friendy form // from sec.miliec since midnight UTC. double hrs, sec, min, milis; hrs = Math.Floor(Result / 3600.00); double tmp = (Result - (hrs * 3600.0)) / 60; min = Math.Floor(tmp); tmp = (tmp * 60.0) - (min * 60.0); sec = Math.Floor(tmp); milis = (tmp - sec) * 1000.0; MyCAT02I030.TimeOfDay = new TimeSpan(0, (int)hrs, (int)min, (int)sec, (int)milis); ////////////////////////////////////////////////////////////////////////////////// // Now assign it to the generic list CAT02.I002DataItems[CAT02.ItemIDToIndex("030")].value = MyCAT02I030; ////////////////////////////////////////////////////////////////////////////////// // Leave it at the current index for the next decode CAT02.CurrentDataBufferOctalIndex = CAT02.CurrentDataBufferOctalIndex + 3; }
private static void ExtractAndDecodeASTERIX_CAT_DataBlock(byte[] DataBlock, bool Is_Live_Data) { // First thing is to store the time of the reception regardless of the category received string Time = DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Second.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Millisecond.ToString().PadLeft(3, '0'); // Save off the time of reception so decoders can use it TimeOfReception = DateTime.Now; // Extract ASTERIX category string Category = ASTERIX.ExtractCategory(DataBlock); // Extract lenght in Bytes, as indicated by the ASTERIX string LengthOfDataBlockInBytes = ASTERIX.ExtractLengthOfDataBlockInBytes(DataBlock); // Here format the lenght of bytes // to always use 3 characters for better alignement if (LengthOfDataBlockInBytes.Length < 3) { LengthOfDataBlockInBytes = "0" + LengthOfDataBlockInBytes; } else if (LengthOfDataBlockInBytes.Length < 2) { LengthOfDataBlockInBytes = "00" + LengthOfDataBlockInBytes; } // Define a string to store data not specific for all messages and add commond data // 1. TIME of reception // 2. Source IP address // 3. Multicast IP address // 4. Length of data block in bytes // 5. Asterix Category // // 6. Append Category specifc data, done just below string Common_Message_Data_String; if (Is_Live_Data == true) Common_Message_Data_String = Time + " " + iep.ToString() + " " + SharedData.CurrentMulticastAddress + ':' + SharedData.Current_Port.ToString() + " " + LengthOfDataBlockInBytes.ToString() + " " + Category + " "; else Common_Message_Data_String = Time + " " + "Recorded" + " " + "Recorded" + ':' + "Recorded" + " " + LengthOfDataBlockInBytes.ToString() + " " + Category + " "; // Hold individual records of the messages // from an individual data block string[] MessageData = new string[3000]; byte[] DataBlockNoCATandLEN = new byte[DataBlock.Length - 3]; // Now after we extracted Category and Lenght of the Data Block lets remove the first three octets from the data // buffer and pass it on to individual message handlers to do message decoding Array.Copy(DataBlock, 3, DataBlockNoCATandLEN, 0, (DataBlock.Length - 3)); DataBlock = DataBlockNoCATandLEN; // Now do a switch based on the category received int NumOfMsgsDecoded = 0; switch (Category) { // Monoradar Data Target Reports, from a Radar Surveillance System to an SDPS // (plots and tracks from PSRs, SSRs, MSSRs, excluding Mode S and ground surveillance) case "001": if (Properties.Settings.Default.CAT_001_Enabled == true) { CAT01 MyCAT01 = new CAT01(); MessageData = MyCAT01.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Monoradar Service Messages (status, North marker, sector crossing messages) case "002": if (Properties.Settings.Default.CAT_002_Enabled == true) { CAT02 MyCAT02 = new CAT02(); MessageData = MyCAT02.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Monoradar Derived Weather Information case "008": if (Properties.Settings.Default.CAT_008_Enabled == true) { CAT08 MyCAT08 = new CAT08(); } break; // Next version of Category 002: PSR Radar, M-SSR Radar, Mode-S Station case "034": if (Properties.Settings.Default.CAT_034_Enabled == true) { CAT34 MyCAT34 = new CAT34(); MessageData = MyCAT34.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Next version of Category 001: PSR Radar, M-SSR Radar, Mode-S Station case "048": if (Properties.Settings.Default.CAT_048_Enabled == true) { CAT48 MyCAT48 = new CAT48(); MessageData = MyCAT48.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // System Track Data(next version of Category 030 & 011, also applicable to non-ARTAS systems) case "062": if (Properties.Settings.Default.CAT_062_Enabled == true) { CAT62 MyCAT62 = new CAT62(); MessageData = MyCAT62.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Sensor Status Messages (SPDS) case "063": if (Properties.Settings.Default.CAT_063_Enabled == true) { CAT63 MyCAT63 = new CAT63(); } break; // SDPS Service Status Messages (SDPS) case "065": if (Properties.Settings.Default.CAT_065_Enabled == true) { CAT65 MyCAT65 = new CAT65(); } break; // Transmission of Reference Trajectory State Vectors case "244": if (Properties.Settings.Default.CAT_244_Enabled == true) { CAT244 MyCAT244 = new CAT244(); } break; // Handle unsupported data/categories default: Common_Message_Data_String = Common_Message_Data_String + " Unsupported category " + Category + " has been received"; break; } if (Properties.Settings.Default.PopulateMainListBox == true) { for (int I = 0; I < NumOfMsgsDecoded; I++) SharedData.DataBox.Items.Add(Common_Message_Data_String + MessageData[I]); } }
private static void ExtractAndDecodeASTERIX_CAT_DataBlock(byte[] DataBlock, bool Is_Live_Data) { // First thing is to store the time of the reception regardless of the category received string Time = DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Second.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Millisecond.ToString().PadLeft(3, '0'); // Save off the time of reception so decoders can use it TimeOfReception = DateTime.Now; // Extract ASTERIX category string Category = ASTERIX.ExtractCategory(DataBlock); // Extract lenght in Bytes, as indicated by the ASTERIX string LengthOfDataBlockInBytes = ASTERIX.ExtractLengthOfDataBlockInBytes(DataBlock); // Here format the lenght of bytes // to always use 3 characters for better alignement if (LengthOfDataBlockInBytes.Length < 3) { LengthOfDataBlockInBytes = "0" + LengthOfDataBlockInBytes; } else if (LengthOfDataBlockInBytes.Length < 2) { LengthOfDataBlockInBytes = "00" + LengthOfDataBlockInBytes; } // Define a string to store data not specific for all messages and add commond data // 1. TIME of reception // 2. Source IP address // 3. Multicast IP address // 4. Length of data block in bytes // 5. Asterix Category // // 6. Append Category specifc data, done just below string Common_Message_Data_String; if (Is_Live_Data == true) { Common_Message_Data_String = Time + " " + iep.ToString() + " " + SharedData.CurrentMulticastAddress + ':' + SharedData.Current_Port.ToString() + " " + LengthOfDataBlockInBytes.ToString() + " " + Category + " "; } else { Common_Message_Data_String = Time + " " + "Recorded" + " " + "Recorded" + ':' + "Recorded" + " " + LengthOfDataBlockInBytes.ToString() + " " + Category + " "; } // Hold individual records of the messages // from an individual data block string[] MessageData = new string[3000]; byte[] DataBlockNoCATandLEN = new byte[DataBlock.Length - 3]; // Now after we extracted Category and Lenght of the Data Block lets remove the first three octets from the data // buffer and pass it on to individual message handlers to do message decoding Array.Copy(DataBlock, 3, DataBlockNoCATandLEN, 0, (DataBlock.Length - 3)); DataBlock = DataBlockNoCATandLEN; // Now do a switch based on the category received int NumOfMsgsDecoded = 0; switch (Category) { // Monoradar Data Target Reports, from a Radar Surveillance System to an SDPS // (plots and tracks from PSRs, SSRs, MSSRs, excluding Mode S and ground surveillance) case "001": if (Properties.Settings.Default.CAT_001_Enabled == true) { CAT01 MyCAT01 = new CAT01(); MessageData = MyCAT01.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Monoradar Service Messages (status, North marker, sector crossing messages) case "002": if (Properties.Settings.Default.CAT_002_Enabled == true) { CAT02 MyCAT02 = new CAT02(); MessageData = MyCAT02.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Monoradar Derived Weather Information case "008": if (Properties.Settings.Default.CAT_008_Enabled == true) { CAT08 MyCAT08 = new CAT08(); } break; // Next version of Category 002: PSR Radar, M-SSR Radar, Mode-S Station case "034": if (Properties.Settings.Default.CAT_034_Enabled == true) { CAT34 MyCAT34 = new CAT34(); MessageData = MyCAT34.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Next version of Category 001: PSR Radar, M-SSR Radar, Mode-S Station case "048": if (Properties.Settings.Default.CAT_048_Enabled == true) { CAT48 MyCAT48 = new CAT48(); MessageData = MyCAT48.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // System Track Data(next version of Category 030 & 011, also applicable to non-ARTAS systems) case "062": if (Properties.Settings.Default.CAT_062_Enabled == true) { CAT62 MyCAT62 = new CAT62(); MessageData = MyCAT62.Decode(DataBlock, Time, out NumOfMsgsDecoded); } break; // Sensor Status Messages (SPDS) case "063": if (Properties.Settings.Default.CAT_063_Enabled == true) { CAT63 MyCAT63 = new CAT63(); } break; // SDPS Service Status Messages (SDPS) case "065": if (Properties.Settings.Default.CAT_065_Enabled == true) { CAT65 MyCAT65 = new CAT65(); } break; // Transmission of Reference Trajectory State Vectors case "244": if (Properties.Settings.Default.CAT_244_Enabled == true) { CAT244 MyCAT244 = new CAT244(); } break; // Handle unsupported data/categories default: Common_Message_Data_String = Common_Message_Data_String + " Unsupported category " + Category + " has been received"; break; } if (Properties.Settings.Default.PopulateMainListBox == true) { for (int I = 0; I < NumOfMsgsDecoded; I++) { SharedData.DataBox.Items.Add(Common_Message_Data_String + MessageData[I]); } } }