]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/tcas.hxx
Support helipad names in the --runway startup option
[flightgear.git] / src / Instrumentation / tcas.hxx
index 6882c83175f3a4a34b8bca0e7bda7563d3091ef9..97fae4f374b1d2192c4d67c18716a253ebcdc233 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,66 +114,48 @@ class TCAS : public SGSubsystem
 
     typedef struct
     {
-        bool  verticalTA;
-        bool  verticalRA;
-        bool  horizontalTA;
-        bool  horizontalRA;
-        float horizontalTau;
-        float verticalTau;
-        float relativeAltitudeFt;
-        float verticalFps;
+        std::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<std::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 ///////////////////////////////////////////////
     /////////////////////////////////////////////////////////////////////////////
 
     class PropertiesHandler : public FGVoicePlayer::PropertiesHandler
     {
-      TCAS *tcas;
-
     public:
-      PropertiesHandler (TCAS *device) :
-        FGVoicePlayer::PropertiesHandler(), tcas(device) {}
+      PropertiesHandler (TCAS *) :
+        FGVoicePlayer::PropertiesHandler() {}
 
       PropertiesHandler (void) : FGVoicePlayer::PropertiesHandler() {}
     };
@@ -236,6 +217,7 @@ class TCAS : public SGSubsystem
         bool isPlaying (void) { return voicePlayer.is_playing();}
 
     private:
+        TCAS* tcas;
         ResolutionAdvisory previous;
         FGVoicePlayer::Voice* pLastVoice;
         VoicePlayer voicePlayer;
@@ -254,6 +236,7 @@ class TCAS : public SGSubsystem
 
         void bind            (SGPropertyNode* node);
         void init            (void);
+        void reinit          (void);
         void update          (int mode);
 
         void clear           (void);
@@ -267,6 +250,32 @@ class TCAS : public SGSubsystem
         SGPropertyNode_ptr nodeTAWarning;
     };
 
+    /////////////////////////////////////////////////////////////////////////////
+    // TCAS::Tracker ////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////////////////
+
+    class Tracker
+    {
+    public:
+        Tracker  (TCAS* _tcas);
+        ~Tracker (void) {}
+
+        void update          (void);
+
+        void add             (const std::string callsign, int detectedLevel);
+        bool active          (void) { return haveTargets;}
+        bool newTraffic      (void) { return newTargets;}
+        bool isTracked       (std::string callsign) { if (!haveTargets) return false;else return _isTracked(callsign);}
+        bool _isTracked      (std::string callsign);
+        int  getThreatLevel  (std::string callsign);
+
+    private:
+        double currentTime;
+        bool   haveTargets;
+        bool   newTargets;
+        TrackerTargets targets;
+    };
+    
     /////////////////////////////////////////////////////////////////////////////
     // TCAS::AdvisoryGenerator //////////////////////////////////////////////////
     /////////////////////////////////////////////////////////////////////////////
@@ -277,7 +286,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 +300,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 +323,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);
@@ -325,11 +339,14 @@ class TCAS : public SGSubsystem
         static const SensitivityLevel sensitivityLevels[];
 
         TCAS*              tcas;
+#ifdef FEATURE_TCAS_DEBUG_THREAT_DETECTOR
         int                checkCount;
-
+#endif // of FEATURE_TCAS_DEBUG_THREAT_DETECTOR
+        
         SGPropertyNode_ptr nodeLat;
         SGPropertyNode_ptr nodeLon;
-        SGPropertyNode_ptr nodeAlt;
+        SGPropertyNode_ptr nodePressureAlt;
+        SGPropertyNode_ptr nodeRadarAlt;
         SGPropertyNode_ptr nodeHeading;
         SGPropertyNode_ptr nodeVelocity;
         SGPropertyNode_ptr nodeVerticalFps;
@@ -340,7 +357,7 @@ class TCAS : public SGSubsystem
     };
 
 private:
-    string              name;
+    std::string              name;
     int                 num;
     double              nextUpdateTime;
     int                 selfTestStep;
@@ -354,6 +371,7 @@ private:
 
     PropertiesHandler   properties_handler;
     ThreatDetector      threatDetector;
+    Tracker             tracker;
     AdvisoryCoordinator advisoryCoordinator;
     AdvisoryGenerator   advisoryGenerator;
     Annunciator         annunciator;
@@ -367,6 +385,7 @@ public:
     virtual void bind   (void);
     virtual void unbind (void);
     virtual void init   (void);
+    virtual void reinit (void);
     virtual void update (double dt);
 };