Beispiel #1
0
        Gyro(FlightControlSystem fcs, XmlElement element)
            : base(fcs, element)
        {
            sensorOrientation = new SensorOrientation(element);
            Propagate         = fcs.GetExec().GetPropagate();

            Debug(0);
        }
Beispiel #2
0
        public Accelerometer(FlightControlSystem fcs, XmlElement element)
            : base(fcs, element)
        {
            sensorOrientation = new SensorOrientation(element);
            Propagate         = fcs.GetExec().GetPropagate();
            Accelerations     = fcs.GetExec().Accelerations;
            MassBalance       = fcs.GetExec().MassBalance;

            XmlElement location_element = element.FindElement("location");

            if (location_element != null)
            {
                vLocation = FormatHelper.TripletConvertTo(location_element, "IN");
            }
            else
            {
                log.Error("No location given for accelerometer. ");
                throw new Exception("Malformed accelerometer specification");
            }

            vRadius = MassBalance.StructuralToBody(vLocation);

            Debug(0);
        }
Beispiel #3
0
        public FCSFunction(FlightControlSystem fcs, XmlElement element)
            : base(fcs, element)
        {
            XmlElement function_element = element.FindElement("function");

            if (function_element != null)
            {
                function = new Function(fcs.GetExec(), function_element);
            }
            else
            {
                log.Error("FCS Function should contain a \"function\" element");
                throw new Exception("Malformed FCS function specification.");
            }

            Bind(element);
            Debug(0);
        }
Beispiel #4
0
        public Waypoint(FlightControlSystem fcs, XmlElement element) : base(fcs, element)
        {
            if (compType == "WAYPOINT_HEADING")
            {
                WaypointType = eWaypointType.eHeading;
            }
            else if (compType == "WAYPOINT_DISTANCE")
            {
                WaypointType = eWaypointType.eDistance;
            }

            target_latitude_unit  = 1.0;
            target_longitude_unit = 1.0;
            source_latitude_unit  = 1.0;
            source_longitude_unit = 1.0;
            source = fcs.GetExec().GetIC().GetPosition();

            if (element.FindElement("target_latitude") != null)
            {
                target_latitude = new PropertyValue(element.FindElementValue("target_latitude"),
                                                    propertyManager);
                if (element.FindElement("target_latitude").HasAttribute("unit"))
                {
                    if (element.FindElement("target_latitude").GetAttribute("unit") == "DEG")
                    {
                        target_latitude_unit = 0.017453293;
                    }
                }
            }
            else
            {
                log.Error("Target latitude is required for waypoint component: " + name);
                throw new Exception("Malformed waypoint definition");
            }

            if (element.FindElement("target_longitude") != null)
            {
                target_longitude = new PropertyValue(element.FindElementValue("target_longitude"),
                                                     propertyManager);
                if (element.FindElement("target_longitude").HasAttribute("unit"))
                {
                    if (element.FindElement("target_longitude").GetAttribute("unit") == "DEG")
                    {
                        target_longitude_unit = 0.017453293;
                    }
                }
            }
            else
            {
                log.Error("Target longitude is required for waypoint component: " + name);
                throw new Exception("Malformed waypoint definition");
            }

            if (element.FindElement("source_latitude") != null)
            {
                source_latitude = new PropertyValue(element.FindElementValue("source_latitude"),
                                                    propertyManager);
                if (element.FindElement("source_latitude").HasAttribute("unit"))
                {
                    if (element.FindElement("source_latitude").GetAttribute("unit") == "DEG")
                    {
                        source_latitude_unit = 0.017453293;
                    }
                }
            }
            else
            {
                log.Error("Source latitude is required for waypoint component: " + name);
                throw new Exception("Malformed waypoint definition");
            }

            if (element.FindElement("source_longitude") != null)
            {
                source_longitude = new PropertyValue(element.FindElementValue("source_longitude"),
                                                     propertyManager);
                if (element.FindElement("source_longitude").HasAttribute("unit"))
                {
                    if (element.FindElement("source_longitude").GetAttribute("unit") == "DEG")
                    {
                        source_longitude_unit = 0.017453293;
                    }
                }
            }
            else
            {
                log.Error("Source longitude is required for waypoint component: " + name);
                throw new Exception("Malformed waypoint definition");
            }

            if (element.FindElement("radius") != null)
            {
                XmlElement elem = element.FindElement("radius");
                radius = FormatHelper.ValueAsNumberConvertTo(elem, "FT");
            }
            else
            {
                radius = -1.0;
            }

            unit = element.GetAttribute("unit");
            if (WaypointType == eWaypointType.eHeading)
            {
                if (!string.IsNullOrEmpty(unit))
                {
                    if (unit == "DEG")
                    {
                        eUnit = eUnitType.eDeg;
                    }
                    else if (unit == "RAD")
                    {
                        eUnit = eUnitType.eRad;
                    }
                    else
                    {
                        log.Error("Unknown unit " + unit + " in HEADING waypoint component, "
                                  + name);
                        throw new Exception("Malformed waypoint definition");
                    }
                }
                else
                {
                    eUnit = eUnitType.eRad; // Default is radians if unspecified
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(unit))
                {
                    if (unit == "FT")
                    {
                        eUnit = eUnitType.eFeet;
                    }
                    else if (unit == "M")
                    {
                        eUnit = eUnitType.eMeters;
                    }
                    else
                    {
                        log.Error("Unknown unit " + unit + " in DISTANCE waypoint component, "
                                  + name);
                        throw new Exception("Malformed waypoint definition");
                    }
                }
                else
                {
                    eUnit = eUnitType.eFeet; // Default is feet if unspecified
                }
            }

            Bind(element);
            Debug(0);
        }