LCOV - code coverage report
Current view: top level - models - FGModel.cpp (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 43 57 75.4 %
Date: 2010-08-24 Functions: 7 10 70.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 23 54 42.6 %

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Module:       FGModel.cpp
       4                 :            :  Author:       Jon Berndt
       5                 :            :  Date started: 11/11/98
       6                 :            :  Purpose:      Base class for all models
       7                 :            :  Called by:    FGSimExec, et. al.
       8                 :            : 
       9                 :            :  ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
      10                 :            : 
      11                 :            :  This program is free software; you can redistribute it and/or modify it under
      12                 :            :  the terms of the GNU Lesser General Public License as published by the Free Software
      13                 :            :  Foundation; either version 2 of the License, or (at your option) any later
      14                 :            :  version.
      15                 :            : 
      16                 :            :  This program is distributed in the hope that it will be useful, but WITHOUT
      17                 :            :  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      18                 :            :  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      19                 :            :  details.
      20                 :            : 
      21                 :            :  You should have received a copy of the GNU Lesser General Public License along with
      22                 :            :  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
      23                 :            :  Place - Suite 330, Boston, MA  02111-1307, USA.
      24                 :            : 
      25                 :            :  Further information about the GNU Lesser General Public License can also be found on
      26                 :            :  the world wide web at http://www.gnu.org.
      27                 :            : 
      28                 :            : FUNCTIONAL DESCRIPTION
      29                 :            : --------------------------------------------------------------------------------
      30                 :            : This base class for the FGAerodynamics, FGPropagate, etc. classes defines methods
      31                 :            : common to all models.
      32                 :            : 
      33                 :            : HISTORY
      34                 :            : --------------------------------------------------------------------------------
      35                 :            : 11/11/98   JSB   Created
      36                 :            : 
      37                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      38                 :            : INCLUDES
      39                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      40                 :            : 
      41                 :            : #include "FGModel.h"
      42                 :            : #include "FGFDMExec.h"
      43                 :            : #include "FGAtmosphere.h"
      44                 :            : #include "FGFCS.h"
      45                 :            : #include "FGPropulsion.h"
      46                 :            : #include "FGMassBalance.h"
      47                 :            : #include "FGAerodynamics.h"
      48                 :            : #include "FGInertial.h"
      49                 :            : #include "FGGroundReactions.h"
      50                 :            : #include "FGExternalReactions.h"
      51                 :            : #include "FGAircraft.h"
      52                 :            : #include "FGPropagate.h"
      53                 :            : #include "FGAuxiliary.h"
      54                 :            : #include <iostream>
      55                 :            : 
      56                 :            : using namespace std;
      57                 :            : 
      58                 :            : namespace JSBSim {
      59                 :            : 
      60                 :            : static const char *IdSrc = "$Id: FGModel.cpp,v 1.14 2010/02/25 05:21:36 jberndt Exp $";
      61                 :            : static const char *IdHdr = ID_MODEL;
      62                 :            : 
      63                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      64                 :            : GLOBAL DECLARATIONS
      65                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      66                 :            : 
      67                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      68                 :            : CLASS IMPLEMENTATION
      69                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      70                 :            : 
      71                 :         14 : FGModel::FGModel(FGFDMExec* fdmex)
      72                 :            : {
      73                 :         14 :   FDMExec     = fdmex;
      74                 :            : 
      75                 :         14 :   Atmosphere      = 0;
      76                 :         14 :   FCS             = 0;
      77                 :         14 :   Propulsion      = 0;
      78                 :         14 :   MassBalance     = 0;
      79                 :         14 :   Aerodynamics    = 0;
      80                 :         14 :   Inertial        = 0;
      81                 :         14 :   GroundReactions = 0;
      82                 :         14 :   ExternalReactions = 0;
      83                 :         14 :   Aircraft        = 0;
      84                 :         14 :   Propagate       = 0;
      85                 :         14 :   Auxiliary       = 0;
      86                 :            : 
      87                 :            :   //in order for FGModel derived classes to self-bind (that is, call
      88                 :            :   //their bind function in the constructor, the PropertyManager pointer
      89                 :            :   //must be brought up now.
      90                 :         14 :   PropertyManager = FDMExec->GetPropertyManager();
      91                 :            : 
      92                 :         14 :   exe_ctr     = 1;
      93                 :         14 :   rate        = 1;
      94                 :            : 
      95 [ #  # ][ -  + ]:         14 :   if (debug_lvl & 2) cout << "              FGModel Base Class" << endl;
      96                 :         14 : }
      97                 :            : 
      98                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      99                 :            : 
     100                 :         14 : FGModel::~FGModel()
     101                 :            : {
     102 [ #  # ][ -  + ]:         14 :   if (debug_lvl & 2) cout << "Destroyed:    FGModel" << endl;
     103                 :         14 : }
     104                 :            : 
     105                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     106                 :            : 
     107                 :         14 : bool FGModel::InitModel(void)
     108                 :            : {
     109                 :         28 :   Atmosphere      = FDMExec->GetAtmosphere();
     110                 :         28 :   FCS             = FDMExec->GetFCS();
     111                 :         28 :   Propulsion      = FDMExec->GetPropulsion();
     112                 :         28 :   MassBalance     = FDMExec->GetMassBalance();
     113                 :         28 :   Aerodynamics    = FDMExec->GetAerodynamics();
     114                 :         28 :   Inertial        = FDMExec->GetInertial();
     115                 :         28 :   GroundReactions = FDMExec->GetGroundReactions();
     116                 :         28 :   ExternalReactions = FDMExec->GetExternalReactions();
     117                 :         28 :   BuoyantForces   = FDMExec->GetBuoyantForces();
     118                 :         28 :   Aircraft        = FDMExec->GetAircraft();
     119                 :         28 :   Propagate       = FDMExec->GetPropagate();
     120                 :         28 :   Auxiliary       = FDMExec->GetAuxiliary();
     121                 :            : 
     122 [ +  - ][ +  - ]:         14 :   if (!Atmosphere ||
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ -  + ]
     123                 :            :       !FCS ||
     124                 :            :       !Propulsion ||
     125                 :            :       !MassBalance ||
     126                 :            :       !Aerodynamics ||
     127                 :            :       !Inertial ||
     128                 :            :       !GroundReactions ||
     129                 :            :       !ExternalReactions ||
     130                 :            :       !Aircraft ||
     131                 :            :       !Propagate ||
     132                 :          0 :       !Auxiliary) return(false);
     133                 :         14 :   else return(true);
     134                 :            : }
     135                 :            : 
     136                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     137                 :            : 
     138                 :     756074 : bool FGModel::Run()
     139                 :            : {
     140         [ -  + ]:     756074 :   if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl;
     141                 :            : 
     142         [ +  + ]:     756074 :   if (rate == 1) return false; // Fast exit if nothing to do
     143                 :            : 
     144         [ +  + ]:      54005 :   if (exe_ctr >= rate) exe_ctr = 1;
     145                 :            : 
     146         [ +  + ]:      54005 :   if (exe_ctr++ == 1) return false;
     147                 :     756074 :   else              return true;
     148                 :            : }
     149                 :            : 
     150                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     151                 :            : //    The bitmasked value choices are as follows:
     152                 :            : //    unset: In this case (the default) JSBSim would only print
     153                 :            : //       out the normally expected messages, essentially echoing
     154                 :            : //       the config files as they are read. If the environment
     155                 :            : //       variable is not set, debug_lvl is set to 1 internally
     156                 :            : //    0: This requests JSBSim not to output any messages
     157                 :            : //       whatsoever.
     158                 :            : //    1: This value explicity requests the normal JSBSim
     159                 :            : //       startup messages
     160                 :            : //    2: This value asks for a message to be printed out when
     161                 :            : //       a class is instantiated
     162                 :            : //    4: When this value is set, a message is displayed when a
     163                 :            : //       FGModel object executes its Run() method
     164                 :            : //    8: When this value is set, various runtime state variables
     165                 :            : //       are printed out periodically
     166                 :            : //    16: When set various parameters are sanity checked and
     167                 :            : //       a message is printed out when they go out of bounds
     168                 :            : 
     169                 :          0 : void FGModel::Debug(int from)
     170                 :            : {
     171         [ #  # ]:          0 :   if (debug_lvl <= 0) return;
     172                 :            : 
     173                 :          0 :   if (debug_lvl & 1) { // Standard console startup message output
     174                 :            :     if (from == 0) { // Constructor
     175                 :            : 
     176                 :            :     }
     177                 :            :   }
     178         [ #  # ]:          0 :   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
     179         [ #  # ]:          0 :     if (from == 0) cout << "Instantiated: FGModel" << endl;
     180         [ #  # ]:          0 :     if (from == 1) cout << "Destroyed:    FGModel" << endl;
     181                 :            :   }
     182                 :          0 :   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
     183                 :            :   }
     184                 :          0 :   if (debug_lvl & 8 ) { // Runtime state variables
     185                 :            :   }
     186                 :          0 :   if (debug_lvl & 16) { // Sanity checking
     187                 :            :   }
     188         [ #  # ]:          0 :   if (debug_lvl & 64) {
     189         [ #  # ]:          0 :     if (from == 0) { // Constructor
     190                 :          0 :       cout << IdSrc << endl;
     191                 :          0 :       cout << IdHdr << endl;
     192                 :            :     }
     193                 :            :   }
     194                 :            : }
     195 [ +  + ][ +  - ]:         12 : }

Generated by: LCOV version 1.9