mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
refs #146 , added methods to update from data file reader (e.g.) updateFromVatsimDataFileAircraft
* updateFromVatsimDataFileStation * updateFromVatsimDataFileAircraft * Changed to 1 line comments //! where applicable
This commit is contained in:
@@ -4,8 +4,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "avaircraftlist.h"
|
||||
#include "nwuser.h"
|
||||
#include "predicates.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -55,5 +58,30 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Merge with aircraft
|
||||
*/
|
||||
int CAircraftList::updateFromVatsimDataFileAircraft(CAircraft &aircraftToBeUpdated) const
|
||||
{
|
||||
if (this->isEmpty()) return 0;
|
||||
if (aircraftToBeUpdated.hasValidRealName() && aircraftToBeUpdated.hasValidId()) return 0;
|
||||
|
||||
int c = 0;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAircraft currentDataFileAircraft = *i;
|
||||
if (currentDataFileAircraft.getCallsign() != aircraftToBeUpdated.getCallsign()) continue;
|
||||
|
||||
CUser user = aircraftToBeUpdated.getPilot();
|
||||
if (!aircraftToBeUpdated.hasValidRealName()) user.setRealName(currentDataFileAircraft.getPilotRealname());
|
||||
if (!aircraftToBeUpdated.hasValidId()) user.setId(currentDataFileAircraft.getPilotId());
|
||||
aircraftToBeUpdated.setPilot(user);
|
||||
c++;
|
||||
}
|
||||
|
||||
// normally 1 expected, as I should find
|
||||
// only one online station for this booking
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -27,46 +27,35 @@ namespace BlackMisc
|
||||
class CAircraftList : public CSequence<CAircraft>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor.
|
||||
*/
|
||||
//! \brief Default constructor.
|
||||
CAircraftList();
|
||||
|
||||
/*!
|
||||
* \brief Construct from a base class object.
|
||||
* \param other
|
||||
*/
|
||||
//! \brief Construct from a base class object.
|
||||
CAircraftList(const CSequence<CAircraft> &other);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \return
|
||||
*/
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Find 0..n stations by callsign
|
||||
* \param callsign
|
||||
* \return
|
||||
*/
|
||||
//! \brief Find 0..n stations by callsign
|
||||
CAircraftList findByCallsign(const CCallsign &callsign) const;
|
||||
|
||||
/*!
|
||||
* \brief Find 0..n stations within range of given coordinate
|
||||
* \param coordinate
|
||||
* \param range
|
||||
* \param coordinate other position
|
||||
* \param range within range of other position
|
||||
* \return
|
||||
*/
|
||||
CAircraftList findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const BlackMisc::PhysicalQuantities::CLength &range) const;
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
//! \brief Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! \brief Update aircraft with data from VATSIM data file
|
||||
//! \remarks The list used needs to contain the VATSIM data file objects
|
||||
int updateFromVatsimDataFileAircraft(CAircraft &aircraftToBeUpdated) const;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
#include "avatcstationlist.h"
|
||||
#include "predicates.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -84,6 +86,7 @@ namespace BlackMisc
|
||||
{
|
||||
int c = 0;
|
||||
bookedAtcStation.setOnline(false); // reset
|
||||
if (this->isEmpty()) return 0;
|
||||
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
@@ -157,5 +160,39 @@ namespace BlackMisc
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Merge with VATSIM data file
|
||||
*/
|
||||
int CAtcStationList::updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const
|
||||
{
|
||||
if (this->isEmpty()) return 0;
|
||||
if (stationToBeUpdated.hasValidRealName() && stationToBeUpdated.hasValidId() && stationToBeUpdated.hasValidFrequency()) return 0;
|
||||
|
||||
int c = 0;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAtcStation currentDataFileStation = *i;
|
||||
if (currentDataFileStation.getCallsign() != stationToBeUpdated.getCallsign()) continue;
|
||||
|
||||
if (!stationToBeUpdated.hasValidRealName() || !stationToBeUpdated.hasValidId())
|
||||
{
|
||||
CUser user = stationToBeUpdated.getController();
|
||||
if (!stationToBeUpdated.hasValidRealName()) user.setRealName(currentDataFileStation.getControllerRealName());
|
||||
if (!stationToBeUpdated.hasValidId()) user.setId(currentDataFileStation.getControllerId());
|
||||
stationToBeUpdated.setController(user);
|
||||
}
|
||||
|
||||
if (!stationToBeUpdated.hasValidFrequency())
|
||||
{
|
||||
stationToBeUpdated.setFrequency(currentDataFileStation.getFrequency());
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
// normally 1 expected, as I should find
|
||||
// only one online station for this booking
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -22,62 +22,45 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of ATC stations.
|
||||
* Value object for a list of ATC stations.
|
||||
*/
|
||||
class CAtcStationList : public CSequence<CAtcStation>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Empty constructor.
|
||||
*/
|
||||
//! \brief Default constructor.
|
||||
CAtcStationList();
|
||||
|
||||
/*!
|
||||
* \brief Construct from a base class object.
|
||||
* \param other
|
||||
*/
|
||||
//! \brief Construct from a base class object.
|
||||
CAtcStationList(const CSequence<CAtcStation> &other);
|
||||
|
||||
/*!
|
||||
* \brief QVariant, required for DBus QVariant lists
|
||||
* \return
|
||||
*/
|
||||
//! \copydoc CValueObject::toQVariant()
|
||||
virtual QVariant toQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Find 0..n stations by callsign
|
||||
*/
|
||||
//! \brief Find 0..n stations by callsign
|
||||
CAtcStationList findByCallsign(const CCallsign &callsign) const;
|
||||
|
||||
/*!
|
||||
* \brief Find 0..n stations within range of given coordinate
|
||||
*/
|
||||
//! \brief Find 0..n stations within range of given coordinate
|
||||
CAtcStationList findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const BlackMisc::PhysicalQuantities::CLength &range) const;
|
||||
|
||||
/*!
|
||||
* \brief Find 0..n stations tune in frequency of COM unit (with 25kHt channel spacing
|
||||
*/
|
||||
//! \brief Find 0..n stations tune in frequency of COM unit (with 25kHt channel spacing
|
||||
CAtcStationList findIfComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
||||
|
||||
/*!
|
||||
* \brief Update distances to coordinate, usually own aircraft's position
|
||||
*/
|
||||
//! \brief Update distances to coordinate, usually own aircraft's position
|
||||
void calculateDistancesToPlane(const BlackMisc::Geo::CCoordinateGeodetic &position);
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
//! \brief Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
/*!
|
||||
* \brief Merge with ATC station representing booking information
|
||||
* \param bookedAtcStation
|
||||
* \return
|
||||
*/
|
||||
//! \brief Merge with ATC station representing booking information
|
||||
//! \remarks Can be used if the stored data in this list are online ATC stations
|
||||
int mergeWithBooking(CAtcStation &bookedAtcStation);
|
||||
|
||||
//! \brief Merge with the data from the VATSIM data file
|
||||
//! \remarks Can be used if the stored data in this list are VATSIM data file stations
|
||||
int updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
Reference in New Issue
Block a user