public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            // quick short circuit for anything more than 24 hours old, or no instruction given, or not a real aircraft
            if (cfr.CFI == 0 || !cfr.fIsRealAircraft || cfr.dtFlight.CompareTo(dt24HoursAgo.Date) < 0)
            {
                return;
            }

            double netCFI = (double)cfr.CFI;

            EffectiveDutyPeriod edp = new EffectiveDutyPeriod(cfr)
            {
                FlightDutyStart = DateTime.UtcNow.AddDays(-1), FlightDutyEnd = DateTime.UtcNow
            };

            TimeSpan ts = edp.TimeSince(dt24HoursAgo, netCFI, cfr);

            if (ts.TotalHours > 0)
            {
                totalInstruction += Math.Min(netCFI, ts.TotalHours);
            }
        }
Esempio n. 2
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            // quick short circuit for anything more than 24 hours old, or not a real aircraft
            if (!cfr.fIsRealAircraft || cfr.dtFlight.CompareTo(dt24HoursAgo.Date) < 0)
            {
                return;
            }

            EffectiveDutyPeriod edp = new EffectiveDutyPeriod(cfr)
            {
                FlightDutyStart = dt24HoursAgo, FlightDutyEnd = DateTime.UtcNow
            };

            TimeSpan ts = edp.TimeSince(dt24HoursAgo, (double)cfr.Total, cfr);

            if (ts.TotalHours > 0)
            {
                TotalFlying += Math.Min((double)cfr.Total, ts.TotalHours);
            }
        }
Esempio n. 3
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            // quick short circuit for anything more than 24 hours old, or no instruction given, or not a real aircraft
            if (cfr.CFI == 0 || !cfr.fIsRealAircraft || cfr.dtFlight.CompareTo(dt24HoursAgo.Date) < 0)
            {
                return;
            }

            double netCFI = (double)cfr.CFI;

            // look for explicit lesson end/lesson start times.
            DateTime lessonStart = cfr.FlightProps.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropLessonStart) ? cfr.FlightProps[CustomPropertyType.KnownProperties.IDPropLessonStart].DateValue : DateTime.MinValue;
            DateTime lessonEnd   = cfr.FlightProps.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropLessonEnd) ? cfr.FlightProps[CustomPropertyType.KnownProperties.IDPropLessonEnd].DateValue : DateTime.MinValue;

            TimeSpan ts;

            if (lessonStart.HasValue() && lessonEnd.HasValue())
            {
                ts = lessonEnd.Subtract(lessonStart.LaterDate(dt24HoursAgo));
            }
            else
            {
                EffectiveDutyPeriod edp = new EffectiveDutyPeriod(cfr)
                {
                    FlightDutyStart = dt24HoursAgo, FlightDutyEnd = DateTime.UtcNow
                };
                ts = edp.TimeSince(dt24HoursAgo, netCFI, cfr);
            }
            if (ts.TotalHours > 0)
            {
                totalInstruction += Math.Min(netCFI, ts.TotalHours);
            }
        }