Ref T270, added CSimulatorPluginCommon as base class in driver project

* unlike BlackCore::CSimulatorCommon we can add also UI aspects here
* used by emulated driver, XP and the FS series
This commit is contained in:
Klaus Basan
2018-05-16 21:23:00 +02:00
parent afe4a09218
commit 2ae8f5b03f
17 changed files with 247 additions and 69 deletions

View File

@@ -8,16 +8,18 @@ TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackmisc blackcore blackgui
DEPENDPATH += . $$SourceRoot/src
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
SOURCES += *.cpp
HEADERS += *.h
FORMS += *.ui
FORMS += *.ui
DISTFILES += simulatoremulated.json
DESTDIR = $$DestRoot/bin/plugins/simulator
LIBS *= -lsimulatorplugincommon
addStaticLibraryDependency(simulatorplugincommon)
win32 {
dlltarget.path = $$PREFIX/bin/plugins/simulator
INSTALLS += dlltarget

View File

@@ -36,7 +36,7 @@ namespace BlackSimPlugin
IWeatherGridProvider *weatherGridProvider,
IClientProvider *clientProvider,
QObject *parent) :
CSimulatorCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent)
CSimulatorPluginCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent)
{
Q_ASSERT_X(sApp && sApp->getIContextSimulator(), Q_FUNC_INFO, "Need context");
@@ -47,6 +47,7 @@ namespace BlackSimPlugin
m_monitorWidget.reset(new CSimulatorEmulatedMonitorDialog(this, sGui->mainApplicationWidget()));
connect(qApp, &QApplication::aboutToQuit, this, &CSimulatorEmulated::closeMonitor);
connect(sGui, &CGuiApplication::aboutToShutdown, this, &CSimulatorEmulated::closeMonitor);
connect(&m_interpolatorFetchTimer, &QTimer::timeout, this, &CSimulatorEmulated::fetchFromInterpolator);
// connect own signals for monitoring
@@ -180,7 +181,7 @@ namespace BlackSimPlugin
bool CSimulatorEmulated::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
{
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, commandLine, originator.toQString());
return CSimulatorCommon::parseCommandLine(commandLine, originator);
return CSimulatorPluginCommon::parseCommandLine(commandLine, originator);
}
void CSimulatorEmulated::registerHelp()
@@ -316,7 +317,7 @@ namespace BlackSimPlugin
if (parser.matchesPart(1, "show")) { m_monitorWidget->show(); return true; }
if (parser.matchesPart(1, "hide")) { m_monitorWidget->hide(); return true; }
}
return false;
return CSimulatorPluginCommon::parseDetails(parser);
}
void CSimulatorEmulated::setObjectName(const CSimulatorInfo &info)

View File

@@ -12,7 +12,7 @@
#ifndef BLACKSIMPLUGIN_EMULATED_SIMULATOREMULATED_H
#define BLACKSIMPLUGIN_EMULATED_SIMULATOREMULATED_H
#include "blackcore/simulatorcommon.h"
#include "../plugincommon/simulatorplugincommon.h"
#include "blackmisc/simulation/interpolatormulti.h"
#include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "blackmisc/simulation/interpolationlogger.h"
@@ -31,7 +31,7 @@ namespace BlackSimPlugin
namespace Emulated
{
//! swift simulator implementation
class CSimulatorEmulated : public BlackCore::CSimulatorCommon
class CSimulatorEmulated : public Common::CSimulatorPluginCommon
{
Q_OBJECT
friend class CSimulatorEmulatedMonitorDialog; //!< the monitor widget represents the simulator and needs access to internals (i.e. private/protected)

View File

@@ -1,20 +1,21 @@
load(common_pre)
QT += core dbus gui network xml
QT += core dbus gui network xml widgets
TARGET = simulatorfs9
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackmisc blackcore
CONFIG += blackmisc blackcore blackgui
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
LIBS += -lsimulatorfscommon -lfsuipc -luuid
LIBS += -ldxguid -lole32
addStaticLibraryDependency(simulatorplugincommon)
addStaticLibraryDependency(simulatorfscommon)
addStaticLibraryDependency(fsuipc)
LIBS += -lsimulatorfscommon -lfsuipc -luuid -lsimulatorplugincommon
LIBS += -ldxguid -lole32
SOURCES += *.cpp
HEADERS += *.h

View File

@@ -31,7 +31,8 @@ namespace BlackSimPlugin
{
namespace Fs9
{
CFs9Client::CFs9Client(const CCallsign &callsign, const QString &modelName, const CTime &updateInterval,
CFs9Client::CFs9Client(const CCallsign &callsign, const QString &modelName,
const CTime &updateInterval,
CInterpolationLogger *logger, ISimulator *simulator) :
CDirectPlayPeer(simulator, callsign),
m_updateInterval(updateInterval),

View File

@@ -14,6 +14,9 @@ INCLUDEPATH += . $$SourceRoot/src
SOURCES += *.cpp
HEADERS += *.h
LIBS *= -lsimulatorplugincommon
addStaticLibraryDependency(simulatorplugincommon)
contains(BLACK_CONFIG, FSUIPC) {
equals(WORD_SIZE,32) {
DEFINES += SWIFT_USING_FSUIPC32

View File

@@ -22,6 +22,7 @@ using namespace BlackMisc::Simulation;
using namespace BlackMisc::Simulation::FsCommon;
using namespace BlackMisc::Weather;
using namespace BlackCore;
using namespace BlackSimPlugin::Common;
namespace BlackSimPlugin
{
@@ -34,7 +35,7 @@ namespace BlackSimPlugin
IWeatherGridProvider *weatherGridProvider,
IClientProvider *clientProvider,
QObject *parent) :
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent),
CSimulatorPluginCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent),
m_fsuipc(std::make_unique<CFsuipc>(this))
{
CSimulatorFsCommon::registerHelp();
@@ -67,7 +68,7 @@ namespace BlackSimPlugin
CLogMessage(this, CLogCategory::cmdLine()).info("FSUIPC is '%1'") << boolToOnOff(s);
return s;
}
return false;
return CSimulatorPluginCommon::parseDetails(parser);
}
void CSimulatorFsCommon::registerHelp()
@@ -121,10 +122,7 @@ namespace BlackSimPlugin
CAirportList CSimulatorFsCommon::getAirportsInRange() const
{
if (!m_airportsInRangeFromSimulator.isEmpty())
{
return m_airportsInRangeFromSimulator;
}
if (!m_airportsInRangeFromSimulator.isEmpty()) { return m_airportsInRangeFromSimulator; }
return CSimulatorCommon::getAirportsInRange();
}

View File

@@ -12,7 +12,7 @@
#ifndef BLACKSIMPLUGIN_FSCOMMON_SIMULATORFSCOMMON_H
#define BLACKSIMPLUGIN_FSCOMMON_SIMULATORFSCOMMON_H
#include "blackcore/simulatorcommon.h"
#include "../plugincommon/simulatorplugincommon.h"
#include "blackmisc/simulation/interpolator.h"
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
#include "fsuipc.h"
@@ -25,7 +25,7 @@ namespace BlackSimPlugin
namespace FsCommon
{
//! Common base class for MS flight simulators
class CSimulatorFsCommon : public BlackCore::CSimulatorCommon
class CSimulatorFsCommon : public Common::CSimulatorPluginCommon
{
public:
//! Destructor

View File

@@ -2,24 +2,25 @@ load(common_pre)
REQUIRES += contains(BLACK_CONFIG,FSX)
QT += core dbus gui network xml
QT += core dbus gui network xml widgets
TARGET = simulatorfsx
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackconfig blackmisc blackcore
CONFIG += blackconfig blackmisc blackcore blackgui
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
INCLUDEPATH *= $$EXTERNALSROOT/common/include/simconnect/FSX-XPack
LIBS *= -L$$EXTERNALS_LIB_DIR/FSX-XPack
LIBS *= -lsimulatorfscommon -lsimulatorfsxcommon -lfsuipc -lSimConnect
LIBS *= -lsimulatorfscommon -lsimulatorfsxcommon -lfsuipc -lSimConnect -lsimulatorplugincommon
LIBS += -ldxguid -lole32
addStaticLibraryDependency(simulatorfscommon)
addStaticLibraryDependency(simulatorfsxcommon)
addStaticLibraryDependency(fsuipc)
addStaticLibraryDependency(simulatorplugincommon)
SOURCES += *.cpp
HEADERS += *.h

View File

@@ -2,13 +2,13 @@ load(common_pre)
REQUIRES += contains(BLACK_CONFIG,P3D)
QT += core dbus gui network xml
QT += core dbus gui network xml widgets
TARGET = simulatorp3d
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackconfig blackmisc blackcore
CONFIG += blackconfig blackmisc blackcore blackgui
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
@@ -23,7 +23,8 @@ equals(WORD_SIZE,32) {
INCLUDEPATH *= $$EXTERNALSROOT/common/include/simconnect/FSX-XPack
}
LIBS += -lsimulatorfscommon -lsimulatorfsxcommon -lfsuipc
LIBS += -lsimulatorfscommon -lsimulatorfsxcommon -lfsuipc -lsimulatorplugincommon
equals(WORD_SIZE,64) {
LIBS *= -L$$EXTERNALS_LIB_DIR/P3D-v4.1
LIBS *= -lAdvapi32
@@ -38,6 +39,7 @@ LIBS += -ldxguid -lole32
addStaticLibraryDependency(simulatorfscommon)
addStaticLibraryDependency(simulatorfsxcommon)
addStaticLibraryDependency(fsuipc)
addStaticLibraryDependency(simulatorplugincommon)
# Ignore linker warning about missing pdb files from Simconnect
msvc: QMAKE_LFLAGS *= /ignore:4099

View File

@@ -0,0 +1,18 @@
load(common_pre)
QT += core dbus xml network widgets
TARGET = simulatorplugincommon
TEMPLATE = lib
CONFIG += staticlib
CONFIG += blackconfig blackmisc blackgui
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
SOURCES += *.cpp
HEADERS += *.h
DESTDIR = $$DestRoot/lib
load(common_post)

View File

@@ -0,0 +1,84 @@
/* Copyright (C) 2018
* 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 "simulatorplugincommon.h"
#include "blackgui/components/interpolationlogdisplaydialog.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/simplecommandparser.h"
using namespace BlackGui::Components;
using namespace BlackCore;
using namespace BlackMisc;
using namespace BlackMisc::Network;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Weather;
namespace BlackSimPlugin
{
namespace Common
{
CSimulatorPluginCommon::CSimulatorPluginCommon(
const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *renderedAircraftProvider,
IWeatherGridProvider *weatherGridProvider,
IClientProvider *clientProvider,
QObject *parent) :
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent)
{
CSimulatorPluginCommon::registerHelp();
}
CSimulatorPluginCommon::~CSimulatorPluginCommon()
{
if (m_interpolationDisplay)
{
m_interpolationDisplay->deleteLater();
}
}
void CSimulatorPluginCommon::showInterpolationDisplay()
{
if (!m_interpolationDisplay)
{
QWidget *parentWidget = sGui ? sGui->mainApplicationWidget() : nullptr;
CInterpolationLogDisplayDialog *dialog = new CInterpolationLogDisplayDialog(this, parentWidget);
m_interpolationDisplay = dialog;
}
m_interpolationDisplay->show();
}
bool CSimulatorPluginCommon::parseDetails(const CSimpleCommandParser &parser)
{
// .driver fsuipc on|off
if (parser.matchesPart(1, "intdisplay"))
{
this->showInterpolationDisplay();
return true;
}
return CSimulatorCommon::parseDetails(parser);
}
void CSimulatorPluginCommon::unload()
{
if (m_interpolationDisplay)
{
m_interpolationDisplay->hide();
m_interpolationDisplay->deleteLater();
}
CSimulatorCommon::unload();
}
void CSimulatorPluginCommon::registerHelp()
{
if (CSimpleCommandParser::registered("BlackSimPlugin::Common::CSimulatorPluginCommon")) { return; }
CSimpleCommandParser::registerCommand({".drv intdisplay", "interpolation display"});
}
} // namespace
} // namespace

View File

@@ -0,0 +1,63 @@
/* Copyright (C) 2018
* 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 BLACKSIMPLUGIN_COMMON_SIMULATORPLUGINCOMMON_H
#define BLACKSIMPLUGIN_COMMON_SIMULATORPLUGINCOMMON_H
#include "blackcore/simulatorcommon.h"
#include <QObject>
#include <QPointer>
namespace BlackGui { namespace Components { class CInterpolationLogDisplayDialog; }}
namespace BlackSimPlugin
{
namespace Common
{
//! Common base class for simulator plugins
class CSimulatorPluginCommon : public BlackCore::CSimulatorCommon
{
public:
//! Destructor
virtual ~CSimulatorPluginCommon();
protected:
//! Constructor
CSimulatorPluginCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *renderedAircraftProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
BlackMisc::Network::IClientProvider *clientProvider,
QObject *parent = nullptr);
//! \addtogroup swiftdotcommands
//! @{
//! <pre>
//! .drv intdisplay interpolation log display
//! </pre>
//! @}
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
// interface implementations
virtual void unload() override;
//! Register help
static void registerHelp();
private:
//! Show the interpolator display
void showInterpolationDisplay();
QPointer<BlackGui::Components::CInterpolationLogDisplayDialog> m_interpolationDisplay; //!< can be owned by main window after setting a parent
};
} // namespace
} // namespace
#endif // guard

View File

@@ -3,6 +3,7 @@ load(common_pre)
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += plugincommon
SUBDIRS += emulated
SUBDIRS += emulatedconfig

View File

@@ -8,33 +8,11 @@
*/
#include "simulatorxplane.h"
#include "qcompilerdetection.h"
#include "xswiftbusserviceproxy.h"
#include "xswiftbustrafficproxy.h"
#include "xswiftbusweatherproxy.h"
#include "blackcore/aircraftmatcher.h"
#include "blackmisc/aviation/aircraftengine.h"
#include "blackmisc/aviation/aircraftenginelist.h"
#include "blackmisc/aviation/aircrafticaocode.h"
#include "blackmisc/aviation/aircraftparts.h"
#include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/airlineicaocode.h"
#include "blackmisc/aviation/altitude.h"
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/aviation/comsystem.h"
#include "blackmisc/aviation/heading.h"
#include "blackmisc/aviation/livery.h"
#include "blackmisc/aviation/transponder.h"
#include "blackmisc/compare.h"
#include "blackmisc/dbusserver.h"
#include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/geo/latitude.h"
#include "blackmisc/geo/longitude.h"
#include "blackmisc/iterator.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/pq/angle.h"
#include "blackmisc/pq/frequency.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/pq/pressure.h"
#include "blackmisc/pq/speed.h"
#include "blackmisc/pq/temperature.h"
#include "blackmisc/simulation/aircraftmodel.h"
#include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/simulation/simulatedaircraftlist.h"
@@ -47,10 +25,32 @@
#include "blackmisc/weather/visibilitylayerlist.h"
#include "blackmisc/weather/windlayer.h"
#include "blackmisc/weather/windlayerlist.h"
#include "qcompilerdetection.h"
#include "xswiftbusserviceproxy.h"
#include "xswiftbustrafficproxy.h"
#include "xswiftbusweatherproxy.h"
#include "blackmisc/aviation/aircraftengine.h"
#include "blackmisc/aviation/aircraftenginelist.h"
#include "blackmisc/aviation/aircrafticaocode.h"
#include "blackmisc/aviation/aircraftparts.h"
#include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/airlineicaocode.h"
#include "blackmisc/aviation/altitude.h"
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/aviation/comsystem.h"
#include "blackmisc/aviation/heading.h"
#include "blackmisc/aviation/livery.h"
#include "blackmisc/aviation/transponder.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/geo/latitude.h"
#include "blackmisc/geo/longitude.h"
#include "blackmisc/pq/angle.h"
#include "blackmisc/pq/frequency.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/pq/pressure.h"
#include "blackmisc/pq/speed.h"
#include "blackmisc/pq/temperature.h"
#include "blackmisc/compare.h"
#include "blackmisc/dbusserver.h"
#include "blackmisc/iterator.h"
#include "blackmisc/logmessage.h"
#include <QColor>
#include <QDBusServiceWatcher>
@@ -86,7 +86,7 @@ namespace BlackSimPlugin
IWeatherGridProvider *weatherGridProvider,
IClientProvider *clientProvider,
QObject *parent) :
CSimulatorCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent)
CSimulatorPluginCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent)
{
m_watcher = new QDBusServiceWatcher(this);
m_watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
@@ -112,7 +112,7 @@ namespace BlackSimPlugin
void CSimulatorXPlane::unload()
{
CSimulatorCommon::unload();
CSimulatorPluginCommon::unload();
delete m_watcher;
m_watcher = nullptr;
}

View File

@@ -13,20 +13,21 @@
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_H
#include "xplanempaircraft.h"
#include "plugins/simulator/xplaneconfig/simulatorxplaneconfig.h"
#include "plugins/simulator/plugincommon/simulatorplugincommon.h"
#include "blackcore/simulator.h"
#include "blackcore/simulatorcommon.h"
#include "plugins/simulator/xplaneconfig/simulatorxplaneconfig.h"
#include "blackmisc/aviation/airportlist.h"
#include "blackmisc/aviation/callsignset.h"
#include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/simulation/data/modelcaches.h"
#include "blackmisc/simulation/settings/simulatorsettings.h"
#include "blackmisc/simulation/settings/xswiftbussettings.h"
#include "blackmisc/simulation/simulatedaircraftlist.h"
#include "blackmisc/weather/weathergrid.h"
#include "blackmisc/aviation/airportlist.h"
#include "blackmisc/aviation/callsignset.h"
#include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/settingscache.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/identifier.h"
@@ -103,7 +104,7 @@ namespace BlackSimPlugin
};
//! X-Plane ISimulator implementation
class CSimulatorXPlane : public BlackCore::CSimulatorCommon
class CSimulatorXPlane : public Common::CSimulatorPluginCommon
{
Q_OBJECT

View File

@@ -1,12 +1,12 @@
load(common_pre)
QT += core dbus network
QT += core dbus network widgets
TARGET = simulatorxplane
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackmisc blackcore
CONFIG += blackmisc blackcore blackgui
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
@@ -14,9 +14,11 @@ INCLUDEPATH += . $$SourceRoot/src
SOURCES += *.cpp
HEADERS += *.h
DISTFILES += simulatorxplane.json
DESTDIR = $$DestRoot/bin/plugins/simulator
LIBS *= -lsimulatorplugincommon
addStaticLibraryDependency(simulatorplugincommon)
win32 {
dlltarget.path = $$PREFIX/bin/plugins/simulator
INSTALLS += dlltarget