-
- if(_transmit) {
- _counter = 0.0;
- _max_count = 5.0; // FIXME - hardwired length of message - need to calculate it!
-
- //cout << "Transmission = " << pending_transmission << '\n';
- if(_display) {
- //Render(pending_transmission, ident, false);
- Render(pending_transmission);
- }
- // Run the callback regardless of whether on same freq as user or not.
- //cout << "_callback_code = " << _callback_code << '\n';
- if(_callback_code) {
- ProcessCallback(_callback_code);
- }
- _transmit = false;
- _transmitting = true;
- } else if(_transmitting) {
- if(_counter >= _max_count) {
- //NoRender(plane.callsign); commented out since at the moment NoRender is designed just to stop repeating messages,
- // and this will be primarily used on single messages.
- _transmitting = false;
- //if(tuned_station) tuned_station->NotifyTransmissionFinished(plane.callsign);
- // TODO - need to let the plane the transmission is aimed at that it's finished.
- // However, for now we'll just release the frequency since if we don't it all goes pear-shaped
- _releaseCounter = 0.0;
- _releaseTime = 0.9;
- _runReleaseCounter = true;
- }
- _counter += dt;
- }
-}
-
-void FGATC::ReceiveUserCallback(int code) {
- SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
-}
-
-void FGATC::SetResponseReqd(const string& rid) {
- receiving = false;
- responseReqd = true;
- respond = false; // TODO - this ignores the fact that more than one plane could call this before response
- // Shouldn't happen with AI only, but user could confuse things??
- responseID = rid;
- runResponseCounter = true;
- responseCounter = 0.0;
- responseTime = 1.8; // TODO - randomize this slightly.
-}
-
-void FGATC::NotifyTransmissionFinished(const string& rid) {
- //cout << "Transmission finished, callsign = " << rid << '\n';
- receiving = false;
- responseID = rid;
- if(responseReqd) {
- runResponseCounter = true;
- responseCounter = 0.0;
- responseTime = 1.2; // TODO - randomize this slightly, and allow it to be dependent on the transmission and how busy the ATC is.
- respond = false; // TODO - this ignores the fact that more than one plane could call this before response
- // Shouldn't happen with AI only, but user could confuse things??
- } else {
- freqClear = true;
- }
-}
-
-void FGATC::Transmit(int callback_code) {
- SG_LOG(SG_ATC, SG_INFO, "Transmit called by " << ident << " " << _type << ", msg = " << pending_transmission);
- _pending = true;
- _callback_code = callback_code;
- _timeout = 0.0;
-}
-
-void FGATC::ConditionalTransmit(double timeout, int callback_code) {
- SG_LOG(SG_ATC, SG_INFO, "Timed transmit called by " << ident << " " << _type << ", msg = " << pending_transmission);
- _pending = true;
- _callback_code = callback_code;
- _timeout = timeout;
-}
-
-void FGATC::ImmediateTransmit(int callback_code) {
- SG_LOG(SG_ATC, SG_INFO, "Immediate transmit called by " << ident << " " << _type << ", msg = " << pending_transmission);
- if(_display) {
- //Render(pending_transmission, ident, false);
- Render(pending_transmission);
- // At the moment Render doesn't work except for ATIS
- }
- if(callback_code) {
- ProcessCallback(callback_code);
- }
-}
-
-// Derived classes should override this.
-void FGATC::ProcessCallback(int code) {
-}
-
-void FGATC::AddPlane(const string& pid) {
-}
-
-int FGATC::RemovePlane() {
- return 0;