コード例 #1
0
ファイル: APITests.cs プロジェクト: mischif/Feral.net
        public void TestDetailsOnPlan()
        {
            String _planDetails = "{\"response\":{\"plan-id\":\"102\",\"name\":\"Power Reloaded\",\"description\":\"250 GB Disk Space, 10 Gbps Network Connection, and 2 TB Monthly Traffic\",\"label\":\"powerReloaded\",\"plan-category-id\":\"71\",\"disk-gb\":\"250\",\"bandwidth-gb\":\"2000\",\"bandwidth-upload\":null,\"bandwidth-ratio\":\"25\",\"type\":\"slot\",\"available-eta\":\"15\",\"available-count\":\"100\"},\"meta\":{\"server\":\"lava.feralhosting.com\",\"protocol\":\"0.3\",\"page\":\"site\\/plan-detail\",\"username\":\"mischif\"},\"error\":[],\"warning\":[]}";
            Response <DetailedPlan> response = JsonConvert.DeserializeObjectAsync <Response <DetailedPlan> >(_planDetails).Result;

            Assert.IsNotNull(response.response, "No response. What's happening?");
            Assert.IsNotNull(response.meta, "No metadata. What's happening?");
            Assert.AreEqual(response.meta.protocol, "0.3");

            DetailedPlan planDetails = response.response;
        }
コード例 #2
0
        /// <summary>
        /// The argument 'plan' should be the return value of FuelCalculator.Create()
        /// method. Note that the fuel consumption depends on the weight of the aircraft,
        /// which depends on the vertical profile of the flight plan. Because of this,
        /// when FuelCalculator creates the DetailedPlan, the fuel values for
        /// nodes in climb segment are estimations.
        ///
        /// Use this method to compute the exact fuel amounts for each node.
        /// </summary>
        public static DetailedPlan ApplyCorrection(this DetailedPlan plan, FuelDataItem item)
        {
            if (item.FuelTable == null)
            {
                return(plan);
            }
            var nodes       = plan.AllNodes;
            var airDis      = nodes.AirDistance();
            var exactFuel   = item.FuelTable.FuelRequired(airDis, nodes.Last().GrossWt);
            var landingFuel = nodes.Last().FuelOnBoard;
            var factor      = exactFuel / (nodes[0].FuelOnBoard - landingFuel);
            var zfw         = nodes[0].GrossWt - nodes[0].FuelOnBoard;

            return(new DetailedPlan(nodes.Select(n =>
            {
                var newFuel = (n.FuelOnBoard - landingFuel) * factor + landingFuel;
                return GetNode(n, newFuel, newFuel + zfw);
            }).ToList()));
        }