LCOV - code coverage report
Current view: top level - models - FGOutput.h (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 1 6 16.7 %
Date: 2010-08-24 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Header:       FGOutput.h
       4                 :            :  Author:       Jon Berndt
       5                 :            :  Date started: 12/2/98
       6                 :            : 
       7                 :            :  ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
       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                 :            : HISTORY
      27                 :            : --------------------------------------------------------------------------------
      28                 :            : 12/02/98   JSB   Created
      29                 :            : 11/09/07   HDW   Added FlightGear Socket Interface
      30                 :            : 
      31                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      32                 :            : SENTRY
      33                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      34                 :            : 
      35                 :            : #ifndef FGOUTPUT_H
      36                 :            : #define FGOUTPUT_H
      37                 :            : 
      38                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      39                 :            : INCLUDES
      40                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      41                 :            : 
      42                 :            : #include "FGModel.h"
      43                 :            : 
      44                 :            : #include <fstream>
      45                 :            : 
      46                 :            : #include "input_output/FGXMLFileRead.h"
      47                 :            : #include "input_output/net_fdm.hxx"
      48                 :            : 
      49                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      50                 :            : DEFINITIONS
      51                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      52                 :            : 
      53                 :            : #define ID_OUTPUT "$Id: FGOutput.h,v 1.17 2009/10/24 22:59:30 jberndt Exp $"
      54                 :            : 
      55                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      56                 :            : FORWARD DECLARATIONS
      57                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      58                 :            : 
      59                 :            : namespace JSBSim {
      60                 :            : 
      61                 :            : class FGfdmSocket;
      62                 :            : 
      63                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      64                 :            : CLASS DOCUMENTATION
      65                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      66                 :            : 
      67                 :            : /** Handles simulation output.
      68                 :            :     OUTPUT section definition
      69                 :            : 
      70                 :            :     The following specifies the way that JSBSim writes out data.
      71                 :            : <pre>
      72                 :            :     NAME is the filename you want the output to go to
      73                 :            : 
      74                 :            :     TYPE can be:
      75                 :            :       CSV         Comma separated data. If a filename is supplied then the
      76                 :            :                   data goes to that file. If "COUT" or "cout" is specified, the
      77                 :            :                   data goes to stdout. If the filename is a null filename the
      78                 :            :                   data goes to stdout, as well.
      79                 :            :       SOCKET      Will eventually send data to a socket output, where NAME
      80                 :            :                   would then be the IP address of the machine the data should
      81                 :            :                   be sent to. DON'T USE THIS YET!
      82                 :            :       FLIGHTGEAR  A socket is created for sending binary data packets to
      83                 :            :                   an external instance of FlightGear for visuals.  Parameters
      84                 :            :                   defining the socket are given on the \<output> line.
      85                 :            :       TABULAR     Columnar data.
      86                 :            :       TERMINAL    Output to terminal. NOT IMPLEMENTED YET!
      87                 :            :       NONE        Specifies to do nothing. This setting makes it easy to turn on and
      88                 :            :                   off the data output without having to mess with anything else.
      89                 :            : 
      90                 :            :       Examples:
      91                 :            : </pre>
      92                 :            : @code
      93                 :            :         <output name="localhost" type="FLIGHTGEAR" port="5500" protocol="tcp" rate="10"/>
      94                 :            : @endcode
      95                 :            : @code
      96                 :            :         <output name="B737_datalog.csv" type="CSV" rate="20">
      97                 :            :            <property> velocities/vc-kts </property>
      98                 :            :            <velocities> ON </velocities>
      99                 :            :         </output>
     100                 :            : @endcode
     101                 :            : <br>
     102                 :            : <pre>
     103                 :            :     The arguments that can be supplied, currently, are:
     104                 :            : 
     105                 :            :     RATE_IN_HZ  An integer rate in times-per-second that the data is output. This
     106                 :            :                 value may not be *exactly* what you want, due to the dependence
     107                 :            :                 on dt, the cycle rate for the FDM.
     108                 :            : 
     109                 :            :     The following parameters tell which subsystems of data to output:
     110                 :            : 
     111                 :            :     simulation       ON|OFF
     112                 :            :     atmosphere       ON|OFF
     113                 :            :     massprops        ON|OFF
     114                 :            :     aerosurfaces     ON|OFF
     115                 :            :     rates            ON|OFF
     116                 :            :     velocities       ON|OFF
     117                 :            :     forces           ON|OFF
     118                 :            :     moments          ON|OFF
     119                 :            :     position         ON|OFF
     120                 :            :     coefficients     ON|OFF
     121                 :            :     ground_reactions ON|OFF
     122                 :            :     fcs              ON|OFF
     123                 :            :     propulsion       ON|OFF
     124                 :            : </pre>
     125                 :            :     NOTE that Time is always output with the data.
     126                 :            :     @version $Id: FGOutput.h,v 1.17 2009/10/24 22:59:30 jberndt Exp $
     127                 :            :  */
     128                 :            : 
     129                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     130                 :            : CLASS DECLARATION
     131                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
     132                 :            : 
     133                 :            : class FGOutput : public FGModel, public FGXMLFileRead
     134                 :            : {
     135                 :            : public:
     136                 :            :   FGOutput(FGFDMExec*);
     137                 :            :   ~FGOutput();
     138                 :            : 
     139                 :            :   bool InitModel(void);
     140                 :            :   bool Run(void);
     141                 :            : 
     142                 :            :   void DelimitedOutput(const std::string&);
     143                 :            :   void SocketOutput(void);
     144                 :            :   void FlightGearSocketOutput(void);
     145                 :            :   void SocketStatusOutput(const std::string&);
     146                 :            :   void SocketDataFill(FGNetFDM* net);
     147                 :            : 
     148                 :            : 
     149                 :            :   void SetType(const std::string& type);
     150                 :          0 :   void SetStartNewFile(bool tt) {StartNewFile = tt;}
     151                 :            :   void SetSubsystems(int tt) {SubSystems = tt;}
     152                 :          2 :   void Enable(void) { enabled = true; }
     153                 :          0 :   void Disable(void) { enabled = false; }
     154                 :            :   bool Toggle(void) {enabled = !enabled; return enabled;}
     155                 :            :   bool Load(Element* el);
     156                 :          0 :   void SetOutputFileName(const std::string& fname) {Filename = fname;}
     157                 :          0 :   void SetDirectivesFile(const std::string& fname) {DirectivesFile = fname;}
     158                 :            :   void SetRate(int rt);
     159                 :          0 :   string GetOutputFileName(void) const {return Filename;}
     160                 :            : 
     161                 :            :   /// Subsystem types for specifying which will be output in the FDM data logging
     162                 :            :   enum  eSubSystems {
     163                 :            :     /** Subsystem: Simulation (= 1)          */ ssSimulation      = 1,
     164                 :            :     /** Subsystem: Aerosurfaces (= 2)        */ ssAerosurfaces    = 2,
     165                 :            :     /** Subsystem: Body rates (= 4)          */ ssRates           = 4,
     166                 :            :     /** Subsystem: Velocities (= 8)          */ ssVelocities      = 8,
     167                 :            :     /** Subsystem: Forces (= 16)             */ ssForces          = 16,
     168                 :            :     /** Subsystem: Moments (= 32)            */ ssMoments         = 32,
     169                 :            :     /** Subsystem: Atmosphere (= 64)         */ ssAtmosphere      = 64,
     170                 :            :     /** Subsystem: Mass Properties (= 128)   */ ssMassProps       = 128,
     171                 :            :     /** Subsystem: Coefficients (= 256)      */ ssCoefficients    = 256,
     172                 :            :     /** Subsystem: Propagate (= 512)         */ ssPropagate       = 512,
     173                 :            :     /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
     174                 :            :     /** Subsystem: FCS (= 2048)              */ ssFCS             = 2048,
     175                 :            :     /** Subsystem: Propulsion (= 4096)       */ ssPropulsion      = 4096
     176                 :            :   } subsystems;
     177                 :            : 
     178                 :            : 
     179                 :            :   FGNetFDM fgSockBuf;
     180                 :            : 
     181                 :            : private:
     182                 :            :   enum {otNone, otCSV, otTab, otSocket, otTerminal, otFlightGear, otUnknown} Type;
     183                 :            :   bool sFirstPass, dFirstPass, enabled;
     184                 :            :   int SubSystems;
     185                 :            :   int runID_postfix;
     186                 :            :   bool StartNewFile;
     187                 :            :   std::string output_file_name, delimeter, BaseFilename, Filename, DirectivesFile;
     188                 :            :   std::ofstream datafile;
     189                 :            :   FGfdmSocket* socket;
     190                 :            :   FGfdmSocket* flightGearSocket;
     191                 :            :   std::vector <FGPropertyManager*> OutputProperties;
     192                 :            : 
     193                 :            :   void Debug(int from);
     194                 :            : };
     195                 :            : }
     196                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     197                 :            : #endif
     198                 :            : 

Generated by: LCOV version 1.9