* A new algorithm for determining hold position instructions. This version still needs some finetuning, but already appears to be more solid than the old version.
* Some tweaks to the traffic scheduling algorithm. * Misc cleanup.
This commit is contained in:
parent
ab84ff5904
commit
4640f5bb02
9 changed files with 1301 additions and 878 deletions
|
@ -773,10 +773,10 @@ bool FGAIAircraft::leadPointReached(FGAIWaypoint* curr) {
|
||||||
}
|
}
|
||||||
if (trafficRef) {
|
if (trafficRef) {
|
||||||
//cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl;
|
//cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl;
|
||||||
/* if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
||||||
cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
|
cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
|
||||||
<< _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->name << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl;
|
<< _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->getName() << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << " " << invisible << endl;
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
if ((dist_to_go < lead_dist) || (bearing > (minBearing * 1.1))) {
|
if ((dist_to_go < lead_dist) || (bearing > (minBearing * 1.1))) {
|
||||||
minBearing = 360;
|
minBearing = 360;
|
||||||
|
@ -1223,20 +1223,20 @@ bool FGAIAircraft::reachedEndOfCruise(double &distance) {
|
||||||
double distanceCovered = descentSpeed * descentTimeNeeded;
|
double distanceCovered = descentSpeed * descentTimeNeeded;
|
||||||
|
|
||||||
//cerr << "Tracking : " << fgGetString("/ai/track-callsign");
|
//cerr << "Tracking : " << fgGetString("/ai/track-callsign");
|
||||||
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
// if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
||||||
cerr << "Checking for end of cruise stage for :" << trafficRef->getCallSign() << endl;
|
// cerr << "Checking for end of cruise stage for :" << trafficRef->getCallSign() << endl;
|
||||||
cerr << "Descent rate : " << descentRate << endl;
|
// cerr << "Descent rate : " << descentRate << endl;
|
||||||
cerr << "Descent speed : " << descentSpeed << endl;
|
// cerr << "Descent speed : " << descentSpeed << endl;
|
||||||
cerr << "VerticalDistance : " << verticalDistance << ". Altitude : " << altitude_ft << ". Elevation " << trafficRef->getArrivalAirport()->getElevation() << endl;
|
// cerr << "VerticalDistance : " << verticalDistance << ". Altitude : " << altitude_ft << ". Elevation " << trafficRef->getArrivalAirport()->getElevation() << endl;
|
||||||
cerr << "DecentTimeNeeded : " << descentTimeNeeded << endl;
|
// cerr << "DecentTimeNeeded : " << descentTimeNeeded << endl;
|
||||||
cerr << "DistanceCovered : " << distanceCovered << endl;
|
// cerr << "DistanceCovered : " << distanceCovered << endl;
|
||||||
}
|
// }
|
||||||
//cerr << "Distance = " << distance << endl;
|
//cerr << "Distance = " << distance << endl;
|
||||||
distance = distanceCovered;
|
distance = distanceCovered;
|
||||||
if (dist < distanceCovered) {
|
if (dist < distanceCovered) {
|
||||||
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
// if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
||||||
//exit(1);
|
// //exit(1);
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1290,8 +1290,8 @@ time_t FGAIAircraft::checkForArrivalTime(string wptName) {
|
||||||
|
|
||||||
time_t ete = tracklength / ((speed * SG_NM_TO_METER) / 3600.0);
|
time_t ete = tracklength / ((speed * SG_NM_TO_METER) / 3600.0);
|
||||||
time_t secondsToGo = arrivalTime - now;
|
time_t secondsToGo = arrivalTime - now;
|
||||||
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
// if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
|
||||||
cerr << "Checking arrival time: ete " << ete << ". Time to go : " << secondsToGo << ". Track length = " << tracklength << endl;
|
// cerr << "Checking arrival time: ete " << ete << ". Time to go : " << secondsToGo << ". Track length = " << tracklength << endl;
|
||||||
}
|
// }
|
||||||
return (ete - secondsToGo); // Positive when we're too slow...
|
return (ete - secondsToGo); // Positive when we're too slow...
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,11 @@ bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep,
|
||||||
case 1:
|
case 1:
|
||||||
retVal = createPushBack(ac, firstFlight, dep, latitude, longitude,
|
retVal = createPushBack(ac, firstFlight, dep, latitude, longitude,
|
||||||
radius, fltType, aircraftType, airline);
|
radius, fltType, aircraftType, airline);
|
||||||
|
// Pregenerate the
|
||||||
|
if (retVal) {
|
||||||
|
waypoints.back()->setName( waypoints.back()->getName() + string("legend"));
|
||||||
|
retVal = createTakeoffTaxi(ac, false, dep, radius, fltType, aircraftType, airline);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType,
|
retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType,
|
||||||
|
|
|
@ -247,5 +247,7 @@ void FGATCManager::update ( double time ) {
|
||||||
//cerr << "Adding groundnetWork to the scenegraph::update" << endl;
|
//cerr << "Adding groundnetWork to the scenegraph::update" << endl;
|
||||||
prevController = controller;
|
prevController = controller;
|
||||||
}
|
}
|
||||||
//globals->get_scenery()->get_scene_graph()->addChild(node);
|
for (AtcVecIterator atc = activeStations.begin(); atc != activeStations.end(); atc++) {
|
||||||
|
(*atc)->update(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ time_t ActiveRunway::requestTimeSlot(time_t eta)
|
||||||
TimeVectorIterator i = estimatedArrivalTimes.begin();
|
TimeVectorIterator i = estimatedArrivalTimes.begin();
|
||||||
//cerr << "Checking eta slots " << eta << ": " << endl;
|
//cerr << "Checking eta slots " << eta << ": " << endl;
|
||||||
for (i = estimatedArrivalTimes.begin();
|
for (i = estimatedArrivalTimes.begin();
|
||||||
i != estimatedArrivalTimes.end(); i++) {
|
i != estimatedArrivalTimes.end(); i++) {
|
||||||
//cerr << "Stored time : " << (*i) << endl;
|
//cerr << "Stored time : " << (*i) << endl;
|
||||||
}
|
}
|
||||||
i = estimatedArrivalTimes.begin();
|
i = estimatedArrivalTimes.begin();
|
||||||
|
@ -144,18 +144,20 @@ time_t ActiveRunway::requestTimeSlot(time_t eta)
|
||||||
* FGTrafficRecord
|
* FGTrafficRecord
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
FGTrafficRecord::FGTrafficRecord():
|
FGTrafficRecord::FGTrafficRecord():
|
||||||
id(0), waitsForId(0),
|
id(0), waitsForId(0),
|
||||||
currentPos(0),
|
currentPos(0),
|
||||||
leg(0),
|
leg(0),
|
||||||
frequencyId(0),
|
frequencyId(0),
|
||||||
state(0),
|
state(0),
|
||||||
allowTransmission(true),
|
allowTransmission(true),
|
||||||
latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0)
|
allowPushback(true),
|
||||||
|
priority(0),
|
||||||
|
latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGTrafficRecord::setPositionAndIntentions(int pos,
|
void FGTrafficRecord::setPositionAndIntentions(int pos,
|
||||||
FGAIFlightPlan * route)
|
FGAIFlightPlan * route)
|
||||||
{
|
{
|
||||||
|
|
||||||
currentPos = pos;
|
currentPos = pos;
|
||||||
|
@ -166,7 +168,7 @@ void FGTrafficRecord::setPositionAndIntentions(int pos,
|
||||||
"Error in FGTrafficRecord::setPositionAndIntentions");
|
"Error in FGTrafficRecord::setPositionAndIntentions");
|
||||||
//cerr << "Pos : " << pos << " Curr " << *(intentions.begin()) << endl;
|
//cerr << "Pos : " << pos << " Curr " << *(intentions.begin()) << endl;
|
||||||
for (intVecIterator i = intentions.begin();
|
for (intVecIterator i = intentions.begin();
|
||||||
i != intentions.end(); i++) {
|
i != intentions.end(); i++) {
|
||||||
//cerr << (*i) << " ";
|
//cerr << (*i) << " ";
|
||||||
}
|
}
|
||||||
//cerr << endl;
|
//cerr << endl;
|
||||||
|
@ -237,8 +239,8 @@ bool FGTrafficRecord::checkPositionAndIntentions(FGTrafficRecord & other)
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGTrafficRecord::setPositionAndHeading(double lat, double lon,
|
void FGTrafficRecord::setPositionAndHeading(double lat, double lon,
|
||||||
double hdg, double spd,
|
double hdg, double spd,
|
||||||
double alt)
|
double alt)
|
||||||
{
|
{
|
||||||
latitude = lat;
|
latitude = lat;
|
||||||
longitude = lon;
|
longitude = lon;
|
||||||
|
@ -251,7 +253,7 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
|
||||||
FGTrafficRecord & other)
|
FGTrafficRecord & other)
|
||||||
{
|
{
|
||||||
if (checkPositionAndIntentions(other)
|
if (checkPositionAndIntentions(other)
|
||||||
|| (other.checkPositionAndIntentions(*this)))
|
|| (other.checkPositionAndIntentions(*this)))
|
||||||
return -1;
|
return -1;
|
||||||
intVecIterator i, j;
|
intVecIterator i, j;
|
||||||
int currentTargetNode = 0, otherTargetNode = 0;
|
int currentTargetNode = 0, otherTargetNode = 0;
|
||||||
|
@ -265,7 +267,7 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
|
||||||
for (i = intentions.begin(); i != intentions.end(); i++) {
|
for (i = intentions.begin(); i != intentions.end(); i++) {
|
||||||
if ((*i) > 0) {
|
if ((*i) > 0) {
|
||||||
if ((currentTargetNode ==
|
if ((currentTargetNode ==
|
||||||
net->findSegment(*i)->getEnd()->getIndex())) {
|
net->findSegment(*i)->getEnd()->getIndex())) {
|
||||||
//cerr << "Current crosses at " << currentTargetNode <<endl;
|
//cerr << "Current crosses at " << currentTargetNode <<endl;
|
||||||
return currentTargetNode;
|
return currentTargetNode;
|
||||||
}
|
}
|
||||||
|
@ -274,10 +276,10 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
|
||||||
}
|
}
|
||||||
if (other.intentions.size()) {
|
if (other.intentions.size()) {
|
||||||
for (i = other.intentions.begin(); i != other.intentions.end();
|
for (i = other.intentions.begin(); i != other.intentions.end();
|
||||||
i++) {
|
i++) {
|
||||||
if ((*i) > 0) {
|
if ((*i) > 0) {
|
||||||
if (otherTargetNode ==
|
if (otherTargetNode ==
|
||||||
net->findSegment(*i)->getEnd()->getIndex()) {
|
net->findSegment(*i)->getEnd()->getIndex()) {
|
||||||
//cerr << "Other crosses at " << currentTargetNode <<endl;
|
//cerr << "Other crosses at " << currentTargetNode <<endl;
|
||||||
return otherTargetNode;
|
return otherTargetNode;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +289,7 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
|
||||||
if (intentions.size() && other.intentions.size()) {
|
if (intentions.size() && other.intentions.size()) {
|
||||||
for (i = intentions.begin(); i != intentions.end(); i++) {
|
for (i = intentions.begin(); i != intentions.end(); i++) {
|
||||||
for (j = other.intentions.begin(); j != other.intentions.end();
|
for (j = other.intentions.begin(); j != other.intentions.end();
|
||||||
j++) {
|
j++) {
|
||||||
//cerr << "finding segment " << *i << " and " << *j << endl;
|
//cerr << "finding segment " << *i << " and " << *j << endl;
|
||||||
if (((*i) > 0) && ((*j) > 0)) {
|
if (((*i) > 0) && ((*j) > 0)) {
|
||||||
currentTargetNode =
|
currentTargetNode =
|
||||||
|
@ -318,7 +320,7 @@ bool FGTrafficRecord::onRoute(FGGroundNetwork * net,
|
||||||
return true;
|
return true;
|
||||||
if (other.intentions.size()) {
|
if (other.intentions.size()) {
|
||||||
for (intVecIterator i = other.intentions.begin();
|
for (intVecIterator i = other.intentions.begin();
|
||||||
i != other.intentions.end(); i++) {
|
i != other.intentions.end(); i++) {
|
||||||
if (*i > 0) {
|
if (*i > 0) {
|
||||||
othernode = net->findSegment(*i)->getEnd()->getIndex();
|
othernode = net->findSegment(*i)->getEnd()->getIndex();
|
||||||
if ((node == othernode) && (node > -1))
|
if ((node == othernode) && (node > -1))
|
||||||
|
@ -358,13 +360,13 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (intVecIterator i = intentions.begin(); i != intentions.end();
|
for (intVecIterator i = intentions.begin(); i != intentions.end();
|
||||||
i++) {
|
i++) {
|
||||||
if ((opp = net->findSegment(other.currentPos)->opposite())) {
|
if ((opp = net->findSegment(other.currentPos)->opposite())) {
|
||||||
if ((*i) > 0)
|
if ((*i) > 0)
|
||||||
if (opp->getIndex() ==
|
if (opp->getIndex() ==
|
||||||
net->findSegment(*i)->getIndex()) {
|
net->findSegment(*i)->getIndex()) {
|
||||||
if (net->findSegment(*i)->getStart()->getIndex() ==
|
if (net->findSegment(*i)->getStart()->getIndex() ==
|
||||||
node) {
|
node) {
|
||||||
{
|
{
|
||||||
//cerr << "Found the node " << node << endl;
|
//cerr << "Found the node " << node << endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -374,17 +376,17 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
|
||||||
}
|
}
|
||||||
if (other.intentions.size()) {
|
if (other.intentions.size()) {
|
||||||
for (intVecIterator j = other.intentions.begin();
|
for (intVecIterator j = other.intentions.begin();
|
||||||
j != other.intentions.end(); j++) {
|
j != other.intentions.end(); j++) {
|
||||||
// cerr << "Current segment 1 " << (*i) << endl;
|
// cerr << "Current segment 1 " << (*i) << endl;
|
||||||
if ((*i) > 0) {
|
if ((*i) > 0) {
|
||||||
if ((opp = net->findSegment(*i)->opposite())) {
|
if ((opp = net->findSegment(*i)->opposite())) {
|
||||||
if (opp->getIndex() ==
|
if (opp->getIndex() ==
|
||||||
net->findSegment(*j)->getIndex()) {
|
net->findSegment(*j)->getIndex()) {
|
||||||
//cerr << "Nodes " << net->findSegment(*i)->getIndex()
|
//cerr << "Nodes " << net->findSegment(*i)->getIndex()
|
||||||
// << " and " << net->findSegment(*j)->getIndex()
|
// << " and " << net->findSegment(*j)->getIndex()
|
||||||
// << " are opposites " << endl;
|
// << " are opposites " << endl;
|
||||||
if (net->findSegment(*i)->getStart()->
|
if (net->findSegment(*i)->getStart()->
|
||||||
getIndex() == node) {
|
getIndex() == node) {
|
||||||
{
|
{
|
||||||
//cerr << "Found the node " << node << endl;
|
//cerr << "Found the node " << node << endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -400,6 +402,14 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FGTrafficRecord::isActive(int margin)
|
||||||
|
{
|
||||||
|
time_t now = time(NULL) + fgGetLong("/sim/time/warp");
|
||||||
|
time_t deptime = aircraft->getTrafficRef()->getDepartureTime();
|
||||||
|
return ((now + margin) > deptime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FGTrafficRecord::setSpeedAdjustment(double spd)
|
void FGTrafficRecord::setSpeedAdjustment(double spd)
|
||||||
{
|
{
|
||||||
instruction.setChangeSpeed(true);
|
instruction.setChangeSpeed(true);
|
||||||
|
@ -414,31 +424,12 @@ void FGTrafficRecord::setHeadingAdjustment(double heading)
|
||||||
|
|
||||||
bool FGTrafficRecord::pushBackAllowed()
|
bool FGTrafficRecord::pushBackAllowed()
|
||||||
{
|
{
|
||||||
// With the user ATC / AI integration, checking whether the user's aircraft is near no longer works, because
|
return allowPushback;
|
||||||
// this will effectively block the user's aircraft itself from receiving pushback clearance.
|
|
||||||
// So, what can we do?
|
|
||||||
/*
|
|
||||||
double course, az2, dist;
|
|
||||||
SGGeod curr(SGGeod::fromDegM(getLongitude(),
|
|
||||||
getLatitude(), getAltitude()));
|
|
||||||
|
|
||||||
double userLatitude = fgGetDouble("/position/latitude-deg");
|
|
||||||
double userLongitude = fgGetDouble("/position/longitude-deg");
|
|
||||||
SGGeod user(SGGeod::fromDeg(userLongitude, userLatitude));
|
|
||||||
SGGeodesy::inverse(curr, user, course, az2, dist);
|
|
||||||
//cerr << "Distance to user : " << dist << endl;
|
|
||||||
return (dist > 250);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// In essence, we should check whether the pusbback route itself, as well as the associcated
|
|
||||||
// taxiways near the pushback point are free of traffic.
|
|
||||||
// To do so, we need to
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* FGATCInstruction
|
* FGATCInstruction
|
||||||
*
|
*
|
||||||
|
@ -483,7 +474,7 @@ FGATCController::FGATCController()
|
||||||
|
|
||||||
FGATCController::~FGATCController()
|
FGATCController::~FGATCController()
|
||||||
{
|
{
|
||||||
//cerr << "running FGATController destructor" << endl;
|
//cerr << "running FGATController destructor" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
string FGATCController::getGateName(FGAIAircraft * ref)
|
string FGATCController::getGateName(FGAIAircraft * ref)
|
||||||
|
@ -585,11 +576,11 @@ void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||||
getRunwayClassFromTrafficType(fltType);
|
getRunwayClassFromTrafficType(fltType);
|
||||||
|
|
||||||
rec->getAircraft()->getTrafficRef()->getDepartureAirport()->
|
rec->getAircraft()->getTrafficRef()->getDepartureAirport()->
|
||||||
getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
|
getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
|
||||||
heading);
|
heading);
|
||||||
rec->getAircraft()->GetFlightPlan()->setRunway(activeRunway);
|
rec->getAircraft()->GetFlightPlan()->setRunway(activeRunway);
|
||||||
fp = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->
|
fp = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->
|
||||||
getDynamics()->getSID(activeRunway, heading);
|
getDynamics()->getSID(activeRunway, heading);
|
||||||
rec->getAircraft()->GetFlightPlan()->setSID(fp);
|
rec->getAircraft()->GetFlightPlan()->setSID(fp);
|
||||||
if (fp) {
|
if (fp) {
|
||||||
SID = fp->getName() + " departure";
|
SID = fp->getName() + " departure";
|
||||||
|
@ -682,16 +673,16 @@ void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||||
activeRunway = rec->getAircraft()->GetFlightPlan()->getRunway();
|
activeRunway = rec->getAircraft()->GetFlightPlan()->getRunway();
|
||||||
//activeRunway = "test";
|
//activeRunway = "test";
|
||||||
text = receiver + ". Holding short runway "
|
text = receiver + ". Holding short runway "
|
||||||
+ activeRunway
|
+ activeRunway
|
||||||
+ ". " + sender;
|
+ ". " + sender;
|
||||||
//text = "test1";
|
//text = "test1";
|
||||||
//cerr << "1 Currently at leg " << rec->getLeg() << endl;
|
//cerr << "1 Currently at leg " << rec->getLeg() << endl;
|
||||||
break;
|
break;
|
||||||
case MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT:
|
case MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT:
|
||||||
activeRunway = rec->getAircraft()->GetFlightPlan()->getRunway();
|
activeRunway = rec->getAircraft()->GetFlightPlan()->getRunway();
|
||||||
text = receiver + "Roger. Holding short runway "
|
text = receiver + "Roger. Holding short runway "
|
||||||
// + activeRunway
|
// + activeRunway
|
||||||
+ ". " + sender;
|
+ ". " + sender;
|
||||||
//text = "test2";
|
//text = "test2";
|
||||||
//cerr << "2 Currently at leg " << rec->getLeg() << endl;
|
//cerr << "2 Currently at leg " << rec->getLeg() << endl;
|
||||||
break;
|
break;
|
||||||
|
@ -725,7 +716,7 @@ void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||||
// the relevant frequency.
|
// the relevant frequency.
|
||||||
// Note that distance attenuation is currently not yet implemented
|
// Note that distance attenuation is currently not yet implemented
|
||||||
if ((onBoardRadioFreqI0 == stationFreq)
|
if ((onBoardRadioFreqI0 == stationFreq)
|
||||||
|| (onBoardRadioFreqI1 == stationFreq)) {
|
|| (onBoardRadioFreqI1 == stationFreq)) {
|
||||||
if (rec->allowTransmissions()) {
|
if (rec->allowTransmissions()) {
|
||||||
fgSetString("/sim/messages/atc", text.c_str());
|
fgSetString("/sim/messages/atc", text.c_str());
|
||||||
}
|
}
|
||||||
|
@ -758,10 +749,10 @@ string FGATCController::genTransponderCode(string fltRules)
|
||||||
|
|
||||||
void FGATCController::init()
|
void FGATCController::init()
|
||||||
{
|
{
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
FGATCManager *mgr = (FGATCManager*) globals->get_subsystem("ATC");
|
FGATCManager *mgr = (FGATCManager*) globals->get_subsystem("ATC");
|
||||||
mgr->addController(this);
|
mgr->addController(this);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,19 +761,19 @@ void FGATCController::init()
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
FGTowerController::FGTowerController(FGAirportDynamics *par) :
|
FGTowerController::FGTowerController(FGAirportDynamics *par) :
|
||||||
FGATCController()
|
FGATCController()
|
||||||
{
|
{
|
||||||
parent = par;
|
parent = par;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void FGTowerController::announcePosition(int id,
|
void FGTowerController::announcePosition(int id,
|
||||||
FGAIFlightPlan * intendedRoute,
|
FGAIFlightPlan * intendedRoute,
|
||||||
int currentPosition, double lat,
|
int currentPosition, double lat,
|
||||||
double lon, double heading,
|
double lon, double heading,
|
||||||
double speed, double alt,
|
double speed, double alt,
|
||||||
double radius, int leg,
|
double radius, int leg,
|
||||||
FGAIAircraft * ref)
|
FGAIAircraft * ref)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
|
@ -835,8 +826,8 @@ void FGTowerController::announcePosition(int id,
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGTowerController::updateAircraftInformation(int id, double lat, double lon,
|
void FGTowerController::updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt,
|
double heading, double speed, double alt,
|
||||||
double dt)
|
double dt)
|
||||||
{
|
{
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
// Search whether the current id has an entry
|
// Search whether the current id has an entry
|
||||||
|
@ -899,6 +890,8 @@ void FGTowerController::updateAircraftInformation(int id, double lat, double lon
|
||||||
rwy->setCleared(id);
|
rwy->setCleared(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,6 +999,11 @@ string FGTowerController::getName() {
|
||||||
return string(parent->getId() + "-tower");
|
return string(parent->getId() + "-tower");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGTowerController::update(double dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
@ -1013,18 +1011,18 @@ string FGTowerController::getName() {
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
FGStartupController::FGStartupController(FGAirportDynamics *par):
|
FGStartupController::FGStartupController(FGAirportDynamics *par):
|
||||||
FGATCController()
|
FGATCController()
|
||||||
{
|
{
|
||||||
parent = par;
|
parent = par;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGStartupController::announcePosition(int id,
|
void FGStartupController::announcePosition(int id,
|
||||||
FGAIFlightPlan * intendedRoute,
|
FGAIFlightPlan * intendedRoute,
|
||||||
int currentPosition, double lat,
|
int currentPosition, double lat,
|
||||||
double lon, double heading,
|
double lon, double heading,
|
||||||
double speed, double alt,
|
double speed, double alt,
|
||||||
double radius, int leg,
|
double radius, int leg,
|
||||||
FGAIAircraft * ref)
|
FGAIAircraft * ref)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
|
@ -1136,7 +1134,7 @@ void FGStartupController::signOff(int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGStartupController::checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId,
|
bool FGStartupController::checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId,
|
||||||
AtcMsgDir msgDir)
|
AtcMsgDir msgDir)
|
||||||
{
|
{
|
||||||
int state = i->getState();
|
int state = i->getState();
|
||||||
if ((state == st) && available) {
|
if ((state == st) && available) {
|
||||||
|
@ -1147,9 +1145,9 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star
|
||||||
int n = trans_num->getIntValue();
|
int n = trans_num->getIntValue();
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
trans_num->setIntValue(-1);
|
trans_num->setIntValue(-1);
|
||||||
// PopupCallback(n);
|
// PopupCallback(n);
|
||||||
//cerr << "Selected transmission message " << n << endl;
|
//cerr << "Selected transmission message " << n << endl;
|
||||||
FGATCDialogNew::instance()->removeEntry(1);
|
FGATCDialogNew::instance()->removeEntry(1);
|
||||||
} else {
|
} else {
|
||||||
//cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
|
//cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
|
||||||
transmit(&(*i), msgId, msgDir, false);
|
transmit(&(*i), msgId, msgDir, false);
|
||||||
|
@ -1169,8 +1167,8 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGStartupController::updateAircraftInformation(int id, double lat, double lon,
|
void FGStartupController::updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt,
|
double heading, double speed, double alt,
|
||||||
double dt)
|
double dt)
|
||||||
{
|
{
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
// Search search if the current id has an entry
|
// Search search if the current id has an entry
|
||||||
|
@ -1269,10 +1267,10 @@ void FGStartupController::render(bool visible)
|
||||||
//while (group->getNumChildren()) {
|
//while (group->getNumChildren()) {
|
||||||
// cerr << "Number of children: " << group->getNumChildren() << endl;
|
// cerr << "Number of children: " << group->getNumChildren() << endl;
|
||||||
//simgear::EffectGeode* geode = (simgear::EffectGeode*) group->getChild(0);
|
//simgear::EffectGeode* geode = (simgear::EffectGeode*) group->getChild(0);
|
||||||
//osg::MatrixTransform *obj_trans = (osg::MatrixTransform*) group->getChild(0);
|
//osg::MatrixTransform *obj_trans = (osg::MatrixTransform*) group->getChild(0);
|
||||||
//geode->releaseGLObjects();
|
//geode->releaseGLObjects();
|
||||||
//group->removeChild(geode);
|
//group->removeChild(geode);
|
||||||
//delete geode;
|
//delete geode;
|
||||||
group = 0;
|
group = 0;
|
||||||
}
|
}
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
@ -1285,108 +1283,39 @@ void FGStartupController::render(bool visible)
|
||||||
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
|
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
|
||||||
double dx = 0;
|
double dx = 0;
|
||||||
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
||||||
// Handle start point
|
if (i->isActive(300)) {
|
||||||
int pos = i->getCurrentPosition();
|
// Handle start point
|
||||||
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
|
int pos = i->getCurrentPosition();
|
||||||
if (pos > 0) {
|
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
|
||||||
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(pos);
|
if (pos > 0) {
|
||||||
SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
|
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(pos);
|
||||||
SGGeod end (SGGeod::fromDeg(segment->getEnd()->getLongitude(), segment->getEnd()->getLatitude()));
|
SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
|
||||||
|
SGGeod end (SGGeod::fromDeg(segment->getEnd()->getLongitude(), segment->getEnd()->getLatitude()));
|
||||||
|
|
||||||
double length = SGGeodesy::distanceM(start, end);
|
double length = SGGeodesy::distanceM(start, end);
|
||||||
//heading = SGGeodesy::headingDeg(start->getGeod(), end->getGeod());
|
//heading = SGGeodesy::headingDeg(start->getGeod(), end->getGeod());
|
||||||
|
|
||||||
double az2, heading; //, distanceM;
|
double az2, heading; //, distanceM;
|
||||||
SGGeodesy::inverse(start, end, heading, az2, length);
|
SGGeodesy::inverse(start, end, heading, az2, length);
|
||||||
double coveredDistance = length * 0.5;
|
double coveredDistance = length * 0.5;
|
||||||
SGGeod center;
|
SGGeod center;
|
||||||
SGGeodesy::direct(start, heading, coveredDistance, center, az2);
|
SGGeodesy::direct(start, heading, coveredDistance, center, az2);
|
||||||
//cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
|
//cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Make a helper function out of this
|
// Make a helper function out of this
|
||||||
osg::Matrix obj_pos;
|
osg::Matrix obj_pos;
|
||||||
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
|
||||||
obj_trans->setDataVariance(osg::Object::STATIC);
|
|
||||||
// Experimental: Calculate slope here, based on length, and the individual elevations
|
|
||||||
double elevationStart;
|
|
||||||
if (isUserAircraft((i)->getAircraft())) {
|
|
||||||
elevationStart = fgGetDouble("/position/ground-elev-m");
|
|
||||||
} else {
|
|
||||||
elevationStart = ((i)->getAircraft()->_getAltitude());
|
|
||||||
}
|
|
||||||
double elevationEnd = segment->getEnd()->getElevation();
|
|
||||||
if ((elevationEnd == 0) || (elevationEnd == parent->getElevation())) {
|
|
||||||
SGGeod center2 = end;
|
|
||||||
center2.setElevationM(SG_MAX_ELEVATION_M);
|
|
||||||
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
|
|
||||||
elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
|
|
||||||
//elevation_meters += 0.5;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
elevationEnd = parent->getElevation();
|
|
||||||
}
|
|
||||||
segment->getEnd()->setElevation(elevationEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
double elevationMean = (elevationStart + elevationEnd) / 2.0;
|
|
||||||
double elevDiff = elevationEnd - elevationStart;
|
|
||||||
|
|
||||||
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
|
||||||
|
|
||||||
//cerr << "1. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
|
||||||
|
|
||||||
WorldCoordinate( obj_pos, center.getLatitudeDeg(), center.getLongitudeDeg(), elevationMean + 0.5, -(heading), slope );
|
|
||||||
;
|
|
||||||
|
|
||||||
obj_trans->setMatrix( obj_pos );
|
|
||||||
//osg::Vec3 center(0, 0, 0)
|
|
||||||
|
|
||||||
float width = length /2.0;
|
|
||||||
osg::Vec3 corner(-width, 0, 0.25f);
|
|
||||||
osg::Vec3 widthVec(2*width + 1, 0, 0);
|
|
||||||
osg::Vec3 heightVec(0, 1, 0);
|
|
||||||
osg::Geometry* geometry;
|
|
||||||
geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec);
|
|
||||||
simgear::EffectGeode* geode = new simgear::EffectGeode;
|
|
||||||
geode->setName("test");
|
|
||||||
geode->addDrawable(geometry);
|
|
||||||
//osg::Node *custom_obj;
|
|
||||||
SGMaterial *mat = matlib->find("UnidirectionalTaper");
|
|
||||||
if (mat)
|
|
||||||
geode->setEffect(mat->get_effect());
|
|
||||||
obj_trans->addChild(geode);
|
|
||||||
// wire as much of the scene graph together as we can
|
|
||||||
//->addChild( obj_trans );
|
|
||||||
group->addChild( obj_trans );
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
} else {
|
|
||||||
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
|
||||||
}
|
|
||||||
for(intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
|
||||||
osg::Matrix obj_pos;
|
|
||||||
int k = (*j);
|
|
||||||
if (k > 0) {
|
|
||||||
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "intention = " << k << endl;
|
|
||||||
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
||||||
obj_trans->setDataVariance(osg::Object::STATIC);
|
obj_trans->setDataVariance(osg::Object::STATIC);
|
||||||
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(k);
|
// Experimental: Calculate slope here, based on length, and the individual elevations
|
||||||
|
double elevationStart;
|
||||||
double elevationStart = segment->getStart()->getElevation();
|
if (isUserAircraft((i)->getAircraft())) {
|
||||||
double elevationEnd = segment->getEnd ()->getElevation();
|
elevationStart = fgGetDouble("/position/ground-elev-m");
|
||||||
if ((elevationStart == 0) || (elevationStart == parent->getElevation())) {
|
} else {
|
||||||
SGGeod center2 = segment->getStart()->getGeod();
|
elevationStart = ((i)->getAircraft()->_getAltitude() * SG_FEET_TO_METER);
|
||||||
center2.setElevationM(SG_MAX_ELEVATION_M);
|
|
||||||
if (local_scenery->get_elevation_m( center2, elevationStart, NULL )) {
|
|
||||||
elevation_feet = elevationStart * SG_METER_TO_FEET + 0.5;
|
|
||||||
//elevation_meters += 0.5;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
elevationStart = parent->getElevation();
|
|
||||||
}
|
|
||||||
segment->getStart()->setElevation(elevationStart);
|
|
||||||
}
|
}
|
||||||
|
double elevationEnd = segment->getEnd()->getElevation();
|
||||||
if ((elevationEnd == 0) || (elevationEnd == parent->getElevation())) {
|
if ((elevationEnd == 0) || (elevationEnd == parent->getElevation())) {
|
||||||
SGGeod center2 = segment->getEnd()->getGeod();
|
SGGeod center2 = end;
|
||||||
center2.setElevationM(SG_MAX_ELEVATION_M);
|
center2.setElevationM(SG_MAX_ELEVATION_M);
|
||||||
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
|
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
|
||||||
elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
|
elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
|
||||||
|
@ -1400,20 +1329,18 @@ void FGStartupController::render(bool visible)
|
||||||
|
|
||||||
double elevationMean = (elevationStart + elevationEnd) / 2.0;
|
double elevationMean = (elevationStart + elevationEnd) / 2.0;
|
||||||
double elevDiff = elevationEnd - elevationStart;
|
double elevDiff = elevationEnd - elevationStart;
|
||||||
double length = segment->getLength();
|
|
||||||
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
||||||
|
|
||||||
//cerr << "2. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
//cerr << "1. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
||||||
|
|
||||||
|
WorldCoordinate( obj_pos, center.getLatitudeDeg(), center.getLongitudeDeg(), elevationMean + 0.5 + dx, -(heading), slope );
|
||||||
WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), elevationMean + 0.5, -(segment->getHeading()), slope );
|
;
|
||||||
|
|
||||||
//WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), parent->getElevation()+8+dx, -(segment->getHeading()) );
|
|
||||||
|
|
||||||
obj_trans->setMatrix( obj_pos );
|
obj_trans->setMatrix( obj_pos );
|
||||||
//osg::Vec3 center(0, 0, 0)
|
//osg::Vec3 center(0, 0, 0)
|
||||||
|
|
||||||
float width = segment->getLength() /2.0;
|
float width = length /2.0;
|
||||||
osg::Vec3 corner(-width, 0, 0.25f);
|
osg::Vec3 corner(-width, 0, 0.25f);
|
||||||
osg::Vec3 widthVec(2*width + 1, 0, 0);
|
osg::Vec3 widthVec(2*width + 1, 0, 0);
|
||||||
osg::Vec3 heightVec(0, 1, 0);
|
osg::Vec3 heightVec(0, 1, 0);
|
||||||
|
@ -1423,18 +1350,101 @@ void FGStartupController::render(bool visible)
|
||||||
geode->setName("test");
|
geode->setName("test");
|
||||||
geode->addDrawable(geometry);
|
geode->addDrawable(geometry);
|
||||||
//osg::Node *custom_obj;
|
//osg::Node *custom_obj;
|
||||||
SGMaterial *mat = matlib->find("UnidirectionalTaper");
|
SGMaterial *mat;
|
||||||
|
if (segment->hasBlock()) {
|
||||||
|
mat = matlib->find("UnidirectionalTaperRed");
|
||||||
|
} else {
|
||||||
|
mat = matlib->find("UnidirectionalTaperGreen");
|
||||||
|
}
|
||||||
if (mat)
|
if (mat)
|
||||||
geode->setEffect(mat->get_effect());
|
geode->setEffect(mat->get_effect());
|
||||||
obj_trans->addChild(geode);
|
obj_trans->addChild(geode);
|
||||||
// wire as much of the scene graph together as we can
|
// wire as much of the scene graph together as we can
|
||||||
//->addChild( obj_trans );
|
//->addChild( obj_trans );
|
||||||
group->addChild( obj_trans );
|
group->addChild( obj_trans );
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
} else {
|
} else {
|
||||||
//cerr << "BIG FAT WARNING: k is here : " << pos << endl;
|
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
||||||
}
|
}
|
||||||
|
for (intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
||||||
|
osg::Matrix obj_pos;
|
||||||
|
int k = (*j);
|
||||||
|
if (k > 0) {
|
||||||
|
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "intention = " << k << endl;
|
||||||
|
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
||||||
|
obj_trans->setDataVariance(osg::Object::STATIC);
|
||||||
|
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(k);
|
||||||
|
|
||||||
|
double elevationStart = segment->getStart()->getElevation();
|
||||||
|
double elevationEnd = segment->getEnd ()->getElevation();
|
||||||
|
if ((elevationStart == 0) || (elevationStart == parent->getElevation())) {
|
||||||
|
SGGeod center2 = segment->getStart()->getGeod();
|
||||||
|
center2.setElevationM(SG_MAX_ELEVATION_M);
|
||||||
|
if (local_scenery->get_elevation_m( center2, elevationStart, NULL )) {
|
||||||
|
elevation_feet = elevationStart * SG_METER_TO_FEET + 0.5;
|
||||||
|
//elevation_meters += 0.5;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elevationStart = parent->getElevation();
|
||||||
|
}
|
||||||
|
segment->getStart()->setElevation(elevationStart);
|
||||||
|
}
|
||||||
|
if ((elevationEnd == 0) || (elevationEnd == parent->getElevation())) {
|
||||||
|
SGGeod center2 = segment->getEnd()->getGeod();
|
||||||
|
center2.setElevationM(SG_MAX_ELEVATION_M);
|
||||||
|
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
|
||||||
|
elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
|
||||||
|
//elevation_meters += 0.5;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elevationEnd = parent->getElevation();
|
||||||
|
}
|
||||||
|
segment->getEnd()->setElevation(elevationEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
double elevationMean = (elevationStart + elevationEnd) / 2.0;
|
||||||
|
double elevDiff = elevationEnd - elevationStart;
|
||||||
|
double length = segment->getLength();
|
||||||
|
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
||||||
|
|
||||||
|
//cerr << "2. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
||||||
|
|
||||||
|
|
||||||
|
WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), elevationMean + 0.5 + dx, -(segment->getHeading()), slope );
|
||||||
|
|
||||||
|
//WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), parent->getElevation()+8+dx, -(segment->getHeading()) );
|
||||||
|
|
||||||
|
obj_trans->setMatrix( obj_pos );
|
||||||
|
//osg::Vec3 center(0, 0, 0)
|
||||||
|
|
||||||
|
float width = segment->getLength() /2.0;
|
||||||
|
osg::Vec3 corner(-width, 0, 0.25f);
|
||||||
|
osg::Vec3 widthVec(2*width + 1, 0, 0);
|
||||||
|
osg::Vec3 heightVec(0, 1, 0);
|
||||||
|
osg::Geometry* geometry;
|
||||||
|
geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec);
|
||||||
|
simgear::EffectGeode* geode = new simgear::EffectGeode;
|
||||||
|
geode->setName("test");
|
||||||
|
geode->addDrawable(geometry);
|
||||||
|
//osg::Node *custom_obj;
|
||||||
|
SGMaterial *mat;
|
||||||
|
if (segment->hasBlock()) {
|
||||||
|
mat = matlib->find("UnidirectionalTaperRed");
|
||||||
|
} else {
|
||||||
|
mat = matlib->find("UnidirectionalTaperGreen");
|
||||||
|
}
|
||||||
|
if (mat)
|
||||||
|
geode->setEffect(mat->get_effect());
|
||||||
|
obj_trans->addChild(geode);
|
||||||
|
// wire as much of the scene graph together as we can
|
||||||
|
//->addChild( obj_trans );
|
||||||
|
group->addChild( obj_trans );
|
||||||
|
} else {
|
||||||
|
//cerr << "BIG FAT WARNING: k is here : " << pos << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dx += 0.2;
|
||||||
}
|
}
|
||||||
//dx += 0.1;
|
|
||||||
}
|
}
|
||||||
globals->get_scenery()->get_scene_graph()->addChild(group);
|
globals->get_scenery()->get_scene_graph()->addChild(group);
|
||||||
}
|
}
|
||||||
|
@ -1444,25 +1454,31 @@ string FGStartupController::getName() {
|
||||||
return string(parent->getId() + "-startup");
|
return string(parent->getId() + "-startup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGStartupController::update(double dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* class FGApproachController
|
* class FGApproachController
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
FGApproachController::FGApproachController(FGAirportDynamics *par):
|
FGApproachController::FGApproachController(FGAirportDynamics *par):
|
||||||
FGATCController()
|
FGATCController()
|
||||||
{
|
{
|
||||||
parent = par;
|
parent = par;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void FGApproachController::announcePosition(int id,
|
void FGApproachController::announcePosition(int id,
|
||||||
FGAIFlightPlan * intendedRoute,
|
FGAIFlightPlan * intendedRoute,
|
||||||
int currentPosition,
|
int currentPosition,
|
||||||
double lat, double lon,
|
double lat, double lon,
|
||||||
double heading, double speed,
|
double heading, double speed,
|
||||||
double alt, double radius,
|
double alt, double radius,
|
||||||
int leg, FGAIAircraft * ref)
|
int leg, FGAIAircraft * ref)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
|
@ -1494,8 +1510,8 @@ void FGApproachController::announcePosition(int id,
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGApproachController::updateAircraftInformation(int id, double lat, double lon,
|
void FGApproachController::updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt,
|
double heading, double speed, double alt,
|
||||||
double dt)
|
double dt)
|
||||||
{
|
{
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
// Search search if the current id has an entry
|
// Search search if the current id has an entry
|
||||||
|
@ -1567,6 +1583,10 @@ void FGApproachController::signOff(int id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGApproachController::update(double dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,14 @@
|
||||||
#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>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using std::list;
|
||||||
|
|
||||||
|
|
||||||
typedef vector<int> intVec;
|
typedef vector<int> intVec;
|
||||||
|
@ -62,43 +65,79 @@ class FGAirportDynamics;
|
||||||
class FGATCInstruction
|
class FGATCInstruction
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool holdPattern;
|
bool holdPattern;
|
||||||
bool holdPosition;
|
bool holdPosition;
|
||||||
bool changeSpeed;
|
bool changeSpeed;
|
||||||
bool changeHeading;
|
bool changeHeading;
|
||||||
bool changeAltitude;
|
bool changeAltitude;
|
||||||
bool resolveCircularWait;
|
bool resolveCircularWait;
|
||||||
|
|
||||||
double speed;
|
double speed;
|
||||||
double heading;
|
double heading;
|
||||||
double alt;
|
double alt;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGATCInstruction();
|
FGATCInstruction();
|
||||||
bool hasInstruction ();
|
bool hasInstruction ();
|
||||||
bool getHoldPattern () { return holdPattern; };
|
bool getHoldPattern () {
|
||||||
bool getHoldPosition () { return holdPosition; };
|
return holdPattern;
|
||||||
bool getChangeSpeed () { return changeSpeed; };
|
};
|
||||||
bool getChangeHeading () { return changeHeading; };
|
bool getHoldPosition () {
|
||||||
bool getChangeAltitude() { return changeAltitude; };
|
return holdPosition;
|
||||||
|
};
|
||||||
|
bool getChangeSpeed () {
|
||||||
|
return changeSpeed;
|
||||||
|
};
|
||||||
|
bool getChangeHeading () {
|
||||||
|
return changeHeading;
|
||||||
|
};
|
||||||
|
bool getChangeAltitude() {
|
||||||
|
return changeAltitude;
|
||||||
|
};
|
||||||
|
|
||||||
double getSpeed () { return speed; };
|
double getSpeed () {
|
||||||
double getHeading () { return heading; };
|
return speed;
|
||||||
double getAlt () { return alt; };
|
};
|
||||||
|
double getHeading () {
|
||||||
|
return heading;
|
||||||
|
};
|
||||||
|
double getAlt () {
|
||||||
|
return alt;
|
||||||
|
};
|
||||||
|
|
||||||
bool getCheckForCircularWait() { return resolveCircularWait; };
|
bool getCheckForCircularWait() {
|
||||||
|
return resolveCircularWait;
|
||||||
|
};
|
||||||
|
|
||||||
void setHoldPattern (bool val) { holdPattern = val; };
|
void setHoldPattern (bool val) {
|
||||||
void setHoldPosition (bool val) { holdPosition = val; };
|
holdPattern = val;
|
||||||
void setChangeSpeed (bool val) { changeSpeed = val; };
|
};
|
||||||
void setChangeHeading (bool val) { changeHeading = val; };
|
void setHoldPosition (bool val) {
|
||||||
void setChangeAltitude(bool val) { changeAltitude = val; };
|
holdPosition = val;
|
||||||
|
};
|
||||||
|
void setChangeSpeed (bool val) {
|
||||||
|
changeSpeed = val;
|
||||||
|
};
|
||||||
|
void setChangeHeading (bool val) {
|
||||||
|
changeHeading = val;
|
||||||
|
};
|
||||||
|
void setChangeAltitude(bool val) {
|
||||||
|
changeAltitude = val;
|
||||||
|
};
|
||||||
|
|
||||||
void setResolveCircularWait (bool val) { resolveCircularWait = val; };
|
void setResolveCircularWait (bool val) {
|
||||||
|
resolveCircularWait = val;
|
||||||
|
};
|
||||||
|
|
||||||
void setSpeed (double val) { speed = val; };
|
void setSpeed (double val) {
|
||||||
void setHeading (double val) { heading = val; };
|
speed = val;
|
||||||
void setAlt (double val) { alt = val; };
|
};
|
||||||
|
void setHeading (double val) {
|
||||||
|
heading = val;
|
||||||
|
};
|
||||||
|
void setAlt (double val) {
|
||||||
|
alt = val;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,88 +150,175 @@ public:
|
||||||
class FGTrafficRecord
|
class FGTrafficRecord
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int id, waitsForId;
|
int id, waitsForId;
|
||||||
int currentPos;
|
int currentPos;
|
||||||
int leg;
|
int leg;
|
||||||
int frequencyId;
|
int frequencyId;
|
||||||
int state;
|
int state;
|
||||||
bool allowTransmission;
|
bool allowTransmission;
|
||||||
time_t timer;
|
bool allowPushback;
|
||||||
intVec intentions;
|
int priority;
|
||||||
FGATCInstruction instruction;
|
time_t timer;
|
||||||
double latitude, longitude, heading, speed, altitude, radius;
|
intVec intentions;
|
||||||
string runway;
|
FGATCInstruction instruction;
|
||||||
//FGAISchedule *trafficRef;
|
double latitude, longitude, heading, speed, altitude, radius;
|
||||||
FGAIAircraft *aircraft;
|
string runway;
|
||||||
|
//FGAISchedule *trafficRef;
|
||||||
|
FGAIAircraft *aircraft;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTrafficRecord();
|
FGTrafficRecord();
|
||||||
|
|
||||||
void setId(int val) { id = val; };
|
void setId(int val) {
|
||||||
void setRadius(double rad) { radius = rad;};
|
id = val;
|
||||||
void setPositionAndIntentions(int pos, FGAIFlightPlan *route);
|
};
|
||||||
void setRunway(string rwy) { runway = rwy;};
|
void setRadius(double rad) {
|
||||||
void setLeg(int lg) { leg = lg;};
|
radius = rad;
|
||||||
int getId() { return id;};
|
};
|
||||||
int getState() { return state;};
|
void setPositionAndIntentions(int pos, FGAIFlightPlan *route);
|
||||||
void setState(int s) { state = s;}
|
void setRunway(string rwy) {
|
||||||
FGATCInstruction getInstruction() { return instruction;};
|
runway = rwy;
|
||||||
bool hasInstruction() { return instruction.hasInstruction(); };
|
};
|
||||||
void setPositionAndHeading(double lat, double lon, double hdg, double spd, double alt);
|
void setLeg(int lg) {
|
||||||
bool checkPositionAndIntentions(FGTrafficRecord &other);
|
leg = lg;
|
||||||
int crosses (FGGroundNetwork *, FGTrafficRecord &other);
|
};
|
||||||
bool isOpposing (FGGroundNetwork *, FGTrafficRecord &other, int node);
|
int getId() {
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
int getState() {
|
||||||
|
return state;
|
||||||
|
};
|
||||||
|
void setState(int s) {
|
||||||
|
state = s;
|
||||||
|
}
|
||||||
|
FGATCInstruction getInstruction() {
|
||||||
|
return instruction;
|
||||||
|
};
|
||||||
|
bool hasInstruction() {
|
||||||
|
return instruction.hasInstruction();
|
||||||
|
};
|
||||||
|
void setPositionAndHeading(double lat, double lon, double hdg, double spd, double alt);
|
||||||
|
bool checkPositionAndIntentions(FGTrafficRecord &other);
|
||||||
|
int crosses (FGGroundNetwork *, FGTrafficRecord &other);
|
||||||
|
bool isOpposing (FGGroundNetwork *, FGTrafficRecord &other, int node);
|
||||||
|
|
||||||
bool onRoute(FGGroundNetwork *, FGTrafficRecord &other);
|
bool isActive(int margin);
|
||||||
|
|
||||||
bool getSpeedAdjustment() { return instruction.getChangeSpeed(); };
|
bool onRoute(FGGroundNetwork *, FGTrafficRecord &other);
|
||||||
|
|
||||||
double getLatitude () { return latitude ; };
|
bool getSpeedAdjustment() {
|
||||||
double getLongitude() { return longitude; };
|
return instruction.getChangeSpeed();
|
||||||
double getHeading () { return heading ; };
|
};
|
||||||
double getSpeed () { return speed ; };
|
|
||||||
double getAltitude () { return altitude ; };
|
|
||||||
double getRadius () { return radius ; };
|
|
||||||
|
|
||||||
int getWaitsForId () { return waitsForId; };
|
double getLatitude () {
|
||||||
|
return latitude ;
|
||||||
|
};
|
||||||
|
double getLongitude() {
|
||||||
|
return longitude;
|
||||||
|
};
|
||||||
|
double getHeading () {
|
||||||
|
return heading ;
|
||||||
|
};
|
||||||
|
double getSpeed () {
|
||||||
|
return speed ;
|
||||||
|
};
|
||||||
|
double getAltitude () {
|
||||||
|
return altitude ;
|
||||||
|
};
|
||||||
|
double getRadius () {
|
||||||
|
return radius ;
|
||||||
|
};
|
||||||
|
|
||||||
void setSpeedAdjustment(double spd);
|
int getWaitsForId () {
|
||||||
void setHeadingAdjustment(double heading);
|
return waitsForId;
|
||||||
void clearSpeedAdjustment () { instruction.setChangeSpeed (false); };
|
};
|
||||||
void clearHeadingAdjustment() { instruction.setChangeHeading(false); };
|
|
||||||
|
|
||||||
bool hasHeadingAdjustment() { return instruction.getChangeHeading(); };
|
void setSpeedAdjustment(double spd);
|
||||||
bool hasHoldPosition() { return instruction.getHoldPosition(); };
|
void setHeadingAdjustment(double heading);
|
||||||
void setHoldPosition (bool inst) { instruction.setHoldPosition(inst); };
|
void clearSpeedAdjustment () {
|
||||||
|
instruction.setChangeSpeed (false);
|
||||||
|
};
|
||||||
|
void clearHeadingAdjustment() {
|
||||||
|
instruction.setChangeHeading(false);
|
||||||
|
};
|
||||||
|
|
||||||
void setWaitsForId(int id) { waitsForId = id; };
|
bool hasHeadingAdjustment() {
|
||||||
|
return instruction.getChangeHeading();
|
||||||
|
};
|
||||||
|
bool hasHoldPosition() {
|
||||||
|
return instruction.getHoldPosition();
|
||||||
|
};
|
||||||
|
void setHoldPosition (bool inst) {
|
||||||
|
instruction.setHoldPosition(inst);
|
||||||
|
};
|
||||||
|
|
||||||
void setResolveCircularWait() { instruction.setResolveCircularWait(true); };
|
void setWaitsForId(int id) {
|
||||||
void clearResolveCircularWait() { instruction.setResolveCircularWait(false); };
|
waitsForId = id;
|
||||||
|
};
|
||||||
|
|
||||||
string getRunway() { return runway; };
|
void setResolveCircularWait() {
|
||||||
//void setCallSign(string clsgn) { callsign = clsgn; };
|
instruction.setResolveCircularWait(true);
|
||||||
void setAircraft(FGAIAircraft *ref) { aircraft = ref;};
|
};
|
||||||
void updateState() { state++; allowTransmission=true; };
|
void clearResolveCircularWait() {
|
||||||
//string getCallSign() { return callsign; };
|
instruction.setResolveCircularWait(false);
|
||||||
FGAIAircraft *getAircraft() { return aircraft;};
|
};
|
||||||
int getTime() { return timer; };
|
|
||||||
int getLeg() { return leg; };
|
|
||||||
void setTime(time_t time) { timer = time; };
|
|
||||||
|
|
||||||
bool pushBackAllowed();
|
string getRunway() {
|
||||||
bool allowTransmissions() { return allowTransmission; };
|
return runway;
|
||||||
void suppressRepeatedTransmissions () { allowTransmission=false; };
|
};
|
||||||
void allowRepeatedTransmissions () { allowTransmission=true; };
|
//void setCallSign(string clsgn) { callsign = clsgn; };
|
||||||
void nextFrequency() { frequencyId++; };
|
void setAircraft(FGAIAircraft *ref) {
|
||||||
int getNextFrequency() { return frequencyId; };
|
aircraft = ref;
|
||||||
intVec& getIntentions() { return intentions; };
|
};
|
||||||
int getCurrentPosition() { return currentPos; };
|
void updateState() {
|
||||||
|
state++;
|
||||||
|
allowTransmission=true;
|
||||||
|
};
|
||||||
|
//string getCallSign() { return callsign; };
|
||||||
|
FGAIAircraft *getAircraft() {
|
||||||
|
return aircraft;
|
||||||
|
};
|
||||||
|
int getTime() {
|
||||||
|
return timer;
|
||||||
|
};
|
||||||
|
int getLeg() {
|
||||||
|
return leg;
|
||||||
|
};
|
||||||
|
void setTime(time_t time) {
|
||||||
|
timer = time;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool pushBackAllowed();
|
||||||
|
bool allowTransmissions() {
|
||||||
|
return allowTransmission;
|
||||||
|
};
|
||||||
|
void allowPushBack() { allowPushback =true;};
|
||||||
|
void denyPushBack () { allowPushback = false;};
|
||||||
|
void suppressRepeatedTransmissions () {
|
||||||
|
allowTransmission=false;
|
||||||
|
};
|
||||||
|
void allowRepeatedTransmissions () {
|
||||||
|
allowTransmission=true;
|
||||||
|
};
|
||||||
|
void nextFrequency() {
|
||||||
|
frequencyId++;
|
||||||
|
};
|
||||||
|
int getNextFrequency() {
|
||||||
|
return frequencyId;
|
||||||
|
};
|
||||||
|
intVec& getIntentions() {
|
||||||
|
return intentions;
|
||||||
|
};
|
||||||
|
int getCurrentPosition() {
|
||||||
|
return currentPos;
|
||||||
|
};
|
||||||
|
void setPriority(int p) { priority = p; };
|
||||||
|
int getPriority() { return priority; };
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<FGTrafficRecord> TrafficVector;
|
typedef list<FGTrafficRecord> TrafficVector;
|
||||||
typedef vector<FGTrafficRecord>::iterator TrafficVectorIterator;
|
typedef list<FGTrafficRecord>::iterator TrafficVectorIterator;
|
||||||
|
|
||||||
typedef vector<time_t> TimeVector;
|
typedef vector<time_t> TimeVector;
|
||||||
typedef vector<time_t>::iterator TimeVectorIterator;
|
typedef vector<time_t>::iterator TimeVectorIterator;
|
||||||
|
@ -207,28 +333,48 @@ typedef vector<FGAIAircraft*>::iterator AircraftVecIterator;
|
||||||
class ActiveRunway
|
class ActiveRunway
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string rwy;
|
string rwy;
|
||||||
int currentlyCleared;
|
int currentlyCleared;
|
||||||
double distanceToFinal;
|
double distanceToFinal;
|
||||||
TimeVector estimatedArrivalTimes;
|
TimeVector estimatedArrivalTimes;
|
||||||
AircraftVec departureCue;
|
AircraftVec departureCue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActiveRunway(string r, int cc) { rwy = r; currentlyCleared = cc; distanceToFinal = 6.0 * SG_NM_TO_METER; };
|
ActiveRunway(string r, int cc) {
|
||||||
|
rwy = r;
|
||||||
|
currentlyCleared = cc;
|
||||||
|
distanceToFinal = 6.0 * SG_NM_TO_METER;
|
||||||
|
};
|
||||||
|
|
||||||
string getRunwayName() { return rwy; };
|
string getRunwayName() {
|
||||||
int getCleared () { return currentlyCleared; };
|
return rwy;
|
||||||
double getApproachDistance() { return distanceToFinal; };
|
};
|
||||||
//time_t getEstApproachTime() { return estimatedArrival; };
|
int getCleared () {
|
||||||
|
return currentlyCleared;
|
||||||
|
};
|
||||||
|
double getApproachDistance() {
|
||||||
|
return distanceToFinal;
|
||||||
|
};
|
||||||
|
//time_t getEstApproachTime() { return estimatedArrival; };
|
||||||
|
|
||||||
//void setEstApproachTime(time_t time) { estimatedArrival = time; };
|
//void setEstApproachTime(time_t time) { estimatedArrival = time; };
|
||||||
void addToDepartureCue(FGAIAircraft *ac) { departureCue.push_back(ac); };
|
void addToDepartureCue(FGAIAircraft *ac) {
|
||||||
void setCleared(int number) { currentlyCleared = number; };
|
departureCue.push_back(ac);
|
||||||
time_t requestTimeSlot(time_t eta);
|
};
|
||||||
|
void setCleared(int number) {
|
||||||
|
currentlyCleared = number;
|
||||||
|
};
|
||||||
|
time_t requestTimeSlot(time_t eta);
|
||||||
|
|
||||||
int getDepartureCueSize() { return departureCue.size(); };
|
int getDepartureCueSize() {
|
||||||
FGAIAircraft* getFirstAircraftInDepartureCue() { return departureCue.size() ? *(departureCue.begin()) : NULL; };
|
return departureCue.size();
|
||||||
void updateDepartureCue() { departureCue.erase(departureCue.begin()); }
|
};
|
||||||
|
FGAIAircraft* getFirstAircraftInDepartureCue() {
|
||||||
|
return departureCue.size() ? *(departureCue.begin()) : NULL;
|
||||||
|
};
|
||||||
|
void updateDepartureCue() {
|
||||||
|
departureCue.erase(departureCue.begin());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<ActiveRunway> ActiveRunwayVec;
|
typedef vector<ActiveRunway> ActiveRunwayVec;
|
||||||
|
@ -244,71 +390,78 @@ private:
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool initialized;
|
bool initialized;
|
||||||
bool available;
|
bool available;
|
||||||
time_t lastTransmission;
|
time_t lastTransmission;
|
||||||
|
|
||||||
double dt_count;
|
double dt_count;
|
||||||
osg::Group* group;
|
osg::Group* group;
|
||||||
|
|
||||||
string formatATCFrequency3_2(int );
|
string formatATCFrequency3_2(int );
|
||||||
string genTransponderCode(string fltRules);
|
string genTransponderCode(string fltRules);
|
||||||
bool isUserAircraft(FGAIAircraft*);
|
bool isUserAircraft(FGAIAircraft*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MSG_ANNOUNCE_ENGINE_START,
|
MSG_ANNOUNCE_ENGINE_START,
|
||||||
MSG_REQUEST_ENGINE_START,
|
MSG_REQUEST_ENGINE_START,
|
||||||
MSG_PERMIT_ENGINE_START,
|
MSG_PERMIT_ENGINE_START,
|
||||||
MSG_DENY_ENGINE_START,
|
MSG_DENY_ENGINE_START,
|
||||||
MSG_ACKNOWLEDGE_ENGINE_START,
|
MSG_ACKNOWLEDGE_ENGINE_START,
|
||||||
MSG_REQUEST_PUSHBACK_CLEARANCE,
|
MSG_REQUEST_PUSHBACK_CLEARANCE,
|
||||||
MSG_PERMIT_PUSHBACK_CLEARANCE,
|
MSG_PERMIT_PUSHBACK_CLEARANCE,
|
||||||
MSG_HOLD_PUSHBACK_CLEARANCE,
|
MSG_HOLD_PUSHBACK_CLEARANCE,
|
||||||
MSG_ACKNOWLEDGE_SWITCH_GROUND_FREQUENCY,
|
MSG_ACKNOWLEDGE_SWITCH_GROUND_FREQUENCY,
|
||||||
MSG_INITIATE_CONTACT,
|
MSG_INITIATE_CONTACT,
|
||||||
MSG_ACKNOWLEDGE_INITIATE_CONTACT,
|
MSG_ACKNOWLEDGE_INITIATE_CONTACT,
|
||||||
MSG_REQUEST_TAXI_CLEARANCE,
|
MSG_REQUEST_TAXI_CLEARANCE,
|
||||||
MSG_ISSUE_TAXI_CLEARANCE,
|
MSG_ISSUE_TAXI_CLEARANCE,
|
||||||
MSG_ACKNOWLEDGE_TAXI_CLEARANCE,
|
MSG_ACKNOWLEDGE_TAXI_CLEARANCE,
|
||||||
MSG_HOLD_POSITION,
|
MSG_HOLD_POSITION,
|
||||||
MSG_ACKNOWLEDGE_HOLD_POSITION,
|
MSG_ACKNOWLEDGE_HOLD_POSITION,
|
||||||
MSG_RESUME_TAXI,
|
MSG_RESUME_TAXI,
|
||||||
MSG_ACKNOWLEDGE_RESUME_TAXI,
|
MSG_ACKNOWLEDGE_RESUME_TAXI,
|
||||||
MSG_REPORT_RUNWAY_HOLD_SHORT,
|
MSG_REPORT_RUNWAY_HOLD_SHORT,
|
||||||
MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT,
|
MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT,
|
||||||
MSG_SWITCH_TOWER_FREQUENCY,
|
MSG_SWITCH_TOWER_FREQUENCY,
|
||||||
MSG_ACKNOWLEDGE_SWITCH_TOWER_FREQUENCY
|
MSG_ACKNOWLEDGE_SWITCH_TOWER_FREQUENCY
|
||||||
} AtcMsgId;
|
} AtcMsgId;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ATC_AIR_TO_GROUND,
|
ATC_AIR_TO_GROUND,
|
||||||
ATC_GROUND_TO_AIR } AtcMsgDir;
|
ATC_GROUND_TO_AIR
|
||||||
FGATCController();
|
} AtcMsgDir;
|
||||||
virtual ~FGATCController();
|
FGATCController();
|
||||||
void init();
|
virtual ~FGATCController();
|
||||||
|
void init();
|
||||||
|
|
||||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||||
double lat, double lon,
|
double lat, double lon,
|
||||||
double hdg, double spd, double alt, double radius, int leg,
|
double hdg, double spd, double alt, double radius, int leg,
|
||||||
FGAIAircraft *aircraft) = 0;
|
FGAIAircraft *aircraft) = 0;
|
||||||
virtual void signOff(int id) = 0;
|
virtual void signOff(int id) = 0;
|
||||||
virtual void updateAircraftInformation(int id, double lat, double lon,
|
virtual void updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt, double dt) = 0;
|
double heading, double speed, double alt, double dt) = 0;
|
||||||
virtual bool hasInstruction(int id) = 0;
|
virtual bool hasInstruction(int id) = 0;
|
||||||
virtual FGATCInstruction getInstruction(int id) = 0;
|
virtual FGATCInstruction getInstruction(int id) = 0;
|
||||||
|
|
||||||
double getDt() { return dt_count; };
|
double getDt() {
|
||||||
void setDt(double dt) { dt_count = dt;};
|
return dt_count;
|
||||||
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
|
};
|
||||||
string getGateName(FGAIAircraft *aircraft);
|
void setDt(double dt) {
|
||||||
virtual void render(bool) = 0;
|
dt_count = dt;
|
||||||
virtual string getName() = 0;
|
};
|
||||||
|
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
|
||||||
|
string getGateName(FGAIAircraft *aircraft);
|
||||||
|
virtual void render(bool) = 0;
|
||||||
|
virtual string getName() = 0;
|
||||||
|
|
||||||
|
virtual void update(double) = 0;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AtcMsgDir lastTransmissionDirection;
|
AtcMsgDir lastTransmissionDirection;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -317,27 +470,32 @@ private:
|
||||||
class FGTowerController : public FGATCController
|
class FGTowerController : public FGATCController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
TrafficVector activeTraffic;
|
TrafficVector activeTraffic;
|
||||||
ActiveRunwayVec activeRunways;
|
ActiveRunwayVec activeRunways;
|
||||||
FGAirportDynamics *parent;
|
FGAirportDynamics *parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTowerController(FGAirportDynamics *parent);
|
FGTowerController(FGAirportDynamics *parent);
|
||||||
virtual ~FGTowerController() {};
|
virtual ~FGTowerController() {};
|
||||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||||
double lat, double lon,
|
double lat, double lon,
|
||||||
double hdg, double spd, double alt, double radius, int leg,
|
double hdg, double spd, double alt, double radius, int leg,
|
||||||
FGAIAircraft *aircraft);
|
FGAIAircraft *aircraft);
|
||||||
virtual void signOff(int id);
|
virtual void signOff(int id);
|
||||||
virtual void updateAircraftInformation(int id, double lat, double lon,
|
virtual void updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt, double dt);
|
double heading, double speed, double alt, double dt);
|
||||||
virtual bool hasInstruction(int id);
|
virtual bool hasInstruction(int id);
|
||||||
virtual FGATCInstruction getInstruction(int id);
|
virtual FGATCInstruction getInstruction(int id);
|
||||||
|
|
||||||
virtual void render(bool);
|
virtual void render(bool);
|
||||||
virtual string getName();
|
virtual string getName();
|
||||||
bool hasActiveTraffic() { return activeTraffic.size() != 0; };
|
virtual void update(double dt);
|
||||||
TrafficVector &getActiveTraffic() { return activeTraffic; };
|
bool hasActiveTraffic() {
|
||||||
|
return activeTraffic.size() != 0;
|
||||||
|
};
|
||||||
|
TrafficVector &getActiveTraffic() {
|
||||||
|
return activeTraffic;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -348,32 +506,37 @@ public:
|
||||||
class FGStartupController : public FGATCController
|
class FGStartupController : public FGATCController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
TrafficVector activeTraffic;
|
TrafficVector activeTraffic;
|
||||||
//ActiveRunwayVec activeRunways;
|
//ActiveRunwayVec activeRunways;
|
||||||
FGAirportDynamics *parent;
|
FGAirportDynamics *parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGStartupController(FGAirportDynamics *parent);
|
FGStartupController(FGAirportDynamics *parent);
|
||||||
virtual ~FGStartupController() {};
|
virtual ~FGStartupController() {};
|
||||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||||
double lat, double lon,
|
double lat, double lon,
|
||||||
double hdg, double spd, double alt, double radius, int leg,
|
double hdg, double spd, double alt, double radius, int leg,
|
||||||
FGAIAircraft *aircraft);
|
FGAIAircraft *aircraft);
|
||||||
virtual void signOff(int id);
|
virtual void signOff(int id);
|
||||||
virtual void updateAircraftInformation(int id, double lat, double lon,
|
virtual void updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt, double dt);
|
double heading, double speed, double alt, double dt);
|
||||||
virtual bool hasInstruction(int id);
|
virtual bool hasInstruction(int id);
|
||||||
virtual FGATCInstruction getInstruction(int id);
|
virtual FGATCInstruction getInstruction(int id);
|
||||||
|
|
||||||
virtual void render(bool);
|
virtual void render(bool);
|
||||||
virtual string getName();
|
virtual string getName();
|
||||||
|
virtual void update(double dt);
|
||||||
|
|
||||||
bool hasActiveTraffic() { return activeTraffic.size() != 0; };
|
bool hasActiveTraffic() {
|
||||||
TrafficVector &getActiveTraffic() { return activeTraffic; };
|
return activeTraffic.size() != 0;
|
||||||
|
};
|
||||||
|
TrafficVector &getActiveTraffic() {
|
||||||
|
return activeTraffic;
|
||||||
|
};
|
||||||
|
|
||||||
// Hpoefully, we can move this function to the base class, but I need to verify what is needed for the other controllers before doing so.
|
// Hpoefully, we can move this function to the base class, but I need to verify what is needed for the other controllers before doing so.
|
||||||
bool checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId,
|
bool checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId,
|
||||||
AtcMsgDir msgDir);
|
AtcMsgDir msgDir);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -383,30 +546,35 @@ public:
|
||||||
class FGApproachController : public FGATCController
|
class FGApproachController : public FGATCController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
TrafficVector activeTraffic;
|
TrafficVector activeTraffic;
|
||||||
ActiveRunwayVec activeRunways;
|
ActiveRunwayVec activeRunways;
|
||||||
FGAirportDynamics *parent;
|
FGAirportDynamics *parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGApproachController(FGAirportDynamics * parent);
|
FGApproachController(FGAirportDynamics * parent);
|
||||||
virtual ~FGApproachController() { };
|
virtual ~FGApproachController() { };
|
||||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||||
double lat, double lon,
|
double lat, double lon,
|
||||||
double hdg, double spd, double alt, double radius, int leg,
|
double hdg, double spd, double alt, double radius, int leg,
|
||||||
FGAIAircraft *aircraft);
|
FGAIAircraft *aircraft);
|
||||||
virtual void signOff(int id);
|
virtual void signOff(int id);
|
||||||
virtual void updateAircraftInformation(int id, double lat, double lon,
|
virtual void updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt, double dt);
|
double heading, double speed, double alt, double dt);
|
||||||
virtual bool hasInstruction(int id);
|
virtual bool hasInstruction(int id);
|
||||||
virtual FGATCInstruction getInstruction(int id);
|
virtual FGATCInstruction getInstruction(int id);
|
||||||
|
|
||||||
virtual void render(bool);
|
virtual void render(bool);
|
||||||
virtual string getName();
|
virtual string getName();
|
||||||
|
virtual void update(double dt);
|
||||||
|
|
||||||
ActiveRunway* getRunway(string name);
|
ActiveRunway* getRunway(string name);
|
||||||
|
|
||||||
bool hasActiveTraffic() { return activeTraffic.size() != 0; };
|
bool hasActiveTraffic() {
|
||||||
TrafficVector &getActiveTraffic() { return activeTraffic; };
|
return activeTraffic.size() != 0;
|
||||||
|
};
|
||||||
|
TrafficVector &getActiveTraffic() {
|
||||||
|
return activeTraffic;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,93 +35,117 @@ class FGEnvironment;
|
||||||
class FGAirportDynamics {
|
class FGAirportDynamics {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FGAirport* _ap;
|
FGAirport* _ap;
|
||||||
|
|
||||||
FGParkingVec parkings;
|
FGParkingVec parkings;
|
||||||
FGRunwayPreference rwyPrefs;
|
FGRunwayPreference rwyPrefs;
|
||||||
FGSidStar SIDs;
|
FGSidStar SIDs;
|
||||||
FGStartupController startupController;
|
FGStartupController startupController;
|
||||||
FGGroundNetwork groundNetwork;
|
FGGroundNetwork groundNetwork;
|
||||||
FGTowerController towerController;
|
FGTowerController towerController;
|
||||||
FGApproachController approachController;
|
FGApproachController approachController;
|
||||||
|
|
||||||
time_t lastUpdate;
|
time_t lastUpdate;
|
||||||
std::string prevTrafficType;
|
std::string prevTrafficType;
|
||||||
stringVec landing;
|
stringVec landing;
|
||||||
stringVec takeoff;
|
stringVec takeoff;
|
||||||
stringVec milActive, comActive, genActive, ulActive;
|
stringVec milActive, comActive, genActive, ulActive;
|
||||||
stringVec *currentlyActive;
|
stringVec *currentlyActive;
|
||||||
intVec freqAwos; // </AWOS>
|
intVec freqAwos; // </AWOS>
|
||||||
intVec freqUnicom; // </UNICOM>
|
intVec freqUnicom; // </UNICOM>
|
||||||
intVec freqClearance;// </CLEARANCE>
|
intVec freqClearance;// </CLEARANCE>
|
||||||
intVec freqGround; // </GROUND>
|
intVec freqGround; // </GROUND>
|
||||||
intVec freqTower; // </TOWER>
|
intVec freqTower; // </TOWER>
|
||||||
intVec freqApproach; // </APPROACH>
|
intVec freqApproach; // </APPROACH>
|
||||||
|
|
||||||
int atisSequenceIndex;
|
int atisSequenceIndex;
|
||||||
double atisSequenceTimeStamp;
|
double atisSequenceTimeStamp;
|
||||||
|
|
||||||
std::string chooseRunwayFallback();
|
std::string chooseRunwayFallback();
|
||||||
bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
|
bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
|
||||||
std::string chooseRwyByHeading(stringVec rwys, double heading);
|
std::string chooseRwyByHeading(stringVec rwys, double heading);
|
||||||
|
|
||||||
double elevation;
|
double elevation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGAirportDynamics(FGAirport* ap);
|
FGAirportDynamics(FGAirport* ap);
|
||||||
~FGAirportDynamics();
|
~FGAirportDynamics();
|
||||||
|
|
||||||
void addAwosFreq (int val) { freqAwos.push_back(val); };
|
void addAwosFreq (int val) {
|
||||||
void addUnicomFreq (int val) { freqUnicom.push_back(val); };
|
freqAwos.push_back(val);
|
||||||
void addClearanceFreq(int val) { freqClearance.push_back(val); };
|
};
|
||||||
void addGroundFreq (int val) { freqGround.push_back(val); };
|
void addUnicomFreq (int val) {
|
||||||
void addTowerFreq (int val) { freqTower.push_back(val); };
|
freqUnicom.push_back(val);
|
||||||
void addApproachFreq (int val) { freqApproach.push_back(val); };
|
};
|
||||||
|
void addClearanceFreq(int val) {
|
||||||
|
freqClearance.push_back(val);
|
||||||
|
};
|
||||||
|
void addGroundFreq (int val) {
|
||||||
|
freqGround.push_back(val);
|
||||||
|
};
|
||||||
|
void addTowerFreq (int val) {
|
||||||
|
freqTower.push_back(val);
|
||||||
|
};
|
||||||
|
void addApproachFreq (int val) {
|
||||||
|
freqApproach.push_back(val);
|
||||||
|
};
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
double getLongitude() const;
|
double getLongitude() const;
|
||||||
// Returns degrees
|
// Returns degrees
|
||||||
double getLatitude() const;
|
double getLatitude() const;
|
||||||
// Returns ft
|
// Returns ft
|
||||||
double getElevation() const;
|
double getElevation() const;
|
||||||
const string& getId() const;
|
const string& getId() const;
|
||||||
|
|
||||||
void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
|
void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
|
||||||
|
|
||||||
void addParking(FGParking& park);
|
void addParking(FGParking& park);
|
||||||
bool getAvailableParking(double *lat, double *lon,
|
bool getAvailableParking(double *lat, double *lon,
|
||||||
double *heading, int *gate, double rad, const string& fltype,
|
double *heading, int *gate, double rad, const string& fltype,
|
||||||
const string& acType, const string& airline);
|
const string& acType, const string& airline);
|
||||||
void getParking (int id, double *lat, double* lon, double *heading);
|
void getParking (int id, double *lat, double* lon, double *heading);
|
||||||
FGParking *getParking(int i);
|
FGParking *getParking(int i);
|
||||||
void releaseParking(int id);
|
void releaseParking(int id);
|
||||||
string getParkingName(int i);
|
string getParkingName(int i);
|
||||||
int getNrOfParkings() { return parkings.size(); };
|
int getNrOfParkings() {
|
||||||
//FGAirport *getAddress() { return this; };
|
return parkings.size();
|
||||||
//const string &getName() const { return _name;};
|
};
|
||||||
// Returns degrees
|
//FGAirport *getAddress() { return this; };
|
||||||
|
//const string &getName() const { return _name;};
|
||||||
|
// Returns degrees
|
||||||
|
|
||||||
// Departure / Arrival procedures
|
// Departure / Arrival procedures
|
||||||
FGSidStar * getSIDs() { return &SIDs; };
|
FGSidStar * getSIDs() {
|
||||||
FGAIFlightPlan * getSID(string activeRunway, double heading);
|
return &SIDs;
|
||||||
|
};
|
||||||
|
FGAIFlightPlan * getSID(string activeRunway, double heading);
|
||||||
|
|
||||||
|
|
||||||
// ATC related functions.
|
// ATC related functions.
|
||||||
FGStartupController *getStartupController() { return &startupController; };
|
FGStartupController *getStartupController() {
|
||||||
FGGroundNetwork *getGroundNetwork() { return &groundNetwork; };
|
return &startupController;
|
||||||
FGTowerController *getTowerController() { return &towerController; };
|
};
|
||||||
FGApproachController *getApproachController() { return &approachController; };
|
FGGroundNetwork *getGroundNetwork() {
|
||||||
|
return &groundNetwork;
|
||||||
|
};
|
||||||
|
FGTowerController *getTowerController() {
|
||||||
|
return &towerController;
|
||||||
|
};
|
||||||
|
FGApproachController *getApproachController() {
|
||||||
|
return &approachController;
|
||||||
|
};
|
||||||
|
|
||||||
int getGroundFrequency(unsigned leg);
|
int getGroundFrequency(unsigned leg);
|
||||||
int getTowerFrequency (unsigned nr);
|
int getTowerFrequency (unsigned nr);
|
||||||
|
|
||||||
/// get current ATIS sequence letter
|
/// get current ATIS sequence letter
|
||||||
const std::string getAtisSequence();
|
const std::string getAtisSequence();
|
||||||
|
|
||||||
/// get the current ATIS sequence number, updating it if necessary
|
/// get the current ATIS sequence number, updating it if necessary
|
||||||
int updateAtisSequence(int interval, bool forceUpdate);
|
int updateAtisSequence(int interval, bool forceUpdate);
|
||||||
|
|
||||||
void setRwyUse(const FGRunwayPreference& ref);
|
void setRwyUse(const FGRunwayPreference& ref);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,11 @@ bool compare_segments(FGTaxiSegment * a, FGTaxiSegment * b)
|
||||||
return (*a) < (*b);
|
return (*a) < (*b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool compare_trafficrecords(FGTrafficRecord a, FGTrafficRecord b)
|
||||||
|
{
|
||||||
|
return (a.getIntentions().size() < b.getIntentions().size());
|
||||||
|
}
|
||||||
|
|
||||||
FGGroundNetwork::FGGroundNetwork()
|
FGGroundNetwork::FGGroundNetwork()
|
||||||
{
|
{
|
||||||
hasNetwork = false;
|
hasNetwork = false;
|
||||||
|
@ -244,18 +249,18 @@ FGGroundNetwork::~FGGroundNetwork()
|
||||||
}
|
}
|
||||||
cachefile << "[GroundNetcachedata:ref:2011:09:04]" << endl;
|
cachefile << "[GroundNetcachedata:ref:2011:09:04]" << endl;
|
||||||
for (FGTaxiNodeVectorIterator node = nodes.begin();
|
for (FGTaxiNodeVectorIterator node = nodes.begin();
|
||||||
node != nodes.end(); node++) {
|
node != nodes.end(); node++) {
|
||||||
if (saveData) {
|
if (saveData) {
|
||||||
cachefile << (*node)->getIndex () << " "
|
cachefile << (*node)->getIndex () << " "
|
||||||
<< (*node)->getElevation () << " "
|
<< (*node)->getElevation () << " "
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
delete(*node);
|
delete(*node);
|
||||||
}
|
}
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
pushBackNodes.clear();
|
pushBackNodes.clear();
|
||||||
for (FGTaxiSegmentVectorIterator seg = segments.begin();
|
for (FGTaxiSegmentVectorIterator seg = segments.begin();
|
||||||
seg != segments.end(); seg++) {
|
seg != segments.end(); seg++) {
|
||||||
delete(*seg);
|
delete(*seg);
|
||||||
}
|
}
|
||||||
segments.clear();
|
segments.clear();
|
||||||
|
@ -288,12 +293,12 @@ void FGGroundNetwork::saveElevationCache() {
|
||||||
}
|
}
|
||||||
cachefile << "[GroundNetcachedata:ref:2011:09:04]" << endl;
|
cachefile << "[GroundNetcachedata:ref:2011:09:04]" << endl;
|
||||||
for (FGTaxiNodeVectorIterator node = nodes.begin();
|
for (FGTaxiNodeVectorIterator node = nodes.begin();
|
||||||
node != nodes.end(); node++) {
|
node != nodes.end(); node++) {
|
||||||
if (saveData) {
|
if (saveData) {
|
||||||
cachefile << (*node)->getIndex () << " "
|
cachefile << (*node)->getIndex () << " "
|
||||||
<< (*node)->getElevation () << " "
|
<< (*node)->getElevation () << " "
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (saveData) {
|
if (saveData) {
|
||||||
cachefile.close();
|
cachefile.close();
|
||||||
|
@ -406,11 +411,11 @@ void FGGroundNetwork::init()
|
||||||
data >> revisionStr;
|
data >> revisionStr;
|
||||||
if (revisionStr != "[GroundNetcachedata:ref:2011:09:04]") {
|
if (revisionStr != "[GroundNetcachedata:ref:2011:09:04]") {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,"GroundNetwork Warning: discarding outdated cachefile " <<
|
SG_LOG(SG_GENERAL, SG_ALERT,"GroundNetwork Warning: discarding outdated cachefile " <<
|
||||||
cacheData.c_str() << " for Airport " << airport);
|
cacheData.c_str() << " for Airport " << airport);
|
||||||
} else {
|
} else {
|
||||||
for (FGTaxiNodeVectorIterator i = nodes.begin();
|
for (FGTaxiNodeVectorIterator i = nodes.begin();
|
||||||
i != nodes.end();
|
i != nodes.end();
|
||||||
i++) {
|
i++) {
|
||||||
(*i)->setElevation(parent->getElevation() * SG_FEET_TO_METER);
|
(*i)->setElevation(parent->getElevation() * SG_FEET_TO_METER);
|
||||||
data >> index >> elev;
|
data >> index >> elev;
|
||||||
if (data.eof())
|
if (data.eof())
|
||||||
|
@ -435,7 +440,7 @@ int FGGroundNetwork::findNearestNode(const SGGeod & aGeod)
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
for (FGTaxiNodeVectorIterator itr = nodes.begin(); itr != nodes.end();
|
for (FGTaxiNodeVectorIterator itr = nodes.begin(); itr != nodes.end();
|
||||||
itr++) {
|
itr++) {
|
||||||
double d = SGGeodesy::distanceM(aGeod, (*itr)->getGeod());
|
double d = SGGeodesy::distanceM(aGeod, (*itr)->getGeod());
|
||||||
if (d < minDist) {
|
if (d < minDist) {
|
||||||
minDist = d;
|
minDist = d;
|
||||||
|
@ -488,7 +493,7 @@ FGTaxiSegment *FGGroundNetwork::findSegment(unsigned idx)
|
||||||
|
|
||||||
|
|
||||||
FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
|
FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
|
||||||
bool fullSearch)
|
bool fullSearch)
|
||||||
{
|
{
|
||||||
//implements Dijkstra's algorithm to find shortest distance route from start to end
|
//implements Dijkstra's algorithm to find shortest distance route from start to end
|
||||||
//taken from http://en.wikipedia.org/wiki/Dijkstra's_algorithm
|
//taken from http://en.wikipedia.org/wiki/Dijkstra's_algorithm
|
||||||
|
@ -504,7 +509,7 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (FGTaxiNodeVectorIterator
|
for (FGTaxiNodeVectorIterator
|
||||||
itr = currNodesSet->begin(); itr != currNodesSet->end(); itr++) {
|
itr = currNodesSet->begin(); itr != currNodesSet->end(); itr++) {
|
||||||
(*itr)->setPathScore(HUGE_VAL); //infinity by all practical means
|
(*itr)->setPathScore(HUGE_VAL); //infinity by all practical means
|
||||||
(*itr)->setPreviousNode(0); //
|
(*itr)->setPreviousNode(0); //
|
||||||
(*itr)->setPreviousSeg(0); //
|
(*itr)->setPreviousSeg(0); //
|
||||||
|
@ -520,7 +525,7 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
|
||||||
while (!unvisited.empty()) {
|
while (!unvisited.empty()) {
|
||||||
FGTaxiNode *best = *(unvisited.begin());
|
FGTaxiNode *best = *(unvisited.begin());
|
||||||
for (FGTaxiNodeVectorIterator
|
for (FGTaxiNodeVectorIterator
|
||||||
itr = unvisited.begin(); itr != unvisited.end(); itr++) {
|
itr = unvisited.begin(); itr != unvisited.end(); itr++) {
|
||||||
if ((*itr)->getPathScore() < best->getPathScore())
|
if ((*itr)->getPathScore() < best->getPathScore())
|
||||||
best = (*itr);
|
best = (*itr);
|
||||||
}
|
}
|
||||||
|
@ -533,8 +538,8 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
for (FGTaxiSegmentVectorIterator
|
for (FGTaxiSegmentVectorIterator
|
||||||
seg = best->getBeginRoute();
|
seg = best->getBeginRoute();
|
||||||
seg != best->getEndRoute(); seg++) {
|
seg != best->getEndRoute(); seg++) {
|
||||||
if (fullSearch || (*seg)->isPushBack()) {
|
if (fullSearch || (*seg)->isPushBack()) {
|
||||||
FGTaxiNode *tgt = (*seg)->getEnd();
|
FGTaxiNode *tgt = (*seg)->getEnd();
|
||||||
double alt =
|
double alt =
|
||||||
|
@ -623,7 +628,8 @@ void FGGroundNetwork::announcePosition(int id,
|
||||||
rec.setPositionAndHeading(lat, lon, heading, speed, alt);
|
rec.setPositionAndHeading(lat, lon, heading, speed, alt);
|
||||||
rec.setRadius(radius); // only need to do this when creating the record.
|
rec.setRadius(radius); // only need to do this when creating the record.
|
||||||
rec.setAircraft(aircraft);
|
rec.setAircraft(aircraft);
|
||||||
activeTraffic.push_back(rec);
|
activeTraffic.push_front(rec);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
i->setPositionAndIntentions(currentPosition, intendedRoute);
|
i->setPositionAndIntentions(currentPosition, intendedRoute);
|
||||||
i->setPositionAndHeading(lat, lon, heading, speed, alt);
|
i->setPositionAndHeading(lat, lon, heading, speed, alt);
|
||||||
|
@ -666,7 +672,7 @@ void FGGroundNetwork::signOff(int id)
|
||||||
* 9 = Acknowledge switch tower frequency
|
* 9 = Acknowledge switch tower frequency
|
||||||
*************************************************************************************************************************/
|
*************************************************************************************************************************/
|
||||||
bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
||||||
AtcMsgDir msgDir)
|
AtcMsgDir msgDir)
|
||||||
{
|
{
|
||||||
int state = i->getState();
|
int state = i->getState();
|
||||||
if ((state >= minState) && (state <= maxState) && available) {
|
if ((state >= minState) && (state <= maxState) && available) {
|
||||||
|
@ -676,10 +682,10 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
|
||||||
int n = trans_num->getIntValue();
|
int n = trans_num->getIntValue();
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
trans_num->setIntValue(-1);
|
trans_num->setIntValue(-1);
|
||||||
// PopupCallback(n);
|
// PopupCallback(n);
|
||||||
//cerr << "Selected transmission message " << n << endl;
|
//cerr << "Selected transmission message " << n << endl;
|
||||||
FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
|
FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
|
||||||
FGATCDialogNew::instance()->removeEntry(1);
|
FGATCDialogNew::instance()->removeEntry(1);
|
||||||
} else {
|
} else {
|
||||||
//cerr << "creating message for " << i->getAircraft()->getCallSign() << endl;
|
//cerr << "creating message for " << i->getAircraft()->getCallSign() << endl;
|
||||||
transmit(&(*i), msgId, msgDir, false);
|
transmit(&(*i), msgId, msgDir, false);
|
||||||
|
@ -696,8 +702,8 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
|
void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt,
|
double heading, double speed, double alt,
|
||||||
double dt)
|
double dt)
|
||||||
{
|
{
|
||||||
time_t currentTime = time(NULL);
|
time_t currentTime = time(NULL);
|
||||||
if (nextSave < currentTime) {
|
if (nextSave < currentTime) {
|
||||||
|
@ -747,9 +753,9 @@ void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
|
||||||
bool needsTaxiClearance = current->getAircraft()->getTaxiClearanceRequest();
|
bool needsTaxiClearance = current->getAircraft()->getTaxiClearanceRequest();
|
||||||
if (!needsTaxiClearance) {
|
if (!needsTaxiClearance) {
|
||||||
checkHoldPosition(id, lat, lon, heading, speed, alt);
|
checkHoldPosition(id, lat, lon, heading, speed, alt);
|
||||||
if (checkForCircularWaits(id)) {
|
//if (checkForCircularWaits(id)) {
|
||||||
i->setResolveCircularWait();
|
// i->setResolveCircularWait();
|
||||||
}
|
//}
|
||||||
} else {
|
} else {
|
||||||
current->setHoldPosition(true);
|
current->setHoldPosition(true);
|
||||||
int state = current->getState();
|
int state = current->getState();
|
||||||
|
@ -791,11 +797,11 @@ void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
||||||
double lon, double heading,
|
double lon, double heading,
|
||||||
double speed, double alt)
|
double speed, double alt)
|
||||||
{
|
{
|
||||||
|
|
||||||
TrafficVectorIterator current, closest;
|
TrafficVectorIterator current, closest, closestOnNetwork;
|
||||||
TrafficVectorIterator i = activeTraffic.begin();
|
TrafficVectorIterator i = activeTraffic.begin();
|
||||||
bool otherReasonToSlowDown = false;
|
bool otherReasonToSlowDown = false;
|
||||||
bool previousInstruction;
|
bool previousInstruction;
|
||||||
|
@ -825,7 +831,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
||||||
//TrafficVector iterator closest;
|
//TrafficVector iterator closest;
|
||||||
closest = current;
|
closest = current;
|
||||||
for (TrafficVectorIterator i = activeTraffic.begin();
|
for (TrafficVectorIterator i = activeTraffic.begin();
|
||||||
i != activeTraffic.end(); i++) {
|
i != activeTraffic.end(); i++) {
|
||||||
if (i == current) {
|
if (i == current) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -840,14 +846,16 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
||||||
if ((dist < mindist) && (bearing < 60.0)) {
|
if ((dist < mindist) && (bearing < 60.0)) {
|
||||||
mindist = dist;
|
mindist = dist;
|
||||||
closest = i;
|
closest = i;
|
||||||
|
closestOnNetwork = i;
|
||||||
minbearing = bearing;
|
minbearing = bearing;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Check traffic at the tower controller
|
//Check traffic at the tower controller
|
||||||
if (towerController->hasActiveTraffic()) {
|
if (towerController->hasActiveTraffic()) {
|
||||||
for (TrafficVectorIterator i =
|
for (TrafficVectorIterator i =
|
||||||
towerController->getActiveTraffic().begin();
|
towerController->getActiveTraffic().begin();
|
||||||
i != towerController->getActiveTraffic().end(); i++) {
|
i != towerController->getActiveTraffic().end(); i++) {
|
||||||
//cerr << "Comparing " << current->getId() << " and " << i->getId() << endl;
|
//cerr << "Comparing " << current->getId() << " and " << i->getId() << endl;
|
||||||
SGGeod other(SGGeod::fromDegM(i->getLongitude(),
|
SGGeod other(SGGeod::fromDegM(i->getLongitude(),
|
||||||
i->getLatitude(),
|
i->getLatitude(),
|
||||||
|
@ -887,9 +895,9 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
current->clearSpeedAdjustment();
|
current->clearSpeedAdjustment();
|
||||||
|
bool needBraking = false;
|
||||||
if (current->checkPositionAndIntentions(*closest)
|
if (current->checkPositionAndIntentions(*closest)
|
||||||
|| otherReasonToSlowDown) {
|
|| otherReasonToSlowDown) {
|
||||||
double maxAllowableDistance =
|
double maxAllowableDistance =
|
||||||
(1.1 * current->getRadius()) +
|
(1.1 * current->getRadius()) +
|
||||||
(1.1 * closest->getRadius());
|
(1.1 * closest->getRadius());
|
||||||
|
@ -901,12 +909,13 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
||||||
if (closest->getId() != current->getId()) {
|
if (closest->getId() != current->getId()) {
|
||||||
current->setSpeedAdjustment(closest->getSpeed() *
|
current->setSpeedAdjustment(closest->getSpeed() *
|
||||||
(mindist / 100));
|
(mindist / 100));
|
||||||
|
needBraking = true;
|
||||||
if (
|
if (
|
||||||
closest->getAircraft()->getTakeOffStatus() &&
|
closest->getAircraft()->getTakeOffStatus() &&
|
||||||
(current->getAircraft()->getTrafficRef()->getDepartureAirport() == closest->getAircraft()->getTrafficRef()->getDepartureAirport()) &&
|
(current->getAircraft()->getTrafficRef()->getDepartureAirport() == closest->getAircraft()->getTrafficRef()->getDepartureAirport()) &&
|
||||||
(current->getAircraft()->GetFlightPlan()->getRunway() == closest->getAircraft()->GetFlightPlan()->getRunway())
|
(current->getAircraft()->GetFlightPlan()->getRunway() == closest->getAircraft()->GetFlightPlan()->getRunway())
|
||||||
)
|
)
|
||||||
current->getAircraft()->scheduleForATCTowerDepartureControl(1);
|
current->getAircraft()->scheduleForATCTowerDepartureControl(1);
|
||||||
} else {
|
} else {
|
||||||
current->setSpeedAdjustment(0); // This can only happen when the user aircraft is the one closest
|
current->setSpeedAdjustment(0); // This can only happen when the user aircraft is the one closest
|
||||||
}
|
}
|
||||||
|
@ -920,6 +929,9 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((closest == closestOnNetwork) && (current->getPriority() < closest->getPriority()) && needBraking) {
|
||||||
|
swap(current, closest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,80 +968,100 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
|
||||||
bool origStatus = current->hasHoldPosition();
|
bool origStatus = current->hasHoldPosition();
|
||||||
current->setHoldPosition(false);
|
current->setHoldPosition(false);
|
||||||
SGGeod curr(SGGeod::fromDegM(lon, lat, alt));
|
SGGeod curr(SGGeod::fromDegM(lon, lat, alt));
|
||||||
|
int currentRoute = i->getCurrentPosition();
|
||||||
|
int nextRoute;
|
||||||
|
if (i->getIntentions().size()) {
|
||||||
|
nextRoute = (*(i->getIntentions().begin()));
|
||||||
|
} else {
|
||||||
|
nextRoute = 0;
|
||||||
|
}
|
||||||
|
if (currentRoute > 0) {
|
||||||
|
FGTaxiSegment *tx = findSegment(currentRoute);
|
||||||
|
FGTaxiSegment *nx;
|
||||||
|
if (nextRoute) {
|
||||||
|
nx = findSegment(nextRoute);
|
||||||
|
} else {
|
||||||
|
nx = tx;
|
||||||
|
}
|
||||||
|
if (tx->hasBlock() || nx->hasBlock() ) {
|
||||||
|
current->setHoldPosition(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
|
||||||
if (i->getId() != current->getId()) {
|
|
||||||
int node = current->crosses(this, *i);
|
|
||||||
if (node != -1) {
|
|
||||||
FGTaxiNode *taxiNode = findNode(node);
|
|
||||||
|
|
||||||
// Determine whether it's save to continue or not.
|
/* for (i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
||||||
// If we have a crossing route, there are two possibilities:
|
if (i->getId() != current->getId()) {
|
||||||
// 1) This is an interestion
|
int node = current->crosses(this, *i);
|
||||||
// 2) This is oncoming two-way traffic, using the same taxiway.
|
if (node != -1) {
|
||||||
//cerr << "Hold check 1 : " << id << " has common node " << node << endl;
|
FGTaxiNode *taxiNode = findNode(node);
|
||||||
|
|
||||||
SGGeod other(SGGeod::
|
// Determine whether it's save to continue or not.
|
||||||
fromDegM(i->getLongitude(), i->getLatitude(),
|
// If we have a crossing route, there are two possibilities:
|
||||||
i->getAltitude()));
|
// 1) This is an interestion
|
||||||
bool needsToWait;
|
// 2) This is oncoming two-way traffic, using the same taxiway.
|
||||||
bool opposing;
|
//cerr << "Hold check 1 : " << id << " has common node " << node << endl;
|
||||||
if (current->isOpposing(this, *i, node)) {
|
|
||||||
needsToWait = true;
|
SGGeod other(SGGeod::
|
||||||
opposing = true;
|
fromDegM(i->getLongitude(), i->getLatitude(),
|
||||||
//cerr << "Hold check 2 : " << node << " has opposing segment " << endl;
|
i->getAltitude()));
|
||||||
// issue a "Hold Position" as soon as we're close to the offending node
|
bool needsToWait;
|
||||||
// For now, I'm doing this as long as the other aircraft doesn't
|
bool opposing;
|
||||||
// have a hold instruction as soon as we're within a reasonable
|
if (current->isOpposing(this, *i, node)) {
|
||||||
// distance from the offending node.
|
|
||||||
// This may be a bit of a conservative estimate though, as it may
|
|
||||||
// be well possible that both aircraft can both continue to taxi
|
|
||||||
// without crashing into each other.
|
|
||||||
} else {
|
|
||||||
opposing = false;
|
|
||||||
if (SGGeodesy::distanceM(other, taxiNode->getGeod()) > 200) // 2.0*i->getRadius())
|
|
||||||
{
|
|
||||||
needsToWait = false;
|
|
||||||
//cerr << "Hold check 3 : " << id <<" Other aircraft approaching node is still far away. (" << dist << " nm). Can safely continue "
|
|
||||||
// << endl;
|
|
||||||
} else {
|
|
||||||
needsToWait = true;
|
needsToWait = true;
|
||||||
//cerr << "Hold check 4: " << id << " Would need to wait for other aircraft : distance = " << dist << " meters" << endl;
|
opposing = true;
|
||||||
}
|
//cerr << "Hold check 2 : " << node << " has opposing segment " << endl;
|
||||||
}
|
// issue a "Hold Position" as soon as we're close to the offending node
|
||||||
|
// For now, I'm doing this as long as the other aircraft doesn't
|
||||||
double dist =
|
// have a hold instruction as soon as we're within a reasonable
|
||||||
SGGeodesy::distanceM(curr, taxiNode->getGeod());
|
// distance from the offending node.
|
||||||
if (!(i->hasHoldPosition())) {
|
// This may be a bit of a conservative estimate though, as it may
|
||||||
|
// be well possible that both aircraft can both continue to taxi
|
||||||
if ((dist < 200) && //2.5*current->getRadius()) &&
|
// without crashing into each other.
|
||||||
(needsToWait) && (i->onRoute(this, *current)) &&
|
|
||||||
//((i->onRoute(this, *current)) || ((!(i->getSpeedAdjustment())))) &&
|
|
||||||
(!(current->getId() == i->getWaitsForId())))
|
|
||||||
//(!(i->getSpeedAdjustment()))) // &&
|
|
||||||
//(!(current->getSpeedAdjustment())))
|
|
||||||
|
|
||||||
{
|
|
||||||
if (!(isUserAircraft(i->getAircraft()))) { // test code. Don't wait for the user, let the user wait for you.
|
|
||||||
current->setHoldPosition(true);
|
|
||||||
current->setWaitsForId(i->getId());
|
|
||||||
}
|
|
||||||
//cerr << "Hold check 5: " << current->getCallSign() <<" Setting Hold Position: distance to node (" << node << ") "
|
|
||||||
// << dist << " meters. Waiting for " << i->getCallSign();
|
|
||||||
//if (opposing)
|
|
||||||
//cerr <<" [opposing] " << endl;
|
|
||||||
//else
|
|
||||||
// cerr << "[non-opposing] " << endl;
|
|
||||||
//if (i->hasSpeefAdjustment())
|
|
||||||
// {
|
|
||||||
// cerr << " (which in turn waits for ) " << i->
|
|
||||||
} else {
|
} else {
|
||||||
//cerr << "Hold check 6: " << id << " No need to hold yet: Distance to node : " << dist << " nm"<< endl;
|
opposing = false;
|
||||||
|
if (SGGeodesy::distanceM(other, taxiNode->getGeod()) > 200) // 2.0*i->getRadius())
|
||||||
|
{
|
||||||
|
needsToWait = false;
|
||||||
|
//cerr << "Hold check 3 : " << id <<" Other aircraft approaching node is still far away. (" << dist << " nm). Can safely continue "
|
||||||
|
// << endl;
|
||||||
|
} else {
|
||||||
|
needsToWait = true;
|
||||||
|
//cerr << "Hold check 4: " << id << " Would need to wait for other aircraft : distance = " << dist << " meters" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double dist =
|
||||||
|
SGGeodesy::distanceM(curr, taxiNode->getGeod());
|
||||||
|
if (!(i->hasHoldPosition())) {
|
||||||
|
|
||||||
|
if ((dist < 200) && //2.5*current->getRadius()) &&
|
||||||
|
(needsToWait) && (i->onRoute(this, *current)) &&
|
||||||
|
//((i->onRoute(this, *current)) || ((!(i->getSpeedAdjustment())))) &&
|
||||||
|
(!(current->getId() == i->getWaitsForId())))
|
||||||
|
//(!(i->getSpeedAdjustment()))) // &&
|
||||||
|
//(!(current->getSpeedAdjustment())))
|
||||||
|
|
||||||
|
{
|
||||||
|
if (!(isUserAircraft(i->getAircraft()))) { // test code. Don't wait for the user, let the user wait for you.
|
||||||
|
current->setHoldPosition(true);
|
||||||
|
current->setWaitsForId(i->getId());
|
||||||
|
}
|
||||||
|
//cerr << "Hold check 5: " << current->getCallSign() <<" Setting Hold Position: distance to node (" << node << ") "
|
||||||
|
// << dist << " meters. Waiting for " << i->getCallSign();
|
||||||
|
//if (opposing)
|
||||||
|
//cerr <<" [opposing] " << endl;
|
||||||
|
//else
|
||||||
|
// cerr << "[non-opposing] " << endl;
|
||||||
|
//if (i->hasSpeefAdjustment())
|
||||||
|
// {
|
||||||
|
// cerr << " (which in turn waits for ) " << i->
|
||||||
|
} else {
|
||||||
|
//cerr << "Hold check 6: " << id << " No need to hold yet: Distance to node : " << dist << " nm"<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
|
||||||
bool currStatus = current->hasHoldPosition();
|
bool currStatus = current->hasHoldPosition();
|
||||||
current->setHoldPosition(origStatus);
|
current->setHoldPosition(origStatus);
|
||||||
// Either a Hold Position or a resume taxi transmission has been issued
|
// Either a Hold Position or a resume taxi transmission has been issued
|
||||||
|
@ -1064,17 +1096,17 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
|
||||||
|
|
||||||
//int state = current->getState();
|
//int state = current->getState();
|
||||||
if (checkTransmissionState(1,1, current, now, MSG_ACKNOWLEDGE_HOLD_POSITION, ATC_AIR_TO_GROUND)) {
|
if (checkTransmissionState(1,1, current, now, MSG_ACKNOWLEDGE_HOLD_POSITION, ATC_AIR_TO_GROUND)) {
|
||||||
current->setState(0);
|
current->setState(0);
|
||||||
current->setHoldPosition(true);
|
current->setHoldPosition(true);
|
||||||
}
|
}
|
||||||
if (checkTransmissionState(2,2, current, now, MSG_ACKNOWLEDGE_RESUME_TAXI, ATC_AIR_TO_GROUND)) {
|
if (checkTransmissionState(2,2, current, now, MSG_ACKNOWLEDGE_RESUME_TAXI, ATC_AIR_TO_GROUND)) {
|
||||||
current->setState(0);
|
current->setState(0);
|
||||||
current->setHoldPosition(false);
|
current->setHoldPosition(false);
|
||||||
}
|
}
|
||||||
if (current->getAircraft()->getTakeOffStatus() && (current->getState() == 0)) {
|
if (current->getAircraft()->getTakeOffStatus() && (current->getState() == 0)) {
|
||||||
//cerr << "Scheduling " << current->getAircraft()->getCallSign() << " for hold short" << endl;
|
//cerr << "Scheduling " << current->getAircraft()->getCallSign() << " for hold short" << endl;
|
||||||
current->setState(6);
|
current->setState(6);
|
||||||
}
|
}
|
||||||
if (checkTransmissionState(6,6, current, now, MSG_REPORT_RUNWAY_HOLD_SHORT, ATC_AIR_TO_GROUND)) {
|
if (checkTransmissionState(6,6, current, now, MSG_REPORT_RUNWAY_HOLD_SHORT, ATC_AIR_TO_GROUND)) {
|
||||||
}
|
}
|
||||||
if (checkTransmissionState(7,7, current, now, MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT, ATC_GROUND_TO_AIR)) {
|
if (checkTransmissionState(7,7, current, now, MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT, ATC_GROUND_TO_AIR)) {
|
||||||
|
@ -1086,7 +1118,7 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//current->setState(0);
|
//current->setState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1271,10 +1303,10 @@ void FGGroundNetwork::render(bool visible)
|
||||||
//while (group->getNumChildren()) {
|
//while (group->getNumChildren()) {
|
||||||
// cerr << "Number of children: " << group->getNumChildren() << endl;
|
// cerr << "Number of children: " << group->getNumChildren() << endl;
|
||||||
//simgear::EffectGeode* geode = (simgear::EffectGeode*) group->getChild(0);
|
//simgear::EffectGeode* geode = (simgear::EffectGeode*) group->getChild(0);
|
||||||
//osg::MatrixTransform *obj_trans = (osg::MatrixTransform*) group->getChild(0);
|
//osg::MatrixTransform *obj_trans = (osg::MatrixTransform*) group->getChild(0);
|
||||||
//geode->releaseGLObjects();
|
//geode->releaseGLObjects();
|
||||||
//group->removeChild(geode);
|
//group->removeChild(geode);
|
||||||
//delete geode;
|
//delete geode;
|
||||||
group = 0;
|
group = 0;
|
||||||
}
|
}
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
@ -1301,7 +1333,7 @@ void FGGroundNetwork::render(bool visible)
|
||||||
SGGeod center;
|
SGGeod center;
|
||||||
SGGeodesy::direct(start, heading, coveredDistance, center, az2);
|
SGGeodesy::direct(start, heading, coveredDistance, center, az2);
|
||||||
//cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
|
//cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Make a helper function out of this
|
// Make a helper function out of this
|
||||||
osg::Matrix obj_pos;
|
osg::Matrix obj_pos;
|
||||||
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
|
||||||
|
@ -1321,7 +1353,7 @@ void FGGroundNetwork::render(bool visible)
|
||||||
center2.setElevationM(SG_MAX_ELEVATION_M);
|
center2.setElevationM(SG_MAX_ELEVATION_M);
|
||||||
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
|
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
|
||||||
elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
|
elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
|
||||||
//elevation_meters += 0.5;
|
//elevation_meters += 0.5;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
elevationEnd = parent->getElevation();
|
elevationEnd = parent->getElevation();
|
||||||
|
@ -1331,9 +1363,9 @@ void FGGroundNetwork::render(bool visible)
|
||||||
double elevationMean = (elevationStart + elevationEnd) / 2.0;
|
double elevationMean = (elevationStart + elevationEnd) / 2.0;
|
||||||
double elevDiff = elevationEnd - elevationStart;
|
double elevDiff = elevationEnd - elevationStart;
|
||||||
|
|
||||||
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
||||||
|
|
||||||
//cerr << "1. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
//cerr << "1. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
||||||
|
|
||||||
WorldCoordinate( obj_pos, center.getLatitudeDeg(), center.getLongitudeDeg(), elevationMean+ 0.5, -(heading), slope );
|
WorldCoordinate( obj_pos, center.getLatitudeDeg(), center.getLongitudeDeg(), elevationMean+ 0.5, -(heading), slope );
|
||||||
|
|
||||||
|
@ -1350,18 +1382,23 @@ void FGGroundNetwork::render(bool visible)
|
||||||
geode->setName("test");
|
geode->setName("test");
|
||||||
geode->addDrawable(geometry);
|
geode->addDrawable(geometry);
|
||||||
//osg::Node *custom_obj;
|
//osg::Node *custom_obj;
|
||||||
SGMaterial *mat = matlib->find("UnidirectionalTaper");
|
SGMaterial *mat;
|
||||||
|
if (segments[pos]->hasBlock()) {
|
||||||
|
mat = matlib->find("UnidirectionalTaperRed");
|
||||||
|
} else {
|
||||||
|
mat = matlib->find("UnidirectionalTaperGreen");
|
||||||
|
}
|
||||||
if (mat)
|
if (mat)
|
||||||
geode->setEffect(mat->get_effect());
|
geode->setEffect(mat->get_effect());
|
||||||
obj_trans->addChild(geode);
|
obj_trans->addChild(geode);
|
||||||
// wire as much of the scene graph together as we can
|
// wire as much of the scene graph together as we can
|
||||||
//->addChild( obj_trans );
|
//->addChild( obj_trans );
|
||||||
group->addChild( obj_trans );
|
group->addChild( obj_trans );
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
} else {
|
} else {
|
||||||
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
||||||
}
|
}
|
||||||
for(intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
for (intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
||||||
osg::Matrix obj_pos;
|
osg::Matrix obj_pos;
|
||||||
int k = (*j)-1;
|
int k = (*j)-1;
|
||||||
if (k >= 0) {
|
if (k >= 0) {
|
||||||
|
@ -1401,7 +1438,7 @@ void FGGroundNetwork::render(bool visible)
|
||||||
double length = segments[k]->getLength();
|
double length = segments[k]->getLength();
|
||||||
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
double slope = atan2(elevDiff, length) * SGD_RADIANS_TO_DEGREES;
|
||||||
|
|
||||||
// cerr << "2. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
// cerr << "2. Using mean elevation : " << elevationMean << " and " << slope << endl;
|
||||||
|
|
||||||
|
|
||||||
WorldCoordinate( obj_pos, segments[k]->getLatitude(), segments[k]->getLongitude(), elevationMean+ 0.5, -(segments[k]->getHeading()), slope );
|
WorldCoordinate( obj_pos, segments[k]->getLatitude(), segments[k]->getLongitude(), elevationMean+ 0.5, -(segments[k]->getHeading()), slope );
|
||||||
|
@ -1419,7 +1456,12 @@ void FGGroundNetwork::render(bool visible)
|
||||||
geode->setName("test");
|
geode->setName("test");
|
||||||
geode->addDrawable(geometry);
|
geode->addDrawable(geometry);
|
||||||
//osg::Node *custom_obj;
|
//osg::Node *custom_obj;
|
||||||
SGMaterial *mat = matlib->find("UnidirectionalTaper");
|
SGMaterial *mat;
|
||||||
|
if (segments[k]->hasBlock()) {
|
||||||
|
mat = matlib->find("UnidirectionalTaperRed");
|
||||||
|
} else {
|
||||||
|
mat = matlib->find("UnidirectionalTaperGreen");
|
||||||
|
}
|
||||||
if (mat)
|
if (mat)
|
||||||
geode->setEffect(mat->get_effect());
|
geode->setEffect(mat->get_effect());
|
||||||
obj_trans->addChild(geode);
|
obj_trans->addChild(geode);
|
||||||
|
@ -1437,3 +1479,96 @@ void FGGroundNetwork::render(bool visible)
|
||||||
string FGGroundNetwork::getName() {
|
string FGGroundNetwork::getName() {
|
||||||
return string(parent->getId() + "-ground");
|
return string(parent->getId() + "-ground");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGGroundNetwork::update(double dt)
|
||||||
|
{
|
||||||
|
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
|
||||||
|
(*tsi)->unblock();
|
||||||
|
}
|
||||||
|
int priority = 1;
|
||||||
|
//sort(activeTraffic.begin(), activeTraffic.end(), compare_trafficrecords);
|
||||||
|
// Handle traffic that is under ground control first; this way we'll prevent clutter at the gate areas.
|
||||||
|
// Don't allow an aircraft to pushback when a taxiing aircraft is currently using part of the intended route.
|
||||||
|
for (TrafficVectorIterator i = parent->getDynamics()->getStartupController()->getActiveTraffic().begin();
|
||||||
|
i != parent->getDynamics()->getStartupController()->getActiveTraffic().end(); i++) {
|
||||||
|
i->allowPushBack();
|
||||||
|
i->setPriority(priority++);
|
||||||
|
if (i->isActive(60)) {
|
||||||
|
|
||||||
|
// Check for all active aircraft whether it's current pos segment is
|
||||||
|
// an opposite of one of the departing aircraft's intentions
|
||||||
|
for (TrafficVectorIterator j = activeTraffic.begin(); j != activeTraffic.end(); j++) {
|
||||||
|
int pos = j->getCurrentPosition();
|
||||||
|
if (pos > 0) {
|
||||||
|
FGTaxiSegment *seg = segments[pos-1]->opposite();
|
||||||
|
if (seg) {
|
||||||
|
int posReverse = seg->getIndex();
|
||||||
|
for (intVecIterator k = i->getIntentions().begin(); k != i->getIntentions().end(); k++) {
|
||||||
|
if ((*k) == posReverse) {
|
||||||
|
i->denyPushBack();
|
||||||
|
segments[posReverse-1]->block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the current aircraft is still allowed to pushback, we can start reserving a route for if by blocking all the entry taxiways.
|
||||||
|
if (i->pushBackAllowed()) {
|
||||||
|
int pos = i->getCurrentPosition();
|
||||||
|
if (pos > 0) {
|
||||||
|
FGTaxiSegment *seg = segments[pos-1];
|
||||||
|
FGTaxiNode *node = seg->getEnd();
|
||||||
|
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
|
||||||
|
if (((*tsi)->getEnd() == node) && ((*tsi) != seg)) {
|
||||||
|
(*tsi)->block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (intVecIterator j = i->getIntentions().begin(); j != i->getIntentions().end(); j++) {
|
||||||
|
int pos = (*j);
|
||||||
|
if (pos > 0) {
|
||||||
|
FGTaxiSegment *seg = segments[pos-1];
|
||||||
|
FGTaxiNode *node = seg->getEnd();
|
||||||
|
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
|
||||||
|
if (((*tsi)->getEnd() == node) && ((*tsi) != seg)) {
|
||||||
|
(*tsi)->block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
||||||
|
i->setPriority(priority++);
|
||||||
|
int pos = i->getCurrentPosition();
|
||||||
|
if (pos > 0) {
|
||||||
|
if (segments[pos-1]->hasBlock()) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "Taxiway incursion for AI aircraft" << i->getAircraft()->getCallSign());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
intVecIterator ivi;
|
||||||
|
for (ivi = i->getIntentions().begin(); ivi != i->getIntentions().end(); ivi++) {
|
||||||
|
int segIndex = (*ivi);
|
||||||
|
if (segIndex > 0) {
|
||||||
|
if (segments[segIndex-1]->hasBlock())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//after this, ivi points just behind the last valid unblocked taxi segment.
|
||||||
|
for (intVecIterator j = i->getIntentions().begin(); j != ivi; j++) {
|
||||||
|
int pos = (*j);
|
||||||
|
if (pos > 0) {
|
||||||
|
FGTaxiSegment *seg = segments[pos-1];
|
||||||
|
FGTaxiNode *node = seg->getEnd();
|
||||||
|
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
|
||||||
|
if (((*tsi)->getEnd() == node) && ((*tsi) != seg)) {
|
||||||
|
(*tsi)->block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,94 +60,139 @@ typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentVectorIterator;
|
||||||
class FGTaxiSegment
|
class FGTaxiSegment
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int startNode;
|
int startNode;
|
||||||
int endNode;
|
int endNode;
|
||||||
double length;
|
double length;
|
||||||
double heading;
|
double heading;
|
||||||
SGGeod center;
|
SGGeod center;
|
||||||
bool isActive;
|
bool isActive;
|
||||||
bool isPushBackRoute;
|
bool isPushBackRoute;
|
||||||
FGTaxiNode *start;
|
bool isBlocked;
|
||||||
FGTaxiNode *end;
|
FGTaxiNode *start;
|
||||||
int index;
|
FGTaxiNode *end;
|
||||||
FGTaxiSegment *oppositeDirection;
|
int index;
|
||||||
|
FGTaxiSegment *oppositeDirection;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTaxiSegment() :
|
FGTaxiSegment() :
|
||||||
startNode(0),
|
startNode(0),
|
||||||
endNode(0),
|
endNode(0),
|
||||||
length(0),
|
length(0),
|
||||||
heading(0),
|
heading(0),
|
||||||
isActive(0),
|
isActive(0),
|
||||||
isPushBackRoute(0),
|
isPushBackRoute(0),
|
||||||
start(0),
|
isBlocked(0),
|
||||||
end(0),
|
start(0),
|
||||||
index(0),
|
end(0),
|
||||||
oppositeDirection(0)
|
index(0),
|
||||||
{
|
oppositeDirection(0)
|
||||||
};
|
{
|
||||||
|
};
|
||||||
|
|
||||||
FGTaxiSegment (const FGTaxiSegment &other) :
|
FGTaxiSegment (const FGTaxiSegment &other) :
|
||||||
startNode (other.startNode),
|
startNode (other.startNode),
|
||||||
endNode (other.endNode),
|
endNode (other.endNode),
|
||||||
length (other.length),
|
length (other.length),
|
||||||
heading (other.heading),
|
heading (other.heading),
|
||||||
center (other.center),
|
center (other.center),
|
||||||
isActive (other.isActive),
|
isActive (other.isActive),
|
||||||
isPushBackRoute (other.isPushBackRoute),
|
isPushBackRoute (other.isPushBackRoute),
|
||||||
start (other.start),
|
isBlocked (other.isBlocked),
|
||||||
end (other.end),
|
start (other.start),
|
||||||
index (other.index),
|
end (other.end),
|
||||||
oppositeDirection (other.oppositeDirection)
|
index (other.index),
|
||||||
{
|
oppositeDirection (other.oppositeDirection)
|
||||||
};
|
{
|
||||||
|
};
|
||||||
|
|
||||||
FGTaxiSegment& operator=(const FGTaxiSegment &other)
|
FGTaxiSegment& operator=(const FGTaxiSegment &other)
|
||||||
{
|
{
|
||||||
startNode = other.startNode;
|
startNode = other.startNode;
|
||||||
endNode = other.endNode;
|
endNode = other.endNode;
|
||||||
length = other.length;
|
length = other.length;
|
||||||
heading = other.heading;
|
heading = other.heading;
|
||||||
center = other.center;
|
center = other.center;
|
||||||
isActive = other.isActive;
|
isActive = other.isActive;
|
||||||
isPushBackRoute = other.isPushBackRoute;
|
isPushBackRoute = other.isPushBackRoute;
|
||||||
start = other.start;
|
isBlocked = other.isBlocked;
|
||||||
end = other.end;
|
start = other.start;
|
||||||
index = other.index;
|
end = other.end;
|
||||||
oppositeDirection = other.oppositeDirection;
|
index = other.index;
|
||||||
return *this;
|
oppositeDirection = other.oppositeDirection;
|
||||||
};
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
void setIndex (int val) { index = val; };
|
void setIndex (int val) {
|
||||||
void setStartNodeRef (int val) { startNode = val; };
|
index = val;
|
||||||
void setEndNodeRef (int val) { endNode = val; };
|
};
|
||||||
|
void setStartNodeRef (int val) {
|
||||||
|
startNode = val;
|
||||||
|
};
|
||||||
|
void setEndNodeRef (int val) {
|
||||||
|
endNode = val;
|
||||||
|
};
|
||||||
|
|
||||||
void setOpposite(FGTaxiSegment *opp) { oppositeDirection = opp; };
|
void setOpposite(FGTaxiSegment *opp) {
|
||||||
|
oppositeDirection = opp;
|
||||||
|
};
|
||||||
|
|
||||||
void setStart(FGTaxiNodeVector *nodes);
|
void setStart(FGTaxiNodeVector *nodes);
|
||||||
void setEnd (FGTaxiNodeVector *nodes);
|
void setEnd (FGTaxiNodeVector *nodes);
|
||||||
void setPushBackType(bool val) { isPushBackRoute = val; };
|
void setPushBackType(bool val) {
|
||||||
void setDimensions(double elevation);
|
isPushBackRoute = val;
|
||||||
|
};
|
||||||
|
void setDimensions(double elevation);
|
||||||
|
void block() {
|
||||||
|
isBlocked = true;
|
||||||
|
}
|
||||||
|
void unblock() {
|
||||||
|
isBlocked = false;
|
||||||
|
};
|
||||||
|
bool hasBlock() {
|
||||||
|
return isBlocked;
|
||||||
|
};
|
||||||
|
|
||||||
FGTaxiNode * getEnd() { return end;};
|
FGTaxiNode * getEnd() {
|
||||||
FGTaxiNode * getStart() { return start; };
|
return end;
|
||||||
double getLength() { return length; };
|
};
|
||||||
int getIndex() { return index; };
|
FGTaxiNode * getStart() {
|
||||||
double getLatitude() { return center.getLatitudeDeg(); };
|
return start;
|
||||||
double getLongitude() { return center.getLongitudeDeg(); };
|
};
|
||||||
double getHeading() { return heading; };
|
double getLength() {
|
||||||
bool isPushBack() { return isPushBackRoute; };
|
return length;
|
||||||
|
};
|
||||||
|
int getIndex() {
|
||||||
|
return index;
|
||||||
|
};
|
||||||
|
double getLatitude() {
|
||||||
|
return center.getLatitudeDeg();
|
||||||
|
};
|
||||||
|
double getLongitude() {
|
||||||
|
return center.getLongitudeDeg();
|
||||||
|
};
|
||||||
|
double getHeading() {
|
||||||
|
return heading;
|
||||||
|
};
|
||||||
|
bool isPushBack() {
|
||||||
|
return isPushBackRoute;
|
||||||
|
};
|
||||||
|
|
||||||
int getPenalty(int nGates);
|
int getPenalty(int nGates);
|
||||||
|
|
||||||
FGTaxiSegment *getAddress() { return this;};
|
FGTaxiSegment *getAddress() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
bool operator<(const FGTaxiSegment &other) const { return index < other.index; };
|
bool operator<(const FGTaxiSegment &other) const {
|
||||||
//bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; };
|
return index < other.index;
|
||||||
FGTaxiSegment *opposite() { return oppositeDirection; };
|
};
|
||||||
void setCourseDiff(double crse);
|
//bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; };
|
||||||
|
FGTaxiSegment *opposite() {
|
||||||
|
return oppositeDirection;
|
||||||
|
};
|
||||||
|
void setCourseDiff(double crse);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,52 +213,67 @@ typedef vector<int>::iterator intVecIterator;
|
||||||
class FGTaxiRoute
|
class FGTaxiRoute
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
intVec nodes;
|
intVec nodes;
|
||||||
intVec routes;
|
intVec routes;
|
||||||
double distance;
|
double distance;
|
||||||
// int depth;
|
// int depth;
|
||||||
intVecIterator currNode;
|
intVecIterator currNode;
|
||||||
intVecIterator currRoute;
|
intVecIterator currRoute;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTaxiRoute() { distance = 0; currNode = nodes.begin(); currRoute = routes.begin();};
|
FGTaxiRoute() {
|
||||||
FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) {
|
distance = 0;
|
||||||
nodes = nds;
|
currNode = nodes.begin();
|
||||||
routes = rts;
|
currRoute = routes.begin();
|
||||||
distance = dist;
|
};
|
||||||
currNode = nodes.begin();
|
FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) {
|
||||||
currRoute = routes.begin();
|
nodes = nds;
|
||||||
|
routes = rts;
|
||||||
|
distance = dist;
|
||||||
|
currNode = nodes.begin();
|
||||||
|
currRoute = routes.begin();
|
||||||
// depth = dpth;
|
// depth = dpth;
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
||||||
nodes = other.nodes;
|
nodes = other.nodes;
|
||||||
routes = other.routes;
|
routes = other.routes;
|
||||||
distance = other.distance;
|
distance = other.distance;
|
||||||
// depth = other.depth;
|
// depth = other.depth;
|
||||||
currNode = nodes.begin();
|
currNode = nodes.begin();
|
||||||
currRoute = routes.begin();
|
currRoute = routes.begin();
|
||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTaxiRoute(const FGTaxiRoute& copy) :
|
FGTaxiRoute(const FGTaxiRoute& copy) :
|
||||||
nodes(copy.nodes),
|
nodes(copy.nodes),
|
||||||
routes(copy.routes),
|
routes(copy.routes),
|
||||||
distance(copy.distance),
|
distance(copy.distance),
|
||||||
// depth(copy.depth),
|
// depth(copy.depth),
|
||||||
currNode(nodes.begin()),
|
currNode(nodes.begin()),
|
||||||
currRoute(routes.begin())
|
currRoute(routes.begin())
|
||||||
{};
|
{};
|
||||||
|
|
||||||
bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
|
bool operator< (const FGTaxiRoute &other) const {
|
||||||
bool empty () { return nodes.begin() == nodes.end(); };
|
return distance < other.distance;
|
||||||
bool next(int *nde);
|
};
|
||||||
bool next(int *nde, int *rte);
|
bool empty () {
|
||||||
void rewind(int legNr);
|
return nodes.begin() == nodes.end();
|
||||||
|
};
|
||||||
|
bool next(int *nde);
|
||||||
|
bool next(int *nde, int *rte);
|
||||||
|
void rewind(int legNr);
|
||||||
|
|
||||||
void first() { currNode = nodes.begin(); currRoute = routes.begin(); };
|
void first() {
|
||||||
int size() { return nodes.size(); };
|
currNode = nodes.begin();
|
||||||
int nodesLeft() { return nodes.end() - currNode; };
|
currRoute = routes.begin();
|
||||||
|
};
|
||||||
|
int size() {
|
||||||
|
return nodes.size();
|
||||||
|
};
|
||||||
|
int nodesLeft() {
|
||||||
|
return nodes.end() - currNode;
|
||||||
|
};
|
||||||
|
|
||||||
// int getDepth() { return depth; };
|
// int getDepth() { return depth; };
|
||||||
};
|
};
|
||||||
|
@ -227,75 +287,84 @@ typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
|
||||||
class FGGroundNetwork : public FGATCController
|
class FGGroundNetwork : public FGATCController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool hasNetwork;
|
bool hasNetwork;
|
||||||
bool networkInitialized;
|
bool networkInitialized;
|
||||||
time_t nextSave;
|
time_t nextSave;
|
||||||
//int maxDepth;
|
//int maxDepth;
|
||||||
int count;
|
int count;
|
||||||
FGTaxiNodeVector nodes;
|
FGTaxiNodeVector nodes;
|
||||||
FGTaxiNodeVector pushBackNodes;
|
FGTaxiNodeVector pushBackNodes;
|
||||||
FGTaxiSegmentVector segments;
|
FGTaxiSegmentVector segments;
|
||||||
//intVec route;
|
//intVec route;
|
||||||
//intVec nodesStack;
|
//intVec nodesStack;
|
||||||
//intVec routesStack;
|
//intVec routesStack;
|
||||||
TaxiRouteVector routes;
|
TaxiRouteVector routes;
|
||||||
TrafficVector activeTraffic;
|
TrafficVector activeTraffic;
|
||||||
TrafficVectorIterator currTraffic;
|
TrafficVectorIterator currTraffic;
|
||||||
|
|
||||||
bool foundRoute;
|
bool foundRoute;
|
||||||
double totalDistance, maxDistance;
|
double totalDistance, maxDistance;
|
||||||
FGTowerController *towerController;
|
FGTowerController *towerController;
|
||||||
FGAirport *parent;
|
FGAirport *parent;
|
||||||
|
|
||||||
|
|
||||||
//void printRoutingError(string);
|
//void printRoutingError(string);
|
||||||
|
|
||||||
void checkSpeedAdjustment(int id, double lat, double lon,
|
void checkSpeedAdjustment(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt);
|
double heading, double speed, double alt);
|
||||||
void checkHoldPosition(int id, double lat, double lon,
|
void checkHoldPosition(int id, double lat, double lon,
|
||||||
double heading, double speed, double alt);
|
double heading, double speed, double alt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGGroundNetwork();
|
FGGroundNetwork();
|
||||||
~FGGroundNetwork();
|
~FGGroundNetwork();
|
||||||
|
|
||||||
void addNode (const FGTaxiNode& node);
|
void addNode (const FGTaxiNode& node);
|
||||||
void addNodes (FGParkingVec *parkings);
|
void addNodes (FGParkingVec *parkings);
|
||||||
void addSegment(const FGTaxiSegment& seg);
|
void addSegment(const FGTaxiSegment& seg);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
bool exists() { return hasNetwork; };
|
bool exists() {
|
||||||
void setTowerController(FGTowerController *twrCtrlr) { towerController = twrCtrlr; };
|
return hasNetwork;
|
||||||
|
};
|
||||||
|
void setTowerController(FGTowerController *twrCtrlr) {
|
||||||
|
towerController = twrCtrlr;
|
||||||
|
};
|
||||||
|
|
||||||
int findNearestNode(double lat, double lon);
|
int findNearestNode(double lat, double lon);
|
||||||
int findNearestNode(const SGGeod& aGeod);
|
int findNearestNode(const SGGeod& aGeod);
|
||||||
|
|
||||||
FGTaxiNode *findNode(unsigned idx);
|
FGTaxiNode *findNode(unsigned idx);
|
||||||
FGTaxiSegment *findSegment(unsigned idx);
|
FGTaxiSegment *findSegment(unsigned idx);
|
||||||
FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true);
|
FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true);
|
||||||
//void trace(FGTaxiNode *, int, int, double dist);
|
//void trace(FGTaxiNode *, int, int, double dist);
|
||||||
|
|
||||||
int getNrOfNodes() { return nodes.size(); };
|
int getNrOfNodes() {
|
||||||
|
return nodes.size();
|
||||||
|
};
|
||||||
|
|
||||||
void setParent(FGAirport *par) { parent = par; };
|
void setParent(FGAirport *par) {
|
||||||
|
parent = par;
|
||||||
|
};
|
||||||
|
|
||||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||||
double lat, double lon, double hdg, double spd, double alt,
|
double lat, double lon, double hdg, double spd, double alt,
|
||||||
double radius, int leg, FGAIAircraft *aircraft);
|
double radius, int leg, FGAIAircraft *aircraft);
|
||||||
virtual void signOff(int id);
|
virtual void signOff(int id);
|
||||||
virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt);
|
virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt);
|
||||||
virtual bool hasInstruction(int id);
|
virtual bool hasInstruction(int id);
|
||||||
virtual FGATCInstruction getInstruction(int id);
|
virtual FGATCInstruction getInstruction(int id);
|
||||||
|
|
||||||
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
||||||
AtcMsgDir msgDir);
|
AtcMsgDir msgDir);
|
||||||
bool checkForCircularWaits(int id);
|
bool checkForCircularWaits(int id);
|
||||||
virtual void render(bool);
|
virtual void render(bool);
|
||||||
virtual string getName();
|
virtual string getName();
|
||||||
|
virtual void update(double dt);
|
||||||
|
|
||||||
void saveElevationCache();
|
void saveElevationCache();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ void FGAISchedule::scheduleFlights(time_t now)
|
||||||
FGScheduledFlight *flight = NULL;
|
FGScheduledFlight *flight = NULL;
|
||||||
do {
|
do {
|
||||||
if (currentDestination.empty()) {
|
if (currentDestination.empty()) {
|
||||||
flight = findAvailableFlight(userPort, flightIdentifier, now, (now+6400));
|
//flight = findAvailableFlight(userPort, flightIdentifier, now, (now+1800));
|
||||||
if (!flight)
|
if (!flight)
|
||||||
flight = findAvailableFlight(currentDestination, flightIdentifier);
|
flight = findAvailableFlight(currentDestination, flightIdentifier);
|
||||||
} else {
|
} else {
|
||||||
|
@ -423,7 +423,7 @@ void FGAISchedule::scheduleFlights(time_t now)
|
||||||
<< " " << arrT << ":");
|
<< " " << arrT << ":");
|
||||||
|
|
||||||
flights.push_back(flight);
|
flights.push_back(flight);
|
||||||
} while (currentDestination != startingPort);
|
} while (1); //(currentDestination != startingPort);
|
||||||
SG_LOG(SG_GENERAL, SG_BULK, " Done ");
|
SG_LOG(SG_GENERAL, SG_BULK, " Done ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue