X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fmk_viii.hxx;h=81a33580b01f6c17b20365d0ca61000b9c7edafa;hb=1eb8ae1fbf43359eec09b99885a9280f529c86fb;hp=423562cfe2cdf5d4dbcfc6cd1a888272a94f3cc4;hpb=67c7d8642aff1cbfda0829f2ff3d1c031a48c423;p=flightgear.git diff --git a/src/Instrumentation/mk_viii.hxx b/src/Instrumentation/mk_viii.hxx old mode 100755 new mode 100644 index 423562cfe..81a33580b --- a/src/Instrumentation/mk_viii.hxx +++ b/src/Instrumentation/mk_viii.hxx @@ -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. // @@ -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_MK_VIII_HXX @@ -29,22 +29,25 @@ #include #include -#include +#include #include - using std::vector; using std::deque; using std::map; +class SGSampleGroup; + #include -#include +#include #include
+#include #ifdef _MSC_VER # pragma warning( push ) # pragma warning( disable: 4355 ) #endif + /////////////////////////////////////////////////////////////////////////////// // MK_VIII //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -54,49 +57,6 @@ class MK_VIII : public SGSubsystem // keep in sync with Mode6Handler::altitude_callout_definitions[] static const unsigned n_altitude_callouts = 11; - ///////////////////////////////////////////////////////////////////////////// - // MK_VIII::RawValueMethodsData ///////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////// - - template - class RawValueMethodsData : public SGRawValue - { - public: - typedef VT (C::*getter_t) (DT) const; - typedef void (C::*setter_t) (DT, VT); - - RawValueMethodsData (C &obj, DT data, getter_t getter = 0, setter_t setter = 0) - : _obj(obj), _data(data), _getter(getter), _setter(setter) {} - - virtual VT getValue () const - { - if (_getter) - return (_obj.*_getter)(_data); - else - return SGRawValue::DefaultValue(); - } - virtual bool setValue (VT value) - { - if (_setter) - { - (_obj.*_setter)(_data, value); - return true; - } - else - return false; - } - virtual SGRawValue *clone () const - { - return new RawValueMethodsData(_obj, _data, _getter, _setter); - } - - private: - C &_obj; - DT _data; - getter_t _getter; - setter_t _setter; - }; - ///////////////////////////////////////////////////////////////////////////// // MK_VIII::Parameter /////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// @@ -182,12 +142,10 @@ class MK_VIII : public SGSubsystem // MK_VIII::PropertiesHandler /////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// - class PropertiesHandler + class PropertiesHandler : public FGVoicePlayer::PropertiesHandler { MK_VIII *mk; - vector tied_properties; - public: struct { @@ -198,6 +156,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; @@ -220,27 +181,11 @@ class MK_VIII : public SGSubsystem } external_properties; inline PropertiesHandler (MK_VIII *device) - : mk(device) {} - - template - inline void tie (SGPropertyNode *node, const SGRawValue &raw_value) - { - node->tie(raw_value); - tied_properties.push_back(node); - } - - template - inline void tie (SGPropertyNode *node, - const char *relative_path, - const SGRawValue &raw_value) - { - tie(node->getNode(relative_path, true), raw_value); - } + : FGVoicePlayer::PropertiesHandler(), mk(device) {} - PropertiesHandler() {}; + PropertiesHandler() : FGVoicePlayer::PropertiesHandler() {} void init (); - void unbind (); }; public: @@ -477,6 +422,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 +550,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 +577,11 @@ public: typedef deque< Sample > 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 (); @@ -707,263 +656,49 @@ public: bool *get_lamp_output (Lamp lamp); }; - - ///////////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer ///////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////// - - class VoicePlayer + + class VoicePlayer : public FGVoicePlayer { public: + VoicePlayer (MK_VIII *device) : + FGVoicePlayer(&device->properties_handler, "mk-viii") + {} - /////////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer::Voice //////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////// - - class Voice - { - public: - - ///////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer::Voice::Element //////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////// - - class Element - { - public: - bool silence; - - virtual inline void play (double volume) {} - virtual inline void stop () {} - virtual bool is_playing () = 0; - virtual inline void set_volume (double volume) {} - }; - - ///////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer::Voice::SampleElement /////////////////////////// - ///////////////////////////////////////////////////////////////////////// - - class SampleElement : public Element - { - SGSoundSample *_sample; - double _volume; - - public: - inline SampleElement (SGSoundSample *sample, double 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 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); } - }; - - ///////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer::Voice::SilenceElement ////////////////////////// - ///////////////////////////////////////////////////////////////////////// - - class SilenceElement : public Element - { - double _duration; - double start_time; - - public: - inline SilenceElement (double duration) - : _duration(duration) { silence = true; } - - virtual inline void play (double volume) { start_time = globals->get_sim_time_sec(); } - virtual inline bool is_playing () { return globals->get_sim_time_sec() - start_time < _duration; } - }; - - ///////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer::Voice (continued) ////////////////////////////// - ///////////////////////////////////////////////////////////////////////// - - Element *element; - - inline Voice (VoicePlayer *_player) - : element(NULL), player(_player), volume(1.0) {} - - ~Voice (); - - inline void append (Element *_element) { elements.push_back(_element); } - - void play (); - void stop (bool now); - void set_volume (double _volume); - void volume_changed (); - void update (); - - private: - VoicePlayer *player; - - double volume; - - vector elements; - vector::iterator iter; - - inline double get_volume () const { return player->volume * player->speaker.volume * volume; } - }; - - /////////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer (continued) /////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////// - - struct - { - double volume; - } conf; - - double volume; - - Voice *voice; - Voice *next_voice; - - struct - { - Voice *application_data_base_failed; - Voice *bank_angle; - Voice *bank_angle_bank_angle; - Voice *bank_angle_bank_angle_3; - Voice *bank_angle_inop; - Voice *bank_angle_pause_bank_angle; - Voice *bank_angle_pause_bank_angle_3; - Voice *callouts_inop; - Voice *configuration_type_invalid; - Voice *dont_sink; - Voice *dont_sink_pause_dont_sink; - Voice *five_hundred_above; - Voice *glideslope; - Voice *glideslope_inop; - Voice *gpws_inop; - Voice *hard_glideslope; - Voice *minimums; - Voice *minimums_minimums; - Voice *pull_up; - Voice *sink_rate; - Voice *sink_rate_pause_sink_rate; - Voice *soft_glideslope; - Voice *terrain; - Voice *terrain_pause_terrain; - Voice *too_low_flaps; - Voice *too_low_gear; - Voice *too_low_terrain; - Voice *altitude_callouts[n_altitude_callouts]; - } voices; - - inline VoicePlayer (MK_VIII *device) - : voice(NULL), next_voice(NULL), mk(device), speaker(this) {} - - ~VoicePlayer (); - - void init (); - - enum - { - PLAY_NOW = 1 << 0, - PLAY_LOOPED = 1 << 1 - }; - void play (Voice *_voice, unsigned int flags = 0); - - enum - { - STOP_NOW = 1 << 0 - }; - void stop (unsigned int flags = 0); - - void set_volume (double _volume); - void update (); - - inline void bind (SGPropertyNode *node) { speaker.bind(node); } - - public: - - /////////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer::Speaker ////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////// - - class Speaker - { - 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 - inline void tie (SGPropertyNode *node, const char *name, T *ptr) - { - player->mk->properties_handler.tie - (node, (string("speaker/") + name).c_str(), - RawValueMethodsData - (*this, ptr, - &MK_VIII::VoicePlayer::Speaker::get_property, - &MK_VIII::VoicePlayer::Speaker::set_property)); - } + ~VoicePlayer() {} + void init (); - public: - template - inline void set_property (T *ptr, T value) { *ptr = value; update_configuration(); } - - template - inline T get_property (T *ptr) const { return *ptr; } - - double 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) + struct { - position[0] = 0; position[1] = 0; position[2] = 0; - orientation[0] = 0; orientation[1] = 0; orientation[2] = 0; - } - - void bind (SGPropertyNode *node); - void update_configuration (); - }; - - private: - /////////////////////////////////////////////////////////////////////////// - // MK_VIII::VoicePlayer (continued) /////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////// - - MK_VIII *mk; - - Speaker speaker; - - map samples; - vector _voices; - - bool looped; - bool next_looped; - - SGSoundSample *get_sample (const char *name); - - inline void append (Voice *voice, Voice::Element *element) { voice->append(element); } - inline void append (Voice *voice, const char *sample_name) { voice->append(new Voice::SampleElement(get_sample(sample_name))); } - inline void append (Voice *voice, double silence) { voice->append(new Voice::SilenceElement(silence)); } - - inline void make_voice (Voice **voice) { *voice = new Voice(this); _voices.push_back(*voice); } - - template - inline void make_voice (Voice **voice, T1 e1) { make_voice(voice); append(*voice, e1); } - template - inline void make_voice (Voice **voice, T1 e1, T2 e2) { make_voice(voice, e1); append(*voice, e2); } - template - inline void make_voice (Voice **voice, T1 e1, T2 e2, T3 e3) { make_voice(voice, e1, e2); append(*voice, e3); } - template - inline void make_voice (Voice **voice, T1 e1, T2 e2, T3 e3, T4 e4) { make_voice(voice, e1, e2, e3); append(*voice, e4); } + Voice *application_data_base_failed; + Voice *bank_angle; + Voice *bank_angle_bank_angle; + Voice *bank_angle_bank_angle_3; + Voice *bank_angle_inop; + Voice *bank_angle_pause_bank_angle; + Voice *bank_angle_pause_bank_angle_3; + Voice *callouts_inop; + Voice *configuration_type_invalid; + Voice *dont_sink; + Voice *dont_sink_pause_dont_sink; + Voice *five_hundred_above; + Voice *glideslope; + Voice *glideslope_inop; + Voice *gpws_inop; + Voice *hard_glideslope; + Voice *minimums; + Voice *minimums_minimums; + Voice *pull_up; + Voice *sink_rate; + Voice *sink_rate_pause_sink_rate; + Voice *soft_glideslope; + Voice *terrain; + Voice *terrain_pause_terrain; + Voice *too_low_flaps; + Voice *too_low_gear; + Voice *too_low_terrain; + Voice *altitude_callouts[n_altitude_callouts]; + } voices; + }; private: @@ -1369,7 +1104,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 +1148,7 @@ private: public: inline Mode5Handler (MK_VIII *device) - : mk(device) {} + : mk(device), soft_bias(0.0) {} void update (); }; @@ -1465,7 +1200,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 +1329,6 @@ private: : mk(device) {} virtual bool passAirport(FGAirport *a) const; - - virtual FGPositioned::Type maxType() const { - return FGPositioned::AIRPORT; - } private: MK_VIII* mk; };