From dee72d34340f49509cf00e6a59b684eb89006211 Mon Sep 17 00:00:00 2001 From: Durk Talsma Date: Thu, 14 Apr 2011 17:51:46 +0200 Subject: [PATCH] * First test scenario to get user ATC interaction working. --- src/ATC/atcdialog.cxx | 5 +++-- src/ATC/trafficcontrol.cxx | 43 +++++++++++++++++++++++++++++++++++++- src/ATC/trafficcontrol.hxx | 4 ++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx index 3ab9e28d7..5feb94dd0 100644 --- a/src/ATC/atcdialog.cxx +++ b/src/ATC/atcdialog.cxx @@ -60,7 +60,7 @@ void FGATCDialogNew::init() { // initialize properties polled in Update() //globals->get_props()->setStringValue("/sim/atc/freq-airport", ""); - //globals->get_props()->setIntValue("/sim/atc/transmission-num", -1); + globals->get_props()->setIntValue("/sim/atc/transmission-num", -1); } @@ -134,11 +134,12 @@ void FGATCDialogNew::PopupDialog() { } void FGATCDialogNew::update(double dt) { + /* static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); int n = trans_num->getIntValue(); if (n >= 0) { trans_num->setIntValue(-1); // PopupCallback(n); cerr << "Selected transmission message" << n << endl; - } + } */ } \ No newline at end of file diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index e24444d13..5dad818ae 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -1002,6 +1002,35 @@ void FGStartupController::signOff(int id) } } +bool FGStartupController::checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId, + AtcMsgDir msgDir) +{ + int state = i->getState(); + if ((state == st) && available) { + if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) { + cerr << "Checking state " << st << " for " << i->getAircraft()->getCallSign() << endl; + static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); + int n = trans_num->getIntValue(); + if (n >= 0) { + trans_num->setIntValue(-1); + // PopupCallback(n); + cerr << "Selected transmission message" << n << endl; + } else { + return false; + } + } + if (now > startTime) { + //cerr << "Transmitting startup msg" << endl; + transmit(&(*i), msgId, msgDir); + i->updateState(); + lastTransmission = now; + available = false; + return true; + } + } + return false; +} + void FGStartupController::updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt) @@ -1044,6 +1073,18 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l available = true; } + checkTransmissionState(0, now, (startTime + 0 ), i, MSG_ANNOUNCE_ENGINE_START, ATC_AIR_TO_GROUND); + checkTransmissionState(1, now, (startTime + 60 ), i, MSG_REQUEST_ENGINE_START, ATC_AIR_TO_GROUND); + checkTransmissionState(2, now, (startTime + 80 ), i, MSG_PERMIT_ENGINE_START, ATC_GROUND_TO_AIR); + checkTransmissionState(3, now, (startTime + 100), i, MSG_ACKNOWLEDGE_ENGINE_START, ATC_AIR_TO_GROUND); + if (checkTransmissionState(4, now, (startTime + 130), i, MSG_ACKNOWLEDGE_SWITCH_GROUND_FREQUENCY, ATC_AIR_TO_GROUND)) { + i->nextFrequency(); + } + checkTransmissionState(5, now, (startTime + 140), i, MSG_INITIATE_CONTACT, ATC_AIR_TO_GROUND); + checkTransmissionState(6, now, (startTime + 150), i, MSG_ACKNOWLEDGE_INITIATE_CONTACT, ATC_GROUND_TO_AIR); + + + /* if ((state == 0) && available) { if (now > startTime) { //cerr << "Transmitting startup msg" << endl; @@ -1118,7 +1159,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l lastTransmission = now; available = false; } - } + } */ if ((state == 8) && available) { if (now > startTime + 200) { if (i->pushBackAllowed()) { diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index 378023340..8de329ba9 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -336,6 +336,10 @@ public: bool hasActiveTraffic() { 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. + bool checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId, + AtcMsgDir msgDir); + }; /******************************************************************************