mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-12 04:35:41 +08:00
Changed order of samples directory, started with aviation classes.
This commit is contained in:
19
samples/blackmiscquantities/main.cpp
Normal file
19
samples/blackmiscquantities/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <QCoreApplication>
|
||||
#include "samplesphysicalquantities.h"
|
||||
#include "samplesaviation.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMiscTest;
|
||||
|
||||
/*!
|
||||
* Sample tests
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
// CSamplesPhysicalQuantities::samples();
|
||||
CSamplesAviation::samples();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
30
samples/blackmiscquantities/sample_blackmisc_quantities.pro
Normal file
30
samples/blackmiscquantities/sample_blackmisc_quantities.pro
Normal file
@@ -0,0 +1,30 @@
|
||||
QT += core
|
||||
QT -= gui
|
||||
|
||||
TARGET = sample_physicalquantities
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEPENDPATH += . ../../src
|
||||
INCLUDEPATH += . ../../src
|
||||
SOURCES += main.cpp \
|
||||
samplesphysicalquantities.cpp \
|
||||
samplesaviation.cpp
|
||||
|
||||
win32-msvc* {
|
||||
PRE_TARGETDEPS += ../../lib/blackmisc.lib
|
||||
LIBS += ../../lib/blackmisc.lib
|
||||
}
|
||||
|
||||
!win32-msvc* {
|
||||
PRE_TARGETDEPS += ../../lib/libblackmisc.a
|
||||
LIBS += ../../lib/libblackmisc.a
|
||||
}
|
||||
|
||||
DESTDIR = ../../bin
|
||||
|
||||
HEADERS += \
|
||||
samplesphysicalquantities.h \
|
||||
samplesaviation.h
|
||||
23
samples/blackmiscquantities/samplesaviation.cpp
Normal file
23
samples/blackmiscquantities/samplesaviation.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "samplesaviation.h"
|
||||
|
||||
namespace BlackMiscTest {
|
||||
|
||||
/**
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesAviation::samples()
|
||||
{
|
||||
// CSpeed s1(10, CSpeedUnit::kts());
|
||||
CHeading h1(180, true, CAngleUnit::deg());
|
||||
CHeading h2(180, false, CAngleUnit::deg());
|
||||
qDebug() << h1 << h2 << (h1 == h2) << (h1 != h2) << (h1 == h1);
|
||||
|
||||
CAviationVerticalPositions vp1 = CAviationVerticalPositions::fromAltitudeAndElevationInFt(10000.0, 1111.0);
|
||||
CAviationVerticalPositions vp2 = vp1;
|
||||
qDebug() << vp1 << (vp1 == vp2) << (vp1 != vp2);
|
||||
|
||||
// bye
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
26
samples/blackmiscquantities/samplesaviation.h
Normal file
26
samples/blackmiscquantities/samplesaviation.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef SAMPLESAVIATION_H
|
||||
#define SAMPLESAVIATION_H
|
||||
|
||||
#include <QDebug>
|
||||
#include "blackmisc/avheading.h"
|
||||
#include "blackmisc/avverticalpositions.h"
|
||||
#include "blackmisc/pqconstants.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMiscTest {
|
||||
|
||||
/*!
|
||||
* \brief Samples for physical quantities
|
||||
*/
|
||||
class CSamplesAviation
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Run the samples
|
||||
*/
|
||||
static int samples();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
97
samples/blackmiscquantities/samplesphysicalquantities.cpp
Normal file
97
samples/blackmiscquantities/samplesphysicalquantities.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#include "samplesphysicalquantities.h"
|
||||
|
||||
namespace BlackMiscTest {
|
||||
|
||||
/**
|
||||
* Running the quantities
|
||||
*/
|
||||
int CSamplesPhysicalQuantities::samples() {
|
||||
|
||||
// cases which must not work
|
||||
// CMeasurementUnit mu; //must not work
|
||||
// CLengthUnit du1(CAngleUnit::rad());
|
||||
CLengthUnit lu1(CLengthUnit::cm());
|
||||
CLengthUnit lu2(CLengthUnit::ft());
|
||||
qDebug() << lu1 << lu2;
|
||||
const CLength l1(5.0, CLengthUnit::ft()); // 5 ft
|
||||
CLength l2(1, CLengthUnit::NM()); // 1NM
|
||||
CLength l3(1, CLengthUnit::km());
|
||||
CLength l4(l3);
|
||||
|
||||
qDebug() << CLengthUnit::ft();
|
||||
qDebug() << l1 << l2 << l3 << l4;
|
||||
qDebug() << l1.valueRoundedWithUnit(CLengthUnit::ft(),5)
|
||||
<< l2.valueRoundedWithUnit(CLengthUnit::km());
|
||||
qDebug() << l3.getUnit();
|
||||
|
||||
|
||||
l2.switchUnit(CLengthUnit::ft()); // now in ft
|
||||
l3 += l3; // 2km now
|
||||
l3 *= 1.5;// 3km now
|
||||
qDebug() << l2 << l3;
|
||||
|
||||
CFrequency f1(1E6, CFrequencyUnit::Hz()); // 1MHz
|
||||
qDebug() << f1 << f1.valueRoundedWithUnit(CFrequencyUnit::MHz()) << f1.valueRoundedWithUnit(CFrequencyUnit::GHz(), 3);
|
||||
|
||||
CSpeed s1 = CSpeed(100, CSpeedUnit::km_h());
|
||||
CSpeed s2 = CSpeed(1000,CSpeedUnit::ft_min());
|
||||
CSpeed s3 = CSpeed(s2);
|
||||
s3.switchUnit(CSpeedUnit::m_s());
|
||||
qDebug() << s1 << s1.convertedSiValueRoundedWithUnit() << s1.valueRoundedWithUnit(CSpeedUnit::NM_h());
|
||||
qDebug() << s2 << s3;
|
||||
|
||||
CAngle a1(180, CAngleUnit::deg());
|
||||
CAngle a2(1.5 * CAngle::pi(), CAngleUnit::rad());
|
||||
CAngle a3(180.5, CAngleUnit::deg());
|
||||
CAngle a4(35.4336,CAngleUnit::sexagesimalDeg()); // 35.72666
|
||||
a1 += a2;
|
||||
// a1 = d2; // must not work
|
||||
qDebug() << a1;
|
||||
a1.switchUnit(CAngleUnit::deg());
|
||||
// a2 += d1; // must not work
|
||||
a2 = a1 + a1;
|
||||
|
||||
a2.switchUnit(CAngleUnit::deg());
|
||||
qDebug() << a1.unitValueRoundedWithUnit() << a1.piFactor();
|
||||
qDebug() << a2;
|
||||
a3.switchUnit(CAngleUnit::sexagesimalDeg());
|
||||
a4.switchUnit(CAngleUnit::deg());
|
||||
qDebug() << a3 << a4;
|
||||
|
||||
CMass w1(1,CMassUnit::t());
|
||||
CMass w2(w1);
|
||||
w2.switchUnit(CMassUnit::lb());
|
||||
qDebug() << w1 << w1.valueRoundedWithUnit(CMassUnit::kg()) << w2;
|
||||
|
||||
CPressure p1(1013.25, CPressureUnit::hPa());
|
||||
qDebug() << p1 << p1.valueRoundedWithUnit(CPressureUnit::psi()) << p1.valueRoundedWithUnit(CPressureUnit::inHg());
|
||||
|
||||
CTemperature t1;
|
||||
CTemperature t2(20, CTemperatureUnit::C());
|
||||
CTemperature t3(1, CTemperatureUnit::F());
|
||||
qDebug() << t1 << t2 << t2.convertedSiValueRoundedWithUnit();
|
||||
qDebug() << t3 << t3.valueRoundedWithUnit(CTemperatureUnit::C());
|
||||
|
||||
// some logging with CLogMessage
|
||||
bDebug << p1;
|
||||
bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
|
||||
|
||||
// some of the faults Mathew has pointed out,not longer possible
|
||||
// CAngleUnit::rad() = CAngleUnit::deg();
|
||||
// qDebug() << CAngleUnit::rad(); // wrong
|
||||
|
||||
(t1 - t2).switchUnit(CTemperatureUnit::F()); // was not working since wrong return type const
|
||||
// CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible
|
||||
CLengthUnit duB(CLengthUnit::cm());
|
||||
qDebug() << duB;
|
||||
|
||||
CTime ti1(1, CTimeUnit::h());
|
||||
CTime ti2(ti1);
|
||||
ti2.switchUnit(CTimeUnit::ms());
|
||||
qDebug() << ti1 << ti2;
|
||||
|
||||
// bye
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
25
samples/blackmiscquantities/samplesphysicalquantities.h
Normal file
25
samples/blackmiscquantities/samplesphysicalquantities.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef SAMPLESPHYSICALQUANTITIES_H
|
||||
#define SAMPLESPHYSICALQUANTITIES_H
|
||||
|
||||
#include <QDebug>
|
||||
#include "blackmisc/pqconstants.h"
|
||||
#include "blackmisc/debug.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMiscTest {
|
||||
|
||||
/*!
|
||||
* \brief Samples for physical quantities
|
||||
*/
|
||||
class CSamplesPhysicalQuantities
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Run the samples
|
||||
*/
|
||||
static int samples();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SAMPLESPHYSICALQUANTITIES_H
|
||||
Reference in New Issue
Block a user