Add some functions to convert between various units
This commit is contained in:
parent
6179c26a04
commit
3340694170
2 changed files with 25 additions and 3 deletions
|
@ -871,10 +871,13 @@ double FGRadioTransmission::LOS_calculate_attenuation(SGGeod pos, double freq, i
|
||||||
if (distance_m > total_horizon) {
|
if (distance_m > total_horizon) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
double pol_loss = 0.0;
|
||||||
|
if (_polarization == 1) {
|
||||||
|
pol_loss = polarization_loss();
|
||||||
|
}
|
||||||
// free-space loss (distance calculation should be changed)
|
// free-space loss (distance calculation should be changed)
|
||||||
dbloss = 20 * log10(distance_m) +20 * log10(frq_mhz) -27.55;
|
dbloss = 20 * log10(distance_m) +20 * log10(frq_mhz) -27.55;
|
||||||
signal = link_budget - dbloss;
|
signal = link_budget - dbloss + pol_loss;
|
||||||
SG_LOG(SG_GENERAL, SG_BULK,
|
SG_LOG(SG_GENERAL, SG_BULK,
|
||||||
"LOS:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm ");
|
"LOS:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm ");
|
||||||
//cerr << "LOS:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm " << endl;
|
//cerr << "LOS:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm " << endl;
|
||||||
|
@ -912,3 +915,16 @@ double FGRadioTransmission::polarization_loss() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double FGRadioTransmission::power_to_dbm(double power_watt) {
|
||||||
|
return 10 * log10(1000 * power_watt); // returns dbm
|
||||||
|
}
|
||||||
|
|
||||||
|
double FGRadioTransmission::dbm_to_power(double dbm) {
|
||||||
|
return exp( (dbm-30) * log(10) / 10); // returns Watts
|
||||||
|
}
|
||||||
|
|
||||||
|
double FGRadioTransmission::dbm_to_microvolt(double dbm) {
|
||||||
|
return sqrt(dbm_to_power(dbm) * 50) * 1000000; // returns microvolts
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
FGRadioTransmission();
|
FGRadioTransmission();
|
||||||
~FGRadioTransmission();
|
~FGRadioTransmission();
|
||||||
|
|
||||||
|
// a couple of setters and getters for convenience
|
||||||
void setFrequency(double freq, int radio);
|
void setFrequency(double freq, int radio);
|
||||||
double getFrequency(int radio);
|
double getFrequency(int radio);
|
||||||
void setTxPower(double txpower) { _transmitter_power = txpower; };
|
void setTxPower(double txpower) { _transmitter_power = txpower; };
|
||||||
|
@ -79,6 +79,12 @@ public:
|
||||||
void setRxLineLosses(double rx_line_losses) { _rx_line_losses = rx_line_losses; };
|
void setRxLineLosses(double rx_line_losses) { _rx_line_losses = rx_line_losses; };
|
||||||
void setPropagationModel(int model) { _propagation_model = model; };
|
void setPropagationModel(int model) { _propagation_model = model; };
|
||||||
void setPolarization(int polarization) { _polarization = polarization; };
|
void setPolarization(int polarization) { _polarization = polarization; };
|
||||||
|
// accessory functions for unit conversions
|
||||||
|
double power_to_dbm(double power_watt);
|
||||||
|
double dbm_to_power(double dbm);
|
||||||
|
double dbm_to_microvolt(double dbm);
|
||||||
|
|
||||||
|
|
||||||
// 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
|
// 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
|
||||||
void receiveATC(SGGeod tx_pos, double freq, string text, int transmission_type);
|
void receiveATC(SGGeod tx_pos, double freq, string text, int transmission_type);
|
||||||
void receiveChat(SGGeod tx_pos, double freq, string text, int transmission_type);
|
void receiveChat(SGGeod tx_pos, double freq, string text, int transmission_type);
|
||||||
|
|
Loading…
Add table
Reference in a new issue