Exemple #1
0
        private void ReadContents()
        {
            using (StringReader sr = new StringReader(Contents))
            {
                while (sr.Peek() >= 0)
                {
                    string l = sr.ReadLine();
                    switch (l.Substring(0, 1))
                    {
                    case "A":
                        ARecord = new ARecord(l);
                        break;

                    case "B":
                        BRecord b = new BRecord(l, FlightDate, IRecord);
                        if (!BRecords.ContainsKey(b.Time))
                        {
                            BRecords.Add(b.Time, b);
                        }
                        break;

                    case "C":
                        break;

                    case "D":
                        break;

                    case "E":
                        ERecord e = new ERecord(l, FlightDate);
                        ERecords.Add(e);
                        if (e.Code == "STA")
                        {
                            DetectedStart = e.Time;
                        }
                        break;

                    case "F":
                        break;

                    case "G":
                        GRecord = GRecord + l.Substring(1);
                        break;

                    case "H":
                        HRecord h = new HRecord(l);
                        HRecords.Add(h.Code, h);
                        if (HRecords.ContainsKey("DTE"))
                        {
                            FlightDate = new DateTime(2000 + int.Parse(HRecords["DTE"].Value.Substring(4, 2)), int.Parse(HRecords["DTE"].Value.Substring(2, 2)), int.Parse(HRecords["DTE"].Value.Substring(0, 2)));
                        }
                        break;

                    case "I":
                        IRecord = new ExtensionRecord(l);
                        break;

                    case "J":
                        JRecord = new ExtensionRecord(l);
                        break;
                    }
                }
            }

            if (DetectedStart == null && BRecords.Count > 0)
            {
                DetectedStart = BRecords.First().Key;
            }

            // Process other H records
            if (HRecords.ContainsKey("PLT"))
            {
                PilotName = HRecords["PLT"].Value.CutOffUntilCharacter(":").Trim();
            }
            if (HRecords.ContainsKey("GTY"))
            {
                GliderType = HRecords["GTY"].Value.CutOffUntilCharacter(":").Trim();
            }
            if (HRecords.ContainsKey("GID"))
            {
                GliderRegistration = HRecords["GID"].Value.CutOffUntilCharacter(":").Trim();
            }
            if (HRecords.ContainsKey("CCL"))
            {
                GliderClass = HRecords["CCL"].Value.CutOffUntilCharacter(":").Trim();
            }

            // Process B records
            BRecord currentRecord = null;

            foreach (DateTime k in BRecords.Keys)
            {
                if (k > DetectedStart & currentRecord != null)
                {
                    if (Takeoff == null)
                    {
                        Takeoff = new Common.Point(currentRecord);
                    }
                    BRecords[k].CompareWith(currentRecord);
                    if (BRecords[k].GnssAltitude > MaxAltitude)
                    {
                        MaxAltitude = BRecords[k].GnssAltitude;
                    }
                    if (BRecords[k].GnssAltitude < MinAltitude)
                    {
                        MinAltitude = BRecords[k].GnssAltitude;
                    }
                    if (BRecords[k].Vario > MaxVario)
                    {
                        MaxVario = BRecords[k].Vario;
                    }
                    if (BRecords[k].Vario < MinVario)
                    {
                        MinVario = BRecords[k].Vario;
                    }
                    if (BRecords[k].Speed > MaxSpeed)
                    {
                        MaxSpeed = BRecords[k].Speed;
                    }
                    Distance = Distance + BRecords[k].Distance;
                }
                currentRecord = BRecords[k];
            }
            DetectedLandingTime = currentRecord.Time;
            FlightTime          = DetectedLandingTime.Subtract(DetectedStart);
            Landing             = new Common.Point(currentRecord);
            AverageSpeed        = Convert.ToSingle((float)Distance / (float)FlightTime.TotalSeconds);
        }
Exemple #2
0
        private void ReadContents()
        {
            using (StringReader sr = new StringReader(Contents))
            {
                while (sr.Peek() >= 0)
                {
                    string l = sr.ReadLine();
                    switch (l.Substring(0, 1))
                    {
                        case "A":
                            ARecord = new ARecord(l);
                            break;
                        case "B":
                            BRecord b = new BRecord(l, FlightDate, IRecord);
                            if (!BRecords.ContainsKey(b.Time))
                            {
                                BRecords.Add(b.Time, b);
                            }
                            break;
                        case "C":
                            break;
                        case "D":
                            break;
                        case "E":
                            ERecord e = new ERecord(l, FlightDate);
                            ERecords.Add(e);
                            if (e.Code == "STA")
                            {
                                DetectedStart = e.Time;
                            }
                            break;
                        case "F":
                            break;
                        case "G":
                            GRecord = GRecord + l.Substring(1);
                            break;
                        case "H":
                            HRecord h = new HRecord(l);
                            HRecords.Add(h.Code, h);
                            if (HRecords.ContainsKey("DTE"))
                            {
                                FlightDate = new DateTime(2000 + int.Parse(HRecords["DTE"].Value.Substring(4, 2)), int.Parse(HRecords["DTE"].Value.Substring(2, 2)), int.Parse(HRecords["DTE"].Value.Substring(0, 2)));
                            }
                            break;
                        case "I":
                            IRecord = new ExtensionRecord(l);
                            break;
                        case "J":
                            JRecord = new ExtensionRecord(l);
                            break;
                    }
                }
            }

            if (DetectedStart == null && BRecords.Count > 0)
            {
                DetectedStart = BRecords.First().Key;
            }

            // Process other H records
            if (HRecords.ContainsKey("PLT"))
            {
                PilotName = HRecords["PLT"].Value.CutOffUntilCharacter(":").Trim();
            }
            if (HRecords.ContainsKey("GTY"))
            {
                GliderType = HRecords["GTY"].Value.CutOffUntilCharacter(":").Trim();
            }
            if (HRecords.ContainsKey("GID"))
            {
                GliderRegistration = HRecords["GID"].Value.CutOffUntilCharacter(":").Trim();
            }
            if (HRecords.ContainsKey("CCL"))
            {
                GliderClass = HRecords["CCL"].Value.CutOffUntilCharacter(":").Trim();
            }

            // Process B records
            BRecord currentRecord = null;
            foreach (DateTime k in BRecords.Keys)
            {
                if (k > DetectedStart & currentRecord != null)
                {
                    if (Takeoff == null)
                    {
                        Takeoff = new Common.Point(currentRecord);
                    }
                    BRecords[k].CompareWith(currentRecord);
                    if (BRecords[k].GnssAltitude > MaxAltitude)
                    {
                        MaxAltitude = BRecords[k].GnssAltitude;
                    }
                    if (BRecords[k].GnssAltitude < MinAltitude)
                    {
                        MinAltitude = BRecords[k].GnssAltitude;
                    }
                    if (BRecords[k].Vario > MaxVario)
                    {
                        MaxVario = BRecords[k].Vario;
                    }
                    if (BRecords[k].Vario < MinVario)
                    {
                        MinVario = BRecords[k].Vario;
                    }
                    if (BRecords[k].Speed > MaxSpeed)
                    {
                        MaxSpeed = BRecords[k].Speed;
                    }
                    Distance = Distance + BRecords[k].Distance;
                }
                currentRecord = BRecords[k];
            }
            DetectedLandingTime = currentRecord.Time;
            FlightTime = DetectedLandingTime.Subtract(DetectedStart);
            Landing = new Common.Point(currentRecord);
            AverageSpeed = Convert.ToSingle((float)Distance / (float)FlightTime.TotalSeconds);
        }