]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/navradio.hxx
Add Mach/TAS computation to the airspeed indicator.
[flightgear.git] / src / Instrumentation / navradio.hxx
index d8cf7c29a6d36bffb75ccbca884fbc821240df89..41d662ff06f7ad6ddd540032c7ecacac7a713466 100644 (file)
@@ -35,6 +35,7 @@
 // forward decls
 class SGInterpTable;
 
+class SGSampleGroup;
 class FGNavRecord;
 typedef SGSharedPtr<FGNavRecord> FGNavRecordPtr;
 
@@ -46,6 +47,7 @@ class FGNavRadio : public SGSubsystem
     SGInterpTable *low_tbl;
     SGInterpTable *high_tbl;
 
+    SGPropertyNode_ptr _radio_node;
     SGPropertyNode_ptr lon_node;
     SGPropertyNode_ptr lat_node;
     SGPropertyNode_ptr alt_node;
@@ -66,7 +68,8 @@ class FGNavRadio : public SGSubsystem
     SGPropertyNode_ptr cdi_serviceable_node;
     SGPropertyNode_ptr gs_serviceable_node;
     SGPropertyNode_ptr tofrom_serviceable_node;
-
+    SGPropertyNode_ptr dme_serviceable_node;
+    
     // property outputs
     SGPropertyNode_ptr fmt_freq_node;     // formated frequency
     SGPropertyNode_ptr fmt_alt_freq_node; // formated alternate frequency
@@ -90,14 +93,19 @@ class FGNavRadio : public SGSubsystem
     SGPropertyNode_ptr inrange_node;
     SGPropertyNode_ptr signal_quality_norm_node;
     SGPropertyNode_ptr cdi_deflection_node;
+    SGPropertyNode_ptr cdi_deflection_norm_node;
     SGPropertyNode_ptr cdi_xtrack_error_node;
     SGPropertyNode_ptr cdi_xtrack_hdg_err_node;
     SGPropertyNode_ptr has_gs_node;
     SGPropertyNode_ptr loc_node;
     SGPropertyNode_ptr loc_dist_node;
     SGPropertyNode_ptr gs_deflection_node;
+    SGPropertyNode_ptr gs_deflection_deg_node;
+    SGPropertyNode_ptr gs_deflection_norm_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;
     SGPropertyNode_ptr id_c1_node;
     SGPropertyNode_ptr id_c2_node;
@@ -110,9 +118,16 @@ class FGNavRadio : public SGSubsystem
     SGPropertyNode_ptr gps_to_flag_node;
     SGPropertyNode_ptr gps_from_flag_node;
     SGPropertyNode_ptr gps_has_gs_node;
+    SGPropertyNode_ptr gps_course_node;
+    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;
@@ -121,10 +136,7 @@ class FGNavRadio : public SGSubsystem
     string nav_fx_name;
     string dme_fx_name;
 
-    bool has_dme;
     double target_radial;
-    SGVec3d gs_base_vec;
-    double gs_dist_signed;
     SGTimeStamp prev_time;
     SGTimeStamp curr_time;
     double effective_range;
@@ -134,13 +146,30 @@ class FGNavRadio : public SGSubsystem
     double last_x;
     double last_loc_dist;
     double last_xtrack_error;
-
+    double xrate_ms;
+    double _localizerWidth; // cached localizer width in degrees
+    
     string _name;
     int _num;
 
     // internal periodic station search timer
     double _time_before_search_sec;
 
+    SGVec3d _gsCart, _gsAxis, _gsVertical;
+
+    FGNavRecordPtr _dme;
+    bool _dmeInRange;
+    
+    // CDI properties
+    bool _toFlag, _fromFlag;
+    double _cdiDeflection;
+    double _cdiCrossTrackErrorM;
+    double _gsNeedleDeflection;
+    double _gsNeedleDeflectionNorm;
+    
+    SGSharedPtr<SGSampleGroup> _sgr;
+    std::vector<SGPropertyNode_ptr> _tiedNodes;
+    
     bool updateWithPower(double aDt);
 
     // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
@@ -151,10 +180,38 @@ class FGNavRadio : public SGSubsystem
     double adjustILSRange( double stationElev, double aircraftElev,
                           double offsetDegrees, double distance );
 
-    void updateAudio(bool aInRange);
+    void updateAudio();
     void audioNavidChanged();
 
+    void updateReceiver(double dt);
+    void updateDME(const SGVec3d& aircraft);
+    void updateGlideSlope(double dt, const SGVec3d& aircraft, double signal_quality_norm);
+    void updateGPSSlaved();
+    void updateCDI(double dt);
+    
+    void clearOutputs();
+
+    /**
+     * Compute the localizer width in degrees - see implementation for 
+     * more information on the relevant standards and formulae.
+     */
+    double localizerWidth(FGNavRecord* aLOC);
     FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
+    
+    /// accessor for tied, read-only 'operable' property
+    bool isOperable() const
+      { return _operable; }
+      
+    /**
+     * Tied-properties helper, record nodes which are tied for easy un-tie-ing
+     */
+    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);
+    }
 public:
 
     FGNavRadio(SGPropertyNode *node);