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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user