Exemplo n.º 1
0
        public override void Process()
        {
            base.Process();

            Track trackPoints;

            if (Task == null)
            {
                trackPoints = Engine.FlightValidTrack;
            }
            else
            {
                trackPoints = Engine.TaskValidTrack;
            }

            var initialCount = trackPoints.Length;

            switch (Definition.ObjectType)
            {
            case "NONE":
                Task.ResetValidTrackPoints();     //Task is never null in NONE filter
                trackPoints = Engine.TaskValidTrack;
                break;

            case "INSIDE":
                trackPoints = trackPoints.Filter(p => area.Contains(p));
                break;

            case "OUTSIDE":
                trackPoints = trackPoints.Filter(p => !area.Contains(p));
                break;

            case "BEFORETIME":
                trackPoints = trackPoints.Filter(p => p.Time <= time);
                break;

            case "AFTERTIME":
                trackPoints = trackPoints.Filter(p => p.Time >= time);
                break;

            case "BEFOREPOINT":
                if (point.Point == null)
                {
                    AddNote("reference point is null", true);
                }
                else
                {
                    trackPoints = trackPoints.Filter(p => p.Time <= point.Point.Time);
                }
                break;

            case "AFTERPOINT":
                if (point.Point == null)
                {
                    AddNote("reference point is null", true);
                }
                else
                {
                    trackPoints = trackPoints.Filter(p => p.Time >= point.Point.Time);
                }
                break;

            case "ABOVE":
                trackPoints = trackPoints.Filter(p => p.Altitude >= altitude);
                break;

            case "BELOW":
                trackPoints = trackPoints.Filter(p => p.Altitude <= altitude);
                break;
            }

            if (Task == null)
            {
                Engine.FlightValidTrack = trackPoints;
            }
            else
            {
                Engine.TaskValidTrack = trackPoints;
            }

            //if (Engine.ValidTrackPoints.Length != initialCount)
            AddNote(string.Format("track filtered from {0} to {1} valid points", initialCount, trackPoints.Length));
        }
Exemplo n.º 2
0
        public override void Process()
        {
            base.Process();

            // parse and resolve pilot dependent values
            // the static values are already defined
            // syntax is already checked
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown restriction type '" + Definition.ObjectType + "'");

            case "DMAX":
                if (CheckParameters(2))
                {
                    var calcDistance    = Math.Round(Physics.Distance2D(pointA.Point, pointB.Point), 0);
                    var pctInfringement = 100 * (calcDistance - distance) / distance;
                    var penalty         = DistanceInfringementPenalty(calcDistance, pctInfringement, description);
                    if (penalty != null)
                    {
                        infringed = true;
                        Task.Penalties.Add(penalty);
                        AddNote(string.Format("distance infringement: {0}m", calcDistance), true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "DMIN":
                if (CheckParameters(2))
                {
                    var calcDistance    = Math.Round(Physics.Distance2D(pointA.Point, pointB.Point), 0);
                    var pctInfringement = 100 * (distance - calcDistance) / distance;
                    var penalty         = DistanceInfringementPenalty(calcDistance, pctInfringement, description);
                    if (penalty != null)
                    {
                        infringed = true;
                        Task.Penalties.Add(penalty);
                        AddNote(string.Format("distance infringement: {0}m", calcDistance), true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "DVMAX":
                if (CheckParameters(2))
                {
                    var calcDifference  = Math.Round(Math.Abs(pointA.Point.Altitude - pointB.Point.Altitude), 0);
                    var pctInfringement = 100 * (calcDifference - distance) / distance;
                    var penalty         = DistanceInfringementPenalty(calcDifference, pctInfringement, description);
                    if (penalty != null)
                    {
                        infringed = true;
                        Task.Penalties.Add(penalty);
                        AddNote(string.Format("distance infringement: {0}m", calcDifference), true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "DVMIN":
                if (CheckParameters(2))
                {
                    var calcDifference  = Math.Round(Math.Abs(pointA.Point.Altitude - pointB.Point.Altitude), 0);
                    var pctInfringement = 100 * (distance - calcDifference) / distance;
                    var penalty         = DistanceInfringementPenalty(calcDifference, pctInfringement, description);
                    if (penalty != null)
                    {
                        infringed = true;
                        Task.Penalties.Add(penalty);
                        AddNote(string.Format("distance infringement: {0}m", calcDifference), true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "TMAX":
                if (CheckParameters(2))
                {
                    var calcTime = (pointB.Point.Time - pointA.Point.Time).TotalMinutes;
                    if (calcTime > time)
                    {
                        infringed = true;
                        var reason = string.Format("{0}", description, MinToHms(calcTime));
                        AddNote(string.Format("time infringement: {0}", MinToHms(calcTime)), true);
                        Task.NewNoResult((Task.Result.Reason + "; " + reason).Trim(new char[] { ';', ' ' }));
                        AddNote("No Result (group B): " + reason, true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "TMIN":
                if (CheckParameters(2))
                {
                    var calcTime = Math.Ceiling((pointB.Point.Time - pointA.Point.Time).TotalMinutes);
                    if (calcTime < time)
                    {
                        infringed = true;
                        var reason = string.Format("{0}", description, MinToHms(calcTime));
                        AddNote(string.Format("time infringement: {0}", MinToHms(calcTime)), true);
                        Task.NewNoResult((Task.Result.Reason + "; " + reason).Trim(new char[] { ';', ' ' }));
                        AddNote("No Result (group B): " + reason, true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "TBTOD":
                if (CheckParameters(1))
                {
                    var refTime = Engine.Settings.Date.Date + timeOfDay;
                    if (pointA.Point.Time > refTime)
                    {
                        infringed = true;
                        var reason = string.Format("{0}", description, MinToHms((pointA.Point.Time - refTime).TotalMinutes));
                        AddNote(string.Format("time infringement: {0}", MinToHms((pointA.Point.Time - refTime).TotalMinutes)), true);
                        Task.NewNoResult((Task.Result.Reason + "; " + reason).Trim(new char[] { ';', ' ' }));
                        AddNote("No Result (group B): " + reason, true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "TATOD":
                if (CheckParameters(1))
                {
                    var refTime = Engine.Settings.Date.Date + timeOfDay;
                    if (pointA.Point.Time < refTime)
                    {
                        infringed = true;
                        var reason = string.Format("{0}", description, MinToHms((refTime - pointA.Point.Time).TotalMinutes));
                        AddNote(string.Format("time infringement: {0}", MinToHms((refTime - pointA.Point.Time).TotalMinutes)), true);
                        Task.NewNoResult((Task.Result.Reason + "; " + reason).Trim(new char[] { ';', ' ' }));
                        AddNote("No Result (group B): " + reason, true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;

            case "PINSIDE":
                if (CheckParameters(1))
                {
                    var refTime = Engine.Settings.Date.Date + timeOfDay;
                    if (!area.Contains(pointA.Point))
                    {
                        infringed = true;
                        var reason = string.Format("{0}", description);
                        AddNote(string.Format("point not inside area infringement"), true);
                        Task.NewNoResult((Task.Result.Reason + "; " + reason).Trim(new char[] { ';', ' ' }));
                        AddNote("No Result (group B): " + reason, true);
                    }
                    else
                    {
                        AddNote("not infringed");
                    }
                }
                break;
            }
        }