LCOV - code coverage report
Current view: top level - models/flight_control - FGDeadBand.cpp (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 1 57 1.8 %
Date: 2010-08-24 Functions: 3 10 30.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 56 5.4 %

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Module:       FGDeadBand.cpp
       4                 :            :  Author:       Jon S. Berndt
       5                 :            :  Date started: 11/1999
       6                 :            : 
       7                 :            :  ------------- Copyright (C) 2000 -------------
       8                 :            : 
       9                 :            :  This program is free software; you can redistribute it and/or modify it under
      10                 :            :  the terms of the GNU Lesser General Public License as published by the Free Software
      11                 :            :  Foundation; either version 2 of the License, or (at your option) any later
      12                 :            :  version.
      13                 :            : 
      14                 :            :  This program is distributed in the hope that it will be useful, but WITHOUT
      15                 :            :  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      16                 :            :  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      17                 :            :  details.
      18                 :            : 
      19                 :            :  You should have received a copy of the GNU Lesser General Public License along with
      20                 :            :  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
      21                 :            :  Place - Suite 330, Boston, MA  02111-1307, USA.
      22                 :            : 
      23                 :            :  Further information about the GNU Lesser General Public License can also be found on
      24                 :            :  the world wide web at http://www.gnu.org.
      25                 :            : 
      26                 :            : FUNCTIONAL DESCRIPTION
      27                 :            : --------------------------------------------------------------------------------
      28                 :            : 
      29                 :            : HISTORY
      30                 :            : --------------------------------------------------------------------------------
      31                 :            : 
      32                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      33                 :            : COMMENTS, REFERENCES,  and NOTES
      34                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      35                 :            : 
      36                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      37                 :            : INCLUDES
      38                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      39                 :            : 
      40                 :            : #include "FGDeadBand.h"
      41                 :            : #include "input_output/FGXMLElement.h"
      42                 :            : #include "input_output/FGPropertyManager.h"
      43                 :            : #include <iostream>
      44                 :            : 
      45                 :            : using namespace std;
      46                 :            : 
      47                 :            : namespace JSBSim {
      48                 :            : 
      49                 :            : static const char *IdSrc = "$Id: FGDeadBand.cpp,v 1.10 2010/08/21 22:56:11 jberndt Exp $";
      50                 :            : static const char *IdHdr = ID_DEADBAND;
      51                 :            : 
      52                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      53                 :            : CLASS IMPLEMENTATION
      54                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      55                 :            : 
      56                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      57                 :            : 
      58                 :          0 : FGDeadBand::FGDeadBand(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
      59                 :            : {
      60                 :          0 :   string width_string;
      61                 :            : 
      62                 :          0 :   WidthPropertyNode = 0;
      63                 :          0 :   WidthPropertySign = 1.0;
      64                 :          0 :   gain = 1.0;
      65                 :          0 :   width = 0.0;
      66                 :            : 
      67 [ #  # ][ #  # ]:          0 :   if ( element->FindElement("width") ) {
      68                 :          0 :     width_string = element->FindElementValue("width");
      69   [ #  #  #  # ]:          0 :     if (!is_number(width_string)) { // property
      70   [ #  #  #  # ]:          0 :       if (width_string[0] == '-') {
      71                 :          0 :        WidthPropertySign = -1.0;
      72                 :          0 :        width_string.erase(0,1);
      73                 :            :       }
      74                 :          0 :       WidthPropertyNode = PropertyManager->GetNode(width_string);
      75                 :            :     } else {
      76                 :          0 :       width = element->FindElementValueAsNumber("width");
      77                 :            :     }
      78                 :            :   }
      79                 :            : 
      80 [ #  # ][ #  # ]:          0 :   if (element->FindElement("gain")) {
      81                 :          0 :     gain = element->FindElementValueAsNumber("gain");
      82                 :            :   }
      83                 :            : 
      84                 :          0 :   FGFCSComponent::bind();
      85                 :          0 :   Debug(0);
      86                 :          0 : }
      87                 :            : 
      88                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      89                 :            : 
      90                 :          0 : FGDeadBand::~FGDeadBand()
      91                 :            : {
      92                 :          0 :   Debug(1);
      93 [ #  # ][ #  # ]:          0 : }
                 [ #  # ]
      94                 :            : 
      95                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      96                 :            : 
      97                 :          0 : bool FGDeadBand::Run(void )
      98                 :            : {
      99                 :          0 :   Input = InputNodes[0]->getDoubleValue() * InputSigns[0];
     100                 :            : 
     101         [ #  # ]:          0 :   if (WidthPropertyNode != 0) {
     102                 :          0 :     width = WidthPropertyNode->getDoubleValue() * WidthPropertySign;
     103                 :            :   }
     104                 :            : 
     105         [ #  # ]:          0 :   if (Input < -width/2.0) {
     106                 :          0 :     Output = (Input + width/2.0)*gain;
     107         [ #  # ]:          0 :   } else if (Input > width/2.0) {
     108                 :          0 :     Output = (Input - width/2.0)*gain;
     109                 :            :   } else {
     110                 :          0 :     Output = 0.0;
     111                 :            :   }
     112                 :            : 
     113                 :          0 :   Clip();
     114                 :            : 
     115         [ #  # ]:          0 :   if (IsOutput) SetOutput();
     116                 :            : 
     117                 :          0 :   return true;
     118                 :            : }
     119                 :            : 
     120                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     121                 :            : //    The bitmasked value choices are as follows:
     122                 :            : //    unset: In this case (the default) JSBSim would only print
     123                 :            : //       out the normally expected messages, essentially echoing
     124                 :            : //       the config files as they are read. If the environment
     125                 :            : //       variable is not set, debug_lvl is set to 1 internally
     126                 :            : //    0: This requests JSBSim not to output any messages
     127                 :            : //       whatsoever.
     128                 :            : //    1: This value explicity requests the normal JSBSim
     129                 :            : //       startup messages
     130                 :            : //    2: This value asks for a message to be printed out when
     131                 :            : //       a class is instantiated
     132                 :            : //    4: When this value is set, a message is displayed when a
     133                 :            : //       FGModel object executes its Run() method
     134                 :            : //    8: When this value is set, various runtime state variables
     135                 :            : //       are printed out periodically
     136                 :            : //    16: When set various parameters are sanity checked and
     137                 :            : //       a message is printed out when they go out of bounds
     138                 :            : 
     139                 :          0 : void FGDeadBand::Debug(int from)
     140                 :            : {
     141         [ #  # ]:          0 :   if (debug_lvl <= 0) return;
     142                 :            : 
     143         [ #  # ]:          0 :   if (debug_lvl & 1) { // Standard console startup message output
     144         [ #  # ]:          0 :     if (from == 0) { // Constructor
     145                 :          0 :       cout << "      INPUT: " << InputNames[0] << endl;
     146         [ #  # ]:          0 :       if (WidthPropertyNode != 0) {
     147                 :          0 :         cout << "      DEADBAND WIDTH: " << WidthPropertyNode->GetName() << endl;
     148                 :            :       } else {
     149                 :          0 :         cout << "      DEADBAND WIDTH: " << width << endl;
     150                 :            :       }
     151                 :          0 :       cout << "      GAIN: " << gain << endl;
     152         [ #  # ]:          0 :       if (IsOutput) {
     153         [ #  # ]:          0 :         for (unsigned int i=0; i<OutputNodes.size(); i++)
     154                 :          0 :           cout << "      OUTPUT: " << OutputNodes[i]->getName() << endl;
     155                 :            :       }
     156                 :            :     }
     157                 :            :   }
     158         [ #  # ]:          0 :   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
     159         [ #  # ]:          0 :     if (from == 0) cout << "Instantiated: FGDeadBand" << endl;
     160         [ #  # ]:          0 :     if (from == 1) cout << "Destroyed:    FGDeadBand" << endl;
     161                 :            :   }
     162                 :          0 :   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
     163                 :            :   }
     164                 :          0 :   if (debug_lvl & 8 ) { // Runtime state variables
     165                 :            :   }
     166                 :          0 :   if (debug_lvl & 16) { // Sanity checking
     167                 :            :   }
     168         [ #  # ]:          0 :   if (debug_lvl & 64) {
     169         [ #  # ]:          0 :     if (from == 0) { // Constructor
     170                 :          0 :       cout << IdSrc << endl;
     171                 :          0 :       cout << IdHdr << endl;
     172                 :            :     }
     173                 :            :   }
     174                 :            : }
     175 [ +  + ][ +  - ]:         12 : }

Generated by: LCOV version 1.9