diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 02d5a5c81..90eba53a9 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -49,7 +49,7 @@ #include #include #include - +#define WITH_POINT_TO_POINT #include "itm.cpp" using std::sort; @@ -521,6 +521,7 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent, FGAIFlightPlan *fp; string fltRules; string instructionText; + int ground_to_air=0; //double commFreqD; sender = rec->getAircraft()->getTrafficRef()->getCallSign(); @@ -561,6 +562,7 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent, string tmp = sender; sender = receiver; receiver = tmp; + ground_to_air=1; } switch (msgId) { case MSG_ANNOUNCE_ENGINE_START: @@ -731,7 +733,7 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent, if ((onBoardRadioFreqI0 == stationFreq) || (onBoardRadioFreqI1 == stationFreq)) { - double snr = calculate_attenuation(rec, parent, msgDir); + double snr = calculate_attenuation(rec, parent, ground_to_air); if (snr <= 0) return; if (snr > 0 && snr < 10) { @@ -751,8 +753,8 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent, } } -int calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, - AtcMsgDir msgDir) { +int FGATCController::calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, + int ground_to_air) { ///////////////////////////////////////////////// /// Implement radio attenuation /// based on the Longley-Rice propagation model @@ -773,15 +775,17 @@ int calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, // sender can be aircraft or ground station double sender_alt_ft,sender_alt; SGGeod sender_pos; - if(msgDir == ATC_GROUND_TO_AIR) { + if(ground_to_air) { sender_alt_ft = parent->getElevation(); sender_alt = sender_alt_ft * SG_FEET_TO_METER; - sender_pos= SGGeod::fromDegM( parent->getLongitude(), parent->getLatitude(), sender_alt ); + sender_pos= SGGeod::fromDegM( parent->getLongitude(), + parent->getLatitude(), sender_alt ); } else { sender_alt_ft = rec->getAltitude(); sender_alt = sender_alt_ft * SG_FEET_TO_METER; - sender_pos= SGGeod::fromDegM( rec->getLongitude(), rec->getLatitude(), sender_alt ); + sender_pos= SGGeod::fromDegM( rec->getLongitude(), + rec->getLatitude(), sender_alt ); } double point_distance= 100.0; // regular SRTM is 90 meters double course = SGGeodesy::courseDeg(own_pos, sender_pos); @@ -818,7 +822,7 @@ int calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, _elevations.push_front(distance_m); _elevations.push_front(num_points -1); int size= _elevations.size(); - double itm_elev[]; + double itm_elev[size]; for(int i=0;igetATCDialog()->removeEntry(1); } else { //cerr << "creading message for " << i->getAircraft()->getCallSign() << endl; - transmit(&(*i), parent, msgId, msgDir, false); + transmit(&(*i), &(*parent), msgId, msgDir, false); return false; } } if (now > startTime) { //cerr << "Transmitting startup msg" << endl; - transmit(&(*i), msgId, msgDir, true); + transmit(&(*i), &(*parent), msgId, msgDir, true); i->updateState(); lastTransmission = now; available = false; @@ -1361,11 +1365,11 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l if (now > startTime + 200) { if (i->pushBackAllowed()) { i->allowRepeatedTransmissions(); - transmit(&(*i), MSG_PERMIT_PUSHBACK_CLEARANCE, + transmit(&(*i), &(*parent), MSG_PERMIT_PUSHBACK_CLEARANCE, ATC_GROUND_TO_AIR, true); i->updateState(); } else { - transmit(&(*i), MSG_HOLD_PUSHBACK_CLEARANCE, + transmit(&(*i), &(*parent), MSG_HOLD_PUSHBACK_CLEARANCE, ATC_GROUND_TO_AIR, true); i->suppressRepeatedTransmissions(); } diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index d915fa264..d6a59384c 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -304,7 +304,7 @@ public: string getGateName(FGAIAircraft *aircraft); virtual void render(bool) = 0; virtual string getName() = 0; - + int calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, int ground_to_air); private: diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index 86beec118..7bf1eac2e 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -674,11 +674,11 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic atc->getATCDialog()->removeEntry(1); } else { //cerr << "creating message for " << i->getAircraft()->getCallSign() << endl; - transmit(&(*i), msgId, msgDir, false); + transmit(&(*i), &(*parent->getDynamics()), msgId, msgDir, false); return false; } } - transmit(&(*i), msgId, msgDir, true); + transmit(&(*i), &(*parent->getDynamics()), msgId, msgDir, true); i->updateState(); lastTransmission = now; available = false; @@ -1033,11 +1033,11 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat, if ((origStatus != currStatus) && available) { //cerr << "Issueing hold short instrudtion " << currStatus << " " << available << endl; if (currStatus == true) { // No has a hold short instruction - transmit(&(*current), MSG_HOLD_POSITION, ATC_GROUND_TO_AIR, true); + transmit(&(*current), &(*parent->getDynamics()), MSG_HOLD_POSITION, ATC_GROUND_TO_AIR, true); //cerr << "Transmittin hold short instrudtion " << currStatus << " " << available << endl; current->setState(1); } else { - transmit(&(*current), MSG_RESUME_TAXI, ATC_GROUND_TO_AIR, true); + transmit(&(*current), &(*parent->getDynamics()), MSG_RESUME_TAXI, ATC_GROUND_TO_AIR, true); //cerr << "Transmittig resume instrudtion " << currStatus << " " << available << endl; current->setState(2); }