示例#1
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);
            }
        }
        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);
            }
        }
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            EffectiveDutyPeriod edp = CurrentEDP = new EffectiveDutyPeriod(cfr, !HasSeenProperDutyPeriod);

            // If we haven't yet seen the start of an open duty period, don't compute the rest yet (need to know the close off point),
            // so store the end of the duty period in m_edpCurrent and leave the computation to a subsequent flight.
            // OR, if we have an open duty period (m_edpCurrent isn't null) and this one can close it off, then we can do so.
            // OR, if we have an open duty period and this one doesn't close it off, continue to a subsequent flight.
            // Of course, if we're including all flights, then we ALWAYS process this flight using effective (computed) times.
            if (!IncludeAllFlights)
            {
                // if neither start nor end duty times were specified, return; no more processing to do on this flight
                if (edp.Specification == DutySpecification.None)
                {
                    return;
                }
                // If it's fully specified, there's nothing to do but to record the duty period
                // OR if we haven't seen a proper duty period yet AND we don't have a current open edp (we shouldn't) AND this indicates a start duty/flightduty, add it to the duty period.
                else if (edp.Specification == DutySpecification.Both || (!HasSeenProperDutyPeriod && m_edpCurrent == null && (edp.FPDutyStart != null || edp.AdditionalDutyStart.HasValue)))
                {
                    AddDutyPeriodToList(edp);
                }
                // Otherwise, if we have just the end of a duty period, open up the active duty period.
                else if (m_edpCurrent == null && edp.Specification == DutySpecification.End) // we've found the end of a duty period - open up an active duty period
                {
                    m_edpCurrent = edp;
                }
                // Otherwise, we've found a start of a period - we can close it off.
                else if (m_edpCurrent != null && edp.FPDutyStart != null)
                {
                    edp.AdditionalDutyEnd        = m_edpCurrent.AdditionalDutyEnd; // be sure to capture any additional duty time from the END of FDP, recorded in a flight we saw previously.
                    m_edpCurrent.FlightDutyEnd   = m_edpCurrent.FPDutyEnd.DateValue;
                    m_edpCurrent.FlightDutyStart = edp.FPDutyStart.DateValue;
                    AddDutyPeriodToList(m_edpCurrent);
                    m_edpCurrent.Specification = DutySpecification.Both;
                    CurrentEDP   = m_edpCurrent; // we'll return this whole EDP.
                    m_edpCurrent = null;
                }
            }
            else
            {
                AddDutyPeriodToList(edp);
            }

            HasSeenProperDutyPeriod = HasSeenProperDutyPeriod || edp.Specification != DutySpecification.None;
        }
        /// <summary>
        /// Adds a duty period to the list of dutyperiods, checking for duplicates (but not overlap!)  Handles multiple flights when IncludeAllFlights is checked.
        /// </summary>
        /// <param name="edp"></param>
        protected void AddDutyPeriodToList(EffectiveDutyPeriod edp)
        {
            if (edp == null)
            {
                throw new ArgumentNullException(nameof(edp));
            }

            if (m_effectiveDutyPeriods.Any())
            {
                EffectiveDutyPeriod edpLatest = m_effectiveDutyPeriods[m_effectiveDutyPeriods.Count - 1];
                if (edp.EffectiveDutyEnd.CompareTo(edpLatest.EffectiveDutyEnd) == 0 && edp.EffectiveDutyStart.CompareTo(edpLatest.EffectiveDutyStart) == 0)
                {
                    return;
                }
            }
            m_effectiveDutyPeriods.Add(edp);
        }
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            base.ExamineFlight(cfr);    // will set CurrentEDP

            EffectiveDutyPeriod edp = CurrentEDP;

            // Add in flight times if
            // (a) we include all flights OR
            // (b) we don't include all flights but we have a currently active duty period, OR
            // (c) this flight has some duty period specified
            if (IncludeAllFlights || HasIndeterminateEDP || edp.Specification != DutySpecification.None)
            {
                Add11723BTime(cfr, edp.FlightDutyEnd);
            }
        }
示例#6
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);
            }
        }
 public DutyPeriodExaminer(bool includeAllFlights) : base()
 {
     IncludeAllFlights = includeAllFlights;
     m_edpCurrent      = null;
 }