1
0
Fork 0

Maintenance: namespace

Clean up namespaces.
Don't use broad 'using namespace' context in header files.
Header Guards.
SPDX tags.
This commit is contained in:
scttgs0 2023-05-20 17:22:15 -05:00
parent 3df69b8381
commit bd3b209466
7 changed files with 488 additions and 595 deletions

View file

@ -1,25 +1,9 @@
// JSBsim.cxx -- interface to the JSBsim flight model
//
// Written by Curtis Olson, started February 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id: FlightGear.cxx,v 1.15 2014/01/28 09:42:20 ehofman Exp $
/*
* SPDX-FileName: JSBsim.cxx
* SPDX-FileComment: interface to the JSBsim flight model
* SPDX-FileCopyrightText: Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
@ -376,7 +360,7 @@ FGJSBsim::FGJSBsim( double dt )
fgtrim->DoTrim();
delete fgtrim;
string directive_file = fgGetString("/sim/jsbsim/output-directive-file");
std::string directive_file = fgGetString("/sim/jsbsim/output-directive-file");
if (!directive_file.empty())
fdmex->SetOutputDirectives(directive_file);
}

View file

@ -1,35 +1,15 @@
/*
* SPDX-FileName: FGPropertyManager.h
* SPDX-FileComment: Based on work originally by David Megginson
* SPDX-FileCopyrightText: Copyright (C) 2002 Tony Peden
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGPropertyManager.h
Author: Tony Peden
Based on work originally by David Megginson
Date: 2/2002
------------- Copyright (C) 2002 -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPROPERTYMANAGER_H
#define FGPROPERTYMANAGER_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -37,14 +17,15 @@ INCLUDES
// This is needed by MSVC9 when included in FlightGear because of
// the new Vec4d class in props.hxx
#if defined( HAVE_CONFIG_H )
# include <config.h>
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <string>
#include "simgear/props/propertyObject.hxx"
#if !PROPS_STANDALONE
# include "simgear/math/SGMath.hxx"
#include "simgear/math/SGMath.hxx"
#endif
#include "FGJSBBase.h"
@ -69,7 +50,7 @@ CLASS DECLARATION
class FGPropertyNode : public SGPropertyNode
{
public:
public:
/// Destructor
virtual ~FGPropertyNode(void) {}
@ -81,10 +62,10 @@ class FGPropertyNode : public SGPropertyNode
* @return The node, or 0 if none exists and none was created.
*/
FGPropertyNode*
GetNode (const std::string &path, bool create = false);
GetNode(const std::string& path, bool create = false);
FGPropertyNode*
GetNode (const std::string &relpath, int index, bool create = false);
GetNode(const std::string& relpath, int index, bool create = false);
/**
* Test whether a given node exists.
@ -92,17 +73,17 @@ class FGPropertyNode : public SGPropertyNode
* @param path The path of the node, relative to root.
* @return true if the node exists, false otherwise.
*/
bool HasNode (const std::string &path);
bool HasNode(const std::string& path);
/**
* Get the name of a node
*/
const std::string& GetName( void ) const { return getNameString(); }
const std::string& GetName(void) const { return getNameString(); }
/**
* Get the name of a node without underscores, etc.
*/
std::string GetPrintableName( void ) const;
std::string GetPrintableName(void) const;
/**
* Get the fully qualified name of a node
@ -117,7 +98,7 @@ class FGPropertyNode : public SGPropertyNode
*
* @param path The path to strip off, if found.
*/
std::string GetRelativeName( const std::string &path = "/fdm/jsbsim/" ) const;
std::string GetRelativeName(const std::string& path = "/fdm/jsbsim/") const;
/**
* Get a bool value for a property.
@ -133,7 +114,7 @@ class FGPropertyNode : public SGPropertyNode
* does not exist.
* @return The property's value as a bool, or the default value provided.
*/
bool GetBool (const std::string &name, bool defaultValue = false) const;
bool GetBool(const std::string& name, bool defaultValue = false) const;
/**
@ -150,7 +131,7 @@ class FGPropertyNode : public SGPropertyNode
* does not exist.
* @return The property's value as an int, or the default value provided.
*/
int GetInt (const std::string &name, int defaultValue = 0) const;
int GetInt(const std::string& name, int defaultValue = 0) const;
/**
@ -167,7 +148,7 @@ class FGPropertyNode : public SGPropertyNode
* does not exist.
* @return The property's value as a long, or the default value provided.
*/
int GetLong (const std::string &name, long defaultValue = 0L) const;
int GetLong(const std::string& name, long defaultValue = 0L) const;
/**
@ -184,7 +165,7 @@ class FGPropertyNode : public SGPropertyNode
* does not exist.
* @return The property's value as a float, or the default value provided.
*/
float GetFloat (const std::string &name, float defaultValue = 0.0) const;
float GetFloat(const std::string& name, float defaultValue = 0.0) const;
/**
@ -201,7 +182,7 @@ class FGPropertyNode : public SGPropertyNode
* does not exist.
* @return The property's value as a double, or the default value provided.
*/
double GetDouble (const std::string &name, double defaultValue = 0.0) const;
double GetDouble(const std::string& name, double defaultValue = 0.0) const;
/**
@ -218,7 +199,7 @@ class FGPropertyNode : public SGPropertyNode
* does not exist.
* @return The property's value as a string, or the default value provided.
*/
std::string GetString (const std::string &name, std::string defaultValue = "") const;
std::string GetString(const std::string& name, std::string defaultValue = "") const;
/**
@ -234,7 +215,7 @@ class FGPropertyNode : public SGPropertyNode
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
bool SetBool (const std::string &name, bool val);
bool SetBool(const std::string& name, bool val);
/**
@ -250,7 +231,7 @@ class FGPropertyNode : public SGPropertyNode
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
bool SetInt (const std::string &name, int val);
bool SetInt(const std::string& name, int val);
/**
@ -266,7 +247,7 @@ class FGPropertyNode : public SGPropertyNode
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
bool SetLong (const std::string &name, long val);
bool SetLong(const std::string& name, long val);
/**
@ -282,7 +263,7 @@ class FGPropertyNode : public SGPropertyNode
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
bool SetFloat (const std::string &name, float val);
bool SetFloat(const std::string& name, float val);
/**
@ -298,7 +279,7 @@ class FGPropertyNode : public SGPropertyNode
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
bool SetDouble (const std::string &name, double val);
bool SetDouble(const std::string& name, double val);
/**
@ -314,7 +295,7 @@ class FGPropertyNode : public SGPropertyNode
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
bool SetString (const std::string &name, const std::string &val);
bool SetString(const std::string& name, const std::string& val);
////////////////////////////////////////////////////////////////////////
@ -334,7 +315,7 @@ class FGPropertyNode : public SGPropertyNode
* @param name The property name.
* @param state The state of the archive attribute (defaults to true).
*/
void SetArchivable (const std::string &name, bool state = true);
void SetArchivable(const std::string& name, bool state = true);
/**
@ -349,7 +330,7 @@ class FGPropertyNode : public SGPropertyNode
* @param name The property name.
* @param state The state of the read attribute (defaults to true).
*/
void SetReadable (const std::string &name, bool state = true);
void SetReadable(const std::string& name, bool state = true);
/**
@ -364,7 +345,7 @@ class FGPropertyNode : public SGPropertyNode
* @param name The property name.
* @param state The state of the write attribute (defaults to true).
*/
void SetWritable (const std::string &name, bool state = true);
void SetWritable(const std::string& name, bool state = true);
};
typedef SGSharedPtr<FGPropertyNode> FGPropertyNode_ptr;
@ -372,25 +353,29 @@ typedef SGSharedPtr<const FGPropertyNode> FGConstPropertyNode_ptr;
class FGPropertyManager
{
public:
public:
/// Default constructor
FGPropertyManager(void) { root = new FGPropertyNode; }
/// Constructor
explicit FGPropertyManager(FGPropertyNode* _root) : root(_root) {};
explicit FGPropertyManager(FGPropertyNode* _root) : root(_root){};
/// Destructor
virtual ~FGPropertyManager(void) { Unbind(); }
FGPropertyNode* GetNode(void) const { return root; }
FGPropertyNode* GetNode(const std::string &path, bool create = false)
{ return root->GetNode(path, create); }
FGPropertyNode* GetNode(const std::string &relpath, int index, bool create = false)
{ return root->GetNode(relpath, index, create); }
FGPropertyNode* GetNode(const std::string& path, bool create = false)
{
return root->GetNode(path, create);
}
FGPropertyNode* GetNode(const std::string& relpath, int index, bool create = false)
{
return root->GetNode(relpath, index, create);
}
bool HasNode(const std::string& path) const
{
std::string newPath = path;
if (newPath[0] == '-') newPath.erase(0,1);
if (newPath[0] == '-') newPath.erase(0, 1);
return root->HasNode(newPath);
}
@ -416,7 +401,7 @@ class FGPropertyManager
*
* @param name The property name to untie (full path).
*/
void Untie (const std::string &name);
void Untie(const std::string& name);
/**
* Untie a property from an external data source.
@ -426,7 +411,7 @@ class FGPropertyManager
*
* @param property A pointer to the property to untie.
*/
void Untie (SGPropertyNode* property);
void Untie(SGPropertyNode* property);
/**
* Unbind all properties bound by this manager to an external data source.
@ -434,7 +419,7 @@ class FGPropertyManager
* Classes should use this function to release control of any
* properties they have bound using this property manager.
*/
void Unbind (void);
void Unbind(void);
/**
* Tie a property to an external variable.
@ -445,20 +430,21 @@ class FGPropertyManager
* @param name The property name to tie (full path).
* @param pointer A pointer to the variable.
*/
template <typename T> void
Tie (const std::string &name, T *pointer)
template <typename T>
void
Tie(const std::string& name, T* pointer)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
if (!property) {
cerr << "Could not get or create property " << name << endl;
std::cerr << "Could not get or create property " << name << std::endl;
return;
}
if (!property->tie(SGRawValuePointer<T>(pointer), false))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
std::cerr << "Failed to tie property " << name << " to a pointer" << std::endl;
else {
tied_properties.push_back(property);
if (FGJSBBase::debug_lvl & 0x20) cout << name << endl;
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
}
}
@ -476,8 +462,9 @@ class FGPropertyManager
* @param setter The setter function, or 0 if the value is unmodifiable.
*/
template <typename T> void
Tie (const std::string &name, T (*getter)(), void (*setter)(T) = nullptr)
template <typename T>
void
Tie(const std::string& name, T (*getter)(), void (*setter)(T) = nullptr)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
if (!property) {
@ -511,8 +498,9 @@ class FGPropertyManager
* @param getter The getter function, or 0 if the value is unreadable.
* @param setter The setter function, or 0 if the value is unmodifiable.
*/
template <typename T> void
Tie (const std::string &name, int index, T (*getter)(int),
template <typename T>
void
Tie(const std::string& name, int index, T (*getter)(int),
void (*setter)(int, T) = nullptr)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
@ -549,8 +537,9 @@ class FGPropertyManager
* @param setter The object's setter method, or 0 if the value is
* unmodifiable.
*/
template <class T, class V> void
Tie (const std::string &name, T * obj, V (T::*getter)() const,
template <class T, class V>
void
Tie(const std::string& name, T* obj, V (T::*getter)() const,
void (T::*setter)(V) = nullptr)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
@ -559,7 +548,7 @@ class FGPropertyManager
return;
}
if (!property->tie(SGRawValueMethods<T,V>(*obj, getter, setter), false))
if (!property->tie(SGRawValueMethods<T, V>(*obj, getter, setter), false))
std::cerr << "Failed to tie property " << name << " to object methods"
<< std::endl;
else {
@ -586,8 +575,9 @@ class FGPropertyManager
* @param getter The getter method, or 0 if the value is unreadable.
* @param setter The setter method, or 0 if the value is unmodifiable.
*/
template <class T, class V> void
Tie (const std::string &name, T * obj, int index, V (T::*getter)(int) const,
template <class T, class V>
void
Tie(const std::string& name, T* obj, int index, V (T::*getter)(int) const,
void (T::*setter)(int, V) = nullptr)
{
SGPropertyNode* property = root->getNode(name.c_str(), true);
@ -596,7 +586,7 @@ class FGPropertyManager
return;
}
if (!property->tie(SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter),
if (!property->tie(SGRawValueMethodsIndexed<T, V>(*obj, index, getter, setter),
false))
std::cerr << "Failed to tie property " << name
<< " to indexed object methods" << std::endl;
@ -608,13 +598,15 @@ class FGPropertyManager
}
}
template <class T> simgear::PropertyObject<T>
CreatePropertyObject(const std::string &path)
{ return simgear::PropertyObject<T>(root->GetNode(path, true)); }
template <class T>
simgear::PropertyObject<T>
CreatePropertyObject(const std::string& path)
{
return simgear::PropertyObject<T>(root->GetNode(path, true));
}
private:
private:
std::vector<SGPropertyNode_ptr> tied_properties;
FGPropertyNode_ptr root;
};
}
#endif // FGPROPERTYMANAGER_H
} // namespace JSBSim

View file

@ -1,34 +1,15 @@
/*
* SPDX-FileName: FGParameterValue.h
* SPDX-FileComment: Author: Bertrand Coconnier, Date started: December 09 2018
* SPDX-FileCopyrightText: Copyright (C) 2018 B. Coconnier (bcoconni@users.sf.net)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGParameterValue.h
Author: Bertrand Coconnier
Date started: December 09 2018
--------- Copyright (C) 2018 B. Coconnier (bcoconni@users.sf.net) -----------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPARAMETERVALUE_H
#define FGPARAMETERVALUE_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -36,9 +17,9 @@
#include <stdexcept>
#include "math/FGRealValue.h"
#include "math/FGPropertyValue.h"
#include "input_output/FGXMLElement.h"
#include "math/FGPropertyValue.h"
#include "math/FGRealValue.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -63,43 +44,49 @@ class FGPropertyManager;
class FGParameterValue : public FGParameter
{
public:
FGParameterValue(Element* el, FGPropertyManager* pm) {
string value = el->GetDataLine();
FGParameterValue(Element* el, FGPropertyManager* pm)
{
std::string value = el->GetDataLine();
if (el->GetNumDataLines() != 1 || value.empty()) {
cerr << el->ReadFrom()
std::cerr << el->ReadFrom()
<< "The element <" << el->GetName()
<< "> must either contain a value number or a property name."
<< endl;
throw invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName());
<< std::endl;
throw std::invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName());
}
Construct(value, pm);
}
FGParameterValue(const std::string& value, FGPropertyManager* pm) {
FGParameterValue(const std::string& value, FGPropertyManager* pm)
{
Construct(value, pm);
}
double GetValue(void) const override { return param->GetValue(); }
bool IsConstant(void) const override { return param->IsConstant(); }
std::string GetName(void) const override {
std::string GetName(void) const override
{
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
if (v)
return v->GetNameWithSign();
else
return to_string(param->GetValue());
return std::to_string(param->GetValue());
}
bool IsLateBound(void) const {
bool IsLateBound(void) const
{
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
return v != nullptr && v->IsLateBound();
}
private:
FGParameter_ptr param;
void Construct(const std::string& value, FGPropertyManager* pm) {
void Construct(const std::string& value, FGPropertyManager* pm)
{
if (is_number(value)) {
param = new FGRealValue(atof(value.c_str()));
} else {
@ -112,5 +99,3 @@ private:
typedef SGSharedPtr<FGParameterValue> FGParameterValue_ptr;
} // namespace JSBSim
#endif

View file

@ -1,31 +1,12 @@
/*
* SPDX-FileName: FGPropertyValue.cpp
* SPDX-FileComment: Stores property values
* SPDX-FileCopyrightText: Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org)
* SPDX-FileContributor: Copyright (C) 2010 - 2011 Anders Gidenstam (anders(at)gidenstam.org)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGPropertyValue.cpp
Author: Jon Berndt
Date started: 12/10/2004
Purpose: Stores property values
------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org) -------------
------ Copyright (C) 2010 - 2011 Anders Gidenstam (anders(at)gidenstam.org) -
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -101,7 +82,7 @@ std::string FGPropertyValue::GetName(void) const
std::string FGPropertyValue::GetNameWithSign(void) const
{
string name;
std::string name;
if (Sign < 0.0) name ="-";

View file

@ -1,28 +1,10 @@
/*
* SPDX-FileName: FGAerodynamics.h
* SPDX-FileCopyrightText: Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGAerodynamics.h
Author: Jon S. Berndt
Date started: 09/13/00
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
09/13/00 JSB Created
@ -31,20 +13,19 @@ HISTORY
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGAERODYNAMICS_H
#define FGAERODYNAMICS_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <map>
#include <string>
#include <vector>
#include <map>
#include "FGModel.h"
#include "math/FGFunction.h"
#include "math/FGColumnVector3.h"
#include "math/FGFunction.h"
#include "math/FGMatrix33.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -112,7 +93,6 @@ CLASS DECLARATION
class FGAerodynamics : public FGModel
{
public:
/** Constructor
@param Executive a pointer to the parent executive object */
@ -140,31 +120,31 @@ public:
/** Gets the total aerodynamic force vector.
@return a force vector reference. */
const FGColumnVector3& GetForces(void) const {return vForces;}
const FGColumnVector3& GetForces(void) const { return vForces; }
/** Gets the aerodynamic force for an axis.
@param n Axis index. This could be 0, 1, or 2, or one of the
axis enums: eX, eY, eZ.
@return the force acting on an axis */
double GetForces(int n) const {return vForces(n);}
double GetForces(int n) const { return vForces(n); }
/** Gets the total aerodynamic moment vector about the CG.
@return a moment vector reference. */
const FGColumnVector3& GetMoments(void) const {return vMoments;}
const FGColumnVector3& GetMoments(void) const { return vMoments; }
/** Gets the aerodynamic moment about the CG for an axis.
@return the moment about a single axis (as described also in the
similar call to GetForces(int n).*/
double GetMoments(int n) const {return vMoments(n);}
double GetMoments(int n) const { return vMoments(n); }
/** Gets the total aerodynamic moment vector about the Moment Reference Center.
@return a moment vector reference. */
const FGColumnVector3& GetMomentsMRC(void) const {return vMomentsMRC;}
const FGColumnVector3& GetMomentsMRC(void) const { return vMomentsMRC; }
/** Gets the aerodynamic moment about the Moment Reference Center for an axis.
@return the moment about a single axis (as described also in the
similar call to GetForces(int n).*/
double GetMomentsMRC(int n) const {return vMomentsMRC(n);}
double GetMomentsMRC(int n) const { return vMomentsMRC(n); }
/** Retrieves the aerodynamic forces in the wind axes.
@return a reference to a column vector containing the wind axis forces. */
@ -188,7 +168,7 @@ public:
/** Gets the total aerodynamic moment vector about the CG in the stability axes.
@return a moment vector reference. */
FGColumnVector3 GetMomentsInStabilityAxes(void) const { return Tb2s*vMoments; }
FGColumnVector3 GetMomentsInStabilityAxes(void) const { return Tb2s * vMoments; }
/** Gets the aerodynamic moment about the CG for an axis.
@return the moment about a single axis (as described also in the
@ -197,7 +177,7 @@ public:
/** Gets the total aerodynamic moment vector about the CG in the wind axes.
@return a moment vector reference. */
FGColumnVector3 GetMomentsInWindAxes(void) const { return in.Tb2w*vMoments; }
FGColumnVector3 GetMomentsInWindAxes(void) const { return in.Tb2w * vMoments; }
/** Gets the aerodynamic moment about the CG for an axis.
@return the moment about a single axis (as described also in the
@ -219,8 +199,8 @@ public:
double GetBI2Vel(void) const { return bi2vel; }
double GetCI2Vel(void) const { return ci2vel; }
void SetAlphaCLMax(double tt) { alphaclmax=tt; }
void SetAlphaCLMin(double tt) { alphaclmin=tt; }
void SetAlphaCLMax(double tt) { alphaclmax = tt; }
void SetAlphaCLMin(double tt) { alphaclmin = tt; }
/** Gets the strings for the current set of aero functions.
@param delimeter either a tab or comma string depending on output type
@ -233,7 +213,7 @@ public:
aero functions */
std::string GetAeroFunctionValues(const std::string& delimeter) const;
std::vector <FGFunction*> * GetAeroFunctions(void) const { return AeroFunctions; }
std::vector<FGFunction*>* GetAeroFunctions(void) const { return AeroFunctions; }
struct Inputs {
double Alpha;
@ -250,11 +230,16 @@ public:
} in;
private:
enum eAxisType {atNone, atWind, atBodyAxialNormal, atBodyXYZ, atStability} forceAxisType, momentAxisType;
typedef std::map<std::string,int> AxisIndex;
enum eAxisType { atNone,
atWind,
atBodyAxialNormal,
atBodyXYZ,
atStability } forceAxisType,
momentAxisType;
typedef std::map<std::string, int> AxisIndex;
AxisIndex AxisIdx;
FGFunction* AeroRPShift;
typedef std::vector <FGFunction*> AeroFunctionArray;
typedef std::vector<FGFunction*> AeroFunctionArray;
AeroFunctionArray* AeroFunctions;
FGMatrix33 Ts2b, Tb2s;
FGColumnVector3 vFnative;
@ -272,14 +257,14 @@ private:
double alphaclmax0, alphaclmin0;
double alphahystmax, alphahystmin;
double impending_stall, stall_hyst;
double bi2vel, ci2vel,alphaw;
double bi2vel, ci2vel, alphaw;
double clsq, lod, qbar_area;
typedef double (FGAerodynamics::*PMF)(int) const;
void DetermineAxisSystem(Element* document);
void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType,
const string& name, const string& frame,
Element* el, const string& validNames);
const std::string& name, const std::string& frame,
Element* el, const std::string& validNames);
void bind(void);
void BuildStabilityTransformMatrices(void);
@ -289,4 +274,3 @@ private:
} // namespace JSBSim
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -1,28 +1,10 @@
/*
* SPDX-FileName: FGTurbine.h
* SPDX-FileCopyrightText: Copyright (C) 2003 David Culp (daveculp@cox.net)
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGTurbine.h
Author: David Culp
Date started: 03/11/2003
------------- Copyright (C) 2003 David Culp (daveculp@cox.net)----------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
03/11/2003 DPC Created, based on FGTurbine
@ -33,8 +15,7 @@ HISTORY
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGTURBINE_H
#define FGTURBINE_H
#pragma once
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -177,11 +158,17 @@ public:
@param Executive pointer to executive structure
@param el pointer to the XML element representing the turbine engine
@param engine_number engine number */
FGTurbine(FGFDMExec* Executive, Element *el, int engine_number, struct Inputs& input);
FGTurbine(FGFDMExec* Executive, Element* el, int engine_number, struct Inputs& input);
/// Destructor
~FGTurbine();
enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
enum phaseType { tpOff,
tpRun,
tpSpinUp,
tpStart,
tpStall,
tpSeize,
tpTrim };
void Calculate(void);
double CalcFuelNeed(void);
@ -196,45 +183,45 @@ public:
phaseType GetPhase(void) { return phase; }
bool GetOvertemp(void) const {return Overtemp; }
bool GetInjection(void) const {return Injection;}
bool GetOvertemp(void) const { return Overtemp; }
bool GetInjection(void) const { return Injection; }
bool GetFire(void) const { return Fire; }
bool GetAugmentation(void) const {return Augmentation;}
bool GetAugmentation(void) const { return Augmentation; }
bool GetReversed(void) const { return Reversed; }
bool GetCutoff(void) const { return Cutoff; }
int GetIgnition(void) const {return Ignition;}
int GetIgnition(void) const { return Ignition; }
double GetInlet(void) const { return InletPosition; }
double GetNozzle(void) const { return NozzlePosition; }
double GetBleedDemand(void) const {return BleedDemand;}
double GetN1(void) const {return N1;}
double GetN2(void) const {return N2;}
double GetEPR(void) const {return EPR;}
double GetEGT(void) const {return EGT_degC;}
double GetBleedDemand(void) const { return BleedDemand; }
double GetN1(void) const { return N1; }
double GetN2(void) const { return N2; }
double GetEPR(void) const { return EPR; }
double GetEGT(void) const { return EGT_degC; }
double GetMaxN1(void) const {return MaxN1;}
double GetMaxN2(void) const {return MaxN2;}
double getOilPressure_psi () const {return OilPressure_psi;}
double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
double GetInjectionTimer(void) const {return InjectionTimer;}
double GetInjWaterNorm(void) const {return InjWaterNorm;}
double GetInjN1increment(void) const {return InjN1increment;}
double GetInjN2increment(void) const {return InjN2increment;}
double GetMaxN1(void) const { return MaxN1; }
double GetMaxN2(void) const { return MaxN2; }
double getOilPressure_psi() const { return OilPressure_psi; }
double getOilTemp_degF(void) { return KelvinToFahrenheit(OilTemp_degK); }
double GetInjectionTimer(void) const { return InjectionTimer; }
double GetInjWaterNorm(void) const { return InjWaterNorm; }
double GetInjN1increment(void) const { return InjN1increment; }
double GetInjN2increment(void) const { return InjN2increment; }
void SetInjection(bool injection) {Injection = injection;}
void SetIgnition(int ignition) {Ignition = ignition;}
void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
void SetPhase( phaseType p ) { phase = p; }
void SetEPR(double epr) {EPR = epr;}
void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
void SetInjection(bool injection) { Injection = injection; }
void SetIgnition(int ignition) { Ignition = ignition; }
void SetAugmentation(bool augmentation) { Augmentation = augmentation; }
void SetPhase(phaseType p) { phase = p; }
void SetEPR(double epr) { EPR = epr; }
void SetBleedDemand(double bleedDemand) { BleedDemand = bleedDemand; }
void SetReverse(bool reversed) { Reversed = reversed; }
void SetCutoff(bool cutoff) { Cutoff = cutoff; }
void SetMaxN1(double maxn1) {MaxN1 = maxn1;}
void SetMaxN2(double maxn2) {MaxN2 = maxn2;}
void SetInjectionTimer(double injtimer) {InjectionTimer = injtimer;}
void SetInjWaterNorm(double injwater) {InjWaterNorm = injwater;}
void SetInjN1increment(double injN1inc) {InjN1increment = injN1inc;}
void SetInjN2increment(double injN2inc) {InjN2increment = injN2inc;}
void SetMaxN1(double maxn1) { MaxN1 = maxn1; }
void SetMaxN2(double maxn2) { MaxN2 = maxn2; }
void SetInjectionTimer(double injtimer) { InjectionTimer = injtimer; }
void SetInjWaterNorm(double injwater) { InjWaterNorm = injwater; }
void SetInjN1increment(double injN1inc) { InjN1increment = injN1inc; }
void SetInjN2increment(double injN2inc) { InjN2increment = injN2inc; }
int InitRunning(void);
void ResetToIC(void);
@ -243,7 +230,6 @@ public:
std::string GetEngineValues(const std::string& delimiter);
private:
phaseType phase; ///< Operating mode, or "phase"
double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf)
@ -307,17 +293,17 @@ private:
double Seize(void);
double Trim();
FGFunction *IdleThrustLookup;
FGFunction *MilThrustLookup;
FGFunction *MaxThrustLookup;
FGFunction *InjectionLookup;
FGFunction* IdleThrustLookup;
FGFunction* MilThrustLookup;
FGFunction* MaxThrustLookup;
FGFunction* InjectionLookup;
FGFDMExec* FDMExec;
FGParameter *N1SpoolUp;
FGParameter *N1SpoolDown;
FGParameter *N2SpoolUp;
FGParameter *N2SpoolDown;
FGParameter* N1SpoolUp;
FGParameter* N1SpoolDown;
FGParameter* N2SpoolUp;
FGParameter* N2SpoolDown;
bool Load(FGFDMExec *exec, Element *el);
bool Load(FGFDMExec* exec, Element* el);
void bindmodel(FGPropertyManager* pm);
void Debug(int from);
@ -329,16 +315,17 @@ class FGSpoolUp : public FGParameter
public:
FGSpoolUp(FGTurbine* _turb, double BPR, double factor)
: turb(_turb), delay(factor * 90.0 / (BPR + 3.0)) {}
string GetName(void) const { return string(); };
double GetValue(void) const {
std::string GetName(void) const { return std::string(); };
double GetValue(void) const
{
// adjust acceleration for N2 and atmospheric density
double n = std::min(1.0, turb->N2norm + 0.1);
return delay / (1 + 3 * (1-n)*(1-n)*(1-n) + (1 - turb->in.DensityRatio));
return delay / (1 + 3 * (1 - n) * (1 - n) * (1 - n) + (1 - turb->in.DensityRatio));
}
private:
FGTurbine* turb;
double delay; ///< Inverse spool-up time from idle to 100% (seconds)
};
}
} // namespace JSBSim
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -1,14 +1,12 @@
/*
* SPDX-FileName: uiuc_recorder.cpp
* SPDX-FileComment: outputs variables specified in input file to recorder file
* SPDX-FileCopyrightText: (C) 2000 by Michael Selig
* SPDX-License-Identifier: GPL-1.0
*/
/**********************************************************************
FILENAME: uiuc_recorder.cpp
----------------------------------------------------------------------
DESCRIPTION: outputs variables specified in input file to recorder
file
----------------------------------------------------------------------
STATUS: alpha version
----------------------------------------------------------------------
@ -68,24 +66,6 @@
----------------------------------------------------------------------
CALLS TO: none
----------------------------------------------------------------------
COPYRIGHT: (C) 2000 by Michael Selig
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/
#ifdef HAVE_CONFIG_H
@ -103,10 +83,10 @@ using std::endl; // -dw
void uiuc_recorder( double dt )
{
::stack command_list;
string linetoken;
std::string linetoken;
// static int init = 0;
static int recordStep = 0;
string record_variables = "# ";
std::string record_variables = "# ";
// int modulus = recordStep % recordRate;