JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGOutputFile.cpp
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGOutputFile.cpp
4 Author: Bertrand Coconnier
5 Date started: 09/10/11
6 Purpose: Manage output of sim parameters to a file
7 Called by: FGOutput
8
9 ------------- Copyright (C) 2011 Bertrand Coconnier -------------
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
28FUNCTIONAL DESCRIPTION
29--------------------------------------------------------------------------------
30This is the place where you create output routines to dump data for perusal
31later.
32
33HISTORY
34--------------------------------------------------------------------------------
3509/10/11 BC Created
36
37%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include <sstream>
42
43#include "FGOutputFile.h"
44#include "input_output/FGXMLElement.h"
45
46using namespace std;
47
48namespace JSBSim {
49
50/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51CLASS IMPLEMENTATION
52%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
55 FGOutputType(fdmex),
56 runID_postfix(-1)
57{
58}
59
60//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61
63{
65 if (Filename.isNull()) {
66 Filename = SGPath(Name);
67 runID_postfix = 0;
68 }
69 return OpenFile();
70 }
71
72 return false;
73}
74
75//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
78{
79 if (runID_postfix >= 0) {
80 ostringstream buf;
81 string::size_type dot = Name.find_last_of('.');
82 if (dot != string::npos) {
83 buf << Name.substr(0, dot) << '_' << runID_postfix++ << Name.substr(dot);
84 } else {
85 buf << Name << '_' << runID_postfix++;
86 }
87 Filename = SGPath(buf.str());
88 }
89
90 CloseFile();
91}
92
93//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
96{
97 if (!FGOutputType::Load(el))
98 return false;
99
100 SetOutputName(el->GetAttributeValue("name"));
101
102 return true;
103}
104
105}
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:185
bool Load(Element *el) override
Init the output directives from an XML file.
FGOutputFile(FGFDMExec *fdmex)
Constructor.
virtual void CloseFile(void)
Closes the file.
void SetOutputName(const std::string &fname) override
Overwrites the name identifier under which the output will be logged.
bool InitModel(void) override
Initializes the instance.
void SetStartNewOutput(void) override
Reset the output prior to a restart of the simulation.
virtual bool OpenFile(void)=0
Opens the file.
Abstract class to provide functions generic to all the output directives.
bool Load(Element *el) override
Init the output directives from an XML file (implement the FGModel interface).
bool InitModel(void) override
Init the output model according to its configitation.
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71