1
0
Fork 0
This commit is contained in:
Torsten Dreyer 2011-02-06 15:44:30 +01:00
commit 49dda9bfb6
22 changed files with 95 additions and 166 deletions

View file

@ -59,8 +59,8 @@ FGAIBase::FGAIBase(object_type ot) :
props( NULL ),
model_removed( fgGetNode("/ai/models/model-removed", true) ),
manager( NULL ),
fp( NULL ),
_installed(false),
fp( NULL ),
_impact_lat(0),
_impact_lon(0),
_impact_elev(0),

View file

@ -375,7 +375,7 @@ void FGAIWingman::Break(double dt) {
void FGAIWingman::Join(double dt) {
double range, bearing, az2;
double parent_hdg, parent_spd, parent_ht= 0;
double parent_hdg, parent_spd = 0;
double p_hdg, p_pch, p_rll = 0;
setTgtOffsets(dt, 25);
@ -425,7 +425,7 @@ void FGAIWingman::Join(double dt) {
double rel_brg = calcRelBearingDeg(bearing, hdg);
double recip_brg = calcRecipBearingDeg(bearing);
double angle = calcAngle(distance,_offsetpos, pos);
double approx_angle = atan2(daltM, range);
//double approx_angle = atan2(daltM, range);
double frm_spd = 50; // formation speed
double join_rnge = 1000.0;
double recip_parent_hdg = calcRecipBearingDeg(parent_hdg);

View file

@ -25,7 +25,7 @@
#include <simgear/compiler.h>
#include <cmath>
#include "tiedpropertylist.hxx"
#include <simgear/props/tiedpropertylist.hxx>
/**
* Model the natural environment.
@ -146,7 +146,7 @@ private:
double wind_from_down_fps;
bool live_update;
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};

View file

@ -123,7 +123,7 @@ private:
LayerTable _aloft_table;
FGEnvironment _environment;
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};
//////////////////////////////////////////////////////////////////////////////

View file

@ -25,7 +25,7 @@
#include <simgear/compiler.h>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/SGMath.hxx>
#include "tiedpropertylist.hxx"
#include <simgear/props/tiedpropertylist.hxx>
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
@ -96,7 +96,7 @@ private:
FGClouds *fgClouds;
SGPropertyNode_ptr _altitudeNode;
bool _cloudLayersDirty;
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};
#endif // _ENVIRONMENT_MGR_HXX

View file

@ -24,7 +24,6 @@
#include <Airports/simple.hxx>
#include <simgear/props/props.hxx>
#include "tiedpropertylist.hxx"
namespace Environment {

View file

@ -25,7 +25,7 @@
#include <Airports/simple.hxx>
#include <simgear/props/props.hxx>
#include "tiedpropertylist.hxx"
#include <simgear/props/tiedpropertylist.hxx>
namespace Environment {
@ -89,7 +89,7 @@ private:
bool _snow_cover;
std::string _decoded;
protected:
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
MagneticVariation * _magneticVariation;
};

View file

@ -25,7 +25,6 @@
#endif
#include "realwx_ctrl.hxx"
#include "tiedpropertylist.hxx"
#include "metarproperties.hxx"
#include "metarairportfilter.hxx"
#include "fgmetar.hxx"
@ -34,6 +33,7 @@
#include <simgear/structure/exception.hxx>
#include <simgear/misc/strutils.hxx>
#include <simgear/props/tiedpropertylist.hxx>
#include <algorithm>
#if defined(ENABLE_THREADS)
#include <OpenThreads/Thread>
@ -105,7 +105,7 @@ protected:
bool _enabled;
bool __enabled;
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
; typedef std::vector<LiveMetarProperties_ptr> MetarPropertiesList;
MetarPropertiesList _metarProperties;
};

View file

@ -32,7 +32,7 @@
#include "terrainsampler.hxx"
using simgear::PropertyList;
#include "tiedpropertylist.hxx"
#include <simgear/props/tiedpropertylist.hxx>
namespace Environment {
/**
@ -93,7 +93,7 @@ private:
SGPropertyNode_ptr _positionLongitudeNode;
deque<double> _elevations;
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};
AreaSampler::AreaSampler( SGPropertyNode_ptr rootNode ) :
@ -329,7 +329,7 @@ private:
SGPropertyNode_ptr _rootNode;
bool _enabled;
TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};
TerrainSamplerImplementation::TerrainSamplerImplementation( SGPropertyNode_ptr rootNode ) :

View file

@ -1,80 +0,0 @@
#ifndef __TIEDPROPERTYLIST_HXX
#define __TIEDPROPERTYLIST_HXX
#include <simgear/props/props.hxx>
using simgear::PropertyList;
// Maybe this goes into SimGear's props.hxx later?
class TiedPropertyList : PropertyList {
public:
TiedPropertyList() {}
TiedPropertyList( SGPropertyNode_ptr root ) : _root(root) {}
void setRoot( SGPropertyNode_ptr root ) { _root = root; }
SGPropertyNode_ptr getRoot() const { return _root; }
template<typename T> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, const SGRawValue<T> &rawValue, bool useDefault = true ) {
bool success = node->tie( rawValue, useDefault );
if( success ) {
SG_LOG( SG_ALL, SG_INFO, "Tied " << node->getPath() );
push_back( node );
} else {
#if PROPS_STANDALONE
cerr << "Failed to tie property " << node->getPath() << endl;
#else
SG_LOG(SG_GENERAL, SG_WARN, "Failed to tie property " << node->getPath() );
#endif
}
return node;
}
template <class V> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, V * value, bool useDefault = true ) {
return Tie( node, SGRawValuePointer<V>(value), useDefault );
}
template <class V> SGPropertyNode_ptr Tie( const char * relative_path, V * value, bool useDefault = true ) {
return Tie( _root->getNode(relative_path,true), SGRawValuePointer<V>(value), useDefault );
}
template <class V> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, V (*getter)(), void (*setter)(V) = 0, bool useDefault = true ) {
return Tie(node, SGRawValueFunctions<V>(getter, setter), useDefault );
}
template <class V> SGPropertyNode_ptr Tie( const char * relative_path, V (*getter)(), void (*setter)(V) = 0, bool useDefault = true ) {
return Tie(_root->getNode(relative_path, true), SGRawValueFunctions<V>(getter, setter), useDefault );
}
template <class V> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, int index, V (*getter)(int), void (*setter)(int, V) = 0, bool useDefault = true) {
return Tie( node, SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault );
}
template <class V> SGPropertyNode_ptr Tie( const char * relative_path, int index, V (*getter)(int), void (*setter)(int, V) = 0, bool useDefault = true) {
return Tie( _root->getNode( relative_path, true ), SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault );
}
template <class T, class V> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, T * obj, V (T::*getter)() const, void (T::*setter)(V) = 0, bool useDefault = true) {
return Tie( node, SGRawValueMethods<T,V>(*obj, getter, setter), useDefault );
}
template <class T, class V> SGPropertyNode_ptr Tie( const char * relative_path, T * obj, V (T::*getter)() const, void (T::*setter)(V) = 0, bool useDefault = true) {
return Tie( _root->getNode( relative_path, true), SGRawValueMethods<T,V>(*obj, getter, setter), useDefault );
}
template <class T, class V> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, T * obj, int index, V (T::*getter)(int) const, void (T::*setter)(int, V) = 0, bool useDefault = true) {
return Tie( node, SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault);
}
template <class T, class V> SGPropertyNode_ptr Tie( const char * relative_path, T * obj, int index, V (T::*getter)(int) const, void (T::*setter)(int, V) = 0, bool useDefault = true) {
return Tie( _root->getNode( relative_path, true ), SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault);
}
void Untie() {
while( size() > 0 ) {
SG_LOG( SG_ALL, SG_INFO, "untie of " << back()->getPath() );
back()->untie();
pop_back();
}
}
private:
SGPropertyNode_ptr _root;
};
#endif

View file

@ -78,22 +78,6 @@ static const char *IdHdr = ID_FDMEXEC;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
void checkTied ( FGPropertyManager *node )
{
int N = node->nChildren();
string name;
for (int i=0; i<N; i++) {
if (node->getChild(i)->nChildren() ) {
checkTied( (FGPropertyManager*)node->getChild(i) );
}
if ( node->getChild(i)->isTied() ) {
name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
node->Untie(name);
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Constructor
@ -185,7 +169,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
FGFDMExec::~FGFDMExec()
{
try {
checkTied( instance );
Unbind();
DeAllocate();
if (IdFDM == 0) { // Meaning this is no child FDM

View file

@ -101,8 +101,8 @@ CLASS DOCUMENTATION
file:
@code
fdmex = new FGFDMExec( );
result = fdmex->LoadModel( );
fdmex = new FGFDMExec( ... );
result = fdmex->LoadModel( ... );
@endcode
When an aircraft model is loaded, the config file is parsed and for each of the
@ -226,6 +226,9 @@ public:
/// Default destructor
~FGFDMExec();
/** Unbind all tied JSBSim properties. */
void Unbind(void) {instance->Unbind();}
/** This routine places a model into the runlist at the specified rate. The
"rate" is not really a clock rate. It represents how many calls to the
FGFDMExec::Run() method must be made before the model is executed. A

View file

@ -422,28 +422,9 @@ void FGJSBsim::init()
/******************************************************************************/
void checkTied ( FGPropertyManager *node )
{
int N = node->nChildren();
string name;
for (int i=0; i<N; i++) {
if (node->getChild(i)->nChildren() ) {
checkTied( (FGPropertyManager*)node->getChild(i) );
}
if ( node->getChild(i)->isTied() ) {
name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
node->Untie(name);
}
}
}
/******************************************************************************/
void FGJSBsim::unbind()
{
SGPropertyNode* instance = globals->get_props()->getNode("/fdm/jsbsim");
checkTied((FGPropertyManager*)instance);
fdmex->Unbind();
FGInterface::unbind();
}

View file

@ -49,6 +49,19 @@ COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
namespace JSBSim {
bool FGPropertyManager::suppress_warning = true;
std::vector<std::string> FGPropertyManager::tied_properties;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropertyManager::Unbind(void)
{
vector<string>::iterator it;
for (it = tied_properties.begin();it < tied_properties.end();it++)
{
Untie(*it);
}
tied_properties.clear();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -303,8 +316,10 @@ void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
{
if (!tie(name.c_str(), SGRawValuePointer<bool>(pointer), useDefault))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
else if (debug_lvl & 0x20)
cout << name << endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -314,8 +329,10 @@ void FGPropertyManager::Tie (const string &name, int *pointer,
{
if (!tie(name.c_str(), SGRawValuePointer<int>(pointer), useDefault))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
else if (debug_lvl & 0x20)
cout << name << endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -325,8 +342,10 @@ void FGPropertyManager::Tie (const string &name, long *pointer,
{
if (!tie(name.c_str(), SGRawValuePointer<long>(pointer), useDefault))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
else if (debug_lvl & 0x20)
cout << name << endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -336,8 +355,10 @@ void FGPropertyManager::Tie (const string &name, float *pointer,
{
if (!tie(name.c_str(), SGRawValuePointer<float>(pointer), useDefault))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
else if (debug_lvl & 0x20)
cout << name << endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -346,8 +367,10 @@ void FGPropertyManager::Tie (const string &name, double *pointer, bool useDefaul
{
if (!tie(name.c_str(), SGRawValuePointer<double>(pointer), useDefault))
cerr << "Failed to tie property " << name << " to a pointer" << endl;
else if (debug_lvl & 0x20)
cout << name << endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
} // namespace JSBSim

View file

@ -77,6 +77,7 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
{
private:
static bool suppress_warning;
static std::vector<std::string> tied_properties;
public:
/// Constructor
FGPropertyManager(void) {suppress_warning = false;}
@ -399,6 +400,13 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
*/
void Untie (const std::string &name);
/**
* Unbind all properties bound by this manager to an external data source.
*
* Classes should use this function to release control of any
* properties they have bound using this property manager.
*/
void Unbind (void);
// Templates cause ambiguity here
@ -526,8 +534,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
{
if (!tie(name.c_str(), SGRawValueFunctions<V>(getter, setter), useDefault))
std::cout << "Failed to tie property " << name << " to functions" << std::endl;
else if (debug_lvl & 0x20)
std::cout << name << std::endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
@ -554,8 +564,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
{
if (!tie(name.c_str(), SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault))
std::cout << "Failed to tie property " << name << " to indexed functions" << std::endl;
else if (debug_lvl & 0x20)
std::cout << name << std::endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
@ -584,8 +596,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
{
if (!tie(name.c_str(), SGRawValueMethods<T,V>(*obj, getter, setter), useDefault))
std::cout << "Failed to tie property " << name << " to object methods" << std::endl;
else if (debug_lvl & 0x20)
std::cout << name << std::endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
/**
@ -613,8 +627,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
{
if (!tie(name.c_str(), SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault))
std::cout << "Failed to tie property " << name << " to indexed object methods" << std::endl;
else if (debug_lvl & 0x20)
std::cout << name << std::endl;
else {
tied_properties.push_back(name);
if (debug_lvl & 0x20) std::cout << name << std::endl;
}
}
};
}

View file

@ -332,8 +332,10 @@ void Gear::calcForce(RigidBody* body, State *s, float* v, float* rot)
float b = ground[3] - Math::dot3(tmp, ground)+BumpAltitude;
// Calculate the point of ground _contact.
_frac = a/(a-b);
if(b < 0) _frac = 1;
if(b < 0)
_frac = 1;
else
_frac = a/(a-b);
for(i=0; i<3; i++)
_contact[i] = _pos[i] + _frac*_cmpr[i];

View file

@ -99,7 +99,7 @@ void Rotorpart::inititeration(float dt,float *rot)
float b;
b=_rotor->getBalance();
float s =Math::sin(_phi+_direction);
float c =Math::cos(_phi+_direction);
//float c =Math::cos(_phi+_direction);
if (s>0)
_balance=(b>0)?(1.-s*(1.-b)):(1.-s)*(1.+b);
else
@ -548,7 +548,7 @@ void Rotorpart::calcForce(float* v, float rho, float* out, float* torque,
float dirblade[3];
Math::cross3(_normal,_directionofcentripetalforce,dirblade);
float vblade=Math::abs(Math::dot3(dirblade,v));
//float vblade=Math::abs(Math::dot3(dirblade,v));
alpha=_alphaalt+(alpha-_alphaalt)*factor;
_alpha=alpha;

View file

@ -654,7 +654,7 @@ string DCLGPS::ExpandSIAPIdent(const string& ident) {
Col 107-111 MSA center fix. We can ignore this.
*/
void DCLGPS::LoadApproachData() {
FGNPIAP* iap;
FGNPIAP* iap = NULL;
GPSWaypoint* wp;
GPSFlightPlan* fp;
const GPSWaypoint* cwp;

View file

@ -125,7 +125,6 @@ HeadingIndicatorDG::update (double dt)
double yaw_rate = _yaw_rate_node->getDoubleValue();
double error = _error_node->getDoubleValue();
double g = _g_node->getDoubleValue();
int sign = 0;
if ( fabs ( yaw_rate ) > 5 ) {
error += 0.033 * -yaw_rate * dt ;

View file

@ -342,6 +342,9 @@ public:
case RESTRICT_NONE:
assert(false);
break;
case SPEED_RESTRICT_MACH:
assert(false);
break;
}
}

View file

@ -70,10 +70,6 @@ FGModelMgr::add_model (SGPropertyNode * node)
{
SG_LOG(SG_GENERAL, SG_INFO,
"Adding model " << node->getStringValue("name", "[unnamed]"));
Instance * instance = new Instance;
SGModelPlacement *model = new SGModelPlacement;
instance->model = model;
instance->node = node;
const char *path = node->getStringValue("path", "Models/Geometry/glider.ac");
osg::Node *object;
@ -83,9 +79,13 @@ FGModelMgr::add_model (SGPropertyNode * node)
} catch (const sg_throwable& t) {
SG_LOG(SG_GENERAL, SG_ALERT, "Error loading " << path << ":\n "
<< t.getFormattedMessage() << t.getOrigin());
delete instance;
return;
}
Instance * instance = new Instance;
SGModelPlacement *model = new SGModelPlacement;
instance->model = model;
instance->node = node;
model->init( object );

View file

@ -53,13 +53,12 @@ void fgSunPositionGST(double gst, double *lon, double *lat) {
/* double *lat; (return) latitude */
/* double *lon; (return) longitude */
double alpha, delta;
double tmp;
SGPropertyNode* sun = fgGetNode("/ephemeris/sun");
assert(sun);
double xs = sun->getDoubleValue("xs");
double ys = sun->getDoubleValue("ys");
//double ys = sun->getDoubleValue("ys");
double ye = sun->getDoubleValue("ye");
double ze = sun->getDoubleValue("ze");
double ra = atan2(ye, xs);