mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T240, use ITimestampBased / ITimestampObjectList
* using the existing base classes (interfaces) gives you plenty of useful utility functions * hint: we do not init with current timestamp as default as this is relatively slow
This commit is contained in:
@@ -1053,6 +1053,7 @@ namespace BlackCore
|
||||
{
|
||||
if (!m_rawFsdMessagesEnabled) { return; }
|
||||
CRawFsdMessage rawFsdMessage(fsdMessage);
|
||||
rawFsdMessage.setCurrentUtcTime();
|
||||
if (m_rawFsdMessageLogFile.isOpen())
|
||||
{
|
||||
QTextStream stream(&m_rawFsdMessageLogFile);
|
||||
@@ -1061,8 +1062,6 @@ namespace BlackCore
|
||||
emit rawFsdMessageReceived(rawFsdMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CNetworkVatlib::fsdMessageSettingsChanged()
|
||||
{
|
||||
if (!m_net) { return; }
|
||||
|
||||
@@ -213,9 +213,9 @@ namespace BlackGui
|
||||
ui->cb_FileWritingMode->setCurrentIndex(static_cast<int>(mode));
|
||||
}
|
||||
|
||||
QString CRawFsdMessagesComponent::rawFsdMessageToString(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
return QString("%1 %2").arg(rawFsdMessage.getReceptionTime().toString("HH:mm:ss"), rawFsdMessage.getRawMessage());
|
||||
}
|
||||
QString CRawFsdMessagesComponent::rawFsdMessageToString(const CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
static const QString s("%1 %2");
|
||||
return s.arg(rawFsdMessage.getFormattedUtcTimestampHmsz(), rawFsdMessage.getRawMessage());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BlackMisc
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
static const QString s("%1 %2");
|
||||
return s.arg(m_receptionTime.toString("dd.MM.yy HH:mm:ss"), m_rawMessage);
|
||||
return s.arg(this->getFormattedUtcTimestampHmsz(), m_rawMessage);
|
||||
}
|
||||
|
||||
bool CRawFsdMessage::isPacketType(const QString &type) const
|
||||
@@ -47,27 +47,30 @@ namespace BlackMisc
|
||||
const QStringList &CRawFsdMessage::getAllPacketTypes()
|
||||
{
|
||||
static const QStringList allPacketTypes = { "@", "%", "#AA", "#DA", "#AP", "#DP", "#TM", "#WX", "#DL", "#TD", "#WD"
|
||||
"#CD", "#PC", "#SB", "$FP", "$AM", "$PI", "$PO", "$HO", "$HA", "$AX", "$AR",
|
||||
"$CQ", "$CR", "$ER", "$!!" };
|
||||
"#CD", "#PC", "#SB", "$FP", "$AM", "$PI", "$PO", "$HO", "$HA", "$AX", "$AR",
|
||||
"$CQ", "$CR", "$ER", "$!!"
|
||||
};
|
||||
return allPacketTypes;
|
||||
}
|
||||
|
||||
CVariant CRawFsdMessage::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexReceptionTime: return CVariant::fromValue(m_rawMessage);
|
||||
case IndexRawMessage: return CVariant::fromValue(m_receptionTime);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexRawMessage: return CVariant::fromValue(m_rawMessage);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CRawFsdMessage::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CRawFsdMessage>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); return; }
|
||||
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_NETWORK_RAWFSDMESSAGE_H
|
||||
#define BLACKMISC_NETWORK_RAWFSDMESSAGE_H
|
||||
|
||||
#include "blackmisc/timestampbased.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
@@ -27,14 +28,15 @@ namespace BlackMisc
|
||||
namespace Network
|
||||
{
|
||||
//! Value object for a raw FSD message
|
||||
class BLACKMISC_EXPORT CRawFsdMessage : public CValueObject<CRawFsdMessage>
|
||||
class BLACKMISC_EXPORT CRawFsdMessage :
|
||||
public CValueObject<CRawFsdMessage>,
|
||||
public ITimestampBased
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexReceptionTime = CPropertyIndex::GlobalIndexCRawFsdMessage,
|
||||
IndexRawMessage
|
||||
IndexRawMessage = CPropertyIndex::GlobalIndexCRawFsdMessage,
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
@@ -49,9 +51,6 @@ namespace BlackMisc
|
||||
//! Set raw message
|
||||
void setRawMessage(const QString &rawMessage) { m_rawMessage = rawMessage; }
|
||||
|
||||
//! Get reception time
|
||||
const QDateTime &getReceptionTime() const { return m_receptionTime; }
|
||||
|
||||
//! Returns true if the raw message is from the given PDU packet type
|
||||
bool isPacketType(const QString &type) const;
|
||||
|
||||
@@ -59,7 +58,7 @@ namespace BlackMisc
|
||||
bool containsString(const QString &str) const;
|
||||
|
||||
//! Returns a list of all known packet types.
|
||||
static const QStringList &getAllPacketTypes ();
|
||||
static const QStringList &getAllPacketTypes();
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
@@ -72,12 +71,11 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
QString m_rawMessage;
|
||||
QDateTime m_receptionTime = QDateTime::currentDateTime();
|
||||
|
||||
BLACK_METACLASS(
|
||||
CRawFsdMessage,
|
||||
BLACK_METAMEMBER(rawMessage),
|
||||
BLACK_METAMEMBER(receptionTime)
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKMISC_NETWORK_RAWFSDMESSAGELIST_H
|
||||
|
||||
#include "rawfsdmessage.h"
|
||||
#include "blackmisc/timestampobjectlist.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/variant.h"
|
||||
@@ -28,7 +29,8 @@ namespace BlackMisc
|
||||
//! Value object encapsulating a list raw FSD messages.
|
||||
class BLACKMISC_EXPORT CRawFsdMessageList :
|
||||
public CSequence<CRawFsdMessage>,
|
||||
public Mixin::MetaType<CRawFsdMessageList>
|
||||
public Mixin::MetaType<CRawFsdMessageList>,
|
||||
public ITimestampObjectList<CRawFsdMessage, CRawFsdMessageList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CRawFsdMessageList)
|
||||
|
||||
@@ -12,14 +12,12 @@
|
||||
#include "blackmisc/aviation/liverylist.h"
|
||||
#include "blackmisc/aviation/aircrafticaocodelist.h"
|
||||
#include "blackmisc/aviation/airlineicaocodelist.h"
|
||||
#include "blackmisc/aviation/airport.h"
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/db/dbinfolist.h"
|
||||
#include "blackmisc/db/artifactlist.h"
|
||||
#include "blackmisc/db/distributionlist.h"
|
||||
#include "blackmisc/network/textmessage.h"
|
||||
#include "blackmisc/network/textmessagelist.h"
|
||||
#include "blackmisc/network/urllog.h"
|
||||
#include "blackmisc/network/rawfsdmessagelist.h"
|
||||
#include "blackmisc/network/urlloglist.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
@@ -348,6 +346,7 @@ namespace BlackMisc
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Db::CDistribution, BlackMisc::Db::CDistributionList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CTextMessage, BlackMisc::Network::CTextMessageList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CUrlLog, BlackMisc::Network::CUrlLogList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CRawFsdMessage, BlackMisc::Network::CRawFsdMessageList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Simulation::CAircraftModel, BlackMisc::Simulation::CAircraftModelList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Simulation::CDistributor, BlackMisc::Simulation::CDistributorList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Simulation::CMatchingStatisticsEntry, BlackMisc::Simulation::CMatchingStatistics>;
|
||||
|
||||
@@ -162,6 +162,8 @@ namespace BlackMisc
|
||||
{
|
||||
class CTextMessage;
|
||||
class CTextMessageList;
|
||||
class CRawFsdMessage;
|
||||
class CRawFsdMessageList;
|
||||
class CUrlLog;
|
||||
class CUrlLogList;
|
||||
}
|
||||
@@ -191,8 +193,6 @@ namespace BlackMisc
|
||||
class CCountry;
|
||||
class CCountryList;
|
||||
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CLivery, BlackMisc::Aviation::CLiveryList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftIcaoCode, BlackMisc::Aviation::CAircraftIcaoCodeList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAirlineIcaoCode, BlackMisc::Aviation::CAirlineIcaoCodeList>;
|
||||
@@ -203,10 +203,14 @@ namespace BlackMisc
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Simulation::CAircraftModel, BlackMisc::Simulation::CAircraftModelList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Simulation::CDistributor, BlackMisc::Simulation::CDistributorList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CTextMessage, BlackMisc::Network::CTextMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CRawFsdMessage, BlackMisc::Network::CRawFsdMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CUrlLog, BlackMisc::Network::CUrlLogList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::CIdentifier, BlackMisc::CIdentifierList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::CCountry, BlackMisc::CCountryList>;
|
||||
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampWithOffsetObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampWithOffsetObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
//! \endcond
|
||||
|
||||
} //namespace
|
||||
|
||||
Reference in New Issue
Block a user