mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Ref T111, access to own aircraft`s situation
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a1357f0bd7
commit
b423a62626
@@ -91,6 +91,12 @@ namespace BlackCore
|
|||||||
return this->m_ownAircraft.getPosition();
|
return this->m_ownAircraft.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftSituation CContextOwnAircraft::getOwnAircraftSituation() const
|
||||||
|
{
|
||||||
|
QReadLocker l(&m_lockAircraft);
|
||||||
|
return this->m_ownAircraft.getSituation();
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftParts CContextOwnAircraft::getOwnAircraftParts() const
|
CAircraftParts CContextOwnAircraft::getOwnAircraftParts() const
|
||||||
{
|
{
|
||||||
QReadLocker l(&m_lockAircraft);
|
QReadLocker l(&m_lockAircraft);
|
||||||
|
|||||||
@@ -72,10 +72,15 @@ namespace BlackCore
|
|||||||
virtual ~CContextOwnAircraft();
|
virtual ~CContextOwnAircraft();
|
||||||
|
|
||||||
// IOwnAircraftProvider overrides
|
// IOwnAircraftProvider overrides
|
||||||
|
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftParts
|
||||||
//! \ingroup ownaircraftprovider
|
//! \ingroup ownaircraftprovider
|
||||||
//! @{
|
|
||||||
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
||||||
|
|
||||||
|
//! Own aircraft's situation
|
||||||
|
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftParts
|
||||||
|
//! \ingroup ownaircraftprovider
|
||||||
|
virtual BlackMisc::Aviation::CAircraftSituation getOwnAircraftSituation() const override;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftParts
|
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftParts
|
||||||
//! \ingroup ownaircraftprovider
|
//! \ingroup ownaircraftprovider
|
||||||
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const override;
|
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const override;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Simulation
|
namespace Simulation
|
||||||
{
|
{
|
||||||
const CSimulatedAircraft COwnAircraftAware::getOwnAircraft() const
|
CSimulatedAircraft COwnAircraftAware::getOwnAircraft() const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||||
return this->m_ownAircraftProvider->getOwnAircraft();
|
return this->m_ownAircraftProvider->getOwnAircraft();
|
||||||
@@ -29,6 +29,12 @@ namespace BlackMisc
|
|||||||
return this->m_ownAircraftProvider->getOwnAircraftPosition();
|
return this->m_ownAircraftProvider->getOwnAircraftPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftSituation COwnAircraftAware::getOwnAircraftSituation() const
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||||
|
return this->m_ownAircraftProvider->getOwnAircraftSituation();
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftParts COwnAircraftAware::getOwnAircraftParts() const
|
CAircraftParts COwnAircraftAware::getOwnAircraftParts() const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const = 0;
|
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const = 0;
|
||||||
|
|
||||||
|
//! Own aircraft's situation
|
||||||
|
//! \threadsafe
|
||||||
|
virtual BlackMisc::Aviation::CAircraftSituation getOwnAircraftSituation() const = 0;
|
||||||
|
|
||||||
//! Own aircraft's parts
|
//! Own aircraft's parts
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const = 0;
|
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const = 0;
|
||||||
@@ -98,7 +102,6 @@ namespace BlackMisc
|
|||||||
//! Update cockpit, but send signals when applicable
|
//! Update cockpit, but send signals when applicable
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) = 0;
|
virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Delegating class which can be directly used to access an \sa IOwnAircraftProvider instance
|
//! Delegating class which can be directly used to access an \sa IOwnAircraftProvider instance
|
||||||
@@ -106,11 +109,14 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||||
virtual const CSimulatedAircraft getOwnAircraft() const;
|
virtual CSimulatedAircraft getOwnAircraft() const;
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
||||||
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const;
|
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const;
|
||||||
|
|
||||||
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
||||||
|
virtual BlackMisc::Aviation::CAircraftSituation getOwnAircraftSituation() const;
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraftParts
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftParts
|
||||||
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const;
|
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const;
|
||||||
|
|
||||||
@@ -149,7 +155,6 @@ namespace BlackMisc
|
|||||||
COwnAircraftAware(IOwnAircraftProvider *ownAircraftProvider) : m_ownAircraftProvider(ownAircraftProvider) { Q_ASSERT(ownAircraftProvider); }
|
COwnAircraftAware(IOwnAircraftProvider *ownAircraftProvider) : m_ownAircraftProvider(ownAircraftProvider) { Q_ASSERT(ownAircraftProvider); }
|
||||||
IOwnAircraftProvider *m_ownAircraftProvider = nullptr; //!< access to object
|
IOwnAircraftProvider *m_ownAircraftProvider = nullptr; //!< access to object
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackmisc/simulation/ownaircraftproviderdummy.h"
|
#include "blackmisc/simulation/ownaircraftproviderdummy.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -18,29 +17,44 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Simulation
|
namespace Simulation
|
||||||
{
|
{
|
||||||
|
CSimulatedAircraft COwnAircraftProviderDummy::getOwnAircraft() const
|
||||||
|
{
|
||||||
|
QReadLocker l(&m_lock);
|
||||||
|
return this->m_ownAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
Geo::CCoordinateGeodetic COwnAircraftProviderDummy::getOwnAircraftPosition() const
|
Geo::CCoordinateGeodetic COwnAircraftProviderDummy::getOwnAircraftPosition() const
|
||||||
{
|
{
|
||||||
|
QReadLocker l(&m_lock);
|
||||||
return m_ownAircraft.getPosition();
|
return m_ownAircraft.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftSituation COwnAircraftProviderDummy::getOwnAircraftSituation() const
|
||||||
|
{
|
||||||
|
QReadLocker l(&m_lock);
|
||||||
|
return m_ownAircraft.getSituation();
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftParts COwnAircraftProviderDummy::getOwnAircraftParts() const
|
CAircraftParts COwnAircraftProviderDummy::getOwnAircraftParts() const
|
||||||
{
|
{
|
||||||
|
QReadLocker l(&m_lock);
|
||||||
return m_ownAircraft.getParts();
|
return m_ownAircraft.getParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel COwnAircraftProviderDummy::getOwnAircraftModel() const
|
CAircraftModel COwnAircraftProviderDummy::getOwnAircraftModel() const
|
||||||
{
|
{
|
||||||
|
QReadLocker l(&m_lock);
|
||||||
return m_ownAircraft.getModel();
|
return m_ownAircraft.getModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLength COwnAircraftProviderDummy::getDistanceToOwnAircraft(const Geo::ICoordinateGeodetic &position) const
|
CLength COwnAircraftProviderDummy::getDistanceToOwnAircraft(const Geo::ICoordinateGeodetic &position) const
|
||||||
{
|
{
|
||||||
return m_ownAircraft.calculateGreatCircleDistance(position);
|
return getOwnAircraft().calculateGreatCircleDistance(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateCockpit(const Aviation::CComSystem &com1, const Aviation::CComSystem &com2, const Aviation::CTransponder &transponder, const CIdentifier &originator)
|
bool COwnAircraftProviderDummy::updateCockpit(const Aviation::CComSystem &com1, const Aviation::CComSystem &com2, const Aviation::CTransponder &transponder, const CIdentifier &originator)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setCom1System(com1);
|
m_ownAircraft.setCom1System(com1);
|
||||||
m_ownAircraft.setCom2System(com2);
|
m_ownAircraft.setCom2System(com2);
|
||||||
m_ownAircraft.setTransponder(transponder);
|
m_ownAircraft.setTransponder(transponder);
|
||||||
@@ -51,6 +65,7 @@ namespace BlackMisc
|
|||||||
bool COwnAircraftProviderDummy::updateActiveComFrequency(const PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator)
|
bool COwnAircraftProviderDummy::updateActiveComFrequency(const PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator)
|
||||||
{
|
{
|
||||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
CComSystem com = m_ownAircraft.getComSystem(comUnit);
|
CComSystem com = m_ownAircraft.getComSystem(comUnit);
|
||||||
com.setFrequencyActive(frequency);
|
com.setFrequencyActive(frequency);
|
||||||
m_ownAircraft.setComSystem(com, comUnit);
|
m_ownAircraft.setComSystem(com, comUnit);
|
||||||
@@ -60,6 +75,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateSelcal(const CSelcal &selcal, const BlackMisc::CIdentifier &originator)
|
bool COwnAircraftProviderDummy::updateSelcal(const CSelcal &selcal, const BlackMisc::CIdentifier &originator)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setSelcal(selcal);
|
m_ownAircraft.setSelcal(selcal);
|
||||||
Q_UNUSED(originator);
|
Q_UNUSED(originator);
|
||||||
return true;
|
return true;
|
||||||
@@ -67,30 +83,35 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateOwnModel(const CAircraftModel &model)
|
bool COwnAircraftProviderDummy::updateOwnModel(const CAircraftModel &model)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setModel(model);
|
m_ownAircraft.setModel(model);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateOwnSituation(const CAircraftSituation &situation)
|
bool COwnAircraftProviderDummy::updateOwnSituation(const CAircraftSituation &situation)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setSituation(situation);
|
m_ownAircraft.setSituation(situation);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateOwnParts(const CAircraftParts &parts)
|
bool COwnAircraftProviderDummy::updateOwnParts(const CAircraftParts &parts)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setParts(parts);
|
m_ownAircraft.setParts(parts);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateOwnCallsign(const CCallsign &callsign)
|
bool COwnAircraftProviderDummy::updateOwnCallsign(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setCallsign(callsign);
|
m_ownAircraft.setCallsign(callsign);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool COwnAircraftProviderDummy::updateOwnIcaoCodes(const CAircraftIcaoCode &aircraftIcaoCode, const CAirlineIcaoCode &airlineIcaoCode)
|
bool COwnAircraftProviderDummy::updateOwnIcaoCodes(const CAircraftIcaoCode &aircraftIcaoCode, const CAirlineIcaoCode &airlineIcaoCode)
|
||||||
{
|
{
|
||||||
|
QWriteLocker l(&m_lock);
|
||||||
m_ownAircraft.setIcaoCodes(aircraftIcaoCode, airlineIcaoCode);
|
m_ownAircraft.setIcaoCodes(aircraftIcaoCode, airlineIcaoCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -100,6 +121,5 @@ namespace BlackMisc
|
|||||||
static COwnAircraftProviderDummy *dummy = new COwnAircraftProviderDummy();
|
static COwnAircraftProviderDummy *dummy = new COwnAircraftProviderDummy();
|
||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
namespace Simulation
|
namespace Simulation
|
||||||
{
|
{
|
||||||
//! For testing, thread safety not implemented in this class
|
//! For testing
|
||||||
class BLACKMISC_EXPORT COwnAircraftProviderDummy :
|
class BLACKMISC_EXPORT COwnAircraftProviderDummy :
|
||||||
public QObject,
|
public QObject,
|
||||||
public IOwnAircraftProvider
|
public IOwnAircraftProvider
|
||||||
@@ -54,11 +55,14 @@ namespace BlackMisc
|
|||||||
static COwnAircraftProviderDummy *instance();
|
static COwnAircraftProviderDummy *instance();
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||||
virtual CSimulatedAircraft getOwnAircraft() const override { return this->m_ownAircraft; }
|
virtual CSimulatedAircraft getOwnAircraft() const override;
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
||||||
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
||||||
|
|
||||||
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftSituation
|
||||||
|
virtual BlackMisc::Aviation::CAircraftSituation getOwnAircraftSituation() const override;
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraftParts
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftParts
|
||||||
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const override;
|
virtual BlackMisc::Aviation::CAircraftParts getOwnAircraftParts() const override;
|
||||||
|
|
||||||
@@ -95,8 +99,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft;
|
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft;
|
||||||
|
mutable QReadWriteLock m_lock; //!< lock for m_ownAircraft
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user