LCOV - code coverage report
Current view: top level - models - FGExternalReactions.cpp (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 27 52 51.9 %
Date: 2010-08-24 Functions: 8 11 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 40 32.5 %

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Module:       FGExternalReactions.cpp
       4                 :            :  Author:       David P. Culp
       5                 :            :  Date started: 17/11/06
       6                 :            :  Purpose:      Manages the External Forces
       7                 :            :  Called by:    FGAircraft
       8                 :            : 
       9                 :            :  ------------- Copyright (C) 2006  David P. Culp (davidculp2@comcast.net) -------------
      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                 :            : 
      31                 :            : HISTORY
      32                 :            : --------------------------------------------------------------------------------
      33                 :            : 17/11/06   DC   Created
      34                 :            : 
      35                 :            : /%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      36                 :            : INCLUDES
      37                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      38                 :            : 
      39                 :            : #include "FGExternalReactions.h"
      40                 :            : #include "input_output/FGXMLElement.h"
      41                 :            : #include <iostream>
      42                 :            : #include <string>
      43                 :            : 
      44                 :            : using namespace std;
      45                 :            : 
      46                 :            : namespace JSBSim {
      47                 :            : 
      48                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      49                 :            : DEFINITIONS
      50                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      51                 :            : 
      52                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      53                 :            : GLOBAL DATA
      54                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      55                 :            : 
      56                 :            : static const char *IdSrc = "$Id: FGExternalReactions.cpp,v 1.8 2009/11/12 13:08:11 jberndt Exp $";
      57                 :            : static const char *IdHdr = ID_EXTERNALREACTIONS;
      58                 :            : 
      59                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      60                 :            : CLASS IMPLEMENTATION
      61                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      62                 :            : 
      63                 :          1 : FGExternalReactions::FGExternalReactions(FGFDMExec* fdmex) : FGModel(fdmex)
      64                 :            : {
      65                 :          1 :   NoneDefined = true;
      66                 :          1 :   Debug(0);
      67                 :          1 : }
      68                 :            : 
      69                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      70                 :            : 
      71                 :          0 : bool FGExternalReactions::Load(Element* el)
      72                 :            : {
      73                 :          0 :   FGModel::Load(el); // Call the base class Load() function to load interface properties.
      74                 :            : 
      75                 :          0 :   Debug(2);
      76                 :            : 
      77                 :            :   // Parse force elements
      78                 :            : 
      79                 :          0 :   int index=0;
      80                 :          0 :   Element* force_element = el->FindElement("force");
      81         [ #  # ]:          0 :   while (force_element) {
      82                 :          0 :     Forces.push_back( new FGExternalForce(FDMExec, force_element, index) );
      83                 :          0 :     NoneDefined = false;
      84                 :          0 :     index++; 
      85                 :          0 :     force_element = el->FindNextElement("force");
      86                 :            :   }
      87                 :            : 
      88                 :          0 :   PostLoad(el, PropertyManager);
      89                 :            : 
      90                 :          0 :   return true;
      91                 :            : }
      92                 :            : 
      93                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      94                 :            : 
      95                 :          1 : FGExternalReactions::~FGExternalReactions()
      96                 :            : {
      97 [ #  # ][ -  + ]:          1 :   for (unsigned int i=0; i<Forces.size(); i++) delete Forces[i];
         [ #  # ][ #  # ]
      98                 :          1 :   Forces.clear();
      99                 :            : 
     100                 :          1 :   Debug(1);
     101                 :          1 : }
     102                 :            : 
     103                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     104                 :            : 
     105                 :          1 : bool FGExternalReactions::InitModel(void)
     106                 :            : {
     107         [ -  + ]:          1 :   if (!FGModel::InitModel()) return false;
     108                 :            : 
     109                 :          1 :   return true;
     110                 :            : }
     111                 :            : 
     112                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     113                 :            : 
     114                 :      54005 : bool FGExternalReactions::Run()
     115                 :            : {
     116         [ -  + ]:      54005 :   if (FGModel::Run()) return true;
     117         [ -  + ]:      54005 :   if (FDMExec->Holding()) return false; // if paused don't execute
     118         [ +  - ]:      54005 :   if (NoneDefined) return true;
     119                 :            : 
     120                 :          0 :   RunPreFunctions();
     121                 :            : 
     122                 :          0 :   vTotalForces.InitMatrix();
     123                 :          0 :   vTotalMoments.InitMatrix();
     124                 :            : 
     125         [ #  # ]:          0 :   for (unsigned int i=0; i<Forces.size(); i++) {
     126                 :          0 :     vTotalForces  += Forces[i]->GetBodyForces();
     127                 :          0 :     vTotalMoments += Forces[i]->GetMoments();
     128                 :            :   }
     129                 :            : 
     130                 :          0 :   RunPostFunctions();
     131                 :            : 
     132                 :      54005 :   return false;
     133                 :            : }
     134                 :            : 
     135                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     136                 :            : //    The bitmasked value choices are as follows:
     137                 :            : //    unset: In this case (the default) JSBSim would only print
     138                 :            : //       out the normally expected messages, essentially echoing
     139                 :            : //       the config files as they are read. If the environment
     140                 :            : //       variable is not set, debug_lvl is set to 1 internally
     141                 :            : //    0: This requests JSBSim not to output any messages
     142                 :            : //       whatsoever.
     143                 :            : //    1: This value explicity requests the normal JSBSim
     144                 :            : //       startup messages
     145                 :            : //    2: This value asks for a message to be printed out when
     146                 :            : //       a class is instantiated
     147                 :            : //    4: When this value is set, a message is displayed when a
     148                 :            : //       FGModel object executes its Run() method
     149                 :            : //    8: When this value is set, various runtime state variables
     150                 :            : //       are printed out periodically
     151                 :            : //    16: When set various parameters are sanity checked and
     152                 :            : //       a message is printed out when they go out of bounds
     153                 :            : 
     154                 :          2 : void FGExternalReactions::Debug(int from)
     155                 :            : {
     156         [ +  - ]:          2 :   if (debug_lvl <= 0) return;
     157                 :            : 
     158         [ +  - ]:          2 :   if (debug_lvl & 1) { // Standard console startup message output
     159                 :            :     if (from == 0) { // Constructor - loading and initialization
     160                 :            :     }
     161         [ -  + ]:          2 :     if (from == 2) { // Loading
     162                 :          0 :       cout << endl << "  External Reactions: " << endl;
     163                 :            :     }
     164                 :            :   }
     165         [ -  + ]:          2 :   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
     166         [ #  # ]:          0 :     if (from == 0) cout << "Instantiated: FGExternalReactions" << endl;
     167         [ #  # ]:          0 :     if (from == 1) cout << "Destroyed:    FGExternalReactions" << endl;
     168                 :            :   }
     169                 :          2 :   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
     170                 :            :   }
     171                 :          2 :   if (debug_lvl & 8 ) { // Runtime state variables
     172                 :            :   }
     173                 :          2 :   if (debug_lvl & 16) { // Sanity checking
     174                 :            :   }
     175         [ -  + ]:          2 :   if (debug_lvl & 64) {
     176         [ #  # ]:          0 :     if (from == 0) { // Constructor
     177                 :          0 :       cout << IdSrc << endl;
     178                 :          0 :       cout << IdHdr << endl;
     179                 :            :     }
     180                 :            :   }
     181                 :            : }
     182                 :            : 
     183 [ +  + ][ +  - ]:         12 : } // namespace JSBSim
     184                 :            : 

Generated by: LCOV version 1.9