public static void DecodeCAT34I060(byte[] Data) { // At this time we do not care about the content of CAT034I060. // However it is necessary to determine how many subfields of 8 octets // is present so that data buffer can be updated accordingly on order to // decode the other fileds of interest // NOTE: We assume that only first 7 defined subfuled // I034/050 Radar Plot Characteristics 1 + 1+ int Number_Of_Octets_Present = 1; // at least two, but that will be determined below // Decode 020 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("060")].HasBeenPresent == true) { // 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[CAT34.CurrentDataBufferOctalIndex + 1]; // Now check how many data octets is present. if (BO.DWord[CAT34I060Types.Subfiled_1] == true) { Number_Of_Octets_Present++; } if (BO.DWord[CAT34I060Types.Subfiled_2] == true) { Number_Of_Octets_Present++; } if (BO.DWord[CAT34I060Types.Subfiled_3] == true) { Number_Of_Octets_Present++; } if (BO.DWord[CAT34I060Types.Subfiled_4] == true) { Number_Of_Octets_Present++; } if (BO.DWord[CAT34I060Types.Subfiled_5] == true) { Number_Of_Octets_Present++; } if (BO.DWord[CAT34I060Types.Subfiled_6] == true) { Number_Of_Octets_Present++; } if (BO.DWord[CAT34I060Types.Subfiled_7] == true) { Number_Of_Octets_Present++; } // Increase data buffer index so it ready for the next data item. CAT34.CurrentDataBufferOctalIndex = CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present; } }
public static void DecodeCAT34I020(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[CAT34.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 CAT34.I034DataItems[CAT34.ItemIDToIndex("020")].value = Result; ////////////////////////////////////////////////////////////////////////////////// // Leave it at the current index for the next decode CAT34.CurrentDataBufferOctalIndex = CAT34.CurrentDataBufferOctalIndex + 1; }
public static void DecodeCAT34I000(byte[] Data) { // First define CAT34I000 class CAT34I000UserData MyCAT34I000UserData = new CAT34I000UserData(); // 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[CAT34.CurrentDataBufferOctalIndex]; int result = BO.DWord[Bit_Ops.Bits0_7_Of_DWord]; switch (result) { case 1: MyCAT34I000UserData.Message_Type = CAT34I000Types.Message_Type.North_Marker_Msg; FormMain MainFrame = Application.OpenForms[0] as FormMain; MainFrame.HandleNorthMarkMessage(); break; case 2: MyCAT34I000UserData.Message_Type = CAT34I000Types.Message_Type.Sector_Crossing_Msg; break; case 3: MyCAT34I000UserData.Message_Type = CAT34I000Types.Message_Type.Geographical_Filtering_Msg; break; case 4: MyCAT34I000UserData.Message_Type = CAT34I000Types.Message_Type.Jamming_Strobe_Msg; break; default: break; } ////////////////////////////////////////////////////////////////////////////////// // Now assign it to the generic list CAT34.I034DataItems[CAT34.ItemIDToIndex("000")].value = MyCAT34I000UserData.Message_Type; ////////////////////////////////////////////////////////////////////////////////// }
public static void DecodeCAT34I050(byte[] Data) { // At this time we do not care about the content of CAT034I050. // However it is necessary to determine how many subfields of 8 octets // is present so that data buffer can be updated accordingly in order to // decode the other fileds of interest // NOTE: We assume that only first 7 defined subfields are present // I034/050 System Configuration and Status 1 + 1+ int Number_Of_Octets_Present = 1; // at least two, but that will be determined below // Decode 020 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("050")].HasBeenPresent == true) { // Get an instance of bit ops Bit_Ops BO = new Bit_Ops(); Bit_Ops CAT34_I050_Data = new Bit_Ops(); //Extract the first octet BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + 1]; CAT34I050Types.CAT34I050UserData ThisCycleData = new CAT34I050Types.CAT34I050UserData(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Now check how many data octets is present and decode the present subfileds at the same time //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // COM - Common elements of a System ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_1] == true) { Number_Of_Octets_Present++; CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; ThisCycleData.COM_Data.Data_Present = true; ThisCycleData.COM_Data.System_is_NOGO = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_1]; ThisCycleData.COM_Data.RDPC2_Selected = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_2]; ThisCycleData.COM_Data.RDPC_Reset = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3]; ThisCycleData.COM_Data.RDP_Overloaded = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_4]; ThisCycleData.COM_Data.Transmision_Sys_Overloaded = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_5]; ThisCycleData.COM_Data.Monitor_Sys_Disconected = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_6]; ThisCycleData.COM_Data.Time_Source_Invalid = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_7]; } ////////////////////////////////////////////////////////////////////////////////// // Spare ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_2] == true) { Number_Of_Octets_Present++; CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; } ////////////////////////////////////////////////////////////////////////////////// // Spare ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_3] == true) { Number_Of_Octets_Present++; CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; } ////////////////////////////////////////////////////////////////////////////////// // PSR - Primary sensor component ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_4] == true) { Number_Of_Octets_Present++; CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; ThisCycleData.PSR_Data.Data_Present = true; ThisCycleData.PSR_Data.Ant_2_Selected = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_1]; if (CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3] == true && CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_2] == true) { ThisCycleData.PSR_Data.CH_Status = CAT34I050Types.PSR.Channel_Status.Channel_A_and_B; } else if (CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3] == false && CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_2] == false) { ThisCycleData.PSR_Data.CH_Status = CAT34I050Types.PSR.Channel_Status.No_Channel; } else if (CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3] == true) { ThisCycleData.PSR_Data.CH_Status = CAT34I050Types.PSR.Channel_Status.Channel_A; } else { ThisCycleData.PSR_Data.CH_Status = CAT34I050Types.PSR.Channel_Status.Channel_B; } ThisCycleData.PSR_Data.PSR_Overloaded = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_4]; ThisCycleData.PSR_Data.Monitor_Sys_Disconected = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_5]; } ////////////////////////////////////////////////////////////////////////////////// // SSR - Secondary sensor component ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_5] == true) { Number_Of_Octets_Present++; CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; ThisCycleData.SSR_Data.Data_Present = true; ThisCycleData.SSR_Data.Ant_2_Selected = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_1]; if (CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3] == true && CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_2] == true) { ThisCycleData.SSR_Data.CH_Status = CAT34I050Types.SSR.Channel_Status.Invalid_Combination; } else if (CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3] == false && CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_2] == false) { ThisCycleData.SSR_Data.CH_Status = CAT34I050Types.SSR.Channel_Status.No_Channel; } else if (CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_3] == true) { ThisCycleData.SSR_Data.CH_Status = CAT34I050Types.SSR.Channel_Status.Channel_A; } else { ThisCycleData.SSR_Data.CH_Status = CAT34I050Types.SSR.Channel_Status.Channel_B; } ThisCycleData.SSR_Data.SSR_Overloaded = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_4]; ThisCycleData.SSR_Data.Monitor_Sys_Disconected = CAT34_I050_Data.DWord[CAT34I050Types.Subfiled_5]; } ////////////////////////////////////////////////////////////////////////////////// // MDS - Mode-S sensor component ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_6] == true) { Number_Of_Octets_Present++; // Mode S subfield is 2 octets CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; ThisCycleData.MDS_Data.Data_Present = true; ThisCycleData.MDS_Data.Ant_2_Selected = BO.DWord[CAT34I050Types.Subfiled_1]; if (BO.DWord[CAT34I050Types.Subfiled_3] == true && BO.DWord[CAT34I050Types.Subfiled_2] == true) { ThisCycleData.MDS_Data.CH_Status = CAT34I050Types.MDS.Channel_Status.Illegal_Combination; } else if (BO.DWord[CAT34I050Types.Subfiled_3] == false && BO.DWord[CAT34I050Types.Subfiled_2] == false) { ThisCycleData.MDS_Data.CH_Status = CAT34I050Types.MDS.Channel_Status.No_Channel; } else if (BO.DWord[CAT34I050Types.Subfiled_3] == true) { ThisCycleData.MDS_Data.CH_Status = CAT34I050Types.MDS.Channel_Status.Channel_A; } else { ThisCycleData.MDS_Data.CH_Status = CAT34I050Types.MDS.Channel_Status.Channel_B; } ThisCycleData.MDS_Data.ModeS_Overloaded = BO.DWord[CAT34I050Types.Subfiled_4]; ThisCycleData.MDS_Data.Monitor_Sys_Disconected = BO.DWord[CAT34I050Types.Subfiled_5]; ThisCycleData.MDS_Data.CH2_For_Coordination_In_Use = BO.DWord[CAT34I050Types.Subfiled_6]; ThisCycleData.MDS_Data.CH2_For_DataLink_In_Use = BO.DWord[CAT34I050Types.Subfiled_7]; ThisCycleData.MDS_Data.Coordination_Func_Overload = BO.DWord[CAT34I050Types.FX_Primary_Subfiled]; // Not really FX but the index is correct Number_Of_Octets_Present++; // Mode S subfield is 2 octets CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; ThisCycleData.MDS_Data.DataLink_Func_Overload = BO.DWord[CAT34I050Types.Subfiled_1]; } ////////////////////////////////////////////////////////////////////////////////// // Spare ////////////////////////////////////////////////////////////////////////////////// if (BO.DWord[CAT34I050Types.Subfiled_7] == true) { Number_Of_Octets_Present++; CAT34_I050_Data.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present]; } ////////////////////////////////////////////////////////////////////////////////// // Now assign it to the generic list CAT34.I034DataItems[CAT34.ItemIDToIndex("050")].value = ThisCycleData; ////////////////////////////////////////////////////////////////////////////////// // Increase data buffer index so it ready for the next data item. CAT34.CurrentDataBufferOctalIndex = CAT34.CurrentDataBufferOctalIndex + Number_Of_Octets_Present; } }
public static void DecodeCAT34I030(byte[] Data) { CAT34I030Types.CAT34I030_Time_Of_The_Day_User_Type MyCAT34I030 = new CAT34I030Types.CAT34I030_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[CAT34.CurrentDataBufferOctalIndex + 3]; BO.DWord[Bit_Ops.Bits8_15_Of_DWord] = Data[CAT34.CurrentDataBufferOctalIndex + 2]; BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT34.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; } MyCAT34I030.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; MyCAT34I030.TimeOfDay = new TimeSpan(0, (int)hrs, (int)min, (int)sec, (int)milis); ////////////////////////////////////////////////////////////////////////////////// // Now assign it to the generic list CAT34.I034DataItems[CAT34.ItemIDToIndex("030")].value = MyCAT34I030; ////////////////////////////////////////////////////////////////////////////////// // Leave it at the current index for the next decode CAT34.CurrentDataBufferOctalIndex = CAT34.CurrentDataBufferOctalIndex + 3; }
// 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. Everry 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) { ///////////////////////////////////////////////////////////////////////// // // Next version of Category 002: PSR Radar, M-SSR Radar, Mode-S Station // Length in bytes // // I002/000, Message Type 1 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("000")].CurrentlyPresent == true) { CAT34I000UserData.DecodeCAT34I000(Data); } // 3 I034/030 Time-of-Day 3 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("030")].CurrentlyPresent == true) { CAT34I030UserData.DecodeCAT34I030(Data); } // 4 I034/020 Sector Number 1 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("020")].CurrentlyPresent == true) { CAT34I020UserData.DecodeCAT34I020(Data); } // 5 I034/041 Antenna Rotation Period 2 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("041")].CurrentlyPresent == true) { CAT34I041UserData.DecodeCAT34I041(Data); } // 6 I034/050 System Configuration and Status 1+ if (CAT34.I034DataItems[CAT34.ItemIDToIndex("050")].CurrentlyPresent == true) { CAT34I050UserData.DecodeCAT34I050(Data); } // 7 I034/060 System Processing Mode 1+ if (CAT34.I034DataItems[CAT34.ItemIDToIndex("060")].CurrentlyPresent == true) { CAT34I060UserData.DecodeCAT34I060(Data); } // FX // 8 I034/070 Message Count Values 1+2N if (CAT34.I034DataItems[CAT34.ItemIDToIndex("070")].CurrentlyPresent == true) { CAT34I070UserData.DecodeCAT34I070(Data); } // 9 I034/100 Generic Polar Window 8 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("100")].CurrentlyPresent == true) { CAT34I100UserData.DecodeCAT34I100(Data); } // 10 I034/110 Data Filter 1 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("110")].CurrentlyPresent == true) { CAT34I110UserData.DecodeCAT34I110(Data); } // 11 I034/120 3D-Position of Data Source 8 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("120")].CurrentlyPresent == true) { CAT34I120UserData.DecodeCAT34I120(Data); } // 12 I034/090 Collimation Error 2 if (CAT34.I034DataItems[CAT34.ItemIDToIndex("090")].CurrentlyPresent == true) { CAT34I090UserData.DecodeCAT34I090(Data); } //////////////////////////////////////////////////////////////////////////////////// // All CAT34 data has been decoded, so lets save off the message data to the global // storage for latter usage MainASTERIXDataStorage.CAT34Data CAT34MessageData = new MainASTERIXDataStorage.CAT34Data(); foreach (CAT34.CAT34DataItem Item in CAT34.I034DataItems) { CAT34.CAT34DataItem MyItem = new CAT34.CAT34DataItem(); MyItem.CurrentlyPresent = Item.CurrentlyPresent; MyItem.Description = Item.Description; MyItem.HasBeenPresent = Item.HasBeenPresent; MyItem.ID = Item.ID; MyItem.value = Item.value; CAT34MessageData.CAT34DataItems.Add(MyItem); } MainASTERIXDataStorage.CAT34Message.Add(CAT34MessageData); CAT34.Intitialize(false); }