Fix that tp_type will return nil for transitions
This commit is contained in:
parent
02c7b37122
commit
d6b7eaf60f
4 changed files with 51 additions and 7 deletions
|
@ -947,6 +947,8 @@ static naRef procedureTpType(naContext c, ProcedureType ty)
|
|||
switch (ty) {
|
||||
case PROCEDURE_SID: return stringToNasal(c, "sid");
|
||||
case PROCEDURE_STAR: return stringToNasal(c, "star");
|
||||
case PROCEDURE_TRANSITION: return stringToNasal(c, "transition");
|
||||
case PROCEDURE_RUNWAY_TRANSITION: return stringToNasal(c, "rwy_transition");
|
||||
case PROCEDURE_APPROACH_VOR:
|
||||
case PROCEDURE_APPROACH_ILS:
|
||||
case PROCEDURE_APPROACH_RNAV:
|
||||
|
|
|
@ -1532,7 +1532,7 @@ void GPSTests::testDMEIntercept()
|
|||
|
||||
void GPSTests::testFinalLegCourse()
|
||||
{
|
||||
// FGTestApi::setUp::logPositionToKML("gps_dme_intercept");
|
||||
// FGTestApi::setUp::logPositionToKML("gps_final_course");
|
||||
auto rm = globals->get_subsystem<FGRouteMgr>();
|
||||
auto fp = new FlightPlan;
|
||||
rm->setFlightPlan(fp);
|
||||
|
@ -1573,9 +1573,45 @@ void GPSTests::testFinalLegCourse()
|
|||
auto gpsNode = globals->get_props()->getNode("instrumentation/gps");
|
||||
gpsNode->setBoolValue("config/delegate-sequencing", true);
|
||||
gpsNode->setStringValue("command", "leg");
|
||||
|
||||
|
||||
FGTestApi::writeFlightPlanToKML(fp);
|
||||
|
||||
|
||||
// FGTestApi::writeFlightPlanToKML(fp);
|
||||
// check that the final leg course doesn't fall back to 233 deg
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(37, gpsNode->getDoubleValue("desired-course-deg"), 2.0);
|
||||
}
|
||||
|
||||
// Test to check the situation where you have two legs forming a straight line
|
||||
// with the current waypoint being the third waypoint
|
||||
void GPSTests::testCourseLegIntermediateWaypoint()
|
||||
{
|
||||
// FGTestApi::setUp::logPositionToKML("gps_leg_course_intermediate");
|
||||
auto rm = globals->get_subsystem<FGRouteMgr>();
|
||||
auto fp = new FlightPlan;
|
||||
rm->setFlightPlan(fp);
|
||||
|
||||
FGTestApi::setUp::populateFPWithoutNasal(fp, "EGAA", "25", "EGPH", "06", "LISBO BLACA");
|
||||
|
||||
// takes the place of the Nasal delegates
|
||||
auto testDelegate = new TestFPDelegate;
|
||||
testDelegate->thePlan = fp;
|
||||
CPPUNIT_ASSERT(rm->activate());
|
||||
fp->addDelegate(testDelegate);
|
||||
auto gps = setupStandardGPS();
|
||||
|
||||
SGGeod decelPos = fp->pointAlongRoute(2, -15.0);
|
||||
fp->insertWayptAtIndex(new BasicWaypt(decelPos, "DECEL", fp), 2);
|
||||
fp->setCurrentIndex(3); // BLACA
|
||||
|
||||
// position halfway between EGAA and EGPF
|
||||
SGGeod initPos = fp->pointAlongRoute(2, -5);
|
||||
FGTestApi::setPositionAndStabilise(initPos);
|
||||
|
||||
auto gpsNode = globals->get_props()->getNode("instrumentation/gps");
|
||||
gpsNode->setBoolValue("config/delegate-sequencing", true);
|
||||
gpsNode->setStringValue("command", "leg");
|
||||
|
||||
|
||||
// FGTestApi::writeFlightPlanToKML(fp);
|
||||
// check that the leg course is correct
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(56.5, gpsNode->getDoubleValue("desired-course-deg"), 2.0);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ class GPSTests : public CppUnit::TestFixture
|
|||
CPPUNIT_TEST(testRadialIntercept);
|
||||
CPPUNIT_TEST(testDMEIntercept);
|
||||
CPPUNIT_TEST(testFinalLegCourse);
|
||||
|
||||
CPPUNIT_TEST(testCourseLegIntermediateWaypoint);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void setPositionAndStabilise(GPS* gps, const SGGeod& g);
|
||||
|
@ -90,6 +91,7 @@ public:
|
|||
void testRadialIntercept();
|
||||
void testDMEIntercept();
|
||||
void testFinalLegCourse();
|
||||
void testCourseLegIntermediateWaypoint();
|
||||
};
|
||||
|
||||
#endif // _FG_GPS_UNIT_TESTS_HXX
|
||||
|
|
|
@ -209,7 +209,7 @@ void FPNasalTests::testSIDTransitionAPI()
|
|||
}
|
||||
|
||||
auto rm = globals->get_subsystem<FGRouteMgr>();
|
||||
|
||||
|
||||
bool ok = FGTestApi::executeNasal(R"(
|
||||
var fp = flightplan();
|
||||
fp.departure = airportinfo("KJFK");
|
||||
|
@ -222,11 +222,12 @@ void FPNasalTests::testSIDTransitionAPI()
|
|||
|
||||
var trans = sid.transition('CANDR');
|
||||
unitTest.assert_equal(trans.id, "CANDR", "Couldn't find transition");
|
||||
unitTest.assert_equal(trans.tp_type, "transition", "Procedure type incorrect");
|
||||
|
||||
fp.sid = trans;
|
||||
fp.departure_runway = fp.departure.runway('13L')
|
||||
)");
|
||||
|
||||
|
||||
CPPUNIT_ASSERT(ok);
|
||||
|
||||
auto fp = rm->flightPlan();
|
||||
|
@ -328,11 +329,13 @@ void FPNasalTests::testApproachTransitionAPI()
|
|||
|
||||
unitTest.assert(trans != nil, "approach transition not found");
|
||||
unitTest.assert_equal(trans.id, "LUL1C", "Incorrect approach transition loaded");
|
||||
unitTest.assert_equal(trans.tp_type, "transition", "Procedure type incorrect");
|
||||
|
||||
fp.approach = trans;
|
||||
|
||||
unitTest.assert_equal(fp.approach.id, "ILS08L", "Incorrect approach returned");
|
||||
unitTest.assert_equal(fp.approach_trans.id, "LUL1C", "Incorrect transition returned");
|
||||
unitTest.assert_equal(fp.approach_trans.tp_type, "transition", "Procedure type incorrect");
|
||||
)");
|
||||
|
||||
CPPUNIT_ASSERT(ok);
|
||||
|
@ -369,6 +372,7 @@ void FPNasalTests::testApproachTransitionAPIWithCloning()
|
|||
|
||||
unitTest.assert_equal(fp.approach.id, "ILS06", "Incorrect approach returned");
|
||||
unitTest.assert_equal(fp.approach_trans.id, "SUG2A", "Incorrect transition returned");
|
||||
unitTest.assert_equal(fp.approach_trans.tp_type, "transition", "Procedure type incorrect");
|
||||
)");
|
||||
|
||||
CPPUNIT_ASSERT(ok);
|
||||
|
|
Loading…
Add table
Reference in a new issue