]> git.mxchange.org Git - flightgear.git/commitdiff
* First test scenario to get user ATC interaction working.
authorDurk Talsma <durk@localhost.(none)>
Thu, 14 Apr 2011 15:51:46 +0000 (17:51 +0200)
committerDurk Talsma <durk@localhost.(none)>
Thu, 14 Apr 2011 15:51:46 +0000 (17:51 +0200)
src/ATC/atcdialog.cxx
src/ATC/trafficcontrol.cxx
src/ATC/trafficcontrol.hxx

index 3ab9e28d7f2fd77df5380ce759193fb97aa30e04..5feb94dd0a73aab6bdda1976d32daaec589b1d64 100644 (file)
@@ -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
index e24444d1317b2b49f94e9133fc9b96ed3c8e41ca..5dad818ae45224729ed2bb4d1ae045373de64fc8 100644 (file)
@@ -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()) {
index 3780233404897c99d3c1f84c75bd0fed96b0df82..8de329ba9026b7fd6dc5db8e0001ce9de430827d 100644 (file)
@@ -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);
+
 }; 
 
 /******************************************************************************