1
0
Fork 0

Added some interface function to traffic manager related classes and added a traffic record that mimicks the users aircraft's traffic intentions.

This commit is contained in:
Durk Talsma 2011-04-12 23:28:48 +02:00
parent 493661a2dc
commit c597f72158
7 changed files with 33 additions and 12 deletions

View file

@ -76,6 +76,7 @@ public:
void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; };
bool getTaxiClearanceRequest() { return needsTaxiClearance; };
FGAISchedule * getTrafficRef() { return trafficRef; };
void setTrafficRef(FGAISchedule *ref) { trafficRef = ref; };
virtual const char* getTypeString(void) const { return "aircraft"; }

View file

@ -29,7 +29,6 @@
#include <simgear/math/SGMath.hxx>
#include <Airports/dynamics.hxx>
#include <Airports/simple.hxx>
#include "atc_mgr.hxx"
@ -69,7 +68,6 @@ void FGATCManager::init() {
double speed = fgGetDouble("/velocities/groundspeed-kt");
double aircraftRadius = 40; // note that this is currently hardcoded to a one-size-fits all JumboJet value. Should change later;
// Next,
ai_ac.setCallSign ( callsign );
ai_ac.setLongitude( longitude );
@ -78,8 +76,19 @@ void FGATCManager::init() {
ai_ac.setPerformance("jet_transport");
// NEXT UP: Create a traffic Schedule and fill that with appropriate information. This we can use to flight plannign.
FGAISchedule *trafficRef = new FGAISchedule;
trafficRef->setFlightType("gate");
FGScheduledFlight *flight = new FGScheduledFlight;
flight->setDepartureAirport(airport);
flight->setArrivalAirport(airport);
flight->initializeAirports();
flight->setFlightRules("IFR");
flight->setCallSign(callsign);
trafficRef->assign(flight);
FGAIFlightPlan *fp = new FGAIFlightPlan;
ai_ac.setTrafficRef(trafficRef);
string flightPlanName = airport + "-" + airport + ".xml";
double cruiseAlt = 100; // Doesn't really matter right now.

View file

@ -1034,14 +1034,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
// The user controlled aircraft should have crased here, because it doesn't have a traffic reference.
// NOTE: if we create a traffic schedule for the user aircraft, we can use this to plan a flight.
time_t startTime = 0;
if (isUserAircraft(i->getAircraft())) {
cerr << i->getAircraft->getCallSign() << " is user aircraft " << endl;
} else {
time_t startTime =
i->getAircraft()->getTrafficRef()->getDepartureTime();
}
time_t startTime = i->getAircraft()->getTrafficRef()->getDepartureTime();
time_t now = time(NULL) + fgGetLong("/sim/time/warp");
//cerr << i->getAircraft()->getTrafficRef()->getCallSign()
// << " is scheduled to depart in " << startTime-now << " seconds. Available = " << available

View file

@ -74,8 +74,12 @@
FGScheduledFlight::FGScheduledFlight()
{
initialized = false;
available = true;
departureTime = 0;
arrivalTime = 0;
cruiseAltitude = 0;
repeatPeriod = 0;
initialized = false;
available = true;
}
FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other)

View file

@ -90,6 +90,8 @@ public:
time_t getDepartureTime() { return departureTime; };
time_t getArrivalTime () { return arrivalTime; };
void setDepartureAirport(string port) { depId = port; };
void setArrivalAirport (string port) { arrId = port; };
FGAirport *getDepartureAirport();
FGAirport *getArrivalAirport ();
@ -109,6 +111,9 @@ public:
void release() { available = true; };
bool isAvailable() { return available; };
void setCallSign(string val) { callsign = val; };
void setFlightRules(string val) { fltRules = val; };
};
typedef vector<FGScheduledFlight*> FGScheduledFlightVec;

View file

@ -344,6 +344,12 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots
return true;
}
// Create an initial heading for user controlled aircraft.
void FGAISchedule::setHeading()
{
courseToDest = SGGeodesy::courseDeg((*flights.begin())->getDepartureAirport()->geod(), (*flights.begin())->getArrivalAirport()->geod());
}
void FGAISchedule::scheduleFlights()
{
if (!flights.empty()) {

View file

@ -117,6 +117,9 @@ class FGAISchedule
void setHits (unsigned int count) { hits = count; };
void setScore ();
double getScore () { return score; };
void setHeading ();
void assign (FGScheduledFlight *ref) { flights.push_back(ref); };
void setFlightType (string val ) { flightType = val; };
FGScheduledFlight*findAvailableFlight (const string &currentDestination, const string &req);
// used to sort in decending order of score: I've probably found a better way to
// decending order sorting, but still need to test that.