Esempio n. 1
0
        public double GetThrustEffectiveness(Thruster Th)
        {
            double AirDensity = GetAirDensity(Settings["Height"]);
            double min        = Math.Min(Th.EffectivenessAtMaxInfluence, Th.EffectivenessAtMinInfluence);
            double max        = Math.Max(Th.EffectivenessAtMaxInfluence, Th.EffectivenessAtMinInfluence);
            double result     = LineFunction(AirDensity, Th.MinPlanetaryInfluence, Th.EffectivenessAtMinInfluence, Th.MaxPlanetaryInfluence, Th.EffectivenessAtMaxInfluence, min, max);

            return(result);
        }
Esempio n. 2
0
        public Dictionary <string, Thruster> GetThtusterList(double GridT = 1)
        {
            string GridType = "Large";

            if (GridT == 0)
            {
                GridType = "Small";
            }
            Dictionary <string, Thruster> result = new Dictionary <string, Thruster>();
            Thruster res;

            foreach (XmlNode xnode in xThrusters)
            {
                if (xnode.Attributes != null && xnode.Attributes.Count > 0)
                {
                    XmlNode xThName   = xnode.Attributes.GetNamedItem("Name");
                    XmlNode xGridType = xnode.Attributes.GetNamedItem("GridType");

                    if ((xThName != null && xThName.Value != "") && (xGridType != null && xGridType.Value == GridType))
                    {
                        res = new Thruster(xThName.Value, xGridType.Value);

                        foreach (XmlNode Attr in xnode.Attributes)
                        {
                            if (Attr.Name == "Name" || Attr.Name == "GridType")
                            {
                                continue;
                            }
                            if (Attr.Name == "DisplayName")
                            {
                                res.DisplayName = Attr.Value;
                                continue;
                            }
                            try
                            {
                                // res.ThParametrs[Attr.Name] = Convert.ToDouble(Attr.Value);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message);
                                return(null);
                            }
                        }
                        result.Add(res.Name, res);
                    }
                    //XmlNode attrName = xnode.Attributes.GetNamedItem("Name");
                }
            }

            return(result);
        }
Esempio n. 3
0
        public Thruster GetThtusterInfo(string ThrusterId, double GridT = 1)
        {
            string   GridType = "Large";
            Thruster result   = new Thruster("NULL");

            if (GridT == 0)
            {
                GridType = "Small";
            }
            foreach (XmlNode xnode in xThrusters)
            {
                if (xnode.Attributes != null && xnode.Attributes.Count > 0)
                {
                    XmlNode xThName   = xnode.Attributes.GetNamedItem("Name");
                    XmlNode xGridType = xnode.Attributes.GetNamedItem("GridType");

                    if ((xThName != null && xThName.Value == ThrusterId) && (xGridType != null && xGridType.Value == GridType))
                    {
                        result = new Thruster(xThName.Value, xGridType.Value);

                        foreach (XmlNode Attr in xnode.Attributes)
                        {
                            if (Attr.Name == "Name" || Attr.Name == "GridType")
                            {
                                continue;
                            }
                            if (Attr.Name == "DisplayName")
                            {
                                result.DisplayName = Attr.Value;
                                continue;
                            }
                            try
                            {
                                //result.ThParametrs[Attr.Name] = Convert.ToDouble(Attr.Value);
                            }
                            catch (Exception e) {
                                MessageBox.Show(e.Message);
                                return(new Thruster("NULL"));
                            }
                        }
                    }
                    //XmlNode attrName = xnode.Attributes.GetNamedItem("Name");
                }
            }
            return(result);
        }
Esempio n. 4
0
        public void GetThtusterInfo(Stream XMLFile)
        {
            XmlReader reader             = XmlReader.Create(XMLFile);
            Thruster  ThrusterItem       = new Thruster();
            string    Parent             = "";
            string    Tagname            = "";
            bool      IsThrustDefinition = true;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    Tagname = reader.Name;
                    if (reader.Name == "Id")
                    {
                        Parent = "Id";
                    }
                    if (reader.Name == "Definition")
                    {
                        ThrusterItem = new Thruster();
                    }
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    Tagname = "";
                    if (reader.Name == "Definition")
                    {
                        IsThrustDefinition = true;
                        if (ThrusterItem.Name != "" && ThrusterItem.Name != null)
                        {
                            if (ThrusterItem.EffectivenessAtMaxInfluence < 0 || ThrusterItem.EffectivenessAtMinInfluence < 0 || ThrusterItem.EffectivenessAtMaxInfluence == ThrusterItem.EffectivenessAtMinInfluence)
                            {
                                ThrusterItem.EffectivenessAtMaxInfluence = 1;
                                ThrusterItem.EffectivenessAtMinInfluence = 1;
                            }

                            if (ThrusterItem.MaxPlanetaryInfluence < 0 || ThrusterItem.MinPlanetaryInfluence < 0 || ThrusterItem.MaxPlanetaryInfluence == ThrusterItem.MinPlanetaryInfluence)
                            {
                                ThrusterItem.MaxPlanetaryInfluence = 1;
                                ThrusterItem.MinPlanetaryInfluence = 0;
                            }
                            ThList.Add(ThrusterItem.Name, ThrusterItem);
                        }
                    }
                }

                if (reader.NodeType == XmlNodeType.Text && IsThrustDefinition)
                {
                    try
                    {
                        switch (Tagname)
                        {
                        case "Definition":
                            ThrusterItem = new Thruster();
                            break;

                        case "TypeId":
                            if (Parent == "Id")
                            {
                                if (reader.Value.ToLower() == "thrust")
                                {
                                    IsThrustDefinition = true;
                                }
                                else
                                {
                                    IsThrustDefinition = false;
                                }
                            }
                            break;

                        case "SubtypeId":
                            if (Parent == "Id")
                            {
                                ThrusterItem.Name = reader.Value;
                                Parent            = "";
                            }

                            break;

                        case "DisplayName":
                            ThrusterItem.DisplayName = reader.Value;
                            break;

                        case "CubeSize":
                            ThrusterItem.GridType = reader.Value;
                            break;

                        case "ForceMagnitude":
                            ThrusterItem.ForceMagnitude = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            break;

                        case "MaxPowerConsumption":
                            ThrusterItem.MaxPowerConsumption = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            break;

                        case "MinPowerConsumption":
                            ThrusterItem.MinPowerConsumption = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            break;

                        case "MinPlanetaryInfluence":
                            ThrusterItem.MinPlanetaryInfluence = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            break;

                        case "MaxPlanetaryInfluence":
                            ThrusterItem.MaxPlanetaryInfluence = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            break;

                        case "EffectivenessAtMinInfluence":
                            ThrusterItem.EffectivenessAtMinInfluence = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            break;

                        case "EffectivenessAtMaxInfluence":
                            ThrusterItem.EffectivenessAtMaxInfluence = Convert.ToDouble(ReplaceSeparator(reader.Value));
                            if (ThrusterItem.EffectivenessAtMaxInfluence == 0)
                            {
                                MessageBox.Show("Err");
                            }
                            break;

                        case "NeedsAtmosphereForInfluence":
                            ThrusterItem.NeedsAtmosphereForInfluence = Convert.ToBoolean(reader.Value);
                            break;
                        }
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(Ex.Message);
                    }
                }
            }
        }