Maintenance: namespace
Clean up namespaces. Don't use broad 'using namespace' context in header files. Header Guards. SPDX tags.
This commit is contained in:
parent
3df69b8381
commit
bd3b209466
7 changed files with 488 additions and 595 deletions
|
@ -1,25 +1,9 @@
|
||||||
// JSBsim.cxx -- interface to the JSBsim flight model
|
/*
|
||||||
//
|
* SPDX-FileName: JSBsim.cxx
|
||||||
// Written by Curtis Olson, started February 1999.
|
* SPDX-FileComment: interface to the JSBsim flight model
|
||||||
//
|
* SPDX-FileCopyrightText: Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
//
|
*/
|
||||||
// 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 $
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
|
@ -376,7 +360,7 @@ FGJSBsim::FGJSBsim( double dt )
|
||||||
fgtrim->DoTrim();
|
fgtrim->DoTrim();
|
||||||
delete fgtrim;
|
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())
|
if (!directive_file.empty())
|
||||||
fdmex->SetOutputDirectives(directive_file);
|
fdmex->SetOutputDirectives(directive_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
|
SENTRY
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
#ifndef FGPROPERTYMANAGER_H
|
#pragma once
|
||||||
#define FGPROPERTYMANAGER_H
|
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
INCLUDES
|
INCLUDES
|
||||||
|
@ -37,14 +17,15 @@ INCLUDES
|
||||||
|
|
||||||
// This is needed by MSVC9 when included in FlightGear because of
|
// This is needed by MSVC9 when included in FlightGear because of
|
||||||
// the new Vec4d class in props.hxx
|
// the new Vec4d class in props.hxx
|
||||||
#if defined( HAVE_CONFIG_H )
|
#if defined(HAVE_CONFIG_H)
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "simgear/props/propertyObject.hxx"
|
#include "simgear/props/propertyObject.hxx"
|
||||||
#if !PROPS_STANDALONE
|
#if !PROPS_STANDALONE
|
||||||
# include "simgear/math/SGMath.hxx"
|
#include "simgear/math/SGMath.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "FGJSBBase.h"
|
#include "FGJSBBase.h"
|
||||||
|
@ -69,7 +50,7 @@ CLASS DECLARATION
|
||||||
|
|
||||||
class FGPropertyNode : public SGPropertyNode
|
class FGPropertyNode : public SGPropertyNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~FGPropertyNode(void) {}
|
virtual ~FGPropertyNode(void) {}
|
||||||
|
|
||||||
|
@ -81,10 +62,10 @@ class FGPropertyNode : public SGPropertyNode
|
||||||
* @return The node, or 0 if none exists and none was created.
|
* @return The node, or 0 if none exists and none was created.
|
||||||
*/
|
*/
|
||||||
FGPropertyNode*
|
FGPropertyNode*
|
||||||
GetNode (const std::string &path, bool create = false);
|
GetNode(const std::string& path, bool create = false);
|
||||||
|
|
||||||
FGPropertyNode*
|
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.
|
* Test whether a given node exists.
|
||||||
|
@ -92,17 +73,17 @@ class FGPropertyNode : public SGPropertyNode
|
||||||
* @param path The path of the node, relative to root.
|
* @param path The path of the node, relative to root.
|
||||||
* @return true if the node exists, false otherwise.
|
* @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
|
* 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.
|
* 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
|
* 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.
|
* @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.
|
* Get a bool value for a property.
|
||||||
|
@ -133,7 +114,7 @@ class FGPropertyNode : public SGPropertyNode
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as a bool, or the default value provided.
|
* @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.
|
* does not exist.
|
||||||
* @return The property's value as an int, or the default value provided.
|
* @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.
|
* does not exist.
|
||||||
* @return The property's value as a long, or the default value provided.
|
* @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.
|
* does not exist.
|
||||||
* @return The property's value as a float, or the default value provided.
|
* @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.
|
* does not exist.
|
||||||
* @return The property's value as a double, or the default value provided.
|
* @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.
|
* does not exist.
|
||||||
* @return The property's value as a string, or the default value provided.
|
* @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.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @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.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @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.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @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.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @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.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @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.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @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 name The property name.
|
||||||
* @param state The state of the archive attribute (defaults to true).
|
* @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 name The property name.
|
||||||
* @param state The state of the read attribute (defaults to true).
|
* @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 name The property name.
|
||||||
* @param state The state of the write attribute (defaults to true).
|
* @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;
|
typedef SGSharedPtr<FGPropertyNode> FGPropertyNode_ptr;
|
||||||
|
@ -372,26 +353,30 @@ typedef SGSharedPtr<const FGPropertyNode> FGConstPropertyNode_ptr;
|
||||||
|
|
||||||
class FGPropertyManager
|
class FGPropertyManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
FGPropertyManager(void) { root = new FGPropertyNode; }
|
FGPropertyManager(void) { root = new FGPropertyNode; }
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
explicit FGPropertyManager(FGPropertyNode* _root) : root(_root) {};
|
explicit FGPropertyManager(FGPropertyNode* _root) : root(_root){};
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~FGPropertyManager(void) { Unbind(); }
|
virtual ~FGPropertyManager(void) { Unbind(); }
|
||||||
|
|
||||||
FGPropertyNode* GetNode(void) const { return root; }
|
FGPropertyNode* GetNode(void) const { return root; }
|
||||||
FGPropertyNode* GetNode(const std::string &path, bool create = false)
|
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(path, create);
|
||||||
{ return root->GetNode(relpath, index, 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
|
bool HasNode(const std::string& path) const
|
||||||
{
|
{
|
||||||
std::string newPath = path;
|
std::string newPath = path;
|
||||||
if (newPath[0] == '-') newPath.erase(0,1);
|
if (newPath[0] == '-') newPath.erase(0, 1);
|
||||||
return root->HasNode(newPath);
|
return root->HasNode(newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Property-ify a name
|
/** Property-ify a name
|
||||||
|
@ -416,7 +401,7 @@ class FGPropertyManager
|
||||||
*
|
*
|
||||||
* @param name The property name to untie (full path).
|
* @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.
|
* Untie a property from an external data source.
|
||||||
|
@ -426,7 +411,7 @@ class FGPropertyManager
|
||||||
*
|
*
|
||||||
* @param property A pointer to the property to untie.
|
* @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.
|
* 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
|
* Classes should use this function to release control of any
|
||||||
* properties they have bound using this property manager.
|
* properties they have bound using this property manager.
|
||||||
*/
|
*/
|
||||||
void Unbind (void);
|
void Unbind(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie a property to an external variable.
|
* Tie a property to an external variable.
|
||||||
|
@ -445,24 +430,25 @@ class FGPropertyManager
|
||||||
* @param name The property name to tie (full path).
|
* @param name The property name to tie (full path).
|
||||||
* @param pointer A pointer to the variable.
|
* @param pointer A pointer to the variable.
|
||||||
*/
|
*/
|
||||||
template <typename T> void
|
template <typename T>
|
||||||
Tie (const std::string &name, T *pointer)
|
void
|
||||||
|
Tie(const std::string& name, T* pointer)
|
||||||
{
|
{
|
||||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||||
if (!property) {
|
if (!property) {
|
||||||
cerr << "Could not get or create property " << name << endl;
|
std::cerr << "Could not get or create property " << name << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!property->tie(SGRawValuePointer<T>(pointer), false))
|
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 {
|
else {
|
||||||
tied_properties.push_back(property);
|
tied_properties.push_back(property);
|
||||||
if (FGJSBBase::debug_lvl & 0x20) cout << name << endl;
|
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie a property to a pair of simple functions.
|
* Tie a property to a pair of simple functions.
|
||||||
*
|
*
|
||||||
* Every time the property value is queried, the getter (if any) will
|
* 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.
|
* @param setter The setter function, or 0 if the value is unmodifiable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <typename T> void
|
template <typename T>
|
||||||
Tie (const std::string &name, T (*getter)(), void (*setter)(T) = nullptr)
|
void
|
||||||
|
Tie(const std::string& name, T (*getter)(), void (*setter)(T) = nullptr)
|
||||||
{
|
{
|
||||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||||
if (!property) {
|
if (!property) {
|
||||||
std::cerr << "Could not get or create property " << name << std::endl;
|
std::cerr << "Could not get or create property " << name << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!property->tie(SGRawValueFunctions<T>(getter, setter), false))
|
if (!property->tie(SGRawValueFunctions<T>(getter, setter), false))
|
||||||
std::cerr << "Failed to tie property " << name << " to functions"
|
std::cerr << "Failed to tie property " << name << " to functions"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else {
|
else {
|
||||||
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
||||||
tied_properties.push_back(property);
|
tied_properties.push_back(property);
|
||||||
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
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 getter The getter function, or 0 if the value is unreadable.
|
||||||
* @param setter The setter function, or 0 if the value is unmodifiable.
|
* @param setter The setter function, or 0 if the value is unmodifiable.
|
||||||
*/
|
*/
|
||||||
template <typename T> void
|
template <typename T>
|
||||||
Tie (const std::string &name, int index, T (*getter)(int),
|
void
|
||||||
void (*setter)(int, T) = nullptr)
|
Tie(const std::string& name, int index, T (*getter)(int),
|
||||||
|
void (*setter)(int, T) = nullptr)
|
||||||
{
|
{
|
||||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||||
if (!property) {
|
if (!property) {
|
||||||
std::cerr << "Could not get or create property " << name << std::endl;
|
std::cerr << "Could not get or create property " << name << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!property->tie(SGRawValueFunctionsIndexed<T>(index, getter, setter),
|
if (!property->tie(SGRawValueFunctionsIndexed<T>(index, getter, setter),
|
||||||
false))
|
false))
|
||||||
std::cerr << "Failed to tie property " << name << " to indexed functions"
|
std::cerr << "Failed to tie property " << name << " to indexed functions"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else {
|
else {
|
||||||
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
||||||
tied_properties.push_back(property);
|
tied_properties.push_back(property);
|
||||||
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
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
|
* @param setter The object's setter method, or 0 if the value is
|
||||||
* unmodifiable.
|
* unmodifiable.
|
||||||
*/
|
*/
|
||||||
template <class T, class V> void
|
template <class T, class V>
|
||||||
Tie (const std::string &name, T * obj, V (T::*getter)() const,
|
void
|
||||||
void (T::*setter)(V) = nullptr)
|
Tie(const std::string& name, T* obj, V (T::*getter)() const,
|
||||||
|
void (T::*setter)(V) = nullptr)
|
||||||
{
|
{
|
||||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||||
if (!property) {
|
if (!property) {
|
||||||
std::cerr << "Could not get or create property " << name << std::endl;
|
std::cerr << "Could not get or create property " << name << std::endl;
|
||||||
return;
|
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::cerr << "Failed to tie property " << name << " to object methods"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else {
|
else {
|
||||||
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
||||||
tied_properties.push_back(property);
|
tied_properties.push_back(property);
|
||||||
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
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 getter The getter method, or 0 if the value is unreadable.
|
||||||
* @param setter The setter method, or 0 if the value is unmodifiable.
|
* @param setter The setter method, or 0 if the value is unmodifiable.
|
||||||
*/
|
*/
|
||||||
template <class T, class V> void
|
template <class T, class V>
|
||||||
Tie (const std::string &name, T * obj, int index, V (T::*getter)(int) const,
|
void
|
||||||
void (T::*setter)(int, V) = nullptr)
|
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);
|
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||||
if (!property) {
|
if (!property) {
|
||||||
std::cerr << "Could not get or create property " << name << std::endl;
|
std::cerr << "Could not get or create property " << name << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!property->tie(SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter),
|
if (!property->tie(SGRawValueMethodsIndexed<T, V>(*obj, index, getter, setter),
|
||||||
false))
|
false))
|
||||||
std::cerr << "Failed to tie property " << name
|
std::cerr << "Failed to tie property " << name
|
||||||
<< " to indexed object methods" << std::endl;
|
<< " to indexed object methods" << std::endl;
|
||||||
else {
|
else {
|
||||||
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
if (!setter) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
if (!getter) property->setAttribute(SGPropertyNode::READ, false);
|
||||||
tied_properties.push_back(property);
|
tied_properties.push_back(property);
|
||||||
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> simgear::PropertyObject<T>
|
template <class T>
|
||||||
CreatePropertyObject(const std::string &path)
|
simgear::PropertyObject<T>
|
||||||
{ return simgear::PropertyObject<T>(root->GetNode(path, true)); }
|
CreatePropertyObject(const std::string& path)
|
||||||
|
{
|
||||||
|
return simgear::PropertyObject<T>(root->GetNode(path, true));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SGPropertyNode_ptr> tied_properties;
|
std::vector<SGPropertyNode_ptr> tied_properties;
|
||||||
FGPropertyNode_ptr root;
|
FGPropertyNode_ptr root;
|
||||||
};
|
};
|
||||||
}
|
} // namespace JSBSim
|
||||||
#endif // FGPROPERTYMANAGER_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
|
SENTRY
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
#ifndef FGPARAMETERVALUE_H
|
#pragma once
|
||||||
#define FGPARAMETERVALUE_H
|
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
INCLUDES
|
INCLUDES
|
||||||
|
@ -36,9 +17,9 @@
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "math/FGRealValue.h"
|
|
||||||
#include "math/FGPropertyValue.h"
|
|
||||||
#include "input_output/FGXMLElement.h"
|
#include "input_output/FGXMLElement.h"
|
||||||
|
#include "math/FGPropertyValue.h"
|
||||||
|
#include "math/FGRealValue.h"
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
FORWARD DECLARATIONS
|
FORWARD DECLARATIONS
|
||||||
|
@ -63,54 +44,58 @@ class FGPropertyManager;
|
||||||
class FGParameterValue : public FGParameter
|
class FGParameterValue : public FGParameter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGParameterValue(Element* el, FGPropertyManager* pm) {
|
FGParameterValue(Element* el, FGPropertyManager* pm)
|
||||||
string value = el->GetDataLine();
|
{
|
||||||
|
std::string value = el->GetDataLine();
|
||||||
|
|
||||||
if (el->GetNumDataLines() != 1 || value.empty()) {
|
if (el->GetNumDataLines() != 1 || value.empty()) {
|
||||||
cerr << el->ReadFrom()
|
std::cerr << el->ReadFrom()
|
||||||
<< "The element <" << el->GetName()
|
<< "The element <" << el->GetName()
|
||||||
<< "> must either contain a value number or a property name."
|
<< "> must either contain a value number or a property name."
|
||||||
<< endl;
|
<< std::endl;
|
||||||
throw invalid_argument("FGParameterValue: Illegal argument defining: " + el->GetName());
|
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) {
|
double GetValue(void) const override { return param->GetValue(); }
|
||||||
Construct(value, pm);
|
bool IsConstant(void) const override { return param->IsConstant(); }
|
||||||
}
|
|
||||||
|
|
||||||
double GetValue(void) const override { return param->GetValue(); }
|
std::string GetName(void) const override
|
||||||
bool IsConstant(void) const override { return param->IsConstant(); }
|
{
|
||||||
|
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
|
||||||
|
if (v)
|
||||||
|
return v->GetNameWithSign();
|
||||||
|
else
|
||||||
|
return std::to_string(param->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetName(void) const override {
|
bool IsLateBound(void) const
|
||||||
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
|
{
|
||||||
if (v)
|
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
|
||||||
return v->GetNameWithSign();
|
return v != nullptr && v->IsLateBound();
|
||||||
else
|
}
|
||||||
return to_string(param->GetValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsLateBound(void) const {
|
|
||||||
FGPropertyValue* v = dynamic_cast<FGPropertyValue*>(param.ptr());
|
|
||||||
return v != nullptr && v->IsLateBound();
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
FGParameter_ptr param;
|
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()));
|
if (is_number(value)) {
|
||||||
} else {
|
param = new FGRealValue(atof(value.c_str()));
|
||||||
// "value" must be a property if execution passes to here.
|
} else {
|
||||||
param = new FGPropertyValue(value, pm);
|
// "value" must be a property if execution passes to here.
|
||||||
|
param = new FGPropertyValue(value, pm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SGSharedPtr<FGParameterValue> FGParameterValue_ptr;
|
typedef SGSharedPtr<FGParameterValue> FGParameterValue_ptr;
|
||||||
|
|
||||||
} // namespace JSBSim
|
} // namespace JSBSim
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -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
|
INCLUDES
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
|
@ -101,7 +82,7 @@ std::string FGPropertyValue::GetName(void) const
|
||||||
|
|
||||||
std::string FGPropertyValue::GetNameWithSign(void) const
|
std::string FGPropertyValue::GetNameWithSign(void) const
|
||||||
{
|
{
|
||||||
string name;
|
std::string name;
|
||||||
|
|
||||||
if (Sign < 0.0) name ="-";
|
if (Sign < 0.0) name ="-";
|
||||||
|
|
||||||
|
|
|
@ -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
|
HISTORY
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
09/13/00 JSB Created
|
09/13/00 JSB Created
|
||||||
|
@ -31,20 +13,19 @@ HISTORY
|
||||||
SENTRY
|
SENTRY
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
#ifndef FGAERODYNAMICS_H
|
#pragma once
|
||||||
#define FGAERODYNAMICS_H
|
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
INCLUDES
|
INCLUDES
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "FGModel.h"
|
#include "FGModel.h"
|
||||||
#include "math/FGFunction.h"
|
|
||||||
#include "math/FGColumnVector3.h"
|
#include "math/FGColumnVector3.h"
|
||||||
|
#include "math/FGFunction.h"
|
||||||
#include "math/FGMatrix33.h"
|
#include "math/FGMatrix33.h"
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
@ -112,181 +93,184 @@ CLASS DECLARATION
|
||||||
|
|
||||||
class FGAerodynamics : public FGModel
|
class FGAerodynamics : public FGModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
@param Executive a pointer to the parent executive object */
|
@param Executive a pointer to the parent executive object */
|
||||||
FGAerodynamics(FGFDMExec* Executive);
|
FGAerodynamics(FGFDMExec* Executive);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~FGAerodynamics() override;
|
~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.
|
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
|
@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
|
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
|
model, which may need to be active to listen on a socket for the
|
||||||
"Resume" command to be given.
|
"Resume" command to be given.
|
||||||
@return false if no error */
|
@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
|
The Load function for this class expects the XML parser to
|
||||||
have found the aerodynamics keyword in the configuration file.
|
have found the aerodynamics keyword in the configuration file.
|
||||||
@param element pointer to the current XML element for aerodynamics parameters.
|
@param element pointer to the current XML element for aerodynamics parameters.
|
||||||
@return true if successful */
|
@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. */
|
@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
|
@param n Axis index. This could be 0, 1, or 2, or one of the
|
||||||
axis enums: eX, eY, eZ.
|
axis enums: eX, eY, eZ.
|
||||||
@return the force acting on an axis */
|
@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. */
|
@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
|
@return the moment about a single axis (as described also in the
|
||||||
similar call to GetForces(int n).*/
|
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. */
|
@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
|
@return the moment about a single axis (as described also in the
|
||||||
similar call to GetForces(int n).*/
|
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. */
|
@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).
|
@param axis the axis to return the force for (eX, eY, eZ).
|
||||||
@return a reference to a column vector containing the requested wind
|
@return a reference to a column vector containing the requested wind
|
||||||
axis force. */
|
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. */
|
@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).
|
@param axis the axis to return the force for (eX, eY, eZ).
|
||||||
@return a reference to a column vector containing the requested stability
|
@return a reference to a column vector containing the requested stability
|
||||||
axis force. */
|
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. */
|
@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
|
@return the moment about a single axis (as described also in the
|
||||||
similar call to GetForces(int n).*/
|
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. */
|
@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
|
@return the moment about a single axis (as described also in the
|
||||||
similar call to GetForces(int n).*/
|
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 */
|
/** Retrieves the lift over drag ratio */
|
||||||
double GetLoD(void) const { return lod; }
|
double GetLoD(void) const { return lod; }
|
||||||
|
|
||||||
/** Retrieves the square of the lift coefficient. */
|
/** Retrieves the square of the lift coefficient. */
|
||||||
double GetClSquared(void) const { return clsq; }
|
double GetClSquared(void) const { return clsq; }
|
||||||
double GetAlphaCLMax(void) const { return alphaclmax; }
|
double GetAlphaCLMax(void) const { return alphaclmax; }
|
||||||
double GetAlphaCLMin(void) const { return alphaclmin; }
|
double GetAlphaCLMin(void) const { return alphaclmin; }
|
||||||
|
|
||||||
double GetHysteresisParm(void) const { return stall_hyst; }
|
double GetHysteresisParm(void) const { return stall_hyst; }
|
||||||
double GetStallWarn(void) const { return impending_stall; }
|
double GetStallWarn(void) const { return impending_stall; }
|
||||||
double GetAlphaW(void) const { return alphaw; }
|
double GetAlphaW(void) const { return alphaw; }
|
||||||
|
|
||||||
double GetBI2Vel(void) const { return bi2vel; }
|
double GetBI2Vel(void) const { return bi2vel; }
|
||||||
double GetCI2Vel(void) const { return ci2vel; }
|
double GetCI2Vel(void) const { return ci2vel; }
|
||||||
|
|
||||||
void SetAlphaCLMax(double tt) { alphaclmax=tt; }
|
void SetAlphaCLMax(double tt) { alphaclmax = tt; }
|
||||||
void SetAlphaCLMin(double tt) { alphaclmin=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
|
@param delimeter either a tab or comma string depending on output type
|
||||||
@return a string containing the descriptive names for all aero functions */
|
@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
|
@param delimeter either a tab or comma string depending on output type
|
||||||
@return a string containing the numeric values for the current set of
|
@return a string containing the numeric values for the current set of
|
||||||
aero functions */
|
aero functions */
|
||||||
std::string GetAeroFunctionValues(const std::string& delimeter) const;
|
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 {
|
struct Inputs {
|
||||||
double Alpha;
|
double Alpha;
|
||||||
double Beta;
|
double Beta;
|
||||||
double Vt;
|
double Vt;
|
||||||
double Qbar;
|
double Qbar;
|
||||||
double Wingarea;
|
double Wingarea;
|
||||||
double Wingspan;
|
double Wingspan;
|
||||||
double Wingchord;
|
double Wingchord;
|
||||||
double Wingincidence;
|
double Wingincidence;
|
||||||
FGColumnVector3 RPBody;
|
FGColumnVector3 RPBody;
|
||||||
FGMatrix33 Tb2w;
|
FGMatrix33 Tb2w;
|
||||||
FGMatrix33 Tw2b;
|
FGMatrix33 Tw2b;
|
||||||
} in;
|
} in;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum eAxisType {atNone, atWind, atBodyAxialNormal, atBodyXYZ, atStability} forceAxisType, momentAxisType;
|
enum eAxisType { atNone,
|
||||||
typedef std::map<std::string,int> AxisIndex;
|
atWind,
|
||||||
AxisIndex AxisIdx;
|
atBodyAxialNormal,
|
||||||
FGFunction* AeroRPShift;
|
atBodyXYZ,
|
||||||
typedef std::vector <FGFunction*> AeroFunctionArray;
|
atStability } forceAxisType,
|
||||||
AeroFunctionArray* AeroFunctions;
|
momentAxisType;
|
||||||
FGMatrix33 Ts2b, Tb2s;
|
typedef std::map<std::string, int> AxisIndex;
|
||||||
FGColumnVector3 vFnative;
|
AxisIndex AxisIdx;
|
||||||
FGColumnVector3 vFw;
|
FGFunction* AeroRPShift;
|
||||||
FGColumnVector3 vForces;
|
typedef std::vector<FGFunction*> AeroFunctionArray;
|
||||||
AeroFunctionArray* AeroFunctionsAtCG;
|
AeroFunctionArray* AeroFunctions;
|
||||||
FGColumnVector3 vFnativeAtCG;
|
FGMatrix33 Ts2b, Tb2s;
|
||||||
FGColumnVector3 vForcesAtCG;
|
FGColumnVector3 vFnative;
|
||||||
FGColumnVector3 vMoments;
|
FGColumnVector3 vFw;
|
||||||
FGColumnVector3 vMomentsMRC;
|
FGColumnVector3 vForces;
|
||||||
FGColumnVector3 vMomentsMRCBodyXYZ;
|
AeroFunctionArray* AeroFunctionsAtCG;
|
||||||
FGColumnVector3 vDXYZcg;
|
FGColumnVector3 vFnativeAtCG;
|
||||||
FGColumnVector3 vDeltaRP;
|
FGColumnVector3 vForcesAtCG;
|
||||||
double alphaclmax, alphaclmin;
|
FGColumnVector3 vMoments;
|
||||||
double alphaclmax0, alphaclmin0;
|
FGColumnVector3 vMomentsMRC;
|
||||||
double alphahystmax, alphahystmin;
|
FGColumnVector3 vMomentsMRCBodyXYZ;
|
||||||
double impending_stall, stall_hyst;
|
FGColumnVector3 vDXYZcg;
|
||||||
double bi2vel, ci2vel,alphaw;
|
FGColumnVector3 vDeltaRP;
|
||||||
double clsq, lod, qbar_area;
|
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;
|
typedef double (FGAerodynamics::*PMF)(int) const;
|
||||||
void DetermineAxisSystem(Element* document);
|
void DetermineAxisSystem(Element* document);
|
||||||
void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType,
|
void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType,
|
||||||
const string& name, const string& frame,
|
const std::string& name, const std::string& frame,
|
||||||
Element* el, const string& validNames);
|
Element* el, const std::string& validNames);
|
||||||
void bind(void);
|
void bind(void);
|
||||||
void BuildStabilityTransformMatrices(void);
|
void BuildStabilityTransformMatrices(void);
|
||||||
|
|
||||||
void Debug(int from) override;
|
void Debug(int from) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace JSBSim
|
} // namespace JSBSim
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
#endif
|
|
||||||
|
|
|
@ -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
|
HISTORY
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
03/11/2003 DPC Created, based on FGTurbine
|
03/11/2003 DPC Created, based on FGTurbine
|
||||||
|
@ -33,8 +15,7 @@ HISTORY
|
||||||
SENTRY
|
SENTRY
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
#ifndef FGTURBINE_H
|
#pragma once
|
||||||
#define FGTURBINE_H
|
|
||||||
|
|
||||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
INCLUDES
|
INCLUDES
|
||||||
|
@ -173,172 +154,178 @@ CLASS DECLARATION
|
||||||
class FGTurbine : public FGEngine
|
class FGTurbine : public FGEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
@param Executive pointer to executive structure
|
@param Executive pointer to executive structure
|
||||||
@param el pointer to the XML element representing the turbine engine
|
@param el pointer to the XML element representing the turbine engine
|
||||||
@param engine_number engine number */
|
@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
|
/// Destructor
|
||||||
~FGTurbine();
|
~FGTurbine();
|
||||||
|
|
||||||
enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
|
enum phaseType { tpOff,
|
||||||
|
tpRun,
|
||||||
|
tpSpinUp,
|
||||||
|
tpStart,
|
||||||
|
tpStall,
|
||||||
|
tpSeize,
|
||||||
|
tpTrim };
|
||||||
|
|
||||||
void Calculate(void);
|
void Calculate(void);
|
||||||
double CalcFuelNeed(void);
|
double CalcFuelNeed(void);
|
||||||
double GetPowerAvailable(void);
|
double GetPowerAvailable(void);
|
||||||
/** A lag filter.
|
/** A lag filter.
|
||||||
Used to control the rate at which values are allowed to change.
|
Used to control the rate at which values are allowed to change.
|
||||||
@param var a pointer to a variable of type double
|
@param var a pointer to a variable of type double
|
||||||
@param target the desired (target) value
|
@param target the desired (target) value
|
||||||
@param accel the rate, per second, the value may increase
|
@param accel the rate, per second, the value may increase
|
||||||
@param decel the rate, per second, the value may decrease */
|
@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 GetOvertemp(void) const { return Overtemp; }
|
||||||
bool GetInjection(void) const {return Injection;}
|
bool GetInjection(void) const { return Injection; }
|
||||||
bool GetFire(void) const { return Fire; }
|
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 GetReversed(void) const { return Reversed; }
|
||||||
bool GetCutoff(void) const { return Cutoff; }
|
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 GetInlet(void) const { return InletPosition; }
|
||||||
double GetNozzle(void) const { return NozzlePosition; }
|
double GetNozzle(void) const { return NozzlePosition; }
|
||||||
double GetBleedDemand(void) const {return BleedDemand;}
|
double GetBleedDemand(void) const { return BleedDemand; }
|
||||||
double GetN1(void) const {return N1;}
|
double GetN1(void) const { return N1; }
|
||||||
double GetN2(void) const {return N2;}
|
double GetN2(void) const { return N2; }
|
||||||
double GetEPR(void) const {return EPR;}
|
double GetEPR(void) const { return EPR; }
|
||||||
double GetEGT(void) const {return EGT_degC;}
|
double GetEGT(void) const { return EGT_degC; }
|
||||||
|
|
||||||
double GetMaxN1(void) const {return MaxN1;}
|
double GetMaxN1(void) const { return MaxN1; }
|
||||||
double GetMaxN2(void) const {return MaxN2;}
|
double GetMaxN2(void) const { return MaxN2; }
|
||||||
double getOilPressure_psi () const {return OilPressure_psi;}
|
double getOilPressure_psi() const { return OilPressure_psi; }
|
||||||
double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
|
double getOilTemp_degF(void) { return KelvinToFahrenheit(OilTemp_degK); }
|
||||||
double GetInjectionTimer(void) const {return InjectionTimer;}
|
double GetInjectionTimer(void) const { return InjectionTimer; }
|
||||||
double GetInjWaterNorm(void) const {return InjWaterNorm;}
|
double GetInjWaterNorm(void) const { return InjWaterNorm; }
|
||||||
double GetInjN1increment(void) const {return InjN1increment;}
|
double GetInjN1increment(void) const { return InjN1increment; }
|
||||||
double GetInjN2increment(void) const {return InjN2increment;}
|
double GetInjN2increment(void) const { return InjN2increment; }
|
||||||
|
|
||||||
void SetInjection(bool injection) {Injection = injection;}
|
void SetInjection(bool injection) { Injection = injection; }
|
||||||
void SetIgnition(int ignition) {Ignition = ignition;}
|
void SetIgnition(int ignition) { Ignition = ignition; }
|
||||||
void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
|
void SetAugmentation(bool augmentation) { Augmentation = augmentation; }
|
||||||
void SetPhase( phaseType p ) { phase = p; }
|
void SetPhase(phaseType p) { phase = p; }
|
||||||
void SetEPR(double epr) {EPR = epr;}
|
void SetEPR(double epr) { EPR = epr; }
|
||||||
void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
|
void SetBleedDemand(double bleedDemand) { BleedDemand = bleedDemand; }
|
||||||
void SetReverse(bool reversed) { Reversed = reversed; }
|
void SetReverse(bool reversed) { Reversed = reversed; }
|
||||||
void SetCutoff(bool cutoff) { Cutoff = cutoff; }
|
void SetCutoff(bool cutoff) { Cutoff = cutoff; }
|
||||||
void SetMaxN1(double maxn1) {MaxN1 = maxn1;}
|
void SetMaxN1(double maxn1) { MaxN1 = maxn1; }
|
||||||
void SetMaxN2(double maxn2) {MaxN2 = maxn2;}
|
void SetMaxN2(double maxn2) { MaxN2 = maxn2; }
|
||||||
void SetInjectionTimer(double injtimer) {InjectionTimer = injtimer;}
|
void SetInjectionTimer(double injtimer) { InjectionTimer = injtimer; }
|
||||||
void SetInjWaterNorm(double injwater) {InjWaterNorm = injwater;}
|
void SetInjWaterNorm(double injwater) { InjWaterNorm = injwater; }
|
||||||
void SetInjN1increment(double injN1inc) {InjN1increment = injN1inc;}
|
void SetInjN1increment(double injN1inc) { InjN1increment = injN1inc; }
|
||||||
void SetInjN2increment(double injN2inc) {InjN2increment = injN2inc;}
|
void SetInjN2increment(double injN2inc) { InjN2increment = injN2inc; }
|
||||||
|
|
||||||
int InitRunning(void);
|
int InitRunning(void);
|
||||||
void ResetToIC(void);
|
void ResetToIC(void);
|
||||||
|
|
||||||
std::string GetEngineLabels(const std::string& delimiter);
|
std::string GetEngineLabels(const std::string& delimiter);
|
||||||
std::string GetEngineValues(const std::string& delimiter);
|
std::string GetEngineValues(const std::string& delimiter);
|
||||||
|
|
||||||
private:
|
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 Off(void);
|
||||||
double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
|
double Run();
|
||||||
double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf)
|
double SpinUp(void);
|
||||||
double BypassRatio; ///< Bypass Ratio
|
double Start(void);
|
||||||
double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf)
|
double Stall(void);
|
||||||
double ATSFC; ///< Augmented TSFC (lbm/hr/lbf)
|
double Seize(void);
|
||||||
double IdleN1; ///< Idle N1
|
double Trim();
|
||||||
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);
|
FGFunction* IdleThrustLookup;
|
||||||
double Run();
|
FGFunction* MilThrustLookup;
|
||||||
double SpinUp(void);
|
FGFunction* MaxThrustLookup;
|
||||||
double Start(void);
|
FGFunction* InjectionLookup;
|
||||||
double Stall(void);
|
FGFDMExec* FDMExec;
|
||||||
double Seize(void);
|
FGParameter* N1SpoolUp;
|
||||||
double Trim();
|
FGParameter* N1SpoolDown;
|
||||||
|
FGParameter* N2SpoolUp;
|
||||||
|
FGParameter* N2SpoolDown;
|
||||||
|
|
||||||
FGFunction *IdleThrustLookup;
|
bool Load(FGFDMExec* exec, Element* el);
|
||||||
FGFunction *MilThrustLookup;
|
void bindmodel(FGPropertyManager* pm);
|
||||||
FGFunction *MaxThrustLookup;
|
void Debug(int from);
|
||||||
FGFunction *InjectionLookup;
|
|
||||||
FGFDMExec* FDMExec;
|
|
||||||
FGParameter *N1SpoolUp;
|
|
||||||
FGParameter *N1SpoolDown;
|
|
||||||
FGParameter *N2SpoolUp;
|
|
||||||
FGParameter *N2SpoolDown;
|
|
||||||
|
|
||||||
bool Load(FGFDMExec *exec, Element *el);
|
friend class FGSpoolUp;
|
||||||
void bindmodel(FGPropertyManager* pm);
|
|
||||||
void Debug(int from);
|
|
||||||
|
|
||||||
friend class FGSpoolUp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FGSpoolUp : public FGParameter
|
class FGSpoolUp : public FGParameter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGSpoolUp(FGTurbine* _turb, double BPR, double factor)
|
FGSpoolUp(FGTurbine* _turb, double BPR, double factor)
|
||||||
: turb(_turb), delay(factor * 90.0 / (BPR + 3.0)) {}
|
: turb(_turb), delay(factor * 90.0 / (BPR + 3.0)) {}
|
||||||
string GetName(void) const { return string(); };
|
std::string GetName(void) const { return std::string(); };
|
||||||
double GetValue(void) const {
|
double GetValue(void) const
|
||||||
// adjust acceleration for N2 and atmospheric density
|
{
|
||||||
double n = std::min(1.0, turb->N2norm + 0.1);
|
// adjust acceleration for N2 and atmospheric density
|
||||||
return delay / (1 + 3 * (1-n)*(1-n)*(1-n) + (1 - turb->in.DensityRatio));
|
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:
|
private:
|
||||||
FGTurbine* turb;
|
FGTurbine* turb;
|
||||||
double delay; ///< Inverse spool-up time from idle to 100% (seconds)
|
double delay; ///< Inverse spool-up time from idle to 100% (seconds)
|
||||||
};
|
};
|
||||||
}
|
} // namespace JSBSim
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
#endif
|
|
||||||
|
|
|
@ -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
|
STATUS: alpha version
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
@ -68,24 +66,6 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
CALLS TO: none
|
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
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -103,10 +83,10 @@ using std::endl; // -dw
|
||||||
void uiuc_recorder( double dt )
|
void uiuc_recorder( double dt )
|
||||||
{
|
{
|
||||||
::stack command_list;
|
::stack command_list;
|
||||||
string linetoken;
|
std::string linetoken;
|
||||||
// static int init = 0;
|
// static int init = 0;
|
||||||
static int recordStep = 0;
|
static int recordStep = 0;
|
||||||
string record_variables = "# ";
|
std::string record_variables = "# ";
|
||||||
|
|
||||||
// int modulus = recordStep % recordRate;
|
// int modulus = recordStep % recordRate;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue