1
0
Fork 0

Expose additional Navaid fields for use by Nasal

This commit is contained in:
Stuart Buchanan 2018-04-16 13:37:17 +01:00
parent 9583e2d7ad
commit 510f2de84d
4 changed files with 318 additions and 305 deletions

View file

@ -93,7 +93,7 @@ double FGNavRecord::localizerWidth() const
} }
bool FGNavRecord::hasDME() bool FGNavRecord::hasDME() const
{ {
return (mColocated > 0); return (mColocated > 0);
} }

View file

@ -98,7 +98,7 @@ class FGNavRecord : public FGPositioned
void unbindFromNode(SGPropertyNode* nd) const; void unbindFromNode(SGPropertyNode* nd) const;
void setColocatedDME(PositionedID other); void setColocatedDME(PositionedID other);
bool hasDME(); bool hasDME() const;
bool isVORTAC() const; bool isVORTAC() const;

View file

@ -934,6 +934,19 @@ static const char* navaidGhostGetMember(naContext c, void* g, naRef field, naRef
*out = naNum(nav->get_freq()); *out = naNum(nav->get_freq());
} else if (!strcmp(fieldName, "range_nm")) { } else if (!strcmp(fieldName, "range_nm")) {
*out = naNum(nav->get_range()); *out = naNum(nav->get_range());
} else if (!strcmp(fieldName, "magvar")) {
if (nav->type() == FGPositioned::VOR) {
// For VORs, the multiuse function provides the magnetic variation
double variation = nav->get_multiuse();
SG_NORMALIZE_RANGE(variation, 0.0, 360.0);
*out = naNum(variation);
} else {
*out = naNil();
}
} else if (!strcmp(fieldName, "dme")) {
*out = naNum(nav->hasDME());
} else if (!strcmp(fieldName, "vortac")) {
*out = naNum(nav->isVORTAC());
} else if (!strcmp(fieldName, "course")) { } else if (!strcmp(fieldName, "course")) {
if ((nav->type() == FGPositioned::ILS) || (nav->type() == FGPositioned::LOC)) { if ((nav->type() == FGPositioned::ILS) || (nav->type() == FGPositioned::LOC)) {
double radial = nav->get_multiuse(); double radial = nav->get_multiuse();
@ -2178,7 +2191,6 @@ static naRef f_registerFPDelegate(naContext c, naRef me, int argc, naRef* args)
if ((argc < 1) || !naIsFunc(args[0])) { if ((argc < 1) || !naIsFunc(args[0])) {
naRuntimeError(c, "non-function argument to registerFlightPlanDelegate"); naRuntimeError(c, "non-function argument to registerFlightPlanDelegate");
} }
NasalFPDelegateFactory* factory = new NasalFPDelegateFactory(args[0]); NasalFPDelegateFactory* factory = new NasalFPDelegateFactory(args[0]);
FlightPlan::registerDelegateFactory(factory); FlightPlan::registerDelegateFactory(factory);
static_nasalDelegateFactories.push_back(factory); static_nasalDelegateFactories.push_back(factory);
@ -2781,7 +2793,7 @@ static naRef f_procedure_route(naContext c, naRef me, int argc, naRef* args)
// note either runway or trans may be NULL - that's ok // note either runway or trans may be NULL - that's ok
WayptVec r; WayptVec r;
if (!ad->route(rwy, trans, r)) { if (!ad->route(rwy, trans, r)) {
SG_LOG(SG_NASAL, SG_WARN, "prcoedure.route failed for ArrvialDeparture somehow"); SG_LOG(SG_NASAL, SG_WARN, "procedure.route failed for ArrivalDeparture somehow");
return naNil(); return naNil();
} }
@ -2896,5 +2908,3 @@ void postinitNasalPositioned(naRef globals, naContext c)
geoCoordClass = naHash_cget(geoModule, (char*) "Coord"); geoCoordClass = naHash_cget(geoModule, (char*) "Coord");
} }

View file

@ -490,7 +490,10 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
.bases<NasalPositioned>() .bases<NasalPositioned>()
.member("frequency", &FGNavRecord::get_freq) .member("frequency", &FGNavRecord::get_freq)
.member("range_nm", &FGNavRecord::get_range) .member("range_nm", &FGNavRecord::get_range)
.member("course", &f_navaid_course); .member("course", &f_navaid_course)
.member("magvar", &FGNavRecord::get_multiuse)
.member("dme", &FGNavRecord::hasDME)
.member("vorac", &FGNavRecord::isVORTAC);
NasalFix::init("Fix") NasalFix::init("Fix")
.bases<NasalPositioned>(); .bases<NasalPositioned>();