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);
|
SGPropertyNode *prop_root);
|
||||||
|
|
||||||
static bool _isNight();
|
static bool _isNight();
|
||||||
|
|
||||||
|
string & getCallSign();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) {
|
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) {
|
inline void FGAIBase::setCallSign(const string& s) {
|
||||||
_callsign = s;
|
_callsign = s;
|
||||||
}
|
}
|
||||||
|
inline string& FGAIBase::getCallSign() {
|
||||||
|
return _callsign;
|
||||||
|
}
|
||||||
|
|
||||||
inline void FGAIBase::setXoffset(double x) {
|
inline void FGAIBase::setXoffset(double x) {
|
||||||
_x_offset = x;
|
_x_offset = x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,8 @@ void FGATCManager::init() {
|
||||||
ai_ac.setAltitude ( altitude );
|
ai_ac.setAltitude ( altitude );
|
||||||
ai_ac.setPerformance("jet_transport");
|
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;
|
FGAIFlightPlan *fp = new FGAIFlightPlan;
|
||||||
|
|
||||||
string flightPlanName = airport + "-" + airport + ".xml";
|
string flightPlanName = airport + "-" + airport + ".xml";
|
||||||
|
@ -105,7 +107,7 @@ void FGATCManager::init() {
|
||||||
string fltType = "ga";
|
string fltType = "ga";
|
||||||
fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
|
fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
|
||||||
} else {
|
} else {
|
||||||
controller = apt->getDynamics()->getGroundNetwork();
|
controller = apt->getDynamics()->getStartupController();
|
||||||
int stationFreq = apt->getDynamics()->getGroundFrequency(2);
|
int stationFreq = apt->getDynamics()->getGroundFrequency(2);
|
||||||
cerr << "Setting radio frequency to : " << stationFreq << endl;
|
cerr << "Setting radio frequency to : " << stationFreq << endl;
|
||||||
fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
|
fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
|
||||||
|
@ -151,11 +153,22 @@ void FGATCManager::addController(FGATCController *controller) {
|
||||||
activeStations.push_back(controller);
|
activeStations.push_back(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FGATCManager::update ( double time ) {
|
void FGATCManager::update ( double time ) {
|
||||||
//cerr << "ATC update code is running at time: " << time << endl;
|
//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();
|
return ref->atGate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FGATCController::isUserAircraft(FGAIAircraft* ac)
|
||||||
|
{
|
||||||
|
return (ac->getCallSign() == fgGetString("/sim/multiplay/callsign")) ? true : false;
|
||||||
|
};
|
||||||
|
|
||||||
void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||||
AtcMsgDir msgDir)
|
AtcMsgDir msgDir)
|
||||||
{
|
{
|
||||||
|
@ -1015,6 +1020,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // update position of the current aircraft
|
// // update position of the current aircraft
|
||||||
|
|
||||||
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
|
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"AI error: updating aircraft without traffic record");
|
"AI error: updating aircraft without traffic record");
|
||||||
|
@ -1025,8 +1031,17 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
|
||||||
setDt(getDt() + dt);
|
setDt(getDt() + dt);
|
||||||
|
|
||||||
int state = i->getState();
|
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");
|
time_t now = time(NULL) + fgGetLong("/sim/time/warp");
|
||||||
//cerr << i->getAircraft()->getTrafficRef()->getCallSign()
|
//cerr << i->getAircraft()->getTrafficRef()->getCallSign()
|
||||||
// << " is scheduled to depart in " << startTime-now << " seconds. Available = " << available
|
// << " is scheduled to depart in " << startTime-now << " seconds. Available = " << available
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -227,6 +225,7 @@ class FGATCController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool available;
|
bool available;
|
||||||
time_t lastTransmission;
|
time_t lastTransmission;
|
||||||
|
@ -236,6 +235,7 @@ protected:
|
||||||
|
|
||||||
string formatATCFrequency3_2(int );
|
string formatATCFrequency3_2(int );
|
||||||
string genTransponderCode(string fltRules);
|
string genTransponderCode(string fltRules);
|
||||||
|
bool isUserAircraft(FGAIAircraft*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -278,6 +278,9 @@ public:
|
||||||
void setDt(double dt) { dt_count = dt;};
|
void setDt(double dt) { dt_count = dt;};
|
||||||
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir);
|
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir);
|
||||||
string getGateName(FGAIAircraft *aircraft);
|
string getGateName(FGAIAircraft *aircraft);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AtcMsgDir lastTransmissionDirection;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
Loading…
Add table
Reference in a new issue