Expose a radio function (receiveBeacon) to the Nasal subsystem
This commit is contained in:
parent
4826b21968
commit
971c2820b9
3 changed files with 45 additions and 1 deletions
|
@ -115,6 +115,28 @@ double FGRadioTransmission::receiveNav(SGGeod tx_pos, double freq, int transmiss
|
|||
|
||||
}
|
||||
|
||||
double FGRadioTransmission::receiveBeacon(double lat, double lon, double elev, double heading, double pitch) {
|
||||
|
||||
|
||||
_transmitter_power = 36;
|
||||
_tx_antenna_height += 0.0;
|
||||
_tx_antenna_gain += 0.5;
|
||||
elev = elev * SG_FEET_TO_METER;
|
||||
double freq = _root_node->getDoubleValue("station[0]/frequency", 118.0);
|
||||
int ground_to_air = 1;
|
||||
string text = "Beacon1";
|
||||
double comm1 = getFrequency(1);
|
||||
double comm2 = getFrequency(2);
|
||||
if ( !(fabs(freq - comm1) <= 0.0001) && !(fabs(freq - comm2) <= 0.0001) ) {
|
||||
return -1;
|
||||
}
|
||||
SGGeod tx_pos = SGGeod::fromDegM( lon, lat, elev );
|
||||
double signal = ITM_calculate_attenuation(tx_pos, freq, ground_to_air);
|
||||
|
||||
return signal;
|
||||
}
|
||||
|
||||
|
||||
/*** Receive ATC radio communication as text
|
||||
***/
|
||||
void FGRadioTransmission::receiveATC(SGGeod tx_pos, double freq, string text, int ground_to_air) {
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
// returns signal quality
|
||||
// transmission_type: 0 for VOR, 1 for ILS
|
||||
double receiveNav(SGGeod tx_pos, double freq, int transmission_type);
|
||||
|
||||
double receiveBeacon(double lat, double lon, double elev, double heading, double pitch);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <Scenery/scenery.hxx>
|
||||
#include <Navaids/navlist.hxx>
|
||||
#include <Navaids/procedure.hxx>
|
||||
#include <Radio/radio.hxx>
|
||||
|
||||
|
||||
#include "NasalSys.hxx"
|
||||
|
@ -500,6 +501,26 @@ static naRef f_carttogeod(naContext c, naRef me, int argc, naRef* args)
|
|||
return vec;
|
||||
}
|
||||
|
||||
// Convert a cartesian point to a geodetic lat/lon/altitude.
|
||||
static naRef f_radioTransmission(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
double lat, lon, elev, heading, pitch;
|
||||
if(argc != 5) naRuntimeError(c, "radioTransmission() expects 5 arguments");
|
||||
for(int i=0; i<argc; i++) {
|
||||
if(naIsNil(args[i]))
|
||||
return naNil();
|
||||
}
|
||||
lat = naNumValue(args[0]).num;
|
||||
lon = naNumValue(args[1]).num;
|
||||
elev = naNumValue(args[2]).num;
|
||||
heading = naNumValue(args[3]).num;
|
||||
pitch = naNumValue(args[4]).num;
|
||||
FGRadioTransmission *radio = new FGRadioTransmission;
|
||||
double signal = radio->receiveBeacon(lat,lon,elev,heading,pitch);
|
||||
delete radio;
|
||||
return naNum(signal);
|
||||
}
|
||||
|
||||
// Convert a geodetic lat/lon/altitude to a cartesian point.
|
||||
static naRef f_geodtocart(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
|
@ -805,6 +826,7 @@ static struct { const char* name; naCFunction func; } funcs[] = {
|
|||
{ "geodinfo", f_geodinfo },
|
||||
{ "airportinfo", f_airportinfo },
|
||||
{ "navinfo", f_navinfo },
|
||||
{ "radioTransmission", f_radioTransmission },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue