diff --git a/src/blackcore/vatsim/networkvatlib.cpp b/src/blackcore/vatsim/networkvatlib.cpp index 3f73317bf..3e5049130 100644 --- a/src/blackcore/vatsim/networkvatlib.cpp +++ b/src/blackcore/vatsim/networkvatlib.cpp @@ -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; } diff --git a/src/blackgui/components/rawfsdmessagescomponent.cpp b/src/blackgui/components/rawfsdmessagescomponent.cpp index f00d030e7..86a38b799 100644 --- a/src/blackgui/components/rawfsdmessagescomponent.cpp +++ b/src/blackgui/components/rawfsdmessagescomponent.cpp @@ -213,9 +213,9 @@ namespace BlackGui ui->cb_FileWritingMode->setCurrentIndex(static_cast(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 diff --git a/src/blackmisc/network/rawfsdmessage.cpp b/src/blackmisc/network/rawfsdmessage.cpp index 8813bc027..ecc6161e1 100644 --- a/src/blackmisc/network/rawfsdmessage.cpp +++ b/src/blackmisc/network/rawfsdmessage.cpp @@ -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(); 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(); return; } + if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); return; } + const ColumnIndex i = index.frontCasted(); switch (i) { diff --git a/src/blackmisc/network/rawfsdmessage.h b/src/blackmisc/network/rawfsdmessage.h index 4c05a41d5..96d18265b 100644 --- a/src/blackmisc/network/rawfsdmessage.h +++ b/src/blackmisc/network/rawfsdmessage.h @@ -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 + class BLACKMISC_EXPORT CRawFsdMessage : + public CValueObject, + 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 diff --git a/src/blackmisc/network/rawfsdmessagelist.h b/src/blackmisc/network/rawfsdmessagelist.h index 9433f2355..94aa132ef 100644 --- a/src/blackmisc/network/rawfsdmessagelist.h +++ b/src/blackmisc/network/rawfsdmessagelist.h @@ -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, - public Mixin::MetaType + public Mixin::MetaType, + public ITimestampObjectList { public: BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CRawFsdMessageList) diff --git a/src/blackmisc/timestampobjectlist.cpp b/src/blackmisc/timestampobjectlist.cpp index 1eb669849..928d7993a 100644 --- a/src/blackmisc/timestampobjectlist.cpp +++ b/src/blackmisc/timestampobjectlist.cpp @@ -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; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; + template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; diff --git a/src/blackmisc/timestampobjectlist.h b/src/blackmisc/timestampobjectlist.h index 9dee725dd..8c5169e7a 100644 --- a/src/blackmisc/timestampobjectlist.h +++ b/src/blackmisc/timestampobjectlist.h @@ -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; - extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; @@ -203,10 +203,14 @@ namespace BlackMisc extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; + extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; + + extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampWithOffsetObjectList; + extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampWithOffsetObjectList; //! \endcond } //namespace