mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
refactor: Split InterpolationStatus related classes into separate files
This commit is contained in:
@@ -539,11 +539,15 @@ add_library(misc SHARED
|
|||||||
simulation/interpolationsetupprovider.h
|
simulation/interpolationsetupprovider.h
|
||||||
simulation/aircraftmodellist.h
|
simulation/aircraftmodellist.h
|
||||||
simulation/interpolationsetupprovider.cpp
|
simulation/interpolationsetupprovider.cpp
|
||||||
|
simulation/interpolationstatus.cpp
|
||||||
|
simulation/interpolationstatus.h
|
||||||
simulation/interpolatorlinear.h
|
simulation/interpolatorlinear.h
|
||||||
simulation/backgroundvalidation.cpp
|
simulation/backgroundvalidation.cpp
|
||||||
simulation/airspaceaircraftsnapshot.cpp
|
simulation/airspaceaircraftsnapshot.cpp
|
||||||
simulation/autopublishdata.h
|
simulation/autopublishdata.h
|
||||||
simulation/interpolationrenderingsetup.h
|
simulation/interpolationrenderingsetup.h
|
||||||
|
simulation/interpolationresult.cpp
|
||||||
|
simulation/interpolationresult.h
|
||||||
simulation/matchingscriptmisc.h
|
simulation/matchingscriptmisc.h
|
||||||
simulation/interpolationsetuplist.cpp
|
simulation/interpolationsetuplist.cpp
|
||||||
simulation/remoteaircraftprovider.h
|
simulation/remoteaircraftprovider.h
|
||||||
@@ -605,6 +609,8 @@ add_library(misc SHARED
|
|||||||
simulation/simulatorinfo.cpp
|
simulation/simulatorinfo.cpp
|
||||||
simulation/matchingstatistics.cpp
|
simulation/matchingstatistics.cpp
|
||||||
simulation/ownaircraftproviderdummy.cpp
|
simulation/ownaircraftproviderdummy.cpp
|
||||||
|
simulation/partsstatus.cpp
|
||||||
|
simulation/partsstatus.h
|
||||||
simulation/simulatorinfolist.cpp
|
simulation/simulatorinfolist.cpp
|
||||||
simulation/aircraftmodelloader.cpp
|
simulation/aircraftmodelloader.cpp
|
||||||
simulation/distributor.h
|
simulation/distributor.h
|
||||||
|
|||||||
21
src/blackmisc/simulation/interpolationresult.cpp
Normal file
21
src/blackmisc/simulation/interpolationresult.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/interpolationresult.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
void CInterpolationResult::setValues(const CAircraftSituation &situation, const CAircraftParts &parts)
|
||||||
|
{
|
||||||
|
m_interpolatedSituation = situation;
|
||||||
|
m_interpolatedParts = parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInterpolationResult::setStatus(const CInterpolationStatus &interpolation, const CPartsStatus &parts)
|
||||||
|
{
|
||||||
|
m_interpolationStatus = interpolation;
|
||||||
|
m_partsStatus = parts;
|
||||||
|
}
|
||||||
|
}
|
||||||
71
src/blackmisc/simulation/interpolationresult.h
Normal file
71
src/blackmisc/simulation/interpolationresult.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SIMULATION_INTERPOLATIONRESULT_H
|
||||||
|
#define BLACKMISC_SIMULATION_INTERPOLATIONRESULT_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
|
||||||
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
|
#include "blackmisc/aviation/aircraftparts.h"
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/interpolationstatus.h"
|
||||||
|
#include "blackmisc/simulation/partsstatus.h"
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
//! Combined results
|
||||||
|
class BLACKMISC_EXPORT CInterpolationResult
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Ctor
|
||||||
|
CInterpolationResult() = default;
|
||||||
|
|
||||||
|
//! Get situation
|
||||||
|
const Aviation::CAircraftSituation &getInterpolatedSituation() const { return m_interpolatedSituation; }
|
||||||
|
|
||||||
|
//! Get parts (interpolated or guessed)
|
||||||
|
const Aviation::CAircraftParts &getInterpolatedParts() const { return m_interpolatedParts; }
|
||||||
|
|
||||||
|
//! Get status
|
||||||
|
const CInterpolationStatus &getInterpolationStatus() const { return m_interpolationStatus; }
|
||||||
|
|
||||||
|
//! Get status
|
||||||
|
const CPartsStatus &getPartsStatus() const { return m_partsStatus; }
|
||||||
|
|
||||||
|
//! Set situation
|
||||||
|
void setInterpolatedSituation(const Aviation::CAircraftSituation &situation) { m_interpolatedSituation = situation; }
|
||||||
|
|
||||||
|
//! Set parts (interpolated or guessed)
|
||||||
|
void setInterpolatedParts(const Aviation::CAircraftParts &parts) { m_interpolatedParts = parts; }
|
||||||
|
|
||||||
|
//! Set values
|
||||||
|
void setValues(const Aviation::CAircraftSituation &situation, const Aviation::CAircraftParts &parts);
|
||||||
|
|
||||||
|
//! Set status
|
||||||
|
void setInterpolationStatus(const CInterpolationStatus &status) { m_interpolationStatus = status; }
|
||||||
|
|
||||||
|
//! Set status
|
||||||
|
void setPartsStatus(const CPartsStatus &status) { m_partsStatus = status; }
|
||||||
|
|
||||||
|
//! Set status values
|
||||||
|
void setStatus(const CInterpolationStatus &interpolation, const CPartsStatus &parts);
|
||||||
|
|
||||||
|
//! @{
|
||||||
|
//! Implicit conversion
|
||||||
|
operator const Aviation::CAircraftSituation &() const { return m_interpolatedSituation; }
|
||||||
|
operator const Aviation::CAircraftParts &() const { return m_interpolatedParts; }
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Aviation::CAircraftSituation m_interpolatedSituation = Aviation::CAircraftSituation::null(); //!< interpolated situation
|
||||||
|
Aviation::CAircraftParts m_interpolatedParts = Aviation::CAircraftParts::null(); //!< guessed or interpolated parts
|
||||||
|
CInterpolationStatus m_interpolationStatus; //!< interpolation status
|
||||||
|
CPartsStatus m_partsStatus; //!< parts status
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BLACKMISC_SIMULATION_INTERPOLATIONRESULT_H
|
||||||
40
src/blackmisc/simulation/interpolationstatus.cpp
Normal file
40
src/blackmisc/simulation/interpolationstatus.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/interpolationstatus.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
void CInterpolationStatus::setExtraInfo(const QString &info)
|
||||||
|
{
|
||||||
|
m_extraInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInterpolationStatus::setInterpolatedAndCheckSituation(bool succeeded, const CAircraftSituation &situation)
|
||||||
|
{
|
||||||
|
m_isInterpolated = succeeded;
|
||||||
|
this->checkIfValidSituation(situation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInterpolationStatus::checkIfValidSituation(const CAircraftSituation &situation)
|
||||||
|
{
|
||||||
|
m_isValidSituation = !situation.isPositionOrAltitudeNull();
|
||||||
|
if (!m_isValidSituation) { m_isValidSituation = false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CInterpolationStatus::hasValidInterpolatedSituation() const
|
||||||
|
{
|
||||||
|
return m_isInterpolated && m_isValidSituation;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CInterpolationStatus::toQString() const
|
||||||
|
{
|
||||||
|
return QStringLiteral("Interpolated: ") % boolToYesNo(m_isInterpolated) %
|
||||||
|
QStringLiteral(" | situations: ") % QString::number(m_situations) %
|
||||||
|
QStringLiteral(" | situation valid: ") % boolToYesNo(m_isValidSituation) %
|
||||||
|
QStringLiteral(" | same: ") % boolToYesNo(m_isSameSituation) %
|
||||||
|
(m_extraInfo.isEmpty() ? QString() : QStringLiteral(" info: ") % m_extraInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/blackmisc/simulation/interpolationstatus.h
Normal file
62
src/blackmisc/simulation/interpolationstatus.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SIMULATION_INTERPOLATIONSTATUS_H
|
||||||
|
#define BLACKMISC_SIMULATION_INTERPOLATIONSTATUS_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
//! Status of interpolation
|
||||||
|
class BLACKMISC_EXPORT CInterpolationStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Did interpolation succeed?
|
||||||
|
bool isInterpolated() const { return m_isInterpolated; }
|
||||||
|
|
||||||
|
//! Set succeeded
|
||||||
|
void setInterpolated(bool interpolated) { m_isInterpolated = interpolated; }
|
||||||
|
|
||||||
|
//! Interpolating between 2 same situations?
|
||||||
|
bool isSameSituation() const { return m_isSameSituation; }
|
||||||
|
|
||||||
|
//! Interpolating between 2 same situations?
|
||||||
|
void setSameSituation(bool same) { m_isSameSituation = same; }
|
||||||
|
|
||||||
|
//! Set situations count
|
||||||
|
void setSituationsCount(int count) { m_situations = count; }
|
||||||
|
|
||||||
|
//! Extra info
|
||||||
|
void setExtraInfo(const QString &info);
|
||||||
|
|
||||||
|
//! Set succeeded
|
||||||
|
void setInterpolatedAndCheckSituation(bool succeeded, const Aviation::CAircraftSituation &situation);
|
||||||
|
|
||||||
|
//! Is the corresponding position valid?
|
||||||
|
bool hasValidSituation() const { return m_isValidSituation; }
|
||||||
|
|
||||||
|
//! Valid interpolated situation
|
||||||
|
bool hasValidInterpolatedSituation() const;
|
||||||
|
|
||||||
|
//! Is that a valid position?
|
||||||
|
void checkIfValidSituation(const Aviation::CAircraftSituation &situation);
|
||||||
|
|
||||||
|
//! Info string
|
||||||
|
QString toQString() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_isInterpolated = false; //!< position is interpolated (means enough values, etc.)
|
||||||
|
bool m_isValidSituation = false; //!< is valid situation
|
||||||
|
bool m_isSameSituation = false; //!< interpolation between 2 same situations
|
||||||
|
int m_situations = -1; //!< number of situations used for interpolation
|
||||||
|
QString m_extraInfo; //!< optional details
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BLACKMISC_SIMULATION_INTERPOLATIONSTATUS_H
|
||||||
@@ -500,7 +500,7 @@ namespace BlackMisc::Simulation
|
|||||||
if (m_interpolationMessages.isEmpty()) { CLogMessage::preformatted(m); }
|
if (m_interpolationMessages.isEmpty()) { CLogMessage::preformatted(m); }
|
||||||
m_interpolationMessages.push_back(m);
|
m_interpolationMessages.push_back(m);
|
||||||
}
|
}
|
||||||
m_currentPartsStatus.reset();
|
m_currentPartsStatus = {};
|
||||||
return CAircraftParts::null();
|
return CAircraftParts::null();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,8 +682,8 @@ namespace BlackMisc::Simulation
|
|||||||
const bool changedSituations = lastModifed > m_situationsLastModified;
|
const bool changedSituations = lastModifed > m_situationsLastModified;
|
||||||
|
|
||||||
m_currentTimeMsSinceEpoch = currentTimeSinceEpoch;
|
m_currentTimeMsSinceEpoch = currentTimeSinceEpoch;
|
||||||
m_currentInterpolationStatus.reset();
|
m_currentInterpolationStatus = {};
|
||||||
m_currentPartsStatus.reset();
|
m_currentPartsStatus = {};
|
||||||
m_currentSetup = setup;
|
m_currentSetup = setup;
|
||||||
|
|
||||||
if (changedSituations)
|
if (changedSituations)
|
||||||
@@ -776,85 +776,6 @@ namespace BlackMisc::Simulation
|
|||||||
m_unitTest = true;
|
m_unitTest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInterpolationResult::CInterpolationResult()
|
|
||||||
{
|
|
||||||
this->reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationResult::setValues(const CAircraftSituation &situation, const CAircraftParts &parts)
|
|
||||||
{
|
|
||||||
m_interpolatedSituation = situation;
|
|
||||||
m_interpolatedParts = parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationResult::setStatus(const CInterpolationStatus &interpolation, const CPartsStatus &parts)
|
|
||||||
{
|
|
||||||
m_interpolationStatus = interpolation;
|
|
||||||
m_partsStatus = parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationResult::reset()
|
|
||||||
{
|
|
||||||
m_interpolatedSituation = CAircraftSituation::null();
|
|
||||||
m_interpolatedParts = CAircraftParts::null();
|
|
||||||
m_interpolationStatus.reset();
|
|
||||||
m_partsStatus.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationStatus::setExtraInfo(const QString &info)
|
|
||||||
{
|
|
||||||
m_extraInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationStatus::setInterpolatedAndCheckSituation(bool succeeded, const CAircraftSituation &situation)
|
|
||||||
{
|
|
||||||
m_isInterpolated = succeeded;
|
|
||||||
this->checkIfValidSituation(situation);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationStatus::checkIfValidSituation(const CAircraftSituation &situation)
|
|
||||||
{
|
|
||||||
m_isValidSituation = !situation.isPositionOrAltitudeNull();
|
|
||||||
if (!m_isValidSituation) { m_isValidSituation = false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CInterpolationStatus::hasValidInterpolatedSituation() const
|
|
||||||
{
|
|
||||||
return m_isInterpolated && m_isValidSituation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpolationStatus::reset()
|
|
||||||
{
|
|
||||||
m_extraInfo.clear();
|
|
||||||
m_isValidSituation = false;
|
|
||||||
m_isInterpolated = false;
|
|
||||||
m_isSameSituation = false;
|
|
||||||
m_situations = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CInterpolationStatus::toQString() const
|
|
||||||
{
|
|
||||||
return QStringLiteral("Interpolated: ") % boolToYesNo(m_isInterpolated) %
|
|
||||||
QStringLiteral(" | situations: ") % QString::number(m_situations) %
|
|
||||||
QStringLiteral(" | situation valid: ") % boolToYesNo(m_isValidSituation) %
|
|
||||||
QStringLiteral(" | same: ") % boolToYesNo(m_isSameSituation) %
|
|
||||||
(m_extraInfo.isEmpty() ? QString() : QStringLiteral(" info: ") % m_extraInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPartsStatus::reset()
|
|
||||||
{
|
|
||||||
m_supportsParts = false;
|
|
||||||
m_resusedParts = false;
|
|
||||||
m_isSameParts = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CPartsStatus::toQString() const
|
|
||||||
{
|
|
||||||
return QStringLiteral("Supported parts: ") % boolToYesNo(m_supportsParts) %
|
|
||||||
QStringLiteral(" | reused: ") % boolToYesNo(m_resusedParts) %
|
|
||||||
QStringLiteral(" | same: ") % boolToYesNo(m_isSameParts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// see here for the reason of thess forward instantiations
|
// see here for the reason of thess forward instantiations
|
||||||
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#ifndef BLACKMISC_SIMULATION_INTERPOLATOR_H
|
#ifndef BLACKMISC_SIMULATION_INTERPOLATOR_H
|
||||||
#define BLACKMISC_SIMULATION_INTERPOLATOR_H
|
#define BLACKMISC_SIMULATION_INTERPOLATOR_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/interpolationresult.h"
|
||||||
|
#include "blackmisc/simulation/interpolationstatus.h"
|
||||||
|
#include "blackmisc/simulation/partsstatus.h"
|
||||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||||
#include "blackmisc/simulation/interpolationsetupprovider.h"
|
#include "blackmisc/simulation/interpolationsetupprovider.h"
|
||||||
@@ -36,148 +39,6 @@ namespace BlackMisc
|
|||||||
class CInterpolatorLinear;
|
class CInterpolatorLinear;
|
||||||
class CInterpolatorSpline;
|
class CInterpolatorSpline;
|
||||||
|
|
||||||
//! Status of interpolation
|
|
||||||
struct BLACKMISC_EXPORT CInterpolationStatus
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Did interpolation succeed?
|
|
||||||
bool isInterpolated() const { return m_isInterpolated; }
|
|
||||||
|
|
||||||
//! Set succeeded
|
|
||||||
void setInterpolated(bool interpolated) { m_isInterpolated = interpolated; }
|
|
||||||
|
|
||||||
//! Interpolating between 2 same situations?
|
|
||||||
bool isSameSituation() const { return m_isSameSituation; }
|
|
||||||
|
|
||||||
//! Interpolating between 2 same situations?
|
|
||||||
void setSameSituation(bool same) { m_isSameSituation = same; }
|
|
||||||
|
|
||||||
//! Set situations count
|
|
||||||
void setSituationsCount(int count) { m_situations = count; }
|
|
||||||
|
|
||||||
//! Extra info
|
|
||||||
void setExtraInfo(const QString &info);
|
|
||||||
|
|
||||||
//! Set succeeded
|
|
||||||
void setInterpolatedAndCheckSituation(bool succeeded, const Aviation::CAircraftSituation &situation);
|
|
||||||
|
|
||||||
//! Is the corresponding position valid?
|
|
||||||
bool hasValidSituation() const { return m_isValidSituation; }
|
|
||||||
|
|
||||||
//! Valid interpolated situation
|
|
||||||
bool hasValidInterpolatedSituation() const;
|
|
||||||
|
|
||||||
//! Is that a valid position?
|
|
||||||
void checkIfValidSituation(const Aviation::CAircraftSituation &situation);
|
|
||||||
|
|
||||||
//! Reset to default values
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
//! Info string
|
|
||||||
QString toQString() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_isInterpolated = false; //!< position is interpolated (means enough values, etc.)
|
|
||||||
bool m_isValidSituation = false; //!< is valid situation
|
|
||||||
bool m_isSameSituation = false; //!< interpolation between 2 same situations
|
|
||||||
int m_situations = -1; //!< number of situations used for interpolation
|
|
||||||
QString m_extraInfo; //!< optional details
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Status regarding parts
|
|
||||||
struct BLACKMISC_EXPORT CPartsStatus
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Ctor
|
|
||||||
CPartsStatus() {}
|
|
||||||
|
|
||||||
//! Ctor
|
|
||||||
CPartsStatus(bool supportsParts) : m_supportsParts(supportsParts) {}
|
|
||||||
|
|
||||||
//! Supporting parts
|
|
||||||
bool isSupportingParts() const { return m_supportsParts; }
|
|
||||||
|
|
||||||
//! Set support flag
|
|
||||||
void setSupportsParts(bool supports) { m_supportsParts = supports; }
|
|
||||||
|
|
||||||
//! Is a reused parts object?
|
|
||||||
//! \remark means using last value again
|
|
||||||
bool isReusedParts() const { return m_resusedParts; }
|
|
||||||
|
|
||||||
//! Mark as reused
|
|
||||||
void setReusedParts(bool reused) { m_resusedParts = reused; }
|
|
||||||
|
|
||||||
//! Same parts as last parts?
|
|
||||||
bool isSameParts() const { return m_isSameParts; }
|
|
||||||
|
|
||||||
//! Same parts as last parts?
|
|
||||||
void setSameParts(bool same) { m_isSameParts = same; }
|
|
||||||
|
|
||||||
//! Reset to default values
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
//! Info string
|
|
||||||
QString toQString() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_supportsParts = false; //!< supports parts for given callsign
|
|
||||||
bool m_resusedParts = false; //!< reusing from last step
|
|
||||||
bool m_isSameParts = false; //!< same as last parts?
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Combined results
|
|
||||||
class BLACKMISC_EXPORT CInterpolationResult
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Ctor
|
|
||||||
CInterpolationResult();
|
|
||||||
|
|
||||||
//! Get situation
|
|
||||||
const Aviation::CAircraftSituation &getInterpolatedSituation() const { return m_interpolatedSituation; }
|
|
||||||
|
|
||||||
//! Get parts (interpolated or guessed)
|
|
||||||
const Aviation::CAircraftParts &getInterpolatedParts() const { return m_interpolatedParts; }
|
|
||||||
|
|
||||||
//! Get status
|
|
||||||
const CInterpolationStatus &getInterpolationStatus() const { return m_interpolationStatus; }
|
|
||||||
|
|
||||||
//! Get status
|
|
||||||
const CPartsStatus &getPartsStatus() const { return m_partsStatus; }
|
|
||||||
|
|
||||||
//! Set situation
|
|
||||||
void setInterpolatedSituation(const Aviation::CAircraftSituation &situation) { m_interpolatedSituation = situation; }
|
|
||||||
|
|
||||||
//! Set parts (interpolated or guessed)
|
|
||||||
void setInterpolatedParts(const Aviation::CAircraftParts &parts) { m_interpolatedParts = parts; }
|
|
||||||
|
|
||||||
//! Set values
|
|
||||||
void setValues(const Aviation::CAircraftSituation &situation, const Aviation::CAircraftParts &parts);
|
|
||||||
|
|
||||||
//! Set status
|
|
||||||
void setInterpolationStatus(const CInterpolationStatus &status) { m_interpolationStatus = status; }
|
|
||||||
|
|
||||||
//! Set status
|
|
||||||
void setPartsStatus(const CPartsStatus &status) { m_partsStatus = status; }
|
|
||||||
|
|
||||||
//! Set status values
|
|
||||||
void setStatus(const CInterpolationStatus &interpolation, const CPartsStatus &parts);
|
|
||||||
|
|
||||||
//! Reset values
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
//! @{
|
|
||||||
//! Implicit conversion
|
|
||||||
operator const Aviation::CAircraftSituation &() const { return m_interpolatedSituation; }
|
|
||||||
operator const Aviation::CAircraftParts &() const { return m_interpolatedParts; }
|
|
||||||
//! @}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Aviation::CAircraftSituation m_interpolatedSituation; //!< interpolated situation
|
|
||||||
Aviation::CAircraftParts m_interpolatedParts; //!< guessed or interpolated parts
|
|
||||||
CInterpolationStatus m_interpolationStatus; //!< interpolation status
|
|
||||||
CPartsStatus m_partsStatus; //!< parts status
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Interpolator, calculation inbetween positions
|
//! Interpolator, calculation inbetween positions
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
class CInterpolator :
|
class CInterpolator :
|
||||||
|
|||||||
16
src/blackmisc/simulation/partsstatus.cpp
Normal file
16
src/blackmisc/simulation/partsstatus.cpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/partsstatus.h"
|
||||||
|
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
QString CPartsStatus::toQString() const
|
||||||
|
{
|
||||||
|
return QStringLiteral("Supported parts: ") % boolToYesNo(m_supportsParts) %
|
||||||
|
QStringLiteral(" | reused: ") % boolToYesNo(m_resusedParts) %
|
||||||
|
QStringLiteral(" | same: ") % boolToYesNo(m_isSameParts);
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/blackmisc/simulation/partsstatus.h
Normal file
54
src/blackmisc/simulation/partsstatus.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SIMULATION_PARTSTATUS_H
|
||||||
|
#define BLACKMISC_SIMULATION_PARTSTATUS_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
//! Status regarding parts
|
||||||
|
class BLACKMISC_EXPORT CPartsStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Ctor
|
||||||
|
CPartsStatus() = default;
|
||||||
|
|
||||||
|
//! Ctor
|
||||||
|
explicit CPartsStatus(bool supportsParts) : m_supportsParts(supportsParts) {}
|
||||||
|
|
||||||
|
//! Supporting parts
|
||||||
|
bool isSupportingParts() const { return m_supportsParts; }
|
||||||
|
|
||||||
|
//! Set support flag
|
||||||
|
void setSupportsParts(bool supports) { m_supportsParts = supports; }
|
||||||
|
|
||||||
|
//! Is a reused parts object?
|
||||||
|
//! \remark means using last value again
|
||||||
|
bool isReusedParts() const { return m_resusedParts; }
|
||||||
|
|
||||||
|
//! Mark as reused
|
||||||
|
void setReusedParts(bool reused) { m_resusedParts = reused; }
|
||||||
|
|
||||||
|
//! Same parts as last parts?
|
||||||
|
bool isSameParts() const { return m_isSameParts; }
|
||||||
|
|
||||||
|
//! Same parts as last parts?
|
||||||
|
void setSameParts(bool same) { m_isSameParts = same; }
|
||||||
|
|
||||||
|
//! Info string
|
||||||
|
QString toQString() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_supportsParts = false; //!< supports parts for given callsign
|
||||||
|
bool m_resusedParts = false; //!< reusing from last step
|
||||||
|
bool m_isSameParts = false; //!< same as last parts?
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BLACKMISC_SIMULATION_PARTSTATUS_H
|
||||||
@@ -209,9 +209,7 @@ namespace BlackSimPlugin::FsxCommon
|
|||||||
{
|
{
|
||||||
if (!m_interpolator)
|
if (!m_interpolator)
|
||||||
{
|
{
|
||||||
CInterpolationResult result;
|
return {};
|
||||||
result.reset();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
return m_interpolator->getInterpolation(currentTimeSinceEpoch, setup, aircraftNumber);
|
return m_interpolator->getInterpolation(currentTimeSinceEpoch, setup, aircraftNumber);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user