Ejemplo n.º 1
0
        // node should be "Dry" or "Wet" node
        private static WtTables SetFieldClimbLimitWt(XElement node, bool lenthIsMeter, bool WtIsKG)
        {
            var wtTables = node.Elements("WeightTable").ToList();

            // x
            var altitudes = wtTables.Select(x => x.Element("Altitude").Value)
                            .ToDoubles();

            var fieldLimTables = wtTables
                                 .Select(x => TableReader2D.Read(x.Element("Table").Value))
                                 .ToList();

            var lengths      = fieldLimTables.First().x;
            var oats         = fieldLimTables.First().y;
            var fieldlimitWt = fieldLimTables.Select(t => t.f).ToArray();

            double[][] climbLimWt = GetClimbLimit(wtTables);

            // Now check units
            if (lenthIsMeter == false)
            {
                lengths.Multiply(FtMeterRatio);
            }

            if (WtIsKG == false)
            {
                climbLimWt.Multiply(LbKgRatio);
                fieldlimitWt.Multiply(LbKgRatio);
            }

            return(new WtTables(
                       new FieldLimitWtTable(altitudes, lengths, oats, fieldlimitWt),
                       new ClimbLimitWtTable(altitudes, oats, climbLimWt)));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var str = @"240000	260000	280000	300000	320000	340000	360000	380000	400000	420000	440000	460000      
      800	14100	14900	15800	16700	17500	18500	19500	20400	21500	22700	23900	25100
      1200	19800	20900	22200	23600	24800	26200	27600	28900	30400	32100	33900	35500
      1600	25400	26800	28500	30300	31900	33700	35600	37300	39200	41300	43500	45700
      2000	30900	32700	34700	36900	38900	41000	43300	45500	47700	50200	52900	55600
      2400	36400	38400	40700	43300	45800	48200	50900	53500	56100	59000	62100	65200
      2800	41700	44000	46600	49500	52400	55200	58300	61300	64400	67600	71000	74600
      3200	47000	49500	52400	55600	58900	62000	65500	68900	72400	76000	79800	83700
      3600	52100	55000	58100	61700	65300	68900	72600	76300	80200	84200	88300	92600
      4000	57200	60300	63800	67600	71500	75500	79600	83600	87800	92200	96700	101300
      4400	62300	65600	69300	73400	77600	81900	86400	90800	95300	100000	104900	109800
      4800	67300	70800	74800	79100	83500	88200	93100	97800	102600	107700	112900	118200
      5200	72300	75900	80100	84700	89400	94400	99500	104700	109700	115100	120700	126400
      5600	77100	80900	85400	90200	95200	100400	105900	111300	116800	122400	128400	134300
      6000	82000	86000	90600	95600	100900	106300	112100	117900	123700	129600	135800	142100
      6400	86700	91000	95700	101000	106400	112200	118200	124200	130400	136600	143100	149700
      6800	91300	95900	100700	106300	111900	117900	124100	130500	136900	143500	150200	157100
      7200	95900	100700	105800	111400	117300	123500	130000	136600	143300	150300	157300	164400
      7600	100400	105500	110800	116500	122700	129100	135700	142600	149600	156800	164200	171500
      8000	104900	110100	115700	121600	127900	134500	141400	148500	155700	163200	170900	178500"    ;

            var table    = TableReader2D.Read(str);
            var table1Ds = new List <Table1D>();

            for (int i = 0; i < table.x.Length; i++)
            {
                var x = table.y.ArrayCopy();
                var f = table.f[i].ArrayCopy();

                for (int j = 0; j < table.y.Length; j++)
                {
                    x[j] -= f[j];
                }

                var table1D = new Table1D(x, f);

                for (int k = 0; k < table.y.Length; k++)
                {
                    table.f[i][k] = table1D.ValueAt(table.y[k]);
                }
            }

            var result = str.Lines()[0] + "\n" + string.Join("\n",
                                                             table.x.Select(x => x.ToString())
                                                             .Zip(table.f.Select(row => string.Join(" ", row.Select(d => d.ToString("F0")))),
                                                                  (s1, s2) => s1 + " " + s2));

            File.WriteAllText("result.txt", result);
        }
Ejemplo n.º 3
0
        private void AssertTable(string source)
        {
            var table = TableReader2D.Read(source);

            var expected = new Table2D(
                new[] { 1500.0, 1600.0, 1800.0 },
                new[] { -40.0, 10.0, 14.0 },
                new[] {
                new[] { 51.2, 47.0, 46.7 },
                new[] { 52.8, 48.5, 48.1 },
                new[] { 55.9, 51.3, 51.0 }
            });

            Assert.IsTrue(table.Equals(expected, delta));
        }
Ejemplo n.º 4
0
        private void AssertTable(string source)
        {
            var table = TableReader2D.Read(source);

            var expected = new Table2D(
                Arr(1500.0, 1600.0, 1800.0),
                Arr(-40.0, 10.0, 14.0),
                Arr(
                    Arr(51.2, 47.0, 46.7),
                    Arr(52.8, 48.5, 48.1),
                    Arr(55.9, 51.3, 51.0)
                    ));

            Assert.IsTrue(table.Equals(expected, delta));
        }
Ejemplo n.º 5
0
        private IndividualPerfTable ReadIndividualTable(XElement node)
        {
            string flaps = node.Element("Flaps").Value;

            //read weight/length units
            bool wtUnitIsTon       = node.Element("WeightUnit").Value == "1000KG";
            bool lengthUnitIsMeter = node.Element("LengthUnit").Value == "M";

            //read adjustment part
            var    adjustments   = node.Element("Adjustments");
            var    packs         = adjustments.Element("Packs");
            double PacksOffDry   = packs.GetDouble("Dry");
            double PacksOffWet   = packs.GetDouble("Wet");
            double PacksOffClimb = packs.GetDouble("Climb");

            var    antiIceEng = adjustments.Element("AntiIce").Element("EngineOnly");
            double AIEngDry   = antiIceEng.GetDouble("Dry");
            double AIEngWet   = antiIceEng.GetDouble("Wet");
            double AIEngClimb = antiIceEng.GetDouble("Climb");

            var    antiIceBoth = adjustments.Element("AntiIce").Element("EngineAndWing");
            double AIBothDry   = antiIceBoth.GetDouble("Dry");
            double AIBothWet   = antiIceBoth.GetDouble("Wet");
            double AIBothClimb = antiIceBoth.GetDouble("Climb");

            //Import tables
            var dryNode = node.Element("Dry");
            var wetNode = node.Element("Wet");

            var slopeCorrDry = TableReader2D.Read(dryNode.Element("SlopeCorrection").Value);
            var windCorrDry  = TableReader2D.Read(dryNode.Element("WindCorrection").Value);
            var SlopeCorrWet = TableReader2D.Read(wetNode.Element("SlopeCorrection").Value);
            var WindCorrWet  = TableReader2D.Read(wetNode.Element("WindCorrection").Value);

            SetUnitSlopeOrWindTable(slopeCorrDry, lengthUnitIsMeter);
            SetUnitSlopeOrWindTable(windCorrDry, lengthUnitIsMeter);
            SetUnitSlopeOrWindTable(SlopeCorrWet, lengthUnitIsMeter);
            SetUnitSlopeOrWindTable(WindCorrWet, lengthUnitIsMeter);

            var tables         = SetFieldClimbLimitWt(dryNode, lengthUnitIsMeter, wtUnitIsTon);
            var WeightTableDry = tables.Field;
            var ClimbLimitWt   = tables.Climb;

            var WeightTableWet = SetFieldClimbLimitWt(wetNode, lengthUnitIsMeter, wtUnitIsTon).Field;

            // Derates (TO1, TO2)
            ImportAltnRating(node, wtUnitIsTon);

            return(new IndividualPerfTable(
                       PacksOffDry,
                       PacksOffWet,
                       PacksOffClimb,
                       AIBothDry,
                       AIBothWet,
                       AIBothClimb,
                       AIEngDry,
                       AIEngWet,
                       AIEngClimb,
                       flaps,
                       thrustRatings.Count > 0,
                       derateTables,
                       thrustRatings,
                       new SlopeCorrTable(slopeCorrDry.x, slopeCorrDry.y, slopeCorrDry.f),
                       new SlopeCorrTable(SlopeCorrWet.x, SlopeCorrWet.y, SlopeCorrWet.f),
                       new WindCorrTable(windCorrDry.x, windCorrDry.y, windCorrDry.f),
                       new WindCorrTable(WindCorrWet.x, WindCorrWet.y, WindCorrWet.f),
                       WeightTableDry,
                       WeightTableWet,
                       ClimbLimitWt));
        }
Ejemplo n.º 6
0
 public FuelTable(string text)
 {
     table = TableReader2D.Read(text);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Loads the performance table when given the root node of xml file.
        /// </summary>
        public static (bool success, AirbusPerfTable val) LoadPerfTable(XElement rootNode)
        {
            try
            {
                if (rootNode.Element("Parameters").Element("Format").Value != "1")
                {
                    return(false, null);
                }

                var(headwind, tailwind) = GetTable3Rows(rootNode.Element("Wind").Value);
                var(uphill, downhill)   = GetTable3Rows(rootNode.Element("Slope").Value);

                var tables = rootNode.Elements("Table").Select(GetTableNode);
                TableDataNode GetTableNode(XElement e)
                {
                    var t     = TableReader2D.Read(e.Value);
                    var flaps = e.Attribute("flaps").Value;
                    var isa   = double.Parse(e.Attribute("ISA_offset").Value);

                    return(new TableDataNode()
                    {
                        Table = t,
                        Flaps = flaps,
                        IsaOffset = isa
                    });
                }


                var wetTable = GetWetTable(rootNode.Element("WetCorrection").Value);
                Table1D GetWetTable(string str)
                {
                    var nums = Regex.Split(str, @"\s").Where(s => s != "")
                               .Select(s => double.Parse(s))
                               .ToList();
                    var count = nums.Count;

                    Ensure <Exception>(count % 2 == 0);
                    var half = count / 2;

                    return(new Table1D(nums.Take(half).ToArray(), nums.Skip(half).ToArray()));
                }

                var bleeds   = rootNode.Element("Bleeds");
                var engineAI = double.Parse(bleeds.Attribute("engine_ai").Value);
                var allAI    = double.Parse(bleeds.Attribute("all_ai").Value);
                var packsOn  = double.Parse(bleeds.Attribute("packs_on").Value);

                return(true,
                       new AirbusPerfTable()
                {
                    HeadwindCorrectionTable = headwind,
                    TailwindCorrectionTable = tailwind,
                    UphillCorrectionTable = uphill,
                    DownHillCorrectionTable = downhill,
                    Tables = tables.ToList(),
                    WetCorrectionTable = wetTable,
                    EngineAICorrection = engineAI,
                    AllAICorrection = allAI,
                    PacksOnCorrection = packsOn
                });
            }
            catch
            {
                return(false, null);
            }
        }