Example #1
0
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            //parse static types
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown filter type '" + Definition.ObjectType + "'");

            case "NONE":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1 && Definition.ObjectParameters[0] == "");
                if (Task == null)
                {
                    throw new InvalidOperationException("Filter NONE is valid only inside tasks");
                }
                break;

            case "INSIDE":
            case "OUTSIDE":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                area = ResolveOrDie <ScriptingArea>(0);
                break;

            case "BEFORETIME":
            case "AFTERTIME":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                time = Engine.Settings.Date.Date + ParseOrDie <TimeSpan>(0, Parsers.ParseTimeSpan);
                break;

            case "BEFOREPOINT":
            case "AFTERPOINT":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                point = ResolveOrDie <ScriptingPoint>(0);
                break;

            case "ABOVE":
            case "BELOW":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 1);
                altitude = ParseOrDie <double>(0, Parsers.ParseLength);
                break;
            }
        }
Example #2
0
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException(string.Format("Unknown area type '{0}'", Definition.ObjectType));

            case "CYLINDER":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length >= 2 && Definition.ObjectParameters.Length <= 4);
                center = ResolveOrDie <ScriptingPoint>(0);    // point will be static or null
                radius = ParseOrDie <double>(1, Parsers.ParseLength);
                if (Definition.ObjectParameters.Length >= 3)
                {
                    upperLimit = ParseOrDie <double>(2, Parsers.ParseLength);
                }
                if (Definition.ObjectParameters.Length >= 4)
                {
                    lowerLimit = ParseOrDie <double>(3, Parsers.ParseLength);
                }

                maxHorizontalInfringement = 2 * radius;
                break;

            case "SPHERE":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                center = ResolveOrDie <ScriptingPoint>(0);    // point will be static or null
                radius = ParseOrDie <double>(1, Parsers.ParseLength);

                maxHorizontalInfringement = 2 * radius;
                break;

            case "PRISM":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length >= 1 && Definition.ObjectParameters.Length <= 3);
                var fileName = ParseOrDie <string>(0, s => s);
                var trackLog = LoggerFile.Load(fileName, Engine.Settings.UtcOffset);
                outline = Engine.Settings.GetTrack(trackLog);
                if (Definition.ObjectParameters.Length >= 2)
                {
                    upperLimit = ParseOrDie <double>(1, Parsers.ParseLength);
                }
                if (Definition.ObjectParameters.Length >= 3)
                {
                    lowerLimit = ParseOrDie <double>(2, Parsers.ParseLength);
                }

                for (var i = 1; i < outline.Count; i++)
                {
                    for (var j = 0; j < i; j++)
                    {
                        maxHorizontalInfringement = Math.Max(maxHorizontalInfringement, Physics.Distance2D(outline[i], outline[j]));
                    }
                }
                break;

            case "TIME":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                lowerTime = Engine.Settings.Date.Date + ParseOrDie <TimeSpan>(0, Parsers.ParseTimeSpan);
                upperTime = Engine.Settings.Date.Date + ParseOrDie <TimeSpan>(1, Parsers.ParseTimeSpan);
                break;

            case "UNION":
            case "INTERSECTION":
            case "SUBTRACTION":
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length > 1);
                areas = new List <ScriptingArea>();
                foreach (var areaName in Definition.ObjectParameters)
                {
                    var area = Engine.Heap.Values.FirstOrDefault(o => o is ScriptingArea && o.Definition.ObjectName == areaName) as ScriptingArea;
                    if (area == null)
                    {
                        throw new ArgumentException("undeclaread area " + areaName);
                    }
                    areas.Add(area);
                }
                break;
            }
        }
Example #3
0
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            if (Task == null)
            {
                throw new ArgumentException(Definition.ObjectName + ": no previous task defined");
            }

            //check syntax and resolve static values (well defined at constructor time, not pilot dependent)
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown result type '" + Definition.ObjectType + "'");

            case "D2D":
            //D2D: distance in 2D
            //D2D(<pointNameA>, <pointNameB> [,<bestPerformance>])
            case "D3D":
                //D3D: distance in 3D
                //D3D(<pointNameA>, <pointNameB> [,<bestPerformance>])
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2 || Definition.ObjectParameters.Length == 3);
                A = ResolveOrDie <ScriptingPoint>(0);
                B = ResolveOrDie <ScriptingPoint>(1);
                if (Definition.ObjectParameters.Length == 3)
                {
                    bestPerformance = ParseOrDie <double>(2, Parsers.ParseLength);
                }
                unit = "m";
                break;

            case "DRAD":
            case "DRAD10":
                //DRAD: relative altitude dependent distance
                //DRAD10: relative altitude dependent distance rounded down to decameter
                //XXXX(<pointNameA>, <pointNameB>, <threshold> [,<bestPerformance>])
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3 || Definition.ObjectParameters.Length == 4);
                A = ResolveOrDie <ScriptingPoint>(0);
                B = ResolveOrDie <ScriptingPoint>(1);
                altitudeThreshold = ParseOrDie <double>(2, Parsers.ParseLength);
                if (Definition.ObjectParameters.Length == 4)
                {
                    bestPerformance = ParseOrDie <double>(3, Parsers.ParseLength);
                }
                unit = "m";
                break;

            case "DACC":
                //DACC: accumulated distance
                //DACC(<pointNameA>, <pointNameB>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                A    = ResolveOrDie <ScriptingPoint>(0);
                B    = ResolveOrDie <ScriptingPoint>(1);
                unit = "m";
                break;

            case "TSEC":
                //TSEC: time in seconds
                //TSEC(<pointNameA>, <pointNameB>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                A    = ResolveOrDie <ScriptingPoint>(0);
                B    = ResolveOrDie <ScriptingPoint>(1);
                unit = "s";
                break;

            case "TMIN":
                //TMIN: time in minutes
                //TMIN(<pointNameA>, <pointNameB>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                A    = ResolveOrDie <ScriptingPoint>(0);
                B    = ResolveOrDie <ScriptingPoint>(1);
                unit = "min";
                break;

            case "ATRI":
                //ATRI: area of triangle
                //ATRI(<pointNameA>, <pointNameB>, <pointNameC>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                A    = ResolveOrDie <ScriptingPoint>(0);
                B    = ResolveOrDie <ScriptingPoint>(1);
                C    = ResolveOrDie <ScriptingPoint>(2);
                unit = "km^2";
                break;

            case "ANG3P":
                //ANG3P: angle between 3 points
                //ANG3P(<pointNameA>, <pointNameB>, <pointNameC>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                A    = ResolveOrDie <ScriptingPoint>(0);
                B    = ResolveOrDie <ScriptingPoint>(1);
                C    = ResolveOrDie <ScriptingPoint>(2);
                unit = "°";
                break;

            case "ANGN":
                //ANGN: angle to the north
                //ANGN(<pointNameA>, <pointNameB>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 2);
                A    = ResolveOrDie <ScriptingPoint>(0);
                B    = ResolveOrDie <ScriptingPoint>(1);
                unit = "°";
                break;

            case "ANGSD":
                //ANGSD: angle to a set direction
                //ANGSD(<pointNameA>, <pointNameB>, <setDirection>)
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                A            = ResolveOrDie <ScriptingPoint>(0);
                B            = ResolveOrDie <ScriptingPoint>(1);
                setDirection = ParseOrDie <double>(2, Parsers.ParseDouble);
                unit         = "°";
                break;
            }
        }
        public override void CheckConstructorSyntax()
        {
            base.CheckConstructorSyntax();

            if (Task == null)
            {
                throw new ArgumentException(Definition.ObjectName + ": no previous task defined");
            }

            //check syntax and resolve static values (well defined at constructor time, not pilot dependent)
            switch (Definition.ObjectType)
            {
            default:
                throw new ArgumentException("Unknown restriction type '" + Definition.ObjectType + "'");

            //DMAX: maximum distance
            //DMAX(<pointNameA>, <pointNameB>, <distance>, <description>)
            case "DMAX":
            //DMIN: minimum distance
            //DMIN(<pointNameA>, <pointNameB>, <distance>, <description>)
            case "DMIN":
            //DVMAX: maximum vertical distance
            //DVMAX(<pointNameA>, <pointNameB>, <altitude>, <description>)
            case "DVMAX":
            //DVMIN: minimum vertical distance
            //DVMIN(<pointNameA>, <pointNameB>, <altitude>, <description>)
            case "DVMIN":
            {
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 4);
                pointA      = ResolveOrDie <ScriptingPoint>(0);
                pointB      = ResolveOrDie <ScriptingPoint>(1);
                distance    = ParseOrDie <double>(2, Parsers.ParseLength);
                description = ParseOrDie <string>(3, Parsers.ParseString);
            }
            break;

            //TMAX: maximum time
            //TMAX(<pointNameA>, <pointNameB>, <time>, <description>)
            case "TMAX":
            //TMIN: minimum time
            //TMIN(<pointNameA>, <pointNameB>, <time>, <description>)
            case "TMIN":
            {
                {
                    AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 4);
                    pointA      = ResolveOrDie <ScriptingPoint>(0);
                    pointB      = ResolveOrDie <ScriptingPoint>(1);
                    time        = ParseOrDie <int>(2, Parsers.ParseInt);
                    description = ParseOrDie <string>(3, Parsers.ParseString);
                }
            }
            break;

            //TBTOD: before time of day
            //TBTOD(<pointNameA>, <time>, <description>)
            case "TBTOD":
            //TATOD: after time of day
            //TATOD(<pointNameA>, <time>, <description>)
            case "TATOD":
            {
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                pointA      = ResolveOrDie <ScriptingPoint>(0);
                timeOfDay   = ParseOrDie <TimeSpan>(1, Parsers.ParseTimeSpan);
                description = ParseOrDie <string>(2, Parsers.ParseString);
            }
            break;

            //PINSIDE: point inside area
            //PINSIDE(<pointNameA>, <area>, <description>)
            case "PINSIDE":
            {
                AssertNumberOfParametersOrDie(Definition.ObjectParameters.Length == 3);
                pointA = ResolveOrDie <ScriptingPoint>(0);
                var areaName = ParseOrDie <string>(1, Parsers.ParseString);
                area = Engine.Heap.Values.FirstOrDefault(o => o is ScriptingArea && o.Definition.ObjectName == areaName) as ScriptingArea;
                if (area == null)
                {
                    throw new ArgumentException("undeclaread area " + areaName);
                }
                description = ParseOrDie <string>(2, Parsers.ParseString);
            }
            break;
            }
        }