diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 66dfdad40..d9ac121c5 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -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 @@ -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); } diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.h b/src/FDM/JSBSim/input_output/FGPropertyManager.h index dfdf2fa02..e0ce26cfc 100644 --- a/src/FDM/JSBSim/input_output/FGPropertyManager.h +++ b/src/FDM/JSBSim/input_output/FGPropertyManager.h @@ -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 +#if defined(HAVE_CONFIG_H) +#include #endif #include + #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_ptr; @@ -372,26 +353,30 @@ typedef SGSharedPtr 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); - return root->HasNode(newPath); + std::string newPath = path; + if (newPath[0] == '-') newPath.erase(0, 1); + return root->HasNode(newPath); } /** Property-ify a name @@ -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,24 +430,25 @@ class FGPropertyManager * @param name The property name to tie (full path). * @param pointer A pointer to the variable. */ - template void - Tie (const std::string &name, T *pointer) + template + 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; - return; - } + SGPropertyNode* property = root->getNode(name.c_str(), true); + if (!property) { + std::cerr << "Could not get or create property " << name << std::endl; + return; + } - if (!property->tie(SGRawValuePointer(pointer), false)) - cerr << "Failed to tie property " << name << " to a pointer" << endl; - else { - tied_properties.push_back(property); - if (FGJSBBase::debug_lvl & 0x20) cout << name << endl; - } + if (!property->tie(SGRawValuePointer(pointer), false)) + std::cerr << "Failed to tie property " << name << " to a pointer" << std::endl; + else { + tied_properties.push_back(property); + if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; + } } - /** + /** * Tie a property to a pair of simple functions. * * Every time the property value is queried, the getter (if any) will @@ -476,24 +462,25 @@ class FGPropertyManager * @param setter The setter function, or 0 if the value is unmodifiable. */ - template void - Tie (const std::string &name, T (*getter)(), void (*setter)(T) = nullptr) + template + void + Tie(const std::string& name, T (*getter)(), void (*setter)(T) = nullptr) { - SGPropertyNode* property = root->getNode(name.c_str(), true); - if (!property) { - std::cerr << "Could not get or create property " << name << std::endl; - return; - } + SGPropertyNode* property = root->getNode(name.c_str(), true); + if (!property) { + std::cerr << "Could not get or create property " << name << std::endl; + return; + } - if (!property->tie(SGRawValueFunctions(getter, setter), false)) - std::cerr << "Failed to tie property " << name << " to functions" - << std::endl; - else { - if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); - if (!getter) property->setAttribute(SGPropertyNode::READ, false); - tied_properties.push_back(property); - if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; - } + if (!property->tie(SGRawValueFunctions(getter, setter), false)) + std::cerr << "Failed to tie property " << name << " to functions" + << std::endl; + else { + if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); + if (!getter) property->setAttribute(SGPropertyNode::READ, false); + tied_properties.push_back(property); + if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; + } } /** @@ -511,26 +498,27 @@ 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 void - Tie (const std::string &name, int index, T (*getter)(int), - void (*setter)(int, T) = nullptr) + template + void + Tie(const std::string& name, int index, T (*getter)(int), + void (*setter)(int, T) = nullptr) { - SGPropertyNode* property = root->getNode(name.c_str(), true); - if (!property) { - std::cerr << "Could not get or create property " << name << std::endl; - return; - } + SGPropertyNode* property = root->getNode(name.c_str(), true); + if (!property) { + std::cerr << "Could not get or create property " << name << std::endl; + return; + } - if (!property->tie(SGRawValueFunctionsIndexed(index, getter, setter), - false)) - std::cerr << "Failed to tie property " << name << " to indexed functions" - << std::endl; - else { - if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); - if (!getter) property->setAttribute(SGPropertyNode::READ, false); - tied_properties.push_back(property); - if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; - } + if (!property->tie(SGRawValueFunctionsIndexed(index, getter, setter), + false)) + std::cerr << "Failed to tie property " << name << " to indexed functions" + << std::endl; + else { + if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); + if (!getter) property->setAttribute(SGPropertyNode::READ, false); + tied_properties.push_back(property); + if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; + } } /** @@ -549,25 +537,26 @@ class FGPropertyManager * @param setter The object's setter method, or 0 if the value is * unmodifiable. */ - template void - Tie (const std::string &name, T * obj, V (T::*getter)() const, - void (T::*setter)(V) = nullptr) + template + 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); - if (!property) { - std::cerr << "Could not get or create property " << name << std::endl; - return; - } + SGPropertyNode* property = root->getNode(name.c_str(), true); + if (!property) { + std::cerr << "Could not get or create property " << name << std::endl; + return; + } - if (!property->tie(SGRawValueMethods(*obj, getter, setter), false)) - std::cerr << "Failed to tie property " << name << " to object methods" - << std::endl; - else { - if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); - if (!getter) property->setAttribute(SGPropertyNode::READ, false); - tied_properties.push_back(property); - if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; - } + if (!property->tie(SGRawValueMethods(*obj, getter, setter), false)) + std::cerr << "Failed to tie property " << name << " to object methods" + << std::endl; + else { + if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); + if (!getter) property->setAttribute(SGPropertyNode::READ, false); + tied_properties.push_back(property); + if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; + } } /** @@ -586,35 +575,38 @@ 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 void - Tie (const std::string &name, T * obj, int index, V (T::*getter)(int) const, - void (T::*setter)(int, V) = nullptr) + template + 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); - if (!property) { - std::cerr << "Could not get or create property " << name << std::endl; - return; - } + SGPropertyNode* property = root->getNode(name.c_str(), true); + if (!property) { + std::cerr << "Could not get or create property " << name << std::endl; + return; + } - if (!property->tie(SGRawValueMethodsIndexed(*obj, index, getter, setter), - false)) - std::cerr << "Failed to tie property " << name - << " to indexed object methods" << std::endl; - else { - if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); - if (!getter) property->setAttribute(SGPropertyNode::READ, false); - tied_properties.push_back(property); - if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; - } - } + if (!property->tie(SGRawValueMethodsIndexed(*obj, index, getter, setter), + false)) + std::cerr << "Failed to tie property " << name + << " to indexed object methods" << std::endl; + else { + if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); + if (!getter) property->setAttribute(SGPropertyNode::READ, false); + tied_properties.push_back(property); + if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl; + } + } - template simgear::PropertyObject - CreatePropertyObject(const std::string &path) - { return simgear::PropertyObject(root->GetNode(path, true)); } + template + simgear::PropertyObject + CreatePropertyObject(const std::string& path) + { + return simgear::PropertyObject(root->GetNode(path, true)); + } - private: +private: std::vector tied_properties; FGPropertyNode_ptr root; }; -} -#endif // FGPROPERTYMANAGER_H +} // namespace JSBSim diff --git a/src/FDM/JSBSim/math/FGParameterValue.h b/src/FDM/JSBSim/math/FGParameterValue.h index cbb2ab9a4..9c1443461 100644 --- a/src/FDM/JSBSim/math/FGParameterValue.h +++ b/src/FDM/JSBSim/math/FGParameterValue.h @@ -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 -#include "math/FGRealValue.h" -#include "math/FGPropertyValue.h" #include "input_output/FGXMLElement.h" +#include "math/FGPropertyValue.h" +#include "math/FGRealValue.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -63,54 +44,58 @@ 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() - << "The element <" << el->GetName() - << "> must either contain a value number or a property name." - << endl; - throw invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName()); + if (el->GetNumDataLines() != 1 || value.empty()) { + std::cerr << el->ReadFrom() + << "The element <" << el->GetName() + << "> must either contain a value number or a property name." + << std::endl; + throw std::invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName()); + } + + Construct(value, pm); } - Construct(value, pm); - } + FGParameterValue(const std::string& value, FGPropertyManager* pm) + { + Construct(value, 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(); } - double GetValue(void) const override { return param->GetValue(); } - bool IsConstant(void) const override { return param->IsConstant(); } + std::string GetName(void) const override + { + FGPropertyValue* v = dynamic_cast(param.ptr()); + if (v) + return v->GetNameWithSign(); + else + return std::to_string(param->GetValue()); + } - std::string GetName(void) const override { - FGPropertyValue* v = dynamic_cast(param.ptr()); - if (v) - return v->GetNameWithSign(); - else - return to_string(param->GetValue()); - } + bool IsLateBound(void) const + { + FGPropertyValue* v = dynamic_cast(param.ptr()); + return v != nullptr && v->IsLateBound(); + } - bool IsLateBound(void) const { - FGPropertyValue* v = dynamic_cast(param.ptr()); - return v != nullptr && v->IsLateBound(); - } private: - FGParameter_ptr param; + FGParameter_ptr param; - void Construct(const std::string& value, FGPropertyManager* pm) { - if (is_number(value)) { - param = new FGRealValue(atof(value.c_str())); - } else { - // "value" must be a property if execution passes to here. - param = new FGPropertyValue(value, pm); + void Construct(const std::string& value, FGPropertyManager* pm) + { + if (is_number(value)) { + param = new FGRealValue(atof(value.c_str())); + } else { + // "value" must be a property if execution passes to here. + param = new FGPropertyValue(value, pm); + } } - } }; typedef SGSharedPtr FGParameterValue_ptr; } // namespace JSBSim - -#endif diff --git a/src/FDM/JSBSim/math/FGPropertyValue.cpp b/src/FDM/JSBSim/math/FGPropertyValue.cpp index 91473f0d3..a2b6d1a56 100644 --- a/src/FDM/JSBSim/math/FGPropertyValue.cpp +++ b/src/FDM/JSBSim/math/FGPropertyValue.cpp @@ -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 ="-"; diff --git a/src/FDM/JSBSim/models/FGAerodynamics.h b/src/FDM/JSBSim/models/FGAerodynamics.h index 68b929578..92bbc55aa 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.h +++ b/src/FDM/JSBSim/models/FGAerodynamics.h @@ -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 #include #include -#include #include "FGModel.h" -#include "math/FGFunction.h" #include "math/FGColumnVector3.h" +#include "math/FGFunction.h" #include "math/FGMatrix33.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -112,181 +93,184 @@ CLASS DECLARATION class FGAerodynamics : public FGModel { - public: - /** Constructor + /** Constructor @param Executive a pointer to the parent executive object */ - FGAerodynamics(FGFDMExec* Executive); - /// Destructor - ~FGAerodynamics() override; + FGAerodynamics(FGFDMExec* Executive); + /// Destructor + ~FGAerodynamics() override; - bool InitModel(void) override; + bool InitModel(void) override; - /** Runs the Aerodynamics model; called by the Executive + /** Runs the Aerodynamics model; called by the Executive Can pass in a value indicating if the executive is directing the simulation to Hold. @param Holding if true, the executive has been directed to hold the sim from advancing time. Some models may ignore this flag, such as the Input model, which may need to be active to listen on a socket for the "Resume" command to be given. @return false if no error */ - bool Run(bool Holding) override; + bool Run(bool Holding) override; - /** Loads the Aerodynamics model. + /** Loads the Aerodynamics model. The Load function for this class expects the XML parser to have found the aerodynamics keyword in the configuration file. @param element pointer to the current XML element for aerodynamics parameters. @return true if successful */ - bool Load(Element* element) override; + bool Load(Element* element) override; - /** Gets the total aerodynamic force vector. + /** 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. + /** 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. + /** 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. + /** 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. + /** 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. + /** 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. + /** Retrieves the aerodynamic forces in the wind axes. @return a reference to a column vector containing the wind axis forces. */ - const FGColumnVector3& GetvFw(void) const { return vFw; } + const FGColumnVector3& GetvFw(void) const { return vFw; } - /** Retrieves the aerodynamic forces in the wind axes, given an axis. + /** Retrieves the aerodynamic forces in the wind axes, given an axis. @param axis the axis to return the force for (eX, eY, eZ). @return a reference to a column vector containing the requested wind axis force. */ - double GetvFw(int axis) const { return vFw(axis); } + double GetvFw(int axis) const { return vFw(axis); } - /** Retrieves the aerodynamic forces in the stability axes. + /** Retrieves the aerodynamic forces in the stability axes. @return a reference to a column vector containing the stability axis forces. */ - FGColumnVector3 GetForcesInStabilityAxes(void) const; + FGColumnVector3 GetForcesInStabilityAxes(void) const; - /** Retrieves the aerodynamic forces in the stability axes, given an axis. + /** Retrieves the aerodynamic forces in the stability axes, given an axis. @param axis the axis to return the force for (eX, eY, eZ). @return a reference to a column vector containing the requested stability axis force. */ - double GetForcesInStabilityAxes(int n) const { return GetForcesInStabilityAxes()(n); } + double GetForcesInStabilityAxes(int n) const { return GetForcesInStabilityAxes()(n); } - /** Gets the total aerodynamic moment vector about the CG in the stability axes. + /** 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. + /** 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 GetMomentsInStabilityAxes(int n) const { return GetMomentsInStabilityAxes()(n); } + double GetMomentsInStabilityAxes(int n) const { return GetMomentsInStabilityAxes()(n); } - /** Gets the total aerodynamic moment vector about the CG in the wind axes. + /** 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. + /** 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 GetMomentsInWindAxes(int n) const { return GetMomentsInWindAxes()(n); } + double GetMomentsInWindAxes(int n) const { return GetMomentsInWindAxes()(n); } - /** Retrieves the lift over drag ratio */ - double GetLoD(void) const { return lod; } + /** Retrieves the lift over drag ratio */ + double GetLoD(void) const { return lod; } - /** Retrieves the square of the lift coefficient. */ - double GetClSquared(void) const { return clsq; } - double GetAlphaCLMax(void) const { return alphaclmax; } - double GetAlphaCLMin(void) const { return alphaclmin; } + /** Retrieves the square of the lift coefficient. */ + double GetClSquared(void) const { return clsq; } + double GetAlphaCLMax(void) const { return alphaclmax; } + double GetAlphaCLMin(void) const { return alphaclmin; } - double GetHysteresisParm(void) const { return stall_hyst; } - double GetStallWarn(void) const { return impending_stall; } - double GetAlphaW(void) const { return alphaw; } + double GetHysteresisParm(void) const { return stall_hyst; } + double GetStallWarn(void) const { return impending_stall; } + double GetAlphaW(void) const { return alphaw; } - double GetBI2Vel(void) const { return bi2vel; } - double GetCI2Vel(void) const { return ci2vel; } + 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. + /** Gets the strings for the current set of aero functions. @param delimeter either a tab or comma string depending on output type @return a string containing the descriptive names for all aero functions */ - std::string GetAeroFunctionStrings(const std::string& delimeter) const; + std::string GetAeroFunctionStrings(const std::string& delimeter) const; - /** Gets the aero function values. + /** Gets the aero function values. @param delimeter either a tab or comma string depending on output type @return a string containing the numeric values for the current set of aero functions */ - std::string GetAeroFunctionValues(const std::string& delimeter) const; + std::string GetAeroFunctionValues(const std::string& delimeter) const; - std::vector * GetAeroFunctions(void) const { return AeroFunctions; } + std::vector* GetAeroFunctions(void) const { return AeroFunctions; } - struct Inputs { - double Alpha; - double Beta; - double Vt; - double Qbar; - double Wingarea; - double Wingspan; - double Wingchord; - double Wingincidence; - FGColumnVector3 RPBody; - FGMatrix33 Tb2w; - FGMatrix33 Tw2b; - } in; + struct Inputs { + double Alpha; + double Beta; + double Vt; + double Qbar; + double Wingarea; + double Wingspan; + double Wingchord; + double Wingincidence; + FGColumnVector3 RPBody; + FGMatrix33 Tb2w; + FGMatrix33 Tw2b; + } in; private: - enum eAxisType {atNone, atWind, atBodyAxialNormal, atBodyXYZ, atStability} forceAxisType, momentAxisType; - typedef std::map AxisIndex; - AxisIndex AxisIdx; - FGFunction* AeroRPShift; - typedef std::vector AeroFunctionArray; - AeroFunctionArray* AeroFunctions; - FGMatrix33 Ts2b, Tb2s; - FGColumnVector3 vFnative; - FGColumnVector3 vFw; - FGColumnVector3 vForces; - AeroFunctionArray* AeroFunctionsAtCG; - FGColumnVector3 vFnativeAtCG; - FGColumnVector3 vForcesAtCG; - FGColumnVector3 vMoments; - FGColumnVector3 vMomentsMRC; - FGColumnVector3 vMomentsMRCBodyXYZ; - FGColumnVector3 vDXYZcg; - FGColumnVector3 vDeltaRP; - double alphaclmax, alphaclmin; - double alphaclmax0, alphaclmin0; - double alphahystmax, alphahystmin; - double impending_stall, stall_hyst; - double bi2vel, ci2vel,alphaw; - double clsq, lod, qbar_area; + enum eAxisType { atNone, + atWind, + atBodyAxialNormal, + atBodyXYZ, + atStability } forceAxisType, + momentAxisType; + typedef std::map AxisIndex; + AxisIndex AxisIdx; + FGFunction* AeroRPShift; + typedef std::vector AeroFunctionArray; + AeroFunctionArray* AeroFunctions; + FGMatrix33 Ts2b, Tb2s; + FGColumnVector3 vFnative; + FGColumnVector3 vFw; + FGColumnVector3 vForces; + AeroFunctionArray* AeroFunctionsAtCG; + FGColumnVector3 vFnativeAtCG; + FGColumnVector3 vForcesAtCG; + FGColumnVector3 vMoments; + FGColumnVector3 vMomentsMRC; + FGColumnVector3 vMomentsMRCBodyXYZ; + FGColumnVector3 vDXYZcg; + FGColumnVector3 vDeltaRP; + double alphaclmax, alphaclmin; + double alphaclmax0, alphaclmin0; + double alphahystmax, alphahystmin; + double impending_stall, stall_hyst; + 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); - void bind(void); - void BuildStabilityTransformMatrices(void); + typedef double (FGAerodynamics::*PMF)(int) const; + void DetermineAxisSystem(Element* document); + void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType, + const std::string& name, const std::string& frame, + Element* el, const std::string& validNames); + void bind(void); + void BuildStabilityTransformMatrices(void); - void Debug(int from) override; + void Debug(int from) override; }; } // namespace JSBSim //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif diff --git a/src/FDM/JSBSim/models/propulsion/FGTurbine.h b/src/FDM/JSBSim/models/propulsion/FGTurbine.h index 4a5328d45..0c13376f9 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTurbine.h +++ b/src/FDM/JSBSim/models/propulsion/FGTurbine.h @@ -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 @@ -173,172 +154,178 @@ CLASS DECLARATION class FGTurbine : public FGEngine { public: - /** Constructor + /** Constructor @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); - /// Destructor - ~FGTurbine(); + 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); - double GetPowerAvailable(void); - /** A lag filter. + void Calculate(void); + double CalcFuelNeed(void); + double GetPowerAvailable(void); + /** A lag filter. Used to control the rate at which values are allowed to change. @param var a pointer to a variable of type double @param target the desired (target) value @param accel the rate, per second, the value may increase @param decel the rate, per second, the value may decrease */ - double Seek(double* var, double target, double accel, double decel); + double Seek(double* var, double target, double accel, double decel); - phaseType GetPhase(void) { return phase; } + phaseType GetPhase(void) { return phase; } - 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 GetReversed(void) const { return Reversed; } - bool GetCutoff(void) const { return Cutoff; } - int GetIgnition(void) const {return Ignition;} + 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 GetReversed(void) const { return Reversed; } + bool GetCutoff(void) const { return Cutoff; } + 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 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 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 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;} - - int InitRunning(void); - void ResetToIC(void); + 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; } - std::string GetEngineLabels(const std::string& delimiter); - std::string GetEngineValues(const std::string& delimiter); + int InitRunning(void); + void ResetToIC(void); + + std::string GetEngineLabels(const std::string& delimiter); + 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) + double BypassRatio; ///< Bypass Ratio + double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf) + double ATSFC; ///< Augmented TSFC (lbm/hr/lbf) + double IdleN1; ///< Idle N1 + double IdleN2; ///< Idle N2 + double IgnitionN1; ///< Ignition N1 + double IgnitionN2; ///< Ignition N2 + double N1; ///< N1 + double N2; ///< N2 + double N2norm; ///< N2 normalized (0=idle, 1=max) + double MaxN1; ///< N1 at 100% throttle + double MaxN2; ///< N2 at 100% throttle + double IdleFF; ///< Idle Fuel Flow (lbm/hr) + double N1_factor; ///< factor to tie N1 and throttle + double N2_factor; ///< factor to tie N2 and throttle + double ThrottlePos; ///< FCS-supplied throttle position - modified for local use! + double AugmentCmd; ///< modulated afterburner command (0.0 to 1.0) + double N1_spinup; ///< N1 spin up rate from pneumatic starter (per second) + double N2_spinup; ///< N2 spin up rate from pneumatic starter (per second) + double N1_start_rate; ///< N1 spin up rate from ignition (per second) + double N2_start_rate; ///< N2 spin up rate from ignition (per second) + double N1_spindown; ///< N1 spin down factor + double N2_spindown; ///< N2 spin down factor + bool Stalled; ///< true if engine is compressor-stalled + bool Seized; ///< true if inner spool is seized + bool Overtemp; ///< true if EGT exceeds limits + bool Fire; ///< true if engine fire detected + bool Injection; + bool Augmentation; + bool Reversed; + bool Cutoff; + bool disableWindmill; ///< flag to disable windmilling of engine in Off phase + int Injected; ///< = 1 if water injection installed + int Ignition; + int Augmented; ///< = 1 if augmentation installed + int AugMethod; ///< = 0 if using property /engine[n]/augmentation + ///< = 1 if using last 1% of throttle movement + ///< = 2 if using FCS-defined throttle + double EGT_degC; + double EPR; + double OilPressure_psi; + double OilTemp_degK; + double BleedDemand; + double InletPosition; + double NozzlePosition; + double correctedTSFC; + double InjectionTimer; + double InjectionTime; + double InjWaterNorm; + double InjN1increment; + double InjN2increment; - phaseType phase; ///< Operating mode, or "phase" - double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf) - double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf) - double BypassRatio; ///< Bypass Ratio - double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf) - double ATSFC; ///< Augmented TSFC (lbm/hr/lbf) - double IdleN1; ///< Idle N1 - double IdleN2; ///< Idle N2 - double IgnitionN1; ///< Ignition N1 - double IgnitionN2; ///< Ignition N2 - double N1; ///< N1 - double N2; ///< N2 - double N2norm; ///< N2 normalized (0=idle, 1=max) - double MaxN1; ///< N1 at 100% throttle - double MaxN2; ///< N2 at 100% throttle - double IdleFF; ///< Idle Fuel Flow (lbm/hr) - double N1_factor; ///< factor to tie N1 and throttle - double N2_factor; ///< factor to tie N2 and throttle - double ThrottlePos; ///< FCS-supplied throttle position - modified for local use! - double AugmentCmd; ///< modulated afterburner command (0.0 to 1.0) - double N1_spinup; ///< N1 spin up rate from pneumatic starter (per second) - double N2_spinup; ///< N2 spin up rate from pneumatic starter (per second) - double N1_start_rate; ///< N1 spin up rate from ignition (per second) - double N2_start_rate; ///< N2 spin up rate from ignition (per second) - double N1_spindown; ///< N1 spin down factor - double N2_spindown; ///< N2 spin down factor - bool Stalled; ///< true if engine is compressor-stalled - bool Seized; ///< true if inner spool is seized - bool Overtemp; ///< true if EGT exceeds limits - bool Fire; ///< true if engine fire detected - bool Injection; - bool Augmentation; - bool Reversed; - bool Cutoff; - bool disableWindmill; ///< flag to disable windmilling of engine in Off phase - int Injected; ///< = 1 if water injection installed - int Ignition; - int Augmented; ///< = 1 if augmentation installed - int AugMethod; ///< = 0 if using property /engine[n]/augmentation - ///< = 1 if using last 1% of throttle movement - ///< = 2 if using FCS-defined throttle - double EGT_degC; - double EPR; - double OilPressure_psi; - double OilTemp_degK; - double BleedDemand; - double InletPosition; - double NozzlePosition; - double correctedTSFC; - double InjectionTimer; - double InjectionTime; - double InjWaterNorm; - double InjN1increment; - double InjN2increment; + double Off(void); + double Run(); + double SpinUp(void); + double Start(void); + double Stall(void); + double Seize(void); + double Trim(); - double Off(void); - double Run(); - double SpinUp(void); - double Start(void); - double Stall(void); - double Seize(void); - double Trim(); + FGFunction* IdleThrustLookup; + FGFunction* MilThrustLookup; + FGFunction* MaxThrustLookup; + FGFunction* InjectionLookup; + FGFDMExec* FDMExec; + FGParameter* N1SpoolUp; + FGParameter* N1SpoolDown; + FGParameter* N2SpoolUp; + FGParameter* N2SpoolDown; - FGFunction *IdleThrustLookup; - FGFunction *MilThrustLookup; - FGFunction *MaxThrustLookup; - FGFunction *InjectionLookup; - FGFDMExec* FDMExec; - FGParameter *N1SpoolUp; - FGParameter *N1SpoolDown; - FGParameter *N2SpoolUp; - FGParameter *N2SpoolDown; + bool Load(FGFDMExec* exec, Element* el); + void bindmodel(FGPropertyManager* pm); + void Debug(int from); - bool Load(FGFDMExec *exec, Element *el); - void bindmodel(FGPropertyManager* pm); - void Debug(int from); - - friend class FGSpoolUp; + friend class FGSpoolUp; }; 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 { - // 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)); - } + FGSpoolUp(FGTurbine* _turb, double BPR, double factor) + : turb(_turb), delay(factor * 90.0 / (BPR + 3.0)) {} + 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)); + } + private: - FGTurbine* turb; - double delay; ///< Inverse spool-up time from idle to 100% (seconds) + FGTurbine* turb; + double delay; ///< Inverse spool-up time from idle to 100% (seconds) }; -} +} // namespace JSBSim //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#endif diff --git a/src/FDM/UIUCModel/uiuc_recorder.cpp b/src/FDM/UIUCModel/uiuc_recorder.cpp index 9269b8b8e..298249a19 100644 --- a/src/FDM/UIUCModel/uiuc_recorder.cpp +++ b/src/FDM/UIUCModel/uiuc_recorder.cpp @@ -1,13 +1,11 @@ +/* + * 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;