]> git.mxchange.org Git - flightgear.git/blob - src/Radio/radio.hxx
Read antenna radiation pattern from file
[flightgear.git] / src / Radio / radio.hxx
1 // radio.hxx -- FGRadio: class to manage radio propagation
2 //
3 // Written by Adrian Musceac, started August 2011.
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
19
20 #ifndef __cplusplus
21 # error This library requires C++
22 #endif
23
24 #include <simgear/compiler.h>
25 #include <simgear/structure/subsystem_mgr.hxx>
26 #include <deque>
27 #include <Main/fg_props.hxx>
28
29 #include <simgear/math/sg_geodesy.hxx>
30 #include <simgear/debug/logstream.hxx>
31 #include "antenna.hxx"
32
33 using std::string;
34
35
36 class FGRadioTransmission 
37 {
38 private:
39         bool isOperable() const
40                 { return _operable; }
41         bool _operable; ///< is the unit serviceable, on, powered, etc
42         
43         double _receiver_sensitivity;
44         double _transmitter_power;
45         double _tx_antenna_height;
46         double _rx_antenna_height;
47         double _rx_antenna_gain;
48         double _tx_antenna_gain;
49         double _rx_line_losses;
50         double _tx_line_losses;
51         FGRadioAntenna* _TX_antenna;
52         FGRadioAntenna* _RX_antenna;
53         double _terrain_sampling_distance;
54         int _polarization;
55         std::map<string, double[2]> _mat_database;
56         SGPropertyNode *_root_node;
57         int _propagation_model; /// 0 none, 1 round Earth, 2 ITM
58         double polarization_loss();
59         double ITM_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
60         double LOS_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
61         void clutterLoss(double freq, double distance_m, double itm_elev[], std::deque<string> materials,
62                         double transmitter_height, double receiver_height, int p_mode,
63                         double horizons[], double &clutter_loss);
64         void get_material_properties(string mat_name, double &height, double &density);
65         
66 public:
67
68     FGRadioTransmission();
69     ~FGRadioTransmission();
70
71     // a couple of setters and getters for convenience
72     void setFrequency(double freq, int radio);
73     double getFrequency(int radio);
74     void setTxPower(double txpower) { _transmitter_power = txpower; };
75     void setRxSensitivity(double sensitivity) { _receiver_sensitivity = sensitivity; };
76     void setTxAntennaHeight(double tx_antenna_height) { _tx_antenna_height = tx_antenna_height; };
77     void setRxAntennaHeight(double rx_antenna_height) { _rx_antenna_height = rx_antenna_height; };
78     void setTxAntennaGain(double tx_antenna_gain) { _tx_antenna_gain = tx_antenna_gain; };
79     void setRxAntennaGain(double rx_antenna_gain) { _rx_antenna_gain = rx_antenna_gain; };
80     void setTxLineLosses(double tx_line_losses) { _tx_line_losses = tx_line_losses; };
81     void setRxLineLosses(double rx_line_losses) { _rx_line_losses = rx_line_losses; };
82     void setPropagationModel(int model) { _propagation_model = model; };
83     void setPolarization(int polarization) { _polarization = polarization; };
84     // accessory functions for unit conversions
85     double watt_to_dbm(double power_watt);
86     double dbm_to_watt(double dbm);
87     double dbm_to_microvolt(double dbm);
88     
89     
90     // transmission_type: 0 for air to ground 1 for ground to air, 2 for air to air, 3 for pilot to ground, 4 for pilot to air
91     void receiveATC(SGGeod tx_pos, double freq, string text, int transmission_type);
92     void receiveChat(SGGeod tx_pos, double freq, string text, int transmission_type);
93     // returns signal quality
94     // transmission_type: 0 for VOR, 1 for ILS
95     double receiveNav(SGGeod tx_pos, double freq, int transmission_type);
96     
97 };
98
99