From: Bertrand <bco...@us...> - 2017-03-11 19:31:51
|
Update of /cvsroot/jsbsim/JSBSim/src/math In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20592/src/math Modified Files: FGFunction.cpp FGFunction.h FGTable.cpp FGTable.h Log Message: Fixed the bug [#96] Table Independent Variables Not Indexed Index: FGFunction.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/math/FGFunction.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -r1.58 -r1.59 *** FGFunction.cpp 12 Jul 2015 19:34:08 -0000 1.58 --- FGFunction.cpp 11 Mar 2017 19:31:47 -0000 1.59 *************** *** 267,271 **** Parameters.push_back(new FGRealValue(element->GetDataAsNumber())); } else if (operation == table_string || operation == t_string) { ! Parameters.push_back(new FGTable(PropertyManager, element)); // operations } else if (operation == product_string || --- 267,271 ---- Parameters.push_back(new FGRealValue(element->GetDataAsNumber())); } else if (operation == table_string || operation == t_string) { ! Parameters.push_back(new FGTable(PropertyManager, element, Prefix)); // operations } else if (operation == product_string || *************** *** 324,328 **** } ! bind(); // Allow any function to save its value Debug(0); --- 324,328 ---- } ! bind(el); // Allow any function to save its value Debug(0); *************** *** 785,789 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! void FGFunction::bind(void) { if ( !Name.empty() ) { --- 785,789 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! void FGFunction::bind(Element* el) { if ( !Name.empty() ) { *************** *** 797,803 **** tmp = PropertyManager->mkPropertyName(Name, false); } else { ! cerr << "Malformed function name with number: " << Prefix ! << " and property name: " << Name ! << " but no \"#\" sign for substitution." << endl; } } else { --- 797,804 ---- tmp = PropertyManager->mkPropertyName(Name, false); } else { ! cerr << el->ReadFrom() ! << "Malformed function name with number: " << Prefix ! << " and property name: " << Name ! << " but no \"#\" sign for substitution." << endl; } } else { *************** *** 809,813 **** FGPropertyNode* _property = PropertyManager->GetNode(tmp); if (_property->isTied()) { ! cout << "Property " << tmp << " has already been successfully bound (late)." << endl; throw("Failed to bind the property to an existing already tied node."); } --- 810,815 ---- FGPropertyNode* _property = PropertyManager->GetNode(tmp); if (_property->isTied()) { ! cerr << el->ReadFrom() ! << "Property " << tmp << " has already been successfully bound (late)." << endl; throw("Failed to bind the property to an existing already tied node."); } Index: FGFunction.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/math/FGFunction.h,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** FGFunction.h 12 Jul 2015 13:03:23 -0000 1.32 --- FGFunction.h 11 Mar 2017 19:31:47 -0000 1.33 *************** *** 813,817 **** unsigned int GetBinary(double) const; ! void bind(void); void Debug(int from); }; --- 813,817 ---- unsigned int GetBinary(double) const; ! void bind(Element*); void Debug(int from); }; Index: FGTable.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/math/FGTable.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** FGTable.cpp 22 May 2016 09:08:05 -0000 1.32 --- FGTable.cpp 11 Mar 2017 19:31:48 -0000 1.33 *************** *** 113,117 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(propMan) { unsigned int i; --- 113,119 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! FGTable::FGTable(FGPropertyManager* propMan, Element* el, ! const std::string& prefix) ! : PropertyManager(propMan), Prefix(prefix) { unsigned int i; *************** *** 175,178 **** --- 177,185 ---- while (axisElement) { property_string = axisElement->GetDataLine(); + if (property_string.find("#") != string::npos) { + if (is_number(Prefix)) { + property_string = replace(property_string,"#",Prefix); + } + } // The property string passed into GetNode() must have no spaces or tabs. node = PropertyManager->GetNode(property_string); *************** *** 348,352 **** } ! bind(); if (debug_lvl & 1) Print(); --- 355,359 ---- } ! bind(el); if (debug_lvl & 1) Print(); *************** *** 633,641 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! void FGTable::bind(void) { typedef double (FGTable::*PMF)(void) const; if ( !Name.empty() && !internal) { ! string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper PropertyManager->Tie( tmp, this, (PMF)&FGTable::GetValue); } --- 640,674 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! void FGTable::bind(Element* el) { typedef double (FGTable::*PMF)(void) const; if ( !Name.empty() && !internal) { ! string tmp; ! if (Prefix.empty()) ! tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper ! else { ! if (is_number(Prefix)) { ! if (Name.find("#") != string::npos) { // if "#" is found ! Name = replace(Name,"#",Prefix); ! tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper ! } else { ! cerr << el->ReadFrom() ! << "Malformed table name with number: " << Prefix ! << " and property name: " << Name ! << " but no \"#\" sign for substitution." << endl; ! } ! } else { ! tmp = PropertyManager->mkPropertyName(Prefix + "/" + Name, false); ! } ! } ! ! if (PropertyManager->HasNode(tmp)) { ! FGPropertyNode* _property = PropertyManager->GetNode(tmp); ! if (_property->isTied()) { ! cerr << el->ReadFrom() ! << "Property " << tmp << " has already been successfully bound (late)." << endl; ! throw("Failed to bind the property to an existing already tied node."); ! } ! } PropertyManager->Tie( tmp, this, (PMF)&FGTable::GetValue); } Index: FGTable.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/math/FGTable.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** FGTable.h 26 Jan 2013 17:06:49 -0000 1.15 --- FGTable.h 11 Mar 2017 19:31:48 -0000 1.16 *************** *** 252,256 **** /// The constructor for a table ! FGTable (FGPropertyManager* propMan, Element* el); FGTable (int ); FGTable (int, int); --- 252,256 ---- /// The constructor for a table ! FGTable (FGPropertyManager* propMan, Element* el, const std::string& prefix=""); FGTable (int ); FGTable (int, int); *************** *** 312,317 **** double** Allocate(void); FGPropertyManager* const PropertyManager; std::string Name; ! void bind(void); unsigned int FindNumColumns(const std::string&); --- 312,318 ---- double** Allocate(void); FGPropertyManager* const PropertyManager; + std::string Prefix; std::string Name; ! void bind(Element*); unsigned int FindNumColumns(const std::string&); |