private static void GetVatsimClientRecordsFromLines(string[] lines) { bool client_section = false; Console.Write("Processing Vatsim Client Records from File... "); using (var progress = new ConsoleProgressBar()) { int count = 0; int total = lines.Length; foreach (string line in lines) { if (!IgnoreThisLine(line)) { progress.Report((double)count++ / total); Thread.Sleep(20); if (line.StartsWith("!CLIENTS:")) { client_section = true; continue; } if (line.StartsWith("!SERVERS:") || line.StartsWith("!PREFILE:")) { client_section = false; return; } if (client_section) { CurrentVatsimData.VatsimClientRecords.Add(VatsimClientRecord.GetVatsimClientRecord(line)); } } } } Console.WriteLine("Done."); }
public bool IFRFlightPlanActive(VatsimClientRecord record) { // only filed/active IFR flight types if( record.PlannedDepairport != "" && record.PlannedDestairport != "" && record.PlannedFlighttype != "" && record.PlannedFlighttype == "I") { return true; } else { return false; } }
/// <summary> /// Read a line from the vatsim data file and parse out appropriate VatsimClientRecord object. /// https://status.vatsim.net/ /// </summary> /// <param name="line">A line containing client data from vatsim-data.txt</param> /// <returns>VatsimClientRecord object</returns> public static VatsimClientRecord GetVatsimClientRecord(string line) { VatsimClientRecord record = new VatsimClientRecord(); string[] parts = line.Split(FIELD_DELIMITER); // Console.WriteLine($"NUMBER OF PARTS: {parts.Length}"); if (parts.Length == 42) { // callsign record.Callsign = parts[CALLSIGN_INDEX]; // cid record.Cid = parts[CID_INDEX]; // realname record.Realname = parts[REALNAME_INDEX]; // clienttype record.Clienttype = parts[CLIENTTYPE_INDEX]; // frequency record.Frequency = parts[FREQUENCY_INDEX]; // latitude record.Latitude = parts[LATITUDE_INDEX]; // longitude record.Longitude = parts[LONGITUDE_INDEX]; // altitude record.Altitude = parts[ALTITUDE_INDEX]; // groundspeed record.Groundspeed = parts[GROUNDSPEED_INDEX]; // planned_aircraft record.PlannedAircraft = parts[PLANNED_AIRCRAFT_INDEX]; // planned_tascruise record.PlannedTascruise = parts[PLANNED_TASCRUISE_INDEX]; // planned_depairport record.PlannedDepairport = parts[PLANNED_DEPAIRPORT_INDEX]; // planned_altitude record.PlannedAltitude = parts[PLANNED_ALTITUDE_INDEX]; // planned_destairport record.PlannedDestairport = parts[PLANNED_DESTAIRPORT_INDEX]; // server record.Server = parts[SERVER_INDEX]; // protrevision record.Protrevision = parts[PROTREVISION_INDEX]; // rating record.Rating = parts[RATING_INDEX]; // transponder record.Transponder = parts[TRANSPONDER_INDEX]; // facilitytype record.Facilitytype = parts[FACILITYTYPE_INDEX]; // visualrange record.Visualrange = parts[VISUALRANGE_INDEX]; // planned_revision record.PlannedRevision = parts[PLANNED_REVISION_INDEX]; // planned_flighttype record.PlannedFlighttype = parts[PLANNED_FLIGHTTYPE_INDEX]; // planned_deptime record.PlannedDeptime = parts[PLANNED_DEPTIME_INDEX]; // planned_actdeptime record.PlannedActdeptime = parts[PLANNED_ACTDEPTIME_INDEX]; // planned_hrsenroute record.PlannedHrsenroute = parts[PLANNED_HRSENROUTE_INDEX]; // planned_minenroute record.PlannedMinenroute = parts[PLANNED_MINENROUTE_INDEX]; // planned_hrsfuel record.PlannedHrsfuel = parts[PLANNED_HRSFUEL_INDEX]; // planned_minfuel record.PlannedMinfuel = parts[PLANNED_MINFUEL_INDEX]; // planned_altairport record.PlannedAltairport = parts[PLANNED_ALTAIRPORT_INDEX]; // planned_remarks record.PlannedRemarks = parts[PLANNED_REMARKS_INDEX]; // planned_route record.PlannedRoute = parts[PLANNED_ROUTE_INDEX]; // planned_depairport_lat record.PlannedDepairportLat = parts[PLANNED_DEPAIRPORT_LAT_INDEX]; // planned_depairport_lon record.PlannedDepairportLon = parts[PLANNED_DEPAIRPORT_LON_INDEX]; // planned_destairport_lat record.PlannedDestairportLat = parts[PLANNED_DESTPAIRPORT_LAT_INDEX]; // planned_destairport_lon record.PlannedDestairportLon = parts[PLANNED_DESTAIRPORT_LON_INDEX]; // atis_message record.AtisMessage = parts[ATIS_MESSAGE_INDEX]; // time_last_atis_received record.TimeLastAtisReceived = parts[TIME_LAST_ATIS_RECEIVED_INDEX]; // time_logon record.TimeLogon = parts[TIME_LOGON_INDEX]; // heading record.Heading = parts[HEADING_INDEX]; // QNH_iHg record.QNH_iHg = parts[QNH_IHG_INDEX]; // QNH_Mb record.QNH_Mb = parts[QNH_MB_INDEX]; } return(record); }