mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Move OnGround information to own class
This commit is contained in:
@@ -76,7 +76,7 @@ namespace BlackMiscTest
|
||||
void CTestAircraftSituation::allGndFlagsAndTakeOff() const
|
||||
{
|
||||
CAircraftSituationList situations = testSituations();
|
||||
situations.setOnGround(CAircraftSituation::OnGround);
|
||||
situations.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::NotSetGroundDetails });
|
||||
const CAircraftSituationChange change(situations, cg(), false);
|
||||
QVERIFY2(change.isConstOnGround(), "Expect const on ground");
|
||||
QVERIFY(!change.isConstNotOnGround());
|
||||
@@ -87,7 +87,7 @@ namespace BlackMiscTest
|
||||
QVERIFY(situations.isSortedAdjustedLatestFirstWithoutNullPositions());
|
||||
|
||||
CAircraftSituation f = situations.front();
|
||||
f.setOnGround(false);
|
||||
f.setOnGroundInfo({ COnGroundInfo::NotOnGround, COnGroundInfo::NotSetGroundDetails });
|
||||
situations.pop_front();
|
||||
situations.push_front(f);
|
||||
const CAircraftSituationChange change2(situations, cg(), false);
|
||||
@@ -100,7 +100,7 @@ namespace BlackMiscTest
|
||||
void CTestAircraftSituation::allNotGndFlagsAndTouchdown() const
|
||||
{
|
||||
CAircraftSituationList situations = testSetDescendingAltitudes(testSituations());
|
||||
situations.setOnGround(CAircraftSituation::NotOnGround);
|
||||
situations.setOnGroundInfo({ COnGroundInfo::NotOnGround, COnGroundInfo::NotSetGroundDetails });
|
||||
const CAircraftSituationChange change(situations, cg(), false);
|
||||
QVERIFY2(change.isConstNotOnGround(), "Expect const not on ground");
|
||||
QVERIFY(!change.isConstOnGround());
|
||||
@@ -111,7 +111,7 @@ namespace BlackMiscTest
|
||||
QVERIFY(situations.isSortedAdjustedLatestFirstWithoutNullPositions());
|
||||
|
||||
CAircraftSituation f = situations.front();
|
||||
f.setOnGround(true);
|
||||
f.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::NotSetGroundDetails });
|
||||
situations.pop_front();
|
||||
situations.push_front(f);
|
||||
const CAircraftSituationChange change2(situations, cg(), false);
|
||||
@@ -215,7 +215,8 @@ namespace BlackMiscTest
|
||||
corAlt = situation.getCorrectedAltitude(true, &correction);
|
||||
QVERIFY2(corAlt == alt, "Expect same altitude, no overflow since not on gnd.");
|
||||
|
||||
situation.setOnGround(CAircraftSituation::OnGround, CAircraftSituation::InFromNetwork);
|
||||
situation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::InFromNetwork });
|
||||
|
||||
corAlt = situation.getCorrectedAltitude(true, &correction);
|
||||
QVERIFY2(correction == CAircraftSituation::DraggedToGround, "Expect dragged to gnd.");
|
||||
QVERIFY2(corAlt < alt, "Expect corrected altitude dragged to gnd.");
|
||||
|
||||
@@ -132,27 +132,27 @@ namespace BlackMiscTest
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
CAircraftSituation s = createTestSituation(cs, i, ts, deltaT, 0);
|
||||
s.setOnGround(CAircraftSituation::OnGroundSituationUnknown, CAircraftSituation::NotSetGroundDetails);
|
||||
s.setOnGroundInfo({ COnGroundInfo::OnGroundSituationUnknown, COnGroundInfo::NotSetGroundDetails });
|
||||
situations.push_back(s);
|
||||
}
|
||||
|
||||
CAircraftSituation s0 = situations[0];
|
||||
s0.adjustGroundFlag(partsOnGround, true);
|
||||
QVERIFY2(s0.getOnGround(), "Supposed to be on ground");
|
||||
QVERIFY2(s0.getOnGroundInfo().getOnGround(), "Supposed to be on ground");
|
||||
|
||||
s0 = situations[0];
|
||||
s0.adjustGroundFlag(partsNotOnGround, true);
|
||||
QVERIFY2(!s0.getOnGround(), "Supposed to be not on ground");
|
||||
QVERIFY2(!s0.getOnGroundInfo().getOnGround(), "Supposed to be not on ground");
|
||||
|
||||
qint64 distanceMs = -1;
|
||||
const qint64 Offset = 33;
|
||||
partsOnGround.addMsecsToOffset(Offset);
|
||||
CAircraftSituation s1 = situations[1];
|
||||
s1.setOnGroundDetails(CAircraftSituation::NotSetGroundDetails);
|
||||
s1.setOnGroundInfo({ COnGroundInfo::OnGroundSituationUnknown, COnGroundInfo::NotSetGroundDetails });
|
||||
s1.adjustGroundFlag(partsOnGround, true, 0.1, &distanceMs);
|
||||
QVERIFY2(s1.getOnGround(), "Supposed to be on ground");
|
||||
QVERIFY2(s1.getOnGroundInfo().getOnGround(), "Supposed to be on ground");
|
||||
QVERIFY2(distanceMs == deltaT - Offset, "Offset time wrong");
|
||||
QVERIFY2(s1.getOnGroundDetails() == CAircraftSituation::InFromParts, "Wrong details");
|
||||
QVERIFY2(s1.getOnGroundInfo().getGroundDetails() == COnGroundInfo::InFromParts, "Wrong details");
|
||||
}
|
||||
|
||||
CAircraftParts CTestInterpolatorParts::createTestParts(int number, qint64 ts, qint64 deltaT, bool onGround)
|
||||
|
||||
Reference in New Issue
Block a user