]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/tcas.hxx
Performance optimization
[flightgear.git] / src / Instrumentation / tcas.hxx
index 6882c83175f3a4a34b8bca0e7bda7563d3091ef9..f44faf3985ecca5c1421671f958274bc66e5f157 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #ifndef __INSTRUMENTS_TCAS_HXX
 #define __INSTRUMENTS_TCAS_HXX
@@ -28,9 +28,8 @@
 #include <map>
 
 #include <simgear/props/props.hxx>
-#include <simgear/sound/sample_openal.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
-#include "mk_viii.hxx" // voiceplayer only
+#include <Sound/voiceplayer.hxx>
 
 using std::vector;
 using std::deque;
@@ -115,55 +114,39 @@ class TCAS : public SGSubsystem
 
     typedef struct
     {
-        bool  verticalTA;
-        bool  verticalRA;
-        bool  horizontalTA;
-        bool  horizontalRA;
-        float horizontalTau;
-        float verticalTau;
-        float relativeAltitudeFt;
-        float verticalFps;
+        string callsign;
+        bool   verticalTA;
+        bool   verticalRA;
+        bool   horizontalTA;
+        bool   horizontalRA;
+        bool   isTracked;
+        float  horizontalTau;
+        float  verticalTau;
+        float  relativeAltitudeFt;
+        float  verticalFps;
+        int    RASense;
     } ThreatInfo;
 
+    typedef struct
+    {
+        int    threatLevel;
+        double TAtimestamp;
+        double RAtimestamp;
+    } TrackerTarget;
+
+    typedef map<string,TrackerTarget*> TrackerTargets;
+
     typedef struct
     {
         double lat;
         double lon;
-        float  altFt;
+        float  pressureAltFt;
+        float  radarAltFt;
         float  heading;
         float  velocityKt;
         float  verticalFps;
     } LocalInfo; /*< info structure for local aircraft */
 
-//    /////////////////////////////////////////////////////////////////////////////
-//    // TCAS::Timer //////////////////////////////////////////////////////////////
-//    /////////////////////////////////////////////////////////////////////////////
-//
-//    class Timer
-//    {
-//        double start_time;
-//
-//    public:
-//        bool   running;
-//
-//        inline Timer ()
-//          : running(false) {}
-//
-//        inline void start () { running = true; start_time = globals->get_sim_time_sec(); }
-//        inline void stop ()  { running = false; }
-//        inline double elapsed () const { assert(running); return globals->get_sim_time_sec() - start_time; }
-//        inline double start_or_elapsed ()
-//        {
-//            if (running)
-//                return elapsed();
-//            else
-//            {
-//                start();
-//                return 0;
-//            }
-//        }
-//    };
-
     /////////////////////////////////////////////////////////////////////////////
     // TCAS::PropertiesHandler ///////////////////////////////////////////////
     /////////////////////////////////////////////////////////////////////////////
@@ -236,6 +219,7 @@ class TCAS : public SGSubsystem
         bool isPlaying (void) { return voicePlayer.is_playing();}
 
     private:
+        TCAS* tcas;
         ResolutionAdvisory previous;
         FGVoicePlayer::Voice* pLastVoice;
         VoicePlayer voicePlayer;
@@ -267,6 +251,33 @@ class TCAS : public SGSubsystem
         SGPropertyNode_ptr nodeTAWarning;
     };
 
+    /////////////////////////////////////////////////////////////////////////////
+    // TCAS::Tracker ////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////////////////
+
+    class Tracker
+    {
+    public:
+        Tracker  (TCAS* _tcas);
+        ~Tracker (void) {}
+
+        void update          (void);
+
+        void add             (const string callsign, int detectedLevel);
+        bool active          (void) { return haveTargets;}
+        bool newTraffic      (void) { return newTargets;}
+        bool isTracked       (string callsign) { if (!haveTargets) return false;else return _isTracked(callsign);}
+        bool _isTracked      (string callsign);
+        int  getThreatLevel  (string callsign);
+
+    private:
+        TCAS*  tcas;
+        double currentTime;
+        bool   haveTargets;
+        bool   newTargets;
+        TrackerTargets targets;
+    };
+    
     /////////////////////////////////////////////////////////////////////////////
     // TCAS::AdvisoryGenerator //////////////////////////////////////////////////
     /////////////////////////////////////////////////////////////////////////////
@@ -277,7 +288,7 @@ class TCAS : public SGSubsystem
         AdvisoryGenerator        (TCAS* _tcas);
         ~AdvisoryGenerator       (void) {}
 
-        void init                (const LocalInfo* _pSelf, const ThreatInfo* _pCurrentThreat);
+        void init                (const LocalInfo* _pSelf, ThreatInfo* _pCurrentThreat);
 
         void setAlarmThresholds  (const SensitivityLevel* _pAlarmThresholds);
 
@@ -291,7 +302,7 @@ class TCAS : public SGSubsystem
     private:
         TCAS*             tcas;
         const LocalInfo*  pSelf;          /*< info structure for local aircraft */
-        const ThreatInfo* pCurrentThreat; /*< info structure on current intruder/threat */
+        ThreatInfo* pCurrentThreat; /*< info structure on current intruder/threat */
         const SensitivityLevel* pAlarmThresholds;
     };
 
@@ -314,9 +325,14 @@ class TCAS : public SGSubsystem
         void  horizontalThreat    (float bearing, float distanceNm, float heading,
                                    float velocityKt);
 
-        void  setAlt              (float altFt) { self.altFt = altFt;}
-        float getAlt              (void)        { return self.altFt;}
+        void  setPressureAlt      (float altFt) { self.pressureAltFt = altFt;}
+        float getPressureAlt      (void)        { return self.pressureAltFt;}
+
+        void  setRadarAlt         (float altFt) { self.radarAltFt = altFt;}
+        float getRadarAlt         (void)        { return self.radarAltFt;}
+
         float getVelocityKt       (void)        { return self.velocityKt;}
+        int   getRASense          (void)        { return currentThreat.RASense;}
 
     private:
         void  unitTest            (void);
@@ -329,7 +345,8 @@ class TCAS : public SGSubsystem
 
         SGPropertyNode_ptr nodeLat;
         SGPropertyNode_ptr nodeLon;
-        SGPropertyNode_ptr nodeAlt;
+        SGPropertyNode_ptr nodePressureAlt;
+        SGPropertyNode_ptr nodeRadarAlt;
         SGPropertyNode_ptr nodeHeading;
         SGPropertyNode_ptr nodeVelocity;
         SGPropertyNode_ptr nodeVerticalFps;
@@ -354,6 +371,7 @@ private:
 
     PropertiesHandler   properties_handler;
     ThreatDetector      threatDetector;
+    Tracker             tracker;
     AdvisoryCoordinator advisoryCoordinator;
     AdvisoryGenerator   advisoryGenerator;
     Annunciator         annunciator;