/***************************************************************************
* FGTrafficRecord
**************************************************************************/
+FGTrafficRecord::FGTrafficRecord() :
+ id(0), waitsForId(0),
+ currentPos(0),
+ leg(0),
+ latitude(0),
+ longitude(0),
+ heading(0),
+ speed(0),
+ altitude(0),
+ radius(0) {
+}
+
void FGTrafficRecord::setPositionAndIntentions(int pos, FGAIFlightPlan *route)
{
intVecIterator i = intentions.begin();
if ((*i) != pos) {
SG_LOG(SG_GENERAL, SG_ALERT, "Error in FGTrafficRecord::setPositionAndIntentions");
- cerr << "Pos : " << pos << " Curr " << *(intentions.begin()) << endl;
+ //cerr << "Pos : " << pos << " Curr " << *(intentions.begin()) << endl;
for (intVecIterator i = intentions.begin(); i != intentions.end() ; i++) {
- cerr << (*i) << " ";
+ //cerr << (*i) << " ";
}
- cerr << endl;
+ //cerr << endl;
}
intentions.erase(i);
} else {
//cerr << "setting intentions ";
for (int i = 0; i < size; i++) {
int val = route->getRouteIndex(i);
-
+ //cerr << val<< " ";
if ((val) && (val != pos))
{
intentions.push_back(val);
- //cerr << val<< " ";
+ //cerr << "[set] ";
}
}
//cerr << endl;
//cerr << "Start check 1" << endl;
if (currentPos == other.currentPos)
{
- //cerr << "Check Position and intentions: current matches" << endl;
+ //cerr << callsign << ": Check Position and intentions: we are on the same taxiway" << other.callsign << "Index = " << currentPos << endl;
result = true;
}
// else if (other.intentions.size())
i++;
}
if (i != intentions.end()) {
- //cerr << "Check Position and intentions: .other.current matches" << endl;
+ //cerr << callsign << ": Check Position and intentions: .other.current matches" << other.callsign << "Index = " << (*i) << endl;
result = true;
}
}
if ((*i) > 0) {
if ((currentTargetNode == net->findSegment(*i)->getEnd()->getIndex()))
{
- cerr << "Current crosses at " << currentTargetNode <<endl;
+ //cerr << "Current crosses at " << currentTargetNode <<endl;
return currentTargetNode;
}
}
if ((*i) > 0) {
if (otherTargetNode == net->findSegment(*i)->getEnd()->getIndex())
{
- cerr << "Other crosses at " << currentTargetNode <<endl;
+ //cerr << "Other crosses at " << currentTargetNode <<endl;
return otherTargetNode;
}
}
return -1;
}
+bool FGTrafficRecord::onRoute(FGGroundNetwork *net, FGTrafficRecord &other)
+{
+ int node = -1, othernode = -1;
+ if (currentPos >0)
+ node = net->findSegment(currentPos)->getEnd()->getIndex();
+ if (other.currentPos > 0)
+ othernode = net->findSegment(other.currentPos)->getEnd()->getIndex();
+ if ((node == othernode) && (node != -1))
+ return true;
+ if (other.intentions.size())
+ {
+ for (intVecIterator i = other.intentions.begin(); i != other.intentions.end(); i++)
+ {
+ if (*i > 0)
+ {
+ othernode = net->findSegment(*i)->getEnd()->getIndex();
+ if ((node == othernode) && (node > -1))
+ return true;
+ }
+ }
+ }
+ //if (other.currentPos > 0)
+ // othernode = net->findSegment(other.currentPos)->getEnd()->getIndex();
+ //if (intentions.size())
+ // {
+ // for (intVecIterator i = intentions.begin(); i != intentions.end(); i++)
+ // {
+ // if (*i > 0)
+ // {
+ // node = net->findSegment(*i)->getEnd()->getIndex();
+ // if ((node == othernode) && (node > -1))
+ // return true;
+ // }
+ // }
+ // }
+ return false;
+}
+
+
bool FGTrafficRecord::isOpposing (FGGroundNetwork *net, FGTrafficRecord &other, int node)
{
// Check if current segment is the reverse segment for the other aircraft
for (intVecIterator i = intentions.begin(); i != intentions.end(); i++)
{
+ if (opp = net->findSegment(other.currentPos)->opposite())
+ {
+ if ((*i) > 0)
+ if (opp->getIndex() == net->findSegment(*i)->getIndex())
+ {
+ if (net->findSegment(*i)->getStart()->getIndex() == node) {
+ {
+ //cerr << "Found the node " << node << endl;
+ return true;
+ }
+ }
+ }
+ }
if (other.intentions.size())
{
for (intVecIterator j = other.intentions.begin(); j != other.intentions.end(); j++)
if (opp->getIndex() ==
net->findSegment(*j)->getIndex())
{
- cerr << "Nodes " << net->findSegment(*i)->getIndex()
- << " and " << net->findSegment(*j)->getIndex()
- << " are opposites " << endl;
+ //cerr << "Nodes " << net->findSegment(*i)->getIndex()
+ // << " and " << net->findSegment(*j)->getIndex()
+ // << " are opposites " << endl;
if (net->findSegment(*i)->getStart()->getIndex() == node) {
{
- cerr << "Found the node" << endl;
+ //cerr << "Found the node " << node << endl;
return true;
}
}
changeSpeed = false;
changeHeading = false;
changeAltitude = false;
+ resolveCircularWait = false;
double speed = 0;
double heading = 0;
bool FGATCInstruction::hasInstruction()
{
- return (holdPattern || holdPosition || changeSpeed || changeHeading || changeAltitude);
+ return (holdPattern || holdPosition || changeSpeed || changeHeading || changeAltitude || resolveCircularWait);
}
//
void FGTowerController::announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentPosition,
double lat, double lon, double heading,
- double speed, double alt, double radius, int leg)
+ double speed, double alt, double radius, int leg,
+ string callsign)
{
TrafficVectorIterator i = activeTraffic.begin();
// Search whether the current id alread has an entry
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
FGTrafficRecord rec;
rec.setId(id);
+
rec.setPositionAndHeading(lat, lon, heading, speed, alt);
rec.setRunway(intendedRoute->getRunway());
rec.setLeg(leg);
+ rec.setCallSign(callsign);
activeTraffic.push_back(rec);
} else {
i->setPositionAndHeading(lat, lon, heading, speed, alt);