Exemplo n.º 1
0
 public BoeingController(AircraftConfigItem ac, PerfTable acPerf, TOPerfElements elements,
                         Control parentControl)
 {
     this.acPerf        = acPerf;
     this.elements      = elements;
     this.parentControl = parentControl;
     this.ac            = ac;
 }
Exemplo n.º 2
0
 private static void CheckRange(AircraftConfigItem item)
 {
     Ensure(item.OewKg < item.MaxZfwKg,
            "Max ZFW must be larger than OEW.");
     Ensure(item.OewKg < item.MaxTOWtKg,
            "Max takeoff weight must be larger than OEW.");
     Ensure(item.OewKg < item.MaxLdgWtKg,
            "Max landing weight must be larger than OEW.");
 }
        public void SerializationTest()
        {
            var serializer = new AircraftConfigItem.Serializer();
            var config     = new AircraftConfigItem("A", "B", "C", "D", "E",
                                                    1.0, 2.0, 3.0, 4.0, 5.0, 1.0, WeightUnit.LB);

            var elem         = serializer.Serialize(config, "Config");
            var deserialized = serializer.Deserialize(elem);

            Assert.IsTrue(config.Equals(deserialized, 0.0, 0.0));
        }
        public static IFormController GetController(ControllerType type, AircraftConfigItem ac,
                                                    PerfTable acPerf, LandingPerfElements elements, Control parentControl)
        {
            switch (type)
            {
            case ControllerType.Boeing:
                return(new BoeingController(ac, acPerf, elements, parentControl));

            default:
                throw new ArgumentException();
            }
        }
Exemplo n.º 5
0
 private bool TrySaveConfig(AircraftConfigItem config, string filePath)
 {
     try
     {
         var serializer = new AircraftConfigItem.Serializer();
         var elem       = serializer.Serialize(config, "Config");
         var doc        = new XDocument(elem);
         File.WriteAllText(filePath, doc.ToString());
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 6
0
        private bool ChangesMade()
        {
            AircraftConfigItem config = null;

            try
            {
                config = new AcConfigValidator(elem).Read();
            }
            catch
            {
                return(true);
            }

            const double deltaWt   = 1.0;
            const double deltaBias = 0.0001;

            if (InEditMode)
            {
                return(!config.Equals(currentConfig.Config, deltaWt, deltaBias));
            }
            return(!config.Equals(DefaultAcConfig, deltaWt, deltaBias));
        }
Exemplo n.º 7
0
        private void FillProperties(AircraftConfigItem config)
        {
            var e = elem;
            var c = config;

            // This is needed, so that if the FuelProfile, ToProfile or LdgProfile is not
            // found in the corresponding ComboBox, it will show "None".
            e.FuelProfile.SelectedIndex = 0;
            e.ToProfile.SelectedIndex   = 0;
            e.LdgProfile.SelectedIndex  = 0;

            e.AcType.Text                  = c.AC;
            e.Registration.Text            = c.Registration;
            e.FuelProfile.Text             = c.FuelProfile;
            e.ToProfile.Text               = c.TOProfile;
            e.LdgProfile.Text              = c.LdgProfile;
            e.WeightUnitCBox.SelectedIndex = (int)config.WtUnit;
            e.Oew.Text      = WtDisplay(c.OewKg);
            e.MaxToWt.Text  = WtDisplay(c.MaxTOWtKg);
            e.MaxLdgWt.Text = WtDisplay(c.MaxLdgWtKg);
            e.MaxZfw.Text   = WtDisplay(c.MaxZfwKg);
            e.MaxFuel.Text  = WtDisplay(c.MaxFuelKg);
            e.Bias.Text     = (c.FuelBias * 100.0).ToString("F1");
        }