Small step forward: Ensure that traffic information is appropriately updated.
This commit is contained in:
parent
416ba93a41
commit
493661a2dc
4 changed files with 46 additions and 9 deletions
|
@ -304,6 +304,8 @@ public:
|
|||
SGPropertyNode *prop_root);
|
||||
|
||||
static bool _isNight();
|
||||
|
||||
string & getCallSign();
|
||||
};
|
||||
|
||||
inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) {
|
||||
|
@ -364,6 +366,10 @@ inline void FGAIBase::setLatitude ( double latitude ) {
|
|||
inline void FGAIBase::setCallSign(const string& s) {
|
||||
_callsign = s;
|
||||
}
|
||||
inline string& FGAIBase::getCallSign() {
|
||||
return _callsign;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setXoffset(double x) {
|
||||
_x_offset = x;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,8 @@ void FGATCManager::init() {
|
|||
ai_ac.setAltitude ( altitude );
|
||||
ai_ac.setPerformance("jet_transport");
|
||||
|
||||
// NEXT UP: Create a traffic Schedule and fill that with appropriate information. This we can use to flight plannign.
|
||||
|
||||
FGAIFlightPlan *fp = new FGAIFlightPlan;
|
||||
|
||||
string flightPlanName = airport + "-" + airport + ".xml";
|
||||
|
@ -105,7 +107,7 @@ void FGATCManager::init() {
|
|||
string fltType = "ga";
|
||||
fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
|
||||
} else {
|
||||
controller = apt->getDynamics()->getGroundNetwork();
|
||||
controller = apt->getDynamics()->getStartupController();
|
||||
int stationFreq = apt->getDynamics()->getGroundFrequency(2);
|
||||
cerr << "Setting radio frequency to : " << stationFreq << endl;
|
||||
fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
|
||||
|
@ -151,11 +153,22 @@ void FGATCManager::addController(FGATCController *controller) {
|
|||
activeStations.push_back(controller);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FGATCManager::update ( double time ) {
|
||||
//cerr << "ATC update code is running at time: " << time << endl;
|
||||
currentATCDialog->update(time);
|
||||
|
||||
currentATCDialog->update(time);
|
||||
if (controller) {
|
||||
double longitude = fgGetDouble("/position/longitude-deg");
|
||||
double latitude = fgGetDouble("/position/latitude-deg");
|
||||
double heading = fgGetDouble("/orientation/heading-deg");
|
||||
double speed = fgGetDouble("/velocities/groundspeed-kt");
|
||||
double altitude = fgGetDouble("/position/altitude-ft");
|
||||
|
||||
cerr << "Running FGATCManager::update()" << endl;
|
||||
controller->updateAircraftInformation(ai_ac.getID(),
|
||||
latitude,
|
||||
longitude,
|
||||
heading,
|
||||
speed,
|
||||
altitude, time);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,6 +465,11 @@ string FGATCController::getGateName(FGAIAircraft * ref)
|
|||
return ref->atGate();
|
||||
}
|
||||
|
||||
bool FGATCController::isUserAircraft(FGAIAircraft* ac)
|
||||
{
|
||||
return (ac->getCallSign() == fgGetString("/sim/multiplay/callsign")) ? true : false;
|
||||
};
|
||||
|
||||
void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||
AtcMsgDir msgDir)
|
||||
{
|
||||
|
@ -1015,6 +1020,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
|
|||
}
|
||||
}
|
||||
// // update position of the current aircraft
|
||||
|
||||
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||
"AI error: updating aircraft without traffic record");
|
||||
|
@ -1025,8 +1031,17 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
|
|||
setDt(getDt() + dt);
|
||||
|
||||
int state = i->getState();
|
||||
time_t startTime =
|
||||
i->getAircraft()->getTrafficRef()->getDepartureTime();
|
||||
|
||||
// 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 now = time(NULL) + fgGetLong("/sim/time/warp");
|
||||
//cerr << i->getAircraft()->getTrafficRef()->getCallSign()
|
||||
// << " is scheduled to depart in " << startTime-now << " seconds. Available = " << available
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <simgear/structure/SGReferenced.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -227,6 +225,7 @@ class FGATCController
|
|||
{
|
||||
private:
|
||||
bool initialized;
|
||||
|
||||
protected:
|
||||
bool available;
|
||||
time_t lastTransmission;
|
||||
|
@ -236,6 +235,7 @@ protected:
|
|||
|
||||
string formatATCFrequency3_2(int );
|
||||
string genTransponderCode(string fltRules);
|
||||
bool isUserAircraft(FGAIAircraft*);
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
|
@ -278,6 +278,9 @@ public:
|
|||
void setDt(double dt) { dt_count = dt;};
|
||||
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir);
|
||||
string getGateName(FGAIAircraft *aircraft);
|
||||
|
||||
private:
|
||||
AtcMsgDir lastTransmissionDirection;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
|
Loading…
Reference in a new issue