]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/mk_viii.hxx
GPWS: avoid "altitude_callout_voice != NULL" assertion
[flightgear.git] / src / Instrumentation / mk_viii.hxx
index 423562cfe2cdf5d4dbcfc6cd1a888272a94f3cc4..e37fc972be2bfa2fa9bfe9ae2b862b9609bed99c 100755 (executable)
@@ -1,4 +1,4 @@
-// mk_viii.cxx -- Honeywell MK VIII EGPWS emulation
+// mk_viii.hxx -- Honeywell MK VIII EGPWS emulation
 //
 // Written by Jean-Yves Lefort, started September 2005.
 //
@@ -36,6 +36,8 @@ using std::vector;
 using std::deque;
 using std::map;
 
+class SGSampleGroup;
+
 #include <Airports/runways.hxx>
 #include <Airports/simple.hxx>
 #include <Main/globals.hxx>
@@ -198,6 +200,9 @@ class MK_VIII : public SGSubsystem
       SGPropertyNode_ptr altimeter_serviceable;
       SGPropertyNode_ptr altitude;
       SGPropertyNode_ptr altitude_agl;
+      SGPropertyNode_ptr altitude_gear_agl;
+      SGPropertyNode_ptr altitude_radar_agl;
+      SGPropertyNode_ptr orientation_roll;
       SGPropertyNode_ptr asi_serviceable;
       SGPropertyNode_ptr asi_speed;
       SGPropertyNode_ptr autopilot_heading_lock;
@@ -477,6 +482,8 @@ public:
       bool                     alternate_steep_approach;
       bool                     use_internal_gps;
       bool                     localizer_enabled;
+      int                      altitude_source;
+      bool                     use_attitude_indicator;
     } conf;
 
     struct _s_input_feeders
@@ -603,6 +610,7 @@ public:
     void update_egpws_alert_discrete_2 ();
     void update_egpwc_alert_discrete_3 ();
     void update_outputs ();
+    void reposition ();
 
     void update_lamps ();
     void set_lamp (Lamp lamp);
@@ -629,10 +637,11 @@ public:
       typedef deque< Sample<double> > samples_type;
       samples_type             samples;
       double                   value;
+      double                   last_update;
 
     public:
       inline TerrainClearanceFilter ()
-       : value(0) {}
+       : value(0.0), last_update(-1.0) {}
 
       double update (double agl);
       void reset ();
@@ -733,10 +742,10 @@ public:
       public:
        bool silence;
 
-       virtual inline void play (double volume) {}
+       virtual inline void play (float volume) {}
        virtual inline void stop () {}
        virtual bool is_playing () = 0;
-       virtual inline void set_volume (double volume) {}
+       virtual inline void set_volume (float volume) {}
       };
 
       /////////////////////////////////////////////////////////////////////////
@@ -745,17 +754,17 @@ public:
 
       class SampleElement : public Element
       {
-       SGSoundSample   *_sample;
-       double          _volume;
+       SGSharedPtr<SGSoundSample>      _sample;
+       float                           _volume;
 
       public:
-       inline SampleElement (SGSoundSample *sample, double volume = 1.0)
+       inline SampleElement (SGSharedPtr<SGSoundSample> sample, float volume = 1.0)
          : _sample(sample), _volume(volume) { silence = false; }
 
-        virtual inline void play (double volume) { if (_sample) { set_volume(volume); _sample->play_once(); } }
+        virtual inline void play (float volume) { if (_sample && (volume > 0.05)) { set_volume(volume); _sample->play_once(); } }
        virtual inline void stop () { if (_sample) _sample->stop(); }
         virtual inline bool is_playing () { return _sample ? _sample->is_playing() : false; }
-       virtual inline void set_volume (double volume) { if (_sample) _sample->set_volume(volume * _volume); }
+       virtual inline void set_volume (float volume) { if (_sample) _sample->set_volume(volume * _volume); }
       };
 
       /////////////////////////////////////////////////////////////////////////
@@ -771,7 +780,7 @@ public:
        inline SilenceElement (double duration)
          : _duration(duration) { silence = true; }
 
-       virtual inline void play (double volume) { start_time = globals->get_sim_time_sec(); }
+       virtual inline void play (float volume) { start_time = globals->get_sim_time_sec(); }
        virtual inline bool is_playing () { return globals->get_sim_time_sec() - start_time < _duration; }
       };
 
@@ -790,19 +799,19 @@ public:
 
       void play ();
       void stop (bool now);
-      void set_volume (double _volume);
+      void set_volume (float _volume);
       void volume_changed ();
       void update ();
 
     private:
       VoicePlayer *player;
 
-      double volume;
+      float volume;
 
       vector<Element *>                        elements;
       vector<Element *>::iterator      iter;
 
-      inline double get_volume () const { return player->volume * player->speaker.volume * volume; }
+      inline float get_volume () const { return player->volume * player->speaker.volume * volume; }
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -811,10 +820,10 @@ public:
 
     struct
     {
-      double volume;
+      float volume;
     } conf;
 
-    double volume;
+    float volume;
 
     Voice *voice;
     Voice *next_voice;
@@ -871,7 +880,7 @@ public:
     };
     void stop (unsigned int flags = 0);
 
-    void set_volume (double _volume);
+    void set_volume (float _volume);
     void update ();
 
     inline void bind (SGPropertyNode *node) { speaker.bind(node); }
@@ -887,13 +896,6 @@ public:
       VoicePlayer *player;
 
       double   pitch;
-      float    position[3];
-      float    orientation[3];
-      float    inner_cone;
-      float    outer_cone;
-      float    outer_gain;
-      float    reference_dist;
-      float    max_dist;
 
       template <class T>
       inline void tie (SGPropertyNode *node, const char *name, T *ptr)
@@ -913,20 +915,13 @@ public:
       template <class T>
       inline T get_property (T *ptr) const { return *ptr; }
 
-      double volume;
+      float volume;
 
       inline Speaker (VoicePlayer *_player)
        : player(_player),
          pitch(1),
-         inner_cone(360),
-         outer_cone(360),
-         outer_gain(0),
-         reference_dist(3),
-         max_dist(10),
          volume(1)
       {
-       position[0] = 0; position[1] = 0; position[2] = 0;
-       orientation[0] = 0; orientation[1] = 0; orientation[2] = 0;
       }
 
       void bind (SGPropertyNode *node);
@@ -940,9 +935,10 @@ public:
 
     MK_VIII *mk;
 
+    SGSharedPtr<SGSampleGroup> _sgr;
     Speaker speaker;
 
-    map<string, SGSoundSample *>       samples;
+    map< string, SGSharedPtr<SGSoundSample> >  samples;
     vector<Voice *>                    _voices;
 
     bool looped;
@@ -1369,7 +1365,7 @@ private:
     } conf;
 
     inline Mode4Handler (MK_VIII *device)
-      : mk(device) {}
+      : mk(device),ab_bias(0.0),ab_expanded_bias(0.0),c_bias(0.0) {}
 
     double get_upper_agl (const EnvelopesConfiguration *c);
     void update ();
@@ -1413,7 +1409,7 @@ private:
 
   public:
     inline Mode5Handler (MK_VIII *device)
-      : mk(device) {}
+      : mk(device), soft_bias(0.0) {}
 
     void update ();
   };
@@ -1465,7 +1461,7 @@ private:
     void power_off ();
     void enter_takeoff ();
     void leave_takeoff ();
-    void set_volume (double volume);
+    void set_volume (float volume);
     bool altitude_callouts_enabled ();
     void update ();
 
@@ -1594,10 +1590,6 @@ private:
         : mk(device) {}
         
       virtual bool passAirport(FGAirport *a) const;
-      
-      virtual FGPositioned::Type maxType() const {
-        return FGPositioned::AIRPORT;
-      }
     private:
       MK_VIII* mk;
     };