Fixes and code clean-up:
- Airports Directory Thomas Foerster: Pulls out the FGTaxiNode implementation into gnnode.cxx. Melchior / Durk: Copy Constructor and assignment operator for FGTaxiRoute - AIModels Directory Durk / Melchior / Czaba Halasz: Ensure that all derived classes use AIBase member 'callsign'. Adapted, moved and deleted getter/setter functions where necessary Czaba Halasz: Fix AIBase model path vs. submodel path consistency. - Traffic Directory and AIModels CreateFlightPlanCruise DT: Temporary revert parts of the position estimation code.
This commit is contained in:
parent
aacabde342
commit
b452234cb2
15 changed files with 136 additions and 112 deletions
|
@ -113,10 +113,6 @@ void FGAIAircraft::bind() {
|
|||
props->tie("controls/gear/gear-down",
|
||||
SGRawValueMethods<FGAIAircraft,bool>(*this,
|
||||
&FGAIAircraft::_getGearDown));
|
||||
props->tie("callsign",
|
||||
SGRawValueMethods<FGAIAircraft,const char *>(*this,
|
||||
&FGAIAircraft::_getCallSign));
|
||||
//props->setStringValue("callsign", callsign.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +120,6 @@ void FGAIAircraft::unbind() {
|
|||
FGAIBase::unbind();
|
||||
|
||||
props->untie("controls/gear/gear-down");
|
||||
props->untie("callsign");
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,10 +320,6 @@ bool FGAIAircraft::_getGearDown() const {
|
|||
return _performance->gearExtensible(this);
|
||||
}
|
||||
|
||||
const char * FGAIAircraft::_getCallSign() const {
|
||||
return callsign.c_str();
|
||||
}
|
||||
|
||||
|
||||
void FGAIAircraft::loadNextLeg() {
|
||||
|
||||
|
@ -410,11 +401,6 @@ void FGAIAircraft::getGroundElev(double dt) {
|
|||
}
|
||||
|
||||
|
||||
void FGAIAircraft::setCallSign(const string& s) {
|
||||
callsign = s;
|
||||
}
|
||||
|
||||
|
||||
void FGAIAircraft::doGroundAltitude() {
|
||||
if (fabs(altitude_ft - (tgt_altitude_ft+groundOffset)) > 1000.0)
|
||||
altitude_ft = (tgt_altitude_ft + groundOffset);
|
||||
|
|
|
@ -61,8 +61,6 @@ public:
|
|||
void ClimbTo(double altitude);
|
||||
void TurnTo(double heading);
|
||||
|
||||
void setCallSign(const string& );
|
||||
|
||||
void getGroundElev(double dt); //TODO these 3 really need to be public?
|
||||
void doGroundAltitude();
|
||||
void loadNextLeg ();
|
||||
|
@ -137,9 +135,8 @@ private:
|
|||
bool holdPos;
|
||||
|
||||
bool _getGearDown() const;
|
||||
const char *_getCallSign() const;
|
||||
|
||||
bool reachedWaypoint;
|
||||
string callsign; // The callsign of this tanker.
|
||||
|
||||
PerformanceData* _performance; // the performance data for this aircraft
|
||||
};
|
||||
|
|
|
@ -245,6 +245,10 @@ void FGAIBase::bind() {
|
|||
SGRawValueMethods<FGAIBase,double>(*this,
|
||||
&FGAIBase::_getCartPosZ,
|
||||
0));
|
||||
props->tie("callsign",
|
||||
SGRawValueMethods<FGAIBase,const char*>(*this,
|
||||
&FGAIBase::_getCallsign,
|
||||
0));
|
||||
|
||||
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
|
||||
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
|
||||
|
@ -290,6 +294,7 @@ void FGAIBase::unbind() {
|
|||
props->untie("position/global-x");
|
||||
props->untie("position/global-y");
|
||||
props->untie("position/global-z");
|
||||
props->untie("callsign");
|
||||
|
||||
props->untie("orientation/pitch-deg");
|
||||
props->untie("orientation/roll-deg");
|
||||
|
@ -581,19 +586,23 @@ double FGAIBase::_getHeading() const {
|
|||
return hdg;
|
||||
}
|
||||
|
||||
const char* FGAIBase::_getPath() {
|
||||
const char* FGAIBase::_getPath() const {
|
||||
return model_path.c_str();
|
||||
}
|
||||
|
||||
const char* FGAIBase::_getSMPath() const {
|
||||
return _path.c_str();
|
||||
}
|
||||
|
||||
const char* FGAIBase::_getName() {
|
||||
const char* FGAIBase::_getName() const {
|
||||
return _name.c_str();
|
||||
}
|
||||
|
||||
const char* FGAIBase::_getCallsign() {
|
||||
const char* FGAIBase::_getCallsign() const {
|
||||
return _callsign.c_str();
|
||||
}
|
||||
|
||||
const char* FGAIBase::_getSubmodel() {
|
||||
const char* FGAIBase::_getSubmodel() const {
|
||||
return _submodel.c_str();
|
||||
}
|
||||
|
||||
|
@ -621,7 +630,7 @@ void FGAIBase::CalculateMach() {
|
|||
// where:
|
||||
// a = speed of sound [ft/s]
|
||||
// g = specific heat ratio, which is usually equal to 1.4
|
||||
// R = specific gas constant, which equals 1716 ft-lb/slug/°R
|
||||
// R = specific gas constant, which equals 1716 ft-lb/slug/R
|
||||
a = sqrt ( 1.4 * 1716 * (T + 459.7));
|
||||
|
||||
// calculate Mach number
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
void setManager(FGAIManager* mgr, SGPropertyNode* p);
|
||||
void setPath( const char* model );
|
||||
void setSMPath( const string& p );
|
||||
void setCallSign(const string& );
|
||||
void setSpeed( double speed_KTAS );
|
||||
void setAltitude( double altitude_ft );
|
||||
void setHeading( double heading );
|
||||
|
@ -225,11 +226,12 @@ public:
|
|||
|
||||
SGPropertyNode* _getProps() const;
|
||||
|
||||
const char* _getPath();
|
||||
const char* _getCallsign();
|
||||
const char* _getTriggerNode();
|
||||
const char* _getName();
|
||||
const char* _getSubmodel();
|
||||
const char* _getPath() const;
|
||||
const char* _getSMPath() const;
|
||||
const char* _getCallsign() const;
|
||||
const char* _getTriggerNode() const;
|
||||
const char* _getName() const;
|
||||
const char* _getSubmodel() const;
|
||||
|
||||
|
||||
// These are used in the Mach number calculations
|
||||
|
@ -305,6 +307,11 @@ inline void FGAIBase::setLatitude ( double latitude ) {
|
|||
pos.setLatitudeDeg( latitude );
|
||||
}
|
||||
|
||||
inline void FGAIBase::setCallSign(const string& s) {
|
||||
_callsign = s;
|
||||
}
|
||||
|
||||
|
||||
inline void FGAIBase::setDie( bool die ) { delete_me = die; }
|
||||
|
||||
inline bool FGAIBase::getDie() { return delete_me; }
|
||||
|
|
|
@ -192,8 +192,8 @@ FGAIFlightPlan::FGAIFlightPlan(const std::string& p,
|
|||
leg = 4;
|
||||
else if (timeDiff >= 2000)
|
||||
leg = 5;
|
||||
|
||||
//cerr << "Set leg to : " << leg << endl;
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Route from " << dep->getId() << " to " << arr->getId() << ". Set leg to : " << leg);
|
||||
wpt_iterator = waypoints.begin();
|
||||
create(dep,arr, leg, alt, speed, lat, lon,
|
||||
firstLeg, radius, fltType, acType, airline);
|
||||
|
|
|
@ -75,9 +75,15 @@ void FGAIFlightPlan::evaluateRoutePart(double deplat,
|
|||
}
|
||||
}
|
||||
//cerr << "1"<< endl;
|
||||
SGGeoc geoc = SGGeoc::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
|
||||
double midlat = geoc.getLatitudeDeg();
|
||||
double midlon = geoc.getLongitudeDeg();
|
||||
//SGGeoc geoc = SGGeoc::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
|
||||
|
||||
//double midlat = geoc.getLatitudeDeg();
|
||||
//double midlon = geoc.getLongitudeDeg();
|
||||
|
||||
Point3D temp = sgCartToPolar3d(Point3D(newPos[0], newPos[1],newPos[2]));
|
||||
double midlat = temp.lat() * SG_RADIANS_TO_DEGREES;
|
||||
double midlon = temp.lon() * SG_RADIANS_TO_DEGREES;
|
||||
|
||||
|
||||
prevNode = tmpNode;
|
||||
tmpNode = globals->get_airwaynet()->findNearestNode(midlat, midlon);
|
||||
|
|
|
@ -48,7 +48,7 @@ bool FGAIMultiplayer::init(bool search_in_AI_path) {
|
|||
isTanker = false; // do this until this property is
|
||||
// passed over the net
|
||||
|
||||
string str1 = mCallSign;
|
||||
string str1 = _getCallsign();
|
||||
string str2 = "MOBIL";
|
||||
|
||||
string::size_type loc1= str1.find( str2, 0 );
|
||||
|
@ -73,7 +73,7 @@ SGRawValueMethods<FGAIMultiplayer, type>(*this, &FGAIMultiplayer::get##name)
|
|||
SGRawValueMethods<FGAIMultiplayer, type>(*this, \
|
||||
&FGAIMultiplayer::get##name, &FGAIMultiplayer::set##name)
|
||||
|
||||
props->tie("callsign", AIMPROProp(const char *, CallSign));
|
||||
//props->tie("callsign", AIMPROProp(const char *, CallSign));
|
||||
|
||||
props->tie("controls/allow-extrapolation",
|
||||
AIMPRWProp(bool, AllowExtrapolation));
|
||||
|
@ -88,7 +88,7 @@ SGRawValueMethods<FGAIMultiplayer, type>(*this, \
|
|||
void FGAIMultiplayer::unbind() {
|
||||
FGAIBase::unbind();
|
||||
|
||||
props->untie("callsign");
|
||||
//props->untie("callsign");
|
||||
props->untie("controls/allow-extrapolation");
|
||||
props->untie("controls/lag-adjust-system-speed");
|
||||
props->untie("refuel/contact");
|
||||
|
|
|
@ -40,11 +40,6 @@ public:
|
|||
void addMotionInfo(const FGExternalMotionData& motionInfo, long stamp);
|
||||
void setDoubleProperty(const std::string& prop, double val);
|
||||
|
||||
void setCallSign(const string& callSign)
|
||||
{ mCallSign = callSign; }
|
||||
const char* getCallSign(void) const
|
||||
{ return mCallSign.c_str(); }
|
||||
|
||||
long getLastTimestamp(void) const
|
||||
{ return mLastTimestamp; }
|
||||
|
||||
|
@ -77,8 +72,6 @@ private:
|
|||
typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
|
||||
PropertyMap mPropertyMap;
|
||||
|
||||
std::string mCallSign;
|
||||
|
||||
double mTimeOffset;
|
||||
bool mTimeOffsetSet;
|
||||
|
||||
|
|
|
@ -517,7 +517,7 @@ void FGSubmodelMgr::loadAI()
|
|||
sm_list_iterator end = sm_list.end();
|
||||
|
||||
while (sm_list_itr != end) {
|
||||
string path = (*sm_list_itr)->_getPath();
|
||||
string path = (*sm_list_itr)->_getSMPath();
|
||||
|
||||
if (path.empty()) {
|
||||
++sm_list_itr;
|
||||
|
|
|
@ -8,13 +8,13 @@ libAirports_a_SOURCES = \
|
|||
simple.cxx simple.hxx \
|
||||
runwayprefs.cxx runwayprefs.hxx \
|
||||
parking.cxx parking.hxx \
|
||||
gnnode.cxx gnnode.hxx \
|
||||
groundnetwork.cxx groundnetwork.hxx \
|
||||
dynamics.cxx dynamics.hxx \
|
||||
trafficcontrol.cxx trafficcontrol.hxx \
|
||||
dynamicloader.cxx dynamicloader.hxx \
|
||||
runwayprefloader.cxx runwayprefloader.hxx \
|
||||
xmlloader.cxx xmlloader.hxx \
|
||||
gnnode.hxx
|
||||
xmlloader.cxx xmlloader.hxx
|
||||
|
||||
calc_loc_SOURCES = calc_loc.cxx
|
||||
calc_loc_LDADD = -lsgmath -lsgdebug -lsgmisc -lz $(base_LIBS)
|
||||
|
|
55
src/Airports/gnnode.cxx
Normal file
55
src/Airports/gnnode.cxx
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "gnnode.hxx"
|
||||
#include "groundnetwork.hxx"
|
||||
|
||||
#include <algorithm>
|
||||
SG_USING_STD(sort);
|
||||
|
||||
/*****************************************************************************
|
||||
* Helper function for parsing position string
|
||||
****************************************************************************/
|
||||
double processPosition(const string &pos)
|
||||
{
|
||||
string prefix;
|
||||
string subs;
|
||||
string degree;
|
||||
string decimal;
|
||||
int sign = 1;
|
||||
double value;
|
||||
subs = pos;
|
||||
prefix= subs.substr(0,1);
|
||||
if (prefix == string("S") || (prefix == string("W")))
|
||||
sign = -1;
|
||||
subs = subs.substr(1, subs.length());
|
||||
degree = subs.substr(0, subs.find(" ",0));
|
||||
decimal = subs.substr(subs.find(" ",0), subs.length());
|
||||
|
||||
|
||||
//cerr << sign << " "<< degree << " " << decimal << endl;
|
||||
value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
|
||||
//cerr << value <<endl;
|
||||
//exit(1);
|
||||
return value;
|
||||
}
|
||||
|
||||
bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
|
||||
return a->hasSmallerHeadingDiff(*b);
|
||||
}
|
||||
|
||||
bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
|
||||
return a->getLength() > b->getLength();
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* FGTaxiNode
|
||||
*************************************************************************/
|
||||
FGTaxiNode::FGTaxiNode()
|
||||
{
|
||||
}
|
||||
|
||||
void FGTaxiNode::sortEndSegments(bool byLength)
|
||||
{
|
||||
if (byLength)
|
||||
sort(next.begin(), next.end(), sortByLength);
|
||||
else
|
||||
sort(next.begin(), next.end(), sortByHeadingDiff);
|
||||
}
|
|
@ -27,6 +27,8 @@ class FGTaxiSegment;
|
|||
typedef vector<FGTaxiSegment*> FGTaxiSegmentVector;
|
||||
typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
|
||||
|
||||
bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
|
||||
bool sortByLength (FGTaxiSegment *a, FGTaxiSegment *b);
|
||||
double processPosition(const string& pos);
|
||||
|
||||
class FGTaxiNode
|
||||
|
|
|
@ -47,55 +47,6 @@
|
|||
|
||||
#include "groundnetwork.hxx"
|
||||
|
||||
SG_USING_STD(sort);
|
||||
|
||||
/*****************************************************************************
|
||||
* Helper function for parsing position string
|
||||
****************************************************************************/
|
||||
double processPosition(const string &pos)
|
||||
{
|
||||
string prefix;
|
||||
string subs;
|
||||
string degree;
|
||||
string decimal;
|
||||
int sign = 1;
|
||||
double value;
|
||||
subs = pos;
|
||||
prefix= subs.substr(0,1);
|
||||
if (prefix == string("S") || (prefix == string("W")))
|
||||
sign = -1;
|
||||
subs = subs.substr(1, subs.length());
|
||||
degree = subs.substr(0, subs.find(" ",0));
|
||||
decimal = subs.substr(subs.find(" ",0), subs.length());
|
||||
|
||||
|
||||
//cerr << sign << " "<< degree << " " << decimal << endl;
|
||||
value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
|
||||
//cerr << value <<endl;
|
||||
//exit(1);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* FGTaxiNode
|
||||
*************************************************************************/
|
||||
FGTaxiNode::FGTaxiNode()
|
||||
{
|
||||
}
|
||||
|
||||
void FGTaxiNode::sortEndSegments(bool byLength)
|
||||
{
|
||||
if (byLength)
|
||||
sort(next.begin(), next.end(), sortByLength);
|
||||
else
|
||||
sort(next.begin(), next.end(), sortByHeadingDiff);
|
||||
}
|
||||
|
||||
|
||||
bool compare_nodes(FGTaxiNode *a, FGTaxiNode *b) {
|
||||
return (*a) < (*b);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* FGTaxiSegment
|
||||
**************************************************************************/
|
||||
|
@ -159,17 +110,7 @@ void FGTaxiSegment::setCourseDiff(double crse)
|
|||
headingDiff = fabs(headingDiff - 360);
|
||||
}
|
||||
|
||||
bool compare_segments(FGTaxiSegment *a, FGTaxiSegment *b) {
|
||||
return (*a) < (*b);
|
||||
}
|
||||
|
||||
bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
|
||||
return a->hasSmallerHeadingDiff(*b);
|
||||
}
|
||||
|
||||
bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
|
||||
return a->getLength() > b->getLength();
|
||||
}
|
||||
/***************************************************************************
|
||||
* FGTaxiRoute
|
||||
**************************************************************************/
|
||||
|
@ -249,6 +190,13 @@ void FGTaxiRoute::rewind(int route)
|
|||
/***************************************************************************
|
||||
* FGGroundNetwork()
|
||||
**************************************************************************/
|
||||
bool compare_nodes(FGTaxiNode *a, FGTaxiNode *b) {
|
||||
return (*a) < (*b);
|
||||
}
|
||||
|
||||
bool compare_segments(FGTaxiSegment *a, FGTaxiSegment *b) {
|
||||
return (*a) < (*b);
|
||||
}
|
||||
|
||||
FGGroundNetwork::FGGroundNetwork()
|
||||
{
|
||||
|
|
|
@ -126,6 +126,26 @@ public:
|
|||
currNode = nodes.begin();
|
||||
depth = dpth;
|
||||
};
|
||||
|
||||
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
||||
nodes = other.nodes;
|
||||
routes = other.routes;
|
||||
distance = other.distance;
|
||||
depth = other.depth;
|
||||
currNode = nodes.begin();
|
||||
currRoute = routes.begin();
|
||||
return *this;
|
||||
};
|
||||
|
||||
FGTaxiRoute(const FGTaxiRoute& copy) :
|
||||
nodes(copy.nodes),
|
||||
routes(copy.routes),
|
||||
distance(copy.distance),
|
||||
depth(copy.depth),
|
||||
currNode(nodes.begin()),
|
||||
currRoute(routes.begin())
|
||||
{};
|
||||
|
||||
bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
|
||||
bool empty () { return nodes.begin() == nodes.end(); };
|
||||
bool next(int *nde);
|
||||
|
@ -140,10 +160,6 @@ public:
|
|||
typedef vector<FGTaxiRoute> TaxiRouteVector;
|
||||
typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
|
||||
|
||||
bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
|
||||
bool sortByLength (FGTaxiSegment *a, FGTaxiSegment *b);
|
||||
|
||||
|
||||
/**************************************************************************************
|
||||
* class FGGroundNetWork
|
||||
*************************************************************************************/
|
||||
|
|
|
@ -315,9 +315,14 @@ bool FGAISchedule::update(time_t now)
|
|||
|
||||
if (now > (*i)->getDepartureTime())
|
||||
{
|
||||
SGGeoc geoc = SGGeoc::fromCart(newPos);
|
||||
lat = geoc.getLatitudeDeg();
|
||||
lon = geoc.getLongitudeDeg();
|
||||
//SGGeoc geoc = SGGeoc::fromCart(newPos);
|
||||
//lat = geoc.getLatitudeDeg();
|
||||
//lon = geoc.getLongitudeDeg();
|
||||
|
||||
Point3D temp = sgCartToPolar3d(Point3D(newPos[0], newPos[1],newPos[2]));
|
||||
lat = temp.lat() * SG_RADIANS_TO_DEGREES;
|
||||
lon = temp.lon() * SG_RADIANS_TO_DEGREES;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue