]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/navradio.hxx
Refactor morse and beacon as singleton
[flightgear.git] / src / Instrumentation / navradio.hxx
index 88f67685a1f5b77f348c28d2cdb72a2309bc8d62..4b2e16918dde9ec5a08db85c84bc202713424646 100644 (file)
@@ -26,7 +26,6 @@
 
 
 #include <Main/fg_props.hxx>
-#include "Sound/morse.hxx"
 
 #include <simgear/compiler.h>
 #include <simgear/structure/subsystem_mgr.hxx>
@@ -39,14 +38,13 @@ class SGSampleGroup;
 class FGNavRecord;
 typedef SGSharedPtr<FGNavRecord> FGNavRecordPtr;
 
-class FGNavRadio : public SGSubsystem
+class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener
 {
-    FGMorse morse;
-
     SGInterpTable *term_tbl;
     SGInterpTable *low_tbl;
     SGInterpTable *high_tbl;
 
+    SGPropertyNode_ptr _radio_node;
     SGPropertyNode_ptr lon_node;
     SGPropertyNode_ptr lat_node;
     SGPropertyNode_ptr alt_node;
@@ -101,7 +99,9 @@ class FGNavRadio : public SGSubsystem
     SGPropertyNode_ptr gs_deflection_node;
     SGPropertyNode_ptr gs_deflection_deg_node;
     SGPropertyNode_ptr gs_deflection_norm_node;
+    SGPropertyNode_ptr gs_direct_node;
     SGPropertyNode_ptr gs_rate_of_climb_node;
+    SGPropertyNode_ptr gs_rate_of_climb_fpm_node;
     SGPropertyNode_ptr gs_dist_node;
     SGPropertyNode_ptr gs_inrange_node;
     SGPropertyNode_ptr nav_id_node;
@@ -120,8 +120,12 @@ class FGNavRadio : public SGSubsystem
     SGPropertyNode_ptr gps_xtrack_error_nm_node;
     SGPropertyNode_ptr _magvarNode;
     
+    // realism setting, are false courses and GS lobes enabled?
+    SGPropertyNode_ptr falseCoursesEnabledNode;
+
     // internal (private) values
 
+    bool _operable; ///< is the unit serviceable, on, powered, etc
     int play_count;
     time_t last_time;
     FGNavRecordPtr _navaid;
@@ -131,14 +135,11 @@ class FGNavRadio : public SGSubsystem
     string dme_fx_name;
 
     double target_radial;
-    SGTimeStamp prev_time;
-    SGTimeStamp curr_time;
     double effective_range;
     double target_gs;
     double twist;
     double horiz_vel;
     double last_x;
-    double last_loc_dist;
     double last_xtrack_error;
     double xrate_ms;
     double _localizerWidth; // cached localizer width in degrees
@@ -149,7 +150,7 @@ class FGNavRadio : public SGSubsystem
     // internal periodic station search timer
     double _time_before_search_sec;
 
-    SGVec3d _gsCart, _gsAxis, _gsVertical;
+    SGVec3d _gsCart, _gsAxis, _gsVertical, _gsBaseline;
 
     FGNavRecordPtr _dme;
     bool _dmeInRange;
@@ -160,11 +161,10 @@ class FGNavRadio : public SGSubsystem
     double _cdiCrossTrackErrorM;
     double _gsNeedleDeflection;
     double _gsNeedleDeflectionNorm;
+    double _gsDirect;
     
-    // realism setting, are false courses and GS lobes enabled?
-    bool _falseCoursesEnabled;
-
     SGSharedPtr<SGSampleGroup> _sgr;
+    std::vector<SGPropertyNode_ptr> _tiedNodes;
     
     bool updateWithPower(double aDt);
 
@@ -187,12 +187,25 @@ class FGNavRadio : public SGSubsystem
     
     void clearOutputs();
 
+    FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
+    
+    /// accessor for tied, read-only 'operable' property
+    bool isOperable() const
+      { return _operable; }
+      
     /**
-     * Compute the localizer width in degrees - see implementation for 
-     * more information on the relevant standards and formulae.
+     * Tied-properties helper, record nodes which are tied for easy un-tie-ing
      */
-    double localizerWidth(FGNavRecord* aLOC);
-    FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
+    template <typename T>
+    void tie(const char* aRelPath, const SGRawValue<T>& aRawValue)
+    {
+      SGPropertyNode_ptr nd = _radio_node->getNode(aRelPath, true);
+      _tiedNodes.push_back(nd);
+      nd->tie(aRawValue);
+    }
+    
+  // implement SGPropertyChangeListener
+    virtual void valueChanged (SGPropertyNode * prop);
 public:
 
     FGNavRadio(SGPropertyNode *node);