mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
refs #395, MS'review points
Also removed blackmisc variant samples, https://dev.vatsim-germany.org/issues/395#note-9
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6119c22c78
commit
b494cb51b8
@@ -12,7 +12,6 @@
|
|||||||
#include "samplesmetadata.h"
|
#include "samplesmetadata.h"
|
||||||
#include "samplescontainer.h"
|
#include "samplescontainer.h"
|
||||||
#include "samplesjson.h"
|
#include "samplesjson.h"
|
||||||
#include "samplesvariant.h"
|
|
||||||
#include "samplesperformance.h"
|
#include "samplesperformance.h"
|
||||||
#include "samplesalgorithm.h"
|
#include "samplesalgorithm.h"
|
||||||
#include "samplesconcurrent.h"
|
#include "samplesconcurrent.h"
|
||||||
@@ -42,7 +41,6 @@ int main(int argc, char *argv[])
|
|||||||
qtout << "2 .. Change object" << endl;
|
qtout << "2 .. Change object" << endl;
|
||||||
qtout << "3 .. Containers" << endl;
|
qtout << "3 .. Containers" << endl;
|
||||||
qtout << "4 .. Metadata" << endl;
|
qtout << "4 .. Metadata" << endl;
|
||||||
qtout << "5 .. Variant" << endl;
|
|
||||||
qtout << "6a .. Performance create / copy / ..." << endl;
|
qtout << "6a .. Performance create / copy / ..." << endl;
|
||||||
qtout << "6b .. 25/100 Performance impl. type" << endl;
|
qtout << "6b .. 25/100 Performance impl. type" << endl;
|
||||||
qtout << "6c .. 25/20 Performance impl. type" << endl;
|
qtout << "6c .. 25/20 Performance impl. type" << endl;
|
||||||
@@ -57,7 +55,6 @@ int main(int argc, char *argv[])
|
|||||||
else if (s.startsWith("2")) { CSamplesChangeObject::samples(); }
|
else if (s.startsWith("2")) { CSamplesChangeObject::samples(); }
|
||||||
else if (s.startsWith("3")) { CSamplesContainer::samples(); }
|
else if (s.startsWith("3")) { CSamplesContainer::samples(); }
|
||||||
else if (s.startsWith("4")) { CSamplesMetadata::samples(); }
|
else if (s.startsWith("4")) { CSamplesMetadata::samples(); }
|
||||||
else if (s.startsWith("5")) { CSamplesVariant::samples(); }
|
|
||||||
else if (s.startsWith("6a")) { CSamplesPerformance::samplesMisc(qtout); }
|
else if (s.startsWith("6a")) { CSamplesPerformance::samplesMisc(qtout); }
|
||||||
else if (s.startsWith("6b")) { CSamplesPerformance::samplesImplementationType(qtout, 25, 100); }
|
else if (s.startsWith("6b")) { CSamplesPerformance::samplesImplementationType(qtout, 25, 100); }
|
||||||
else if (s.startsWith("6c")) { CSamplesPerformance::samplesImplementationType(qtout, 25, 20); }
|
else if (s.startsWith("6c")) { CSamplesPerformance::samplesImplementationType(qtout, 25, 20); }
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
/* Copyright (C) 2013
|
|
||||||
* swift Project Community / Contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "samplesvariant.h"
|
|
||||||
#include "blackmisc/variant.h"
|
|
||||||
#include "blackmisc/pq/pq.h"
|
|
||||||
#include "blackmisc/aviation/aviation.h"
|
|
||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
using namespace BlackMisc;
|
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
|
||||||
using namespace BlackMisc::Aviation;
|
|
||||||
using namespace BlackMisc::Simulation;
|
|
||||||
using namespace BlackMisc::Network;
|
|
||||||
|
|
||||||
namespace BlackMiscTest
|
|
||||||
{
|
|
||||||
|
|
||||||
int CSamplesVariant::samples()
|
|
||||||
{
|
|
||||||
BlackMisc::registerMetadata();
|
|
||||||
|
|
||||||
CAngle a1(30.0, CAngleUnit::deg());
|
|
||||||
CVariant cva = a1.toCVariant();
|
|
||||||
qDebug() << a1 << cva.userType();
|
|
||||||
|
|
||||||
CHeading h1(45, CHeading::True, CAngleUnit::deg());
|
|
||||||
CHeading h2(60, CHeading::True, CAngleUnit::deg());
|
|
||||||
CVariant cvh = h1.toCVariant();
|
|
||||||
qDebug() << h1 << cvh.userType();
|
|
||||||
|
|
||||||
CSimulatedAircraft sa(CAircraft("FOO", CUser("123", "Joe Doe"), CAircraftSituation()));
|
|
||||||
CVariant cvsa = sa.toCVariant();
|
|
||||||
qDebug() << sa << cvsa.userType();
|
|
||||||
|
|
||||||
qDebug() << cva << cvh << cvsa; // CVariant knows how to stringify the contained value object
|
|
||||||
|
|
||||||
// from variant
|
|
||||||
CAngle *ap_heading = &h1; // angle actually heading
|
|
||||||
CAngle *ap_angle = &a1; // angle really heading
|
|
||||||
qDebug() << (*ap_heading) << ap_heading->toCVariant().userType();
|
|
||||||
qDebug() << (*ap_angle) << ap_angle->toCVariant().userType();
|
|
||||||
|
|
||||||
// This works, because ap is actually heading
|
|
||||||
ap_heading->convertFromCVariant(h2.toCVariant());
|
|
||||||
qDebug() << (*ap_heading) << ap_heading->toCVariant().userType();
|
|
||||||
|
|
||||||
// This works, angle from variant angle
|
|
||||||
ap_angle->convertFromCVariant(a1.toCVariant());
|
|
||||||
qDebug() << (*ap_angle) << ap_angle->toCVariant().userType();
|
|
||||||
|
|
||||||
// Sim aircraft
|
|
||||||
CAircraft a;
|
|
||||||
sa.convertFromCVariant(cvsa);
|
|
||||||
a.convertFromCVariant(cvsa);
|
|
||||||
qDebug() << sa << a;
|
|
||||||
|
|
||||||
qDebug() << "--";
|
|
||||||
qDebug() << "Expected 2xASSERT";
|
|
||||||
|
|
||||||
// This gives me an unwanted(!) assert, canConvert is not smart enough to detect upcasting
|
|
||||||
// because CValueObjects are not QObjects
|
|
||||||
ap_angle->convertFromCVariant(h2.toCVariant());
|
|
||||||
qDebug() << (*ap_angle) << ap_angle->toCVariant().userType();
|
|
||||||
|
|
||||||
// This gives me the intended assert, because I assign angle to heading
|
|
||||||
ap_heading->convertFromCVariant(a1.toCVariant());
|
|
||||||
qDebug() << (*ap_heading) << ap_heading->toCVariant().userType();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/* Copyright (C) 2013
|
|
||||||
* swift Project Community / Contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//! \file
|
|
||||||
|
|
||||||
#ifndef BLACKMISCTEST_SAMPLESVARIANT_H
|
|
||||||
#define BLACKMISCTEST_SAMPLESVARIANT_H
|
|
||||||
|
|
||||||
namespace BlackMiscTest
|
|
||||||
{
|
|
||||||
|
|
||||||
//! Samples for metadata
|
|
||||||
class CSamplesVariant
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Run the samples
|
|
||||||
static int samples();
|
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -115,6 +115,8 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
m_aircraftCallsignTimestamps.clear();
|
m_aircraftCallsignTimestamps.clear();
|
||||||
m_atcCallsignTimestamps.clear();
|
m_atcCallsignTimestamps.clear();
|
||||||
|
|
||||||
|
QWriteLocker l(&m_lockSnapshot);
|
||||||
m_latestAircraftSnapshot = CAirspaceAircraftSnapshot();
|
m_latestAircraftSnapshot = CAirspaceAircraftSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace BlackCore
|
|||||||
static QString getMessageCategory() { return "swift.interpolatorlinear"; }
|
static QString getMessageCategory() { return "swift.interpolatorlinear"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BlackCore
|
} // guard
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace BlackMisc
|
|||||||
double c = 2.0 * qAtan(qSqrt(a) / qSqrt(1.0 - a));
|
double c = 2.0 * qAtan(qSqrt(a) / qSqrt(1.0 - a));
|
||||||
double distance = earthRadiusM * c;
|
double distance = earthRadiusM * c;
|
||||||
|
|
||||||
Q_ASSERT_X(distance >= 0, Q_FUNC_INFO, "distance < 0");
|
Q_ASSERT_X(distance >= 0, Q_FUNC_INFO, "distance should never calculate to negative values");
|
||||||
return CLength(distance, CLengthUnit::m());
|
return CLength(distance, CLengthUnit::m());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ namespace BlackMisc
|
|||||||
m_updateTimer(new QTimer(this))
|
m_updateTimer(new QTimer(this))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
QDateTime CThreadedReader::getUpdateTimestamp() const
|
QDateTime CThreadedReader::getUpdateTimestamp() const
|
||||||
{
|
{
|
||||||
QReadLocker(&this->m_lock);
|
QReadLocker(&this->m_lock);
|
||||||
@@ -49,14 +48,17 @@ namespace BlackMisc
|
|||||||
void CThreadedReader::setInterval(int updatePeriodMs)
|
void CThreadedReader::setInterval(int updatePeriodMs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->m_updateTimer);
|
Q_ASSERT(this->m_updateTimer);
|
||||||
|
bool s;
|
||||||
if (updatePeriodMs < 1)
|
if (updatePeriodMs < 1)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(m_updateTimer, "stop");
|
s = QMetaObject::invokeMethod(m_updateTimer, "stop");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(m_updateTimer, "start", Q_ARG(int, updatePeriodMs));
|
s = QMetaObject::invokeMethod(m_updateTimer, "start", Q_ARG(int, updatePeriodMs));
|
||||||
}
|
}
|
||||||
|
Q_ASSERT_X(s, Q_FUNC_INFO, "Failed invoke");
|
||||||
|
Q_UNUSED(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CThreadedReader::interval() const
|
int CThreadedReader::interval() const
|
||||||
@@ -67,8 +69,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
void CThreadedReader::threadAssertCheck() const
|
void CThreadedReader::threadAssertCheck() const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(QCoreApplication::instance()->thread() != QThread::currentThread(), "CThreadedReader::threadAssertCheck", "Needs to run in own thread");
|
Q_ASSERT_X(QCoreApplication::instance()->thread() != QThread::currentThread(), Q_FUNC_INFO, "Needs to run in own thread");
|
||||||
Q_ASSERT_X(QObject::thread() == QThread::currentThread(), "CThreadedReader::threadAssertCheck", "Needs to run in own thread");
|
Q_ASSERT_X(QObject::thread() == QThread::currentThread(), Q_FUNC_INFO, "Wrong object thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user