mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
second draft of ISimulator, and put units of measurement on some identifiers
This commit is contained in:
@@ -34,7 +34,7 @@ namespace BlackCore
|
|||||||
const double KnotsToMeterPerSecond = 0.5144444444;
|
const double KnotsToMeterPerSecond = 0.5144444444;
|
||||||
|
|
||||||
//! Equatorial radius of WGS84 ellipsoid (6378137 m)
|
//! Equatorial radius of WGS84 ellipsoid (6378137 m)
|
||||||
const double EarthRadius = 6378137.0;
|
const double EarthRadiusMeters = 6378137.0;
|
||||||
|
|
||||||
//! Flattening of WGS84 ellipsoid (1/298.257223563).
|
//! Flattening of WGS84 ellipsoid (1/298.257223563).
|
||||||
const double Flattening = 1/298.257223563;
|
const double Flattening = 1/298.257223563;
|
||||||
|
|||||||
@@ -3,14 +3,4 @@
|
|||||||
//! License, v. 2.0. If a copy of the MPL was not distributed with this
|
//! License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
//! file, You can obtain one at http://mozilla.org/MPL/2.0/
|
//! file, You can obtain one at http://mozilla.org/MPL/2.0/
|
||||||
|
|
||||||
#ifndef SIM_CALLBACKS_H
|
//TODO remove this file
|
||||||
#define SIM_CALLBACKS_H
|
|
||||||
|
|
||||||
typedef void (* cbChangedRadioFreq)(const int radioNumber, const QString &frequency);
|
|
||||||
typedef void (* cbChangedGearPosition)(const int percentage);
|
|
||||||
typedef void (* cbChangedLights)(const int map);
|
|
||||||
typedef void (* cbSimStarted)(const bool status);
|
|
||||||
typedef void (* cbChangedAircraftType)(const QString &type);
|
|
||||||
typedef void (* cbChangedFlaps)(const int percentage);
|
|
||||||
|
|
||||||
#endif // CALLBACKS_H
|
|
||||||
|
|||||||
@@ -8,22 +8,75 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <blackcore/sim_callbacks.h>
|
#include "blackcore/sim_callbacks.h"
|
||||||
|
|
||||||
#include "blackcore/vector_geo.h"
|
#include "blackcore/vector_geo.h"
|
||||||
class CLibraryContext;
|
|
||||||
|
|
||||||
#define SHARED_LIBRARY_NAME_FS9 "bb_driver_fs9"
|
#define SHARED_LIBRARY_NAME_FS9 "bb_driver_fs9"
|
||||||
#define SHARED_LIBRARY_NAME_FSX "bb_driver_fsx"
|
#define SHARED_LIBRARY_NAME_FSX "bb_driver_fsx"
|
||||||
#define SHARED_LIBRARY_NAME_XPLANE "bb_driver_xplane"
|
#define SHARED_LIBRARY_NAME_XPLANE "bb_driver_xplane"
|
||||||
|
|
||||||
|
namespace BlackMisc {
|
||||||
|
|
||||||
|
class IContext;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace BlackCore {
|
namespace BlackCore {
|
||||||
|
|
||||||
class CVector3D;
|
class CPlaneModel
|
||||||
class CVectorGEO;
|
{
|
||||||
class IContext;
|
public:
|
||||||
|
QString name;
|
||||||
|
QString typeCode;
|
||||||
|
QString airlineCode;
|
||||||
|
};
|
||||||
|
|
||||||
class ISimulator
|
class CPhysicalState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPhysicalState() : headingDegrees(0), pitchDegrees(0), bankDegrees(0), groundSpeedKnots(0)
|
||||||
|
{}
|
||||||
|
CVectorGeo position;
|
||||||
|
float headingDegrees;
|
||||||
|
float pitchDegrees;
|
||||||
|
float bankDegrees;
|
||||||
|
float groundSpeedKnots;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CAvionicsState
|
||||||
|
{
|
||||||
|
CAvionicsState() : squawkCode(0), squawkModeC(false), squawkIdent(false),
|
||||||
|
com1FreqHz(0), com2FreqHz(0)
|
||||||
|
{}
|
||||||
|
qint16 squawkCode;
|
||||||
|
bool squawkModeC;
|
||||||
|
bool squawkIdent;
|
||||||
|
qint32 com1FreqHz;
|
||||||
|
qint32 com2FreqHz;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CAnimationState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAnimationState() : gearPercent(0), flapsPercent(0), landingLights(false),
|
||||||
|
taxiLights(false), navLights(false), strobeLights(false), beaconLights(false)
|
||||||
|
{}
|
||||||
|
qint8 gearPercent;
|
||||||
|
qint8 flapsPercent;
|
||||||
|
bool landingLights;
|
||||||
|
bool taxiLights;
|
||||||
|
bool navLights;
|
||||||
|
bool strobeLights;
|
||||||
|
bool beaconLights;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::tr1::function<void(const bool status)> cbSimStarted;
|
||||||
|
typedef std::tr1::function<void(const CAvionicsState &state)> cbChangedAvionicsState;
|
||||||
|
typedef std::tr1::function<void(const CAnimationState &state)> cbChangedAnimationState;
|
||||||
|
typedef std::tr1::function<void(const CPlaneModel &model)> cbChangedModel;
|
||||||
|
typedef std::tr1::function<void(const QString &message)> cbSendTextMessage;
|
||||||
|
|
||||||
|
class ISimulator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -31,103 +84,82 @@ namespace BlackCore {
|
|||||||
static const quint32 InterfaceVersionMajor;
|
static const quint32 InterfaceVersionMajor;
|
||||||
static const quint32 InterfaceVersionMinor;
|
static const quint32 InterfaceVersionMinor;
|
||||||
|
|
||||||
|
enum ESimulator {
|
||||||
|
FS9 = 0,
|
||||||
|
FSX,
|
||||||
|
XPLANE,
|
||||||
|
};
|
||||||
|
|
||||||
enum ESimulator { FS9 = 0,
|
ISimulator() {}
|
||||||
FSX,
|
|
||||||
XPLANE};
|
|
||||||
|
|
||||||
ISimulator(void) {}
|
|
||||||
virtual ~ISimulator() {}
|
virtual ~ISimulator() {}
|
||||||
|
|
||||||
virtual void setLibraryContext(IContext *context) = 0;
|
virtual void setLibraryContext(BlackMisc::IContext *context);
|
||||||
|
|
||||||
|
static ISimulator *createDriver(ESimulator sim);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// Global section
|
// Global section
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
virtual int init() = 0;
|
virtual int init() = 0;
|
||||||
|
|
||||||
virtual int connectTo() = 0;
|
virtual int connect() = 0;
|
||||||
|
|
||||||
// Callback when the Simulation starts
|
// Callback when the Simulation starts
|
||||||
virtual void setcbSimStarted(cbSimStarted func, void *context);
|
virtual void setcbSimStarted(const cbSimStarted &func);
|
||||||
|
|
||||||
virtual bool isRunning() = 0;
|
virtual bool isConnected() = 0;
|
||||||
|
|
||||||
virtual QString getLastErrorMessage() = 0;
|
virtual QString getLastErrorMessage() = 0;
|
||||||
|
|
||||||
virtual qint32 sendTextMessage(const QString &text) = 0;
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// Remote plane section
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
virtual qint32 addPlane(const QString& callsign, const QString &type, const CVectorGEO * const pos, const double groundSpeed) = 0;
|
|
||||||
|
|
||||||
virtual bool removePlane(const qint32 id) = 0;
|
|
||||||
|
|
||||||
virtual bool updatePositionAndSpeed(const qint32 id, const CVectorGEO * const pos, const double groundSpeed) = 0;
|
|
||||||
|
|
||||||
virtual bool setGear(const qint32 id, const qint32 percentage) = 0;
|
|
||||||
|
|
||||||
virtual bool setFlaps(const qint32 id, const qint32 percentage) = 0;
|
|
||||||
|
|
||||||
virtual bool setLights(const qint32 id, const qint32 map) = 0;
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// User plane section
|
// User plane section
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
// Callback frequency tuner
|
// Callback avionics state
|
||||||
virtual void setChangedRadioFreq(cbChangedRadioFreq func, void * context);
|
virtual void setcbChangedAvionicsState(const cbChangedAvionicsState &func);
|
||||||
|
|
||||||
// Callback when the gear is moving
|
// Callback animation state
|
||||||
virtual void setcbChangedGearPosition(cbChangedGearPosition func, void *context);
|
virtual void setcbChangedAnimationState(const cbChangedAnimationState &func);
|
||||||
|
|
||||||
// Callback if the user switched on/off a light
|
|
||||||
virtual void setcbChangedLights(cbChangedLights func, void *context);
|
|
||||||
|
|
||||||
// Callback, when the Aircraft is set or gets changed
|
// Callback, when the Aircraft is set or gets changed
|
||||||
virtual void setcbChangedAircraftType(cbChangedAircraftType func, void *context);
|
virtual void setcbChangedModel(const cbChangedModel &func);
|
||||||
|
|
||||||
// Callback, when the Flaps are moving
|
// Not const because it may need to mutate state in order to communicate with the sim
|
||||||
virtual void setcbChangedFlaps(cbChangedFlaps func, void *context);
|
virtual bool isOnGround() = 0;
|
||||||
|
|
||||||
// This one is called regular and when we actually need it, therefor not a callback
|
// This might block - use QtConcurrent::run if that is a problem
|
||||||
virtual double getUserSpeed() const = 0;
|
virtual CPhysicalState getPhysicalState() = 0;
|
||||||
|
|
||||||
// This one is called regular and when we actually need it, therefor not a callback
|
////////////////////////////////
|
||||||
virtual CVectorGEO getUserPosition() const = 0;
|
// Remote plane section
|
||||||
|
////////////////////////////////
|
||||||
// This one is called regular and when we actually need it, therefor not a callback
|
|
||||||
virtual qint32 getUserPitch() const = 0;
|
|
||||||
|
|
||||||
// This one is called regular and when we actually need it, therefor not a callback
|
|
||||||
virtual qint32 getUserBank() const = 0;
|
|
||||||
|
|
||||||
// This one is called regular and when we actually need it, therefor not a callback
|
|
||||||
virtual qint32 getUserHeading() const = 0;
|
|
||||||
|
|
||||||
// This one is called regular and when we actually need it, therefor not a callback
|
|
||||||
virtual qint32 getUserPitchBankHeading() const = 0;
|
|
||||||
|
|
||||||
virtual bool isOnGround() const = 0;
|
// This might block - use QtConcurrent::run if that is a problem
|
||||||
|
virtual qint32 addPlane(const QString &callsign) = 0;
|
||||||
|
|
||||||
|
virtual bool removePlane(const qint32 planeID) = 0;
|
||||||
|
|
||||||
|
virtual void setModel(const qint32 planeID, const CPlaneModel &model) = 0;
|
||||||
|
|
||||||
|
virtual bool setPhysicalState(const qint32 planeID, const CPhysicalState &state) = 0;
|
||||||
|
|
||||||
|
virtual bool setAnimationState(const qint32 planeID, const CAnimationState &state) = 0;
|
||||||
|
|
||||||
|
// Calls the supplied visitor function once for every model available in the simulator.
|
||||||
|
virtual void visitAllModels(const std::tr1::function<void(const CPlaneModel &)> &visitor) = 0;
|
||||||
|
|
||||||
|
// Fills container with all models. Works for any container that supports push_back.
|
||||||
|
template <class T>
|
||||||
|
void getAllModels(T &container) { visitAllModels(std::tr1::bind(T::push_back, container)); }
|
||||||
|
|
||||||
static ISimulator *createDriver(ESimulator sim);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
BlackMisc::IContext *m_libraryContext;
|
||||||
CLibraryContext * mLibraryContext;
|
|
||||||
|
|
||||||
cbSimStarted mSimStarted;
|
|
||||||
cbChangedRadioFreq mChangedRadioFreq;
|
|
||||||
cbChangedGearPosition mChangedGearPosition;
|
|
||||||
cbChangedLights mChangedLights;
|
|
||||||
cbChangedAircraftType mChangedAircraftType;
|
|
||||||
cbChangedFlaps mChangedFlaps;
|
|
||||||
|
|
||||||
void *m_CallbackContext;
|
|
||||||
|
|
||||||
|
cbSimStarted m_cbSimStarted;
|
||||||
|
cbChangedAvionicsState m_cbChangedAvionicsState;
|
||||||
|
cbChangedAnimationState m_cbChangedAnimationState;
|
||||||
|
cbChangedModel m_cbChangedModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //! namespace BlackCore
|
} //! namespace BlackCore
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#ifndef VECTOR_GEO_H
|
#ifndef VECTOR_GEO_H
|
||||||
#define VECTOR_GEO_H
|
#define VECTOR_GEO_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -15,40 +17,40 @@ class CVectorGeo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CVectorGeo();
|
CVectorGeo();
|
||||||
CVectorGeo(double lat, double lon, double alt);
|
CVectorGeo(double latitudeDegrees, double longintudeDegrees, double altitudeMeters);
|
||||||
CVectorGeo( const CVectorGeo &other );
|
CVectorGeo(const CVectorGeo &other);
|
||||||
|
|
||||||
void setLatitude( double latitude)
|
void setLatitudeDegrees(double latitudeDegrees)
|
||||||
{
|
{
|
||||||
m_latitude = latitude;
|
m_latitudeDegrees = latitudeDegrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLongitude( double longitude)
|
void setLongitudeDegrees(double longitudeDegrees)
|
||||||
{
|
{
|
||||||
m_longitude = longitude;
|
m_longitudeDegrees = longitudeDegrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAltitude( double altitude)
|
void setAltitude(double altitudeMeters)
|
||||||
{
|
{
|
||||||
m_altitude = altitude;
|
m_altitudeMeters = altitudeMeters;
|
||||||
}
|
}
|
||||||
|
|
||||||
double latitude() const {return m_latitude;}
|
double latitudeDegrees() const { return m_latitudeDegrees; }
|
||||||
double longitude() const {return m_longitude;}
|
double longitudeDegrees() const { return m_longitudeDegrees; }
|
||||||
double altitude() const {return m_altitude;}
|
double altitudeMeters() const { return m_altitudeMeters; }
|
||||||
|
|
||||||
CEcef toCartesian();
|
CEcef toCartesian();
|
||||||
|
|
||||||
void zeros();
|
void zeros();
|
||||||
|
|
||||||
void print();
|
void print(std::ostream &stream = std::cout);
|
||||||
|
|
||||||
CVectorGeo & operator = (const CVectorGeo &rhs);
|
CVectorGeo &operator=(const CVectorGeo &rhs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_latitude;
|
double m_latitudeDegrees;
|
||||||
double m_longitude;
|
double m_longitudeDegrees;
|
||||||
double m_altitude;
|
double m_altitudeMeters;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BlackCore
|
} // namespace BlackCore
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ CNed CEcef::toNED(const CVectorGeo &pos)
|
|||||||
{
|
{
|
||||||
CNed result;
|
CNed result;
|
||||||
|
|
||||||
double angle = - ( pos.latitude() * Constants::DegToRad ) - Constants::PI/2;
|
double angle = - ( pos.latitudeDegrees() * Constants::DegToRad ) - Constants::PI/2;
|
||||||
|
|
||||||
CMatrix3D dcm1;
|
CMatrix3D dcm1;
|
||||||
CMatrix3D dcm2;
|
CMatrix3D dcm2;
|
||||||
@@ -55,7 +55,7 @@ CNed CEcef::toNED(const CVectorGeo &pos)
|
|||||||
dcm2(2,0) = sin( angle );
|
dcm2(2,0) = sin( angle );
|
||||||
dcm2(2,2) = cos( angle );
|
dcm2(2,2) = cos( angle );
|
||||||
|
|
||||||
angle = pos.longitude() * Constants::DegToRad;
|
angle = pos.longitudeDegrees() * Constants::DegToRad;
|
||||||
|
|
||||||
dcm3(0,0) = cos(angle );
|
dcm3(0,0) = cos(angle );
|
||||||
dcm3(0,1) = sin(angle );
|
dcm3(0,1) = sin(angle );
|
||||||
@@ -103,8 +103,8 @@ CVectorGeo CEcef::toGeodetic()
|
|||||||
double sphi = 0;
|
double sphi = 0;
|
||||||
double cphi = 0;
|
double cphi = 0;
|
||||||
|
|
||||||
double p = CMath::square(R / Constants::EarthRadius);
|
double p = CMath::square(R / Constants::EarthRadiusMeters);
|
||||||
double q = Constants::e2m * CMath::square(v[2] / Constants::EarthRadius);
|
double q = Constants::e2m * CMath::square(v[2] / Constants::EarthRadiusMeters);
|
||||||
double r = (p + q - Constants::e4) / 6.0;
|
double r = (p + q - Constants::e4) / 6.0;
|
||||||
|
|
||||||
if ( !(Constants::e4 * q == 0 && r <= 0) )
|
if ( !(Constants::e4 * q == 0 && r <= 0) )
|
||||||
@@ -188,7 +188,7 @@ CVectorGeo CEcef::toGeodetic()
|
|||||||
sphi = zz / H;
|
sphi = zz / H;
|
||||||
cphi = xx / H;
|
cphi = xx / H;
|
||||||
if (v[2] < 0) sphi = -sphi; // for tiny negative Z (not for prolate)
|
if (v[2] < 0) sphi = -sphi; // for tiny negative Z (not for prolate)
|
||||||
h = - Constants::EarthRadius * (Constants::e2m) * H / Constants::e2absolute;
|
h = - Constants::EarthRadiusMeters * (Constants::e2m) * H / Constants::e2absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lat = atan2(sphi, cphi) * Constants::RadToDeg;
|
double lat = atan2(sphi, cphi) * Constants::RadToDeg;
|
||||||
@@ -196,8 +196,8 @@ CVectorGeo CEcef::toGeodetic()
|
|||||||
//! Negative signs return lon in [-180, 180).
|
//! Negative signs return lon in [-180, 180).
|
||||||
double lon = -atan2(-slam, clam) * Constants::RadToDeg;
|
double lon = -atan2(-slam, clam) * Constants::RadToDeg;
|
||||||
|
|
||||||
result.setLongitude(lon);
|
result.setLongitudeDegrees(lon);
|
||||||
result.setLatitude(lat);
|
result.setLatitudeDegrees(lat);
|
||||||
result.setAltitude(h);
|
result.setAltitude(h);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
CEcef CNed::toECEF()
|
CEcef CNed::toECEF()
|
||||||
{
|
{
|
||||||
double angle = - ( m_position.latitude() * Constants::DegToRad ) - Constants::PI/2;
|
double angle = - ( m_position.latitudeDegrees() * Constants::DegToRad ) - Constants::PI/2;
|
||||||
|
|
||||||
CMatrix3D dcm1;
|
CMatrix3D dcm1;
|
||||||
CMatrix3D dcm2;
|
CMatrix3D dcm2;
|
||||||
@@ -47,7 +47,7 @@ namespace BlackCore
|
|||||||
dcm2(2,0) = sin( angle );
|
dcm2(2,0) = sin( angle );
|
||||||
dcm2(2,2) = cos( angle );
|
dcm2(2,2) = cos( angle );
|
||||||
|
|
||||||
angle = m_position.longitude() * Constants::DegToRad;
|
angle = m_position.longitudeDegrees() * Constants::DegToRad;
|
||||||
|
|
||||||
dcm3(0,0) = cos(angle );
|
dcm3(0,0) = cos(angle );
|
||||||
dcm3(0,1) = sin(angle );
|
dcm3(0,1) = sin(angle );
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ namespace BlackCore {
|
|||||||
typedef quint32 (*getDriverVersionMinor)(void);
|
typedef quint32 (*getDriverVersionMinor)(void);
|
||||||
const char *DRIVER_VERSION_MINOR = "BB_InterfaceVersionMinor";
|
const char *DRIVER_VERSION_MINOR = "BB_InterfaceVersionMinor";
|
||||||
|
|
||||||
|
void ISimulator::setLibraryContext(BlackMisc::IContext *context)
|
||||||
|
{
|
||||||
|
m_libraryContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
ISimulator *ISimulator::createDriver(ESimulator sim)
|
ISimulator *ISimulator::createDriver(ESimulator sim)
|
||||||
{
|
{
|
||||||
QLibrary myLib;
|
QLibrary myLib;
|
||||||
@@ -108,55 +113,24 @@ namespace BlackCore {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
void ISimulator::setcbSimStarted(const cbSimStarted &func)
|
||||||
// Global section
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
// Callback when the Simulation starts
|
|
||||||
void ISimulator::setcbSimStarted(cbSimStarted func, void *context)
|
|
||||||
{
|
{
|
||||||
mSimStarted = func;
|
m_cbSimStarted = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
void ISimulator::setcbChangedAvionicsState(const cbChangedAvionicsState &func)
|
||||||
// User plane section
|
|
||||||
////////////////////////////////
|
|
||||||
// Callback frequency tuner
|
|
||||||
void ISimulator::setChangedRadioFreq(cbChangedRadioFreq func, void * context)
|
|
||||||
{
|
{
|
||||||
mChangedRadioFreq = func;
|
m_cbChangedAvionicsState = func;
|
||||||
m_CallbackContext = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback when the gear is moving
|
void ISimulator::setcbChangedAnimationState(const cbChangedAnimationState &func)
|
||||||
void ISimulator::setcbChangedGearPosition(cbChangedGearPosition func, void *context)
|
|
||||||
{
|
{
|
||||||
mChangedGearPosition = func;
|
m_cbChangedAnimationState = func;
|
||||||
m_CallbackContext = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback if the user switched on/off a light
|
void ISimulator::setcbChangedModel(const cbChangedModel &func)
|
||||||
void ISimulator::setcbChangedLights(cbChangedLights func, void *context)
|
|
||||||
{
|
{
|
||||||
mChangedLights = func;
|
m_cbChangedModel = func;
|
||||||
m_CallbackContext = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback, when the Aircraft is set or gets changed
|
} //! namespace BlackCore
|
||||||
void ISimulator::setcbChangedAircraftType(cbChangedAircraftType func, void *context)
|
|
||||||
{
|
|
||||||
mChangedAircraftType = func;
|
|
||||||
m_CallbackContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback, when the Flaps are moving
|
|
||||||
void ISimulator::setcbChangedFlaps(cbChangedFlaps func, void *context)
|
|
||||||
{
|
|
||||||
mChangedFlaps = func;
|
|
||||||
m_CallbackContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //! namespace BlackCore {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,48 +9,41 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
|
|
||||||
CVectorGeo::CVectorGeo()
|
CVectorGeo::CVectorGeo()
|
||||||
{
|
: m_latitudeDegrees(0), m_longitudeDegrees(0), m_altitudeMeters(0)
|
||||||
zeros();
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
CVectorGeo::CVectorGeo(double lat, double lon, double alt)
|
CVectorGeo::CVectorGeo(double latitudeDegrees, double longitudeDegrees, double altitudeMeters)
|
||||||
{
|
: m_latitudeDegrees(latitudeDegrees), m_longitudeDegrees(longitudeDegrees),
|
||||||
zeros();
|
m_altitudeMeters(altitudeMeters)
|
||||||
m_latitude = lat;
|
{}
|
||||||
m_longitude = lon;
|
|
||||||
m_altitude = alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
CVectorGeo::CVectorGeo(const CVectorGeo &other)
|
CVectorGeo::CVectorGeo(const CVectorGeo &other)
|
||||||
{
|
: m_latitudeDegrees(other.m_latitudeDegrees), m_longitudeDegrees(other.m_longitudeDegrees),
|
||||||
zeros();
|
m_altitudeMeters(other.m_altitudeMeters)
|
||||||
m_latitude = other.latitude();
|
{}
|
||||||
m_longitude = other.longitude();
|
|
||||||
m_altitude = other.altitude();
|
|
||||||
}
|
|
||||||
|
|
||||||
CEcef CVectorGeo::toCartesian()
|
CEcef CVectorGeo::toCartesian()
|
||||||
{
|
{
|
||||||
CEcef result;
|
CEcef result;
|
||||||
|
|
||||||
double phi = m_latitude * Constants::DegToRad;
|
double phi = m_latitudeDegrees * Constants::DegToRad;
|
||||||
double lambda = m_longitude * Constants::DegToRad;
|
double lambda = m_longitudeDegrees * Constants::DegToRad;
|
||||||
double sphi = sin(phi);
|
double sphi = sin(phi);
|
||||||
double cphi = 0;
|
double cphi = 0;
|
||||||
if (std::abs(m_latitude) != 90)
|
if (std::abs(m_latitudeDegrees) != 90)
|
||||||
cphi = cos(phi);
|
cphi = cos(phi);
|
||||||
|
|
||||||
double n = Constants::EarthRadius/sqrt(1-Constants::e2 * CMath::square(sphi));
|
double n = Constants::EarthRadiusMeters/sqrt(1-Constants::e2 * CMath::square(sphi));
|
||||||
|
|
||||||
double slambda = 0;
|
double slambda = 0;
|
||||||
if (m_longitude != -180)
|
if (m_longitudeDegrees != -180)
|
||||||
slambda = sin(lambda);
|
slambda = sin(lambda);
|
||||||
|
|
||||||
double clambda = 0;
|
double clambda = 0;
|
||||||
if (std::abs(m_longitude) != 90)
|
if (std::abs(m_longitudeDegrees) != 90)
|
||||||
clambda = cos(lambda);
|
clambda = cos(lambda);
|
||||||
|
|
||||||
double h = m_altitude * Constants::FeetToMeter;
|
double h = m_altitudeMeters;
|
||||||
|
|
||||||
double X = (n + h) * cphi;
|
double X = (n + h) * cphi;
|
||||||
double Y = X * slambda;
|
double Y = X * slambda;
|
||||||
@@ -65,27 +58,27 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CVectorGeo::zeros()
|
void CVectorGeo::zeros()
|
||||||
{
|
{
|
||||||
m_latitude = 0;
|
m_latitudeDegrees = 0;
|
||||||
m_longitude = 0;
|
m_longitudeDegrees = 0;
|
||||||
m_altitude = 0;
|
m_altitudeMeters = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVectorGeo::print()
|
void CVectorGeo::print(std::ostream &stream)
|
||||||
{
|
{
|
||||||
std::cout << "v = " << std::endl;
|
stream << "v = " << std::endl;
|
||||||
std::cout << std::fixed;
|
stream << std::fixed;
|
||||||
std::cout << "[" << m_latitude << "]" << std::endl;
|
stream << "[" << m_latitudeDegrees << "]" << std::endl;
|
||||||
std::cout << "[" << m_longitude << "]" << std::endl;
|
stream << "[" << m_longitudeDegrees << "]" << std::endl;
|
||||||
std::cout << "[" << m_altitude << "]" << std::endl;
|
stream << "[" << m_altitudeMeters << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVectorGeo &CVectorGeo::operator =(const CVectorGeo &rhs)
|
CVectorGeo &CVectorGeo::operator =(const CVectorGeo &rhs)
|
||||||
{
|
{
|
||||||
if (this != &rhs)
|
if (this != &rhs)
|
||||||
{
|
{
|
||||||
m_latitude = rhs.latitude();
|
m_latitudeDegrees = rhs.latitudeDegrees();
|
||||||
m_longitude = rhs.longitude();
|
m_longitudeDegrees = rhs.longitudeDegrees();
|
||||||
m_altitude = rhs.altitude();
|
m_altitudeMeters = rhs.altitudeMeters();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user