mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T259, Ref T243 remove aircraft parts and situations from interpolator
* no longer using the add parts/situations signals * will use the remote aircraft provider parts directly Result: all parts/situations are stored only once in memory and in one single place
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
|
||||
#include "testinterpolatorlinear.h"
|
||||
#include "blackmisc/simulation/interpolator.h"
|
||||
#include "blackmisc/simulation/interpolatorlinear.h"
|
||||
#include "blackmisc/simulation/remoteaircraftproviderdummy.h"
|
||||
#include "blackmisc/aviation/aircraftengine.h"
|
||||
#include "blackmisc/aviation/aircraftenginelist.h"
|
||||
#include "blackmisc/aviation/aircraftlights.h"
|
||||
@@ -23,18 +26,15 @@
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/aviation/heading.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
#include "blackmisc/geo/latitude.h"
|
||||
#include "blackmisc/geo/longitude.h"
|
||||
#include "blackmisc/simulation/interpolator.h"
|
||||
#include "blackmisc/simulation/interpolatorlinear.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||
#include "blackmisc/compare.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -55,7 +55,9 @@ namespace BlackMiscTest
|
||||
void CTestInterpolatorLinear::basicInterpolatorTests()
|
||||
{
|
||||
CCallsign cs("SWIFT");
|
||||
CRemoteAircraftProviderDummy provider;
|
||||
CInterpolatorLinear interpolator(cs);
|
||||
interpolator.setRemoteAircraftProvider(&provider);
|
||||
|
||||
// fixed time so everything can be debugged
|
||||
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch();
|
||||
@@ -68,14 +70,14 @@ namespace BlackMiscTest
|
||||
// check height above ground
|
||||
CLength hag = (s.getAltitude() - s.getGroundElevation());
|
||||
QVERIFY2(s.getHeightAboveGround() == hag, "Wrong elevation");
|
||||
interpolator.addAircraftSituation(s);
|
||||
provider.insertNewSituation(s);
|
||||
}
|
||||
|
||||
constexpr int partsCount = 10;
|
||||
for (int i = partsCount - 1; i >= 0; i--)
|
||||
{
|
||||
CAircraftParts p(getTestParts(i, ts, deltaT));
|
||||
interpolator.addAircraftParts(p);
|
||||
provider.insertNewAircraftParts(cs, p);
|
||||
}
|
||||
|
||||
// make sure signals are processed, if the interpolator depends on those signals
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "testinterpolatorparts.h"
|
||||
#include "blackmisc/simulation/interpolatorspline.h"
|
||||
#include "blackmisc/simulation/remoteaircraftproviderdummy.h"
|
||||
#include <QTest>
|
||||
#include <QtDebug>
|
||||
|
||||
@@ -30,12 +31,14 @@ namespace BlackMiscTest
|
||||
void CTestInterpolatorParts::groundFlagInterpolation()
|
||||
{
|
||||
CCallsign cs("SWIFT");
|
||||
CRemoteAircraftProviderDummy provider;
|
||||
CInterpolatorSpline interpolator(cs);
|
||||
interpolator.setRemoteAircraftProvider(&provider);
|
||||
|
||||
// fixed time so everything can be debugged
|
||||
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch()
|
||||
const qint64 deltaT = 5000; // ms
|
||||
const int number = interpolator.maxParts();
|
||||
const int number = CRemoteAircraftProviderDummy::MaxPartsPerCallsign;
|
||||
// const int numberHalf = number / 2;
|
||||
const qint64 farFuture = ts + 3 * number * deltaT;
|
||||
const qint64 farPast = ts - 4 * number * deltaT;
|
||||
@@ -43,7 +46,7 @@ namespace BlackMiscTest
|
||||
CAircraftPartsList parts;
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
const CAircraftParts p = getTestParts(i, ts, deltaT, true);
|
||||
const CAircraftParts p = createTestParts(i, ts, deltaT, true);
|
||||
parts.push_back(p);
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ namespace BlackMiscTest
|
||||
|
||||
// Testing for a time >> last time
|
||||
// all on ground flags true
|
||||
interpolator.addAircraftParts(parts, false); // we work with 0 offsets here
|
||||
provider.insertNewAircraftParts(cs, parts); // we work with 0 offsets here
|
||||
CAircraftParts p = interpolator.getInterpolatedParts(farFuture, setup, status);
|
||||
qint64 pTs = p.getAdjustedMSecsSinceEpoch();
|
||||
QVERIFY2(status.isSupportingParts(), "Should support parts");
|
||||
@@ -69,8 +72,10 @@ namespace BlackMiscTest
|
||||
// Testing for a time >> last time
|
||||
// all on ground flags true
|
||||
interpolator.clear();
|
||||
provider.clear();
|
||||
|
||||
parts.setOnGround(false);
|
||||
interpolator.addAircraftParts(parts, false); // we work with 0 offsets here
|
||||
provider.insertNewAircraftParts(cs, parts); // we work with 0 offsets here
|
||||
p = interpolator.getInterpolatedParts(farFuture, setup, status);
|
||||
pTs = p.getAdjustedMSecsSinceEpoch();
|
||||
QVERIFY2(status.isSupportingParts(), "Should support parts");
|
||||
@@ -90,21 +95,21 @@ namespace BlackMiscTest
|
||||
CAircraftPartsList partsOnGround;
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
const CAircraftParts p = getTestParts(i, ts, deltaT, true);
|
||||
const CAircraftParts p = createTestParts(i, ts, deltaT, true);
|
||||
partsOnGround.push_back(p);
|
||||
}
|
||||
|
||||
CAircraftPartsList partsNotOnGround;
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
const CAircraftParts p = getTestParts(i, ts, deltaT, false);
|
||||
const CAircraftParts p = createTestParts(i, ts, deltaT, false);
|
||||
partsNotOnGround.push_back(p);
|
||||
}
|
||||
|
||||
CAircraftSituationList situations;
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
CAircraftSituation s = getTestSituation(cs, i, ts, deltaT, 0);
|
||||
CAircraftSituation s = createTestSituation(cs, i, ts, deltaT, 0);
|
||||
s.setOnGround(CAircraftSituation::OnGroundSituationUnknown, CAircraftSituation::NotSet);
|
||||
situations.push_back(s);
|
||||
}
|
||||
@@ -128,7 +133,7 @@ namespace BlackMiscTest
|
||||
QVERIFY2(s1.getOnGroundDetails() == CAircraftSituation::InFromParts, "Wrong details");
|
||||
}
|
||||
|
||||
CAircraftParts CTestInterpolatorParts::getTestParts(int number, qint64 ts, qint64 deltaT, bool onGround)
|
||||
CAircraftParts CTestInterpolatorParts::createTestParts(int number, qint64 ts, qint64 deltaT, bool onGround)
|
||||
{
|
||||
CAircraftLights l(true, false, true, false, true, false);
|
||||
CAircraftEngineList e({ CAircraftEngine(1, true), CAircraftEngine(2, false), CAircraftEngine(3, true) });
|
||||
@@ -139,7 +144,7 @@ namespace BlackMiscTest
|
||||
return p;
|
||||
}
|
||||
|
||||
CAircraftSituation CTestInterpolatorParts::getTestSituation(const CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset)
|
||||
CAircraftSituation CTestInterpolatorParts::createTestSituation(const CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset)
|
||||
{
|
||||
const CAltitude alt(number, CAltitude::MeanSeaLevel, CLengthUnit::m());
|
||||
const CLatitude lat(number, CAngleUnit::deg());
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace BlackMiscTest
|
||||
|
||||
private:
|
||||
//! Test parts
|
||||
static BlackMisc::Aviation::CAircraftParts getTestParts(int number, qint64 ts, qint64 deltaT, bool onGround);
|
||||
static BlackMisc::Aviation::CAircraftParts createTestParts(int number, qint64 ts, qint64 deltaT, bool onGround);
|
||||
|
||||
//! Test situation for testing
|
||||
static BlackMisc::Aviation::CAircraftSituation getTestSituation(const BlackMisc::Aviation::CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset);
|
||||
static BlackMisc::Aviation::CAircraftSituation createTestSituation(const BlackMisc::Aviation::CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user