Exemplo n.º 1
0
        public override bool Run()
        {
            // There is no input assumed. This is a dedicated acceleration sensor.

            vRadius = MassBalance.StructuralToBody(vLocation);

            //aircraft forces
            vAccel = (Accelerations.GetBodyAccel()
                      + Accelerations.GetPQRidot() * vRadius
                      + Propagate.GetPQRi() * (Propagate.GetPQRi() * vRadius));

            // transform to the specified orientation
            vAccel = sensorOrientation.mT * vAccel;

            input = vAccel[sensorOrientation.axis - 1];

            ProcessSensorSignal();

            SetOutput();

            return(true);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        private bool Allocate()
        {
            bool result = true;

            models = new Model[(int)eModels.eNumStandardModels];

            // First build the inertial model since some other models are relying on
            // the inertial model and the ground callback to build themselves.
            // Note that this does not affect the order in which the models will be
            // executed later.
            models[(int)eModels.eInertial] = new Inertial(this);

            // See the eModels enum specification in the header file. The order of the
            // enums specifies the order of execution. The Models[] vector is the primary
            // storage array for the list of models.
            models[(int)eModels.ePropagate]       = new Propagate(this);
            models[(int)eModels.eInput]           = new Input(this);
            models[(int)eModels.eAtmosphere]      = new StandardAtmosphere(this);
            models[(int)eModels.eWinds]           = new Winds(this);
            models[(int)eModels.eSystems]         = new FlightControlSystem(this);
            models[(int)eModels.eMassBalance]     = new MassBalance(this);
            models[(int)eModels.eAuxiliary]       = new Auxiliary(this);
            models[(int)eModels.ePropulsion]      = new Propulsion(this);
            models[(int)eModels.eAerodynamics]    = new Aerodynamics(this);
            models[(int)eModels.eGroundReactions] = new GroundReactions(this);
            //PENDING new JSBSIM models[(int)eModels.eExternalReactions] = new ExternalReactions(this);
            //PENDING new JSBSIM models[(int)eModels.eBuoyantForces] = new BuoyantForces(this);
            models[(int)eModels.eAircraft]      = new Aircraft(this);
            models[(int)eModels.eAccelerations] = new Accelerations(this);
            models[(int)eModels.eOutput]        = new Output(this);

            // Assign the Model shortcuts for internal executive use only.
            propagate       = (Propagate)models[(int)eModels.ePropagate];
            inertial        = (Inertial)models[(int)eModels.eInertial];
            atmosphere      = (Atmosphere)models[(int)eModels.eAtmosphere];
            winds           = (Winds)models[(int)eModels.eWinds];
            FCS             = (FlightControlSystem)models[(int)eModels.eSystems];
            massBalance     = (MassBalance)models[(int)eModels.eMassBalance];
            auxiliary       = (Auxiliary)models[(int)eModels.eAuxiliary];
            propulsion      = (Propulsion)models[(int)eModels.ePropulsion];
            aerodynamics    = (Aerodynamics)models[(int)eModels.eAerodynamics];
            groundReactions = (GroundReactions)models[(int)eModels.eGroundReactions];
            //PENDING new JSBSIM  externalReactions = (ExternalReactions)models[(int)eModels.eExternalReactions];
            //PENDING new JSBSIM buoyantForces = (BuoyantForces)models[(int)eModels.eBuoyantForces];
            aircraft      = (Aircraft)models[(int)eModels.eAircraft];
            accelerations = (Accelerations)models[(int)eModels.eAccelerations];
            //PENDING new JSBSIM output = (Output)models[(int)eModels.eOutput];

            // Initialize planet (environment) constants
            LoadPlanetConstants();

            // Initialize models
            for (int i = 0; i < models.Length; i++)
            {
                // The Input/Output models must not be initialized prior to IC loading
                if (i == (int)eModels.eInput || i == (int)eModels.eOutput)
                {
                    continue;
                }

                //PENDING new JSBSIM LoadInputs(i);
                if (models[i] != null)
                {
                    models[i].InitModel();
                }
            }

            ic = new InitialCondition(this);
            ic.Bind(instance);

            modelLoaded = false;

            return(result);

            //---------------------- old code pending
#if DELETEME
            bool result = true;
            massBalance = new MassBalance(this);
            //output = new Output(this);
            input = new Input(this);
            //TODO groundCallback = new DefaultGroundCallback();
            state = new State(this); // This must be done here, as the State
            // class needs valid pointers to the above model classes


            // Initialize models so they can communicate with each other

            if (!atmosphere.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Atmosphere model init failed");
                }
                error += 1;
            }
            if (!FCS.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("FCS model init failed");
                }
                error += 2;
            }
            if (!propulsion.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Propulsion model init failed");
                }
                error += 4;
            }
            if (!massBalance.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("MassBalance model init failed");
                }
                error += 8;
            }
            if (!aerodynamics.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Aerodynamics model init failed");
                }
                error += 16;
            }
            if (!inertial.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Inertial model init failed");
                }
                error += 32;
            }
            if (!groundReactions.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Ground Reactions model init failed");
                }
                error += 64;
            }
            if (!aircraft.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Aircraft model init failed");
                }
                error += 128;
            }
            if (!propagate.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Propagate model init failed");
                }
                error += 256;
            }
            if (!auxiliary.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Auxiliary model init failed");
                }
                error += 512;
            }
            if (!input.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Intput model init failed");
                }
                error += 1024;
            }

            if (error > 0)
            {
                result = false;
            }

            ic = new InitialCondition(this);

            // Schedule a model. The second arg (the integer) is the pass number. For
            // instance, the atmosphere model gets executed every fifth pass it is called
            // by the executive. Everything else here gets executed each pass.
            // IC and Trim objects are NOT scheduled.

            Schedule(input, 1);
            Schedule(atmosphere, 1);
            Schedule(FCS, 1);
            Schedule(propulsion, 1);
            Schedule(massBalance, 1);
            Schedule(aerodynamics, 1);
            Schedule(inertial, 1);
            Schedule(groundReactions, 1);
            Schedule(aircraft, 1);
            Schedule(propagate, 1);
            Schedule(auxiliary, 1);
            //Schedule(output, 1);

            modelLoaded = false;
            return(result);
#endif
        }
Exemplo n.º 4
0
        private bool Allocate()
        {
            bool result = true;

            atmosphere      = new Atmosphere(this);
            propulsion      = new Propulsion(this);
            aerodynamics    = new Aerodynamics(this);
            FCS             = new FlightControlSystem(this);
            groundReactions = new GroundReactions(this);
            inertial        = new Inertial(this);
            massBalance     = new MassBalance(this);
            propagate       = new Propagate(this);
            auxiliary       = new Auxiliary(this);
            aircraft        = new Aircraft(this);
            //output = new Output(this);
            input          = new Input(this);
            groundCallback = new GroundCallback();
            state          = new State(this); // This must be done here, as the State
            // class needs valid pointers to the above model classes


            // Initialize models so they can communicate with each other

            if (!atmosphere.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Atmosphere model init failed");
                }
                error += 1;
            }
            if (!FCS.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("FCS model init failed");
                }
                error += 2;
            }
            if (!propulsion.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Propulsion model init failed");
                }
                error += 4;
            }
            if (!massBalance.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("MassBalance model init failed");
                }
                error += 8;
            }
            if (!aerodynamics.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Aerodynamics model init failed");
                }
                error += 16;
            }
            if (!inertial.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Inertial model init failed");
                }
                error += 32;
            }
            if (!groundReactions.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Ground Reactions model init failed");
                }
                error += 64;
            }
            if (!aircraft.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Aircraft model init failed");
                }
                error += 128;
            }
            if (!propagate.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Propagate model init failed");
                }
                error += 256;
            }
            if (!auxiliary.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Auxiliary model init failed");
                }
                error += 512;
            }
            if (!input.InitModel())
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Intput model init failed");
                }
                error += 1024;
            }

            if (error > 0)
            {
                result = false;
            }

            ic = new InitialCondition(this);

            // Schedule a model. The second arg (the integer) is the pass number. For
            // instance, the atmosphere model gets executed every fifth pass it is called
            // by the executive. Everything else here gets executed each pass.
            // IC and Trim objects are NOT scheduled.

            Schedule(input, 1);
            Schedule(atmosphere, 1);
            Schedule(FCS, 1);
            Schedule(propulsion, 1);
            Schedule(massBalance, 1);
            Schedule(aerodynamics, 1);
            Schedule(inertial, 1);
            Schedule(groundReactions, 1);
            Schedule(aircraft, 1);
            Schedule(propagate, 1);
            Schedule(auxiliary, 1);
            //Schedule(output, 1);

            modelLoaded = false;
            return(result);
        }