SGPropertyNode *prop_root);
static bool _isNight();
+
+ string & getCallSign();
};
inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) {
inline void FGAIBase::setCallSign(const string& s) {
_callsign = s;
}
+inline string& FGAIBase::getCallSign() {
+ return _callsign;
+}
+
inline void FGAIBase::setXoffset(double x) {
_x_offset = x;
}
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";
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));
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);
+ }
}
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)
{
}
}
// // 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");
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
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
-
-
#include <string>
#include <vector>
{
private:
bool initialized;
+
protected:
bool available;
time_t lastTransmission;
string formatATCFrequency3_2(int );
string genTransponderCode(string fltRules);
+ bool isUserAircraft(FGAIAircraft*);
public:
typedef enum {
void setDt(double dt) { dt_count = dt;};
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir);
string getGateName(FGAIAircraft *aircraft);
+
+private:
+ AtcMsgDir lastTransmissionDirection;
};
/******************************************************************************