From 32f60722c818518b9dc45e3310080e5539d11cc8 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 3 Apr 2015 18:17:54 +0200 Subject: [PATCH] refs #396, move subproject BlackSim into BlackMisc::Simulation * removed unused samples / tests * fixed found Doxygen issues * removed blacksimfreefunctions, now in BlackMisc::Simulation::registerMetadata() * samples_vetcor_geo to samples_geo --- config.pri | 3 +- libraries.pri | 4 - .../main.cpp | 0 .../sample_geo.pro} | 0 .../samplesgeo.cpp | 6 +- .../samplesgeo.h | 0 samples/{blacksim => blackmiscsim}/main.cpp | 0 .../sample_blackmisc_sim.pro} | 6 +- .../samplesfscommon.cpp | 0 .../samplesfscommon.h | 0 .../{blacksim => blackmiscsim}/samplesfsx.cpp | 0 .../{blacksim => blackmiscsim}/samplesfsx.h | 0 .../samplesmodelmapping.cpp | 0 .../samplesmodelmapping.h | 0 samples/cli_client/client.cpp | 1 - samples/cli_client/client.h | 2 +- src/blackcore/airspace_monitor.h | 4 +- src/blackcore/blackcore.pro | 6 +- src/blackcore/context_network_impl.cpp | 3 +- src/blackcore/context_network_impl.h | 2 +- src/blackcore/context_ownaircraft_impl.h | 2 +- src/blackcore/context_runtime.cpp | 3 +- src/blackcore/context_runtime.h | 2 +- src/blackcore/context_settings.h | 2 +- src/blackcore/context_settings_impl.cpp | 2 +- src/blackcore/context_settings_impl.h | 4 +- src/blackcore/context_settings_proxy.cpp | 2 +- src/blackcore/context_settings_proxy.h | 2 +- src/blackcore/context_simulator.h | 12 +- src/blackcore/context_simulator_impl.cpp | 8 +- src/blackcore/context_simulator_impl.h | 18 +- src/blackcore/context_simulator_proxy.cpp | 8 +- src/blackcore/context_simulator_proxy.h | 8 +- src/blackcore/interpolator.h | 2 +- src/blackcore/network.h | 4 +- src/blackcore/network_vatlib.cpp | 2 +- src/blackcore/network_vatlib.h | 8 +- src/blackcore/settingsallclasses.h | 2 +- src/blackcore/simulator.cpp | 2 +- src/blackcore/simulator.h | 6 +- src/blackgui/blackgui.pro | 6 +- .../components/settingsfsxcomponent.cpp | 12 +- .../components/settingssimulatorcomponent.cpp | 8 +- .../components/settingssimulatorcomponent.h | 4 +- src/blackgui/foreignwindows.h | 2 +- src/blackmisc/blackmisc.pro | 8 +- .../blackmiscfreefunctions_simmeta.cpp | 19 +- src/blackmisc/nwaircraftmapping.h | 2 +- src/blackmisc/simulation/aircraftmodel.h | 4 +- src/blackmisc/simulation/aircraftmodellist.h | 4 +- .../fscommon/aircraftcfgentries.cpp | 156 ++++++++++++ .../simulation/fscommon/aircraftcfgentries.h | 154 ++++++++++++ .../fscommon/aircraftcfgentrieslist.cpp | 235 ++++++++++++++++++ .../fscommon/aircraftcfgentrieslist.h | 136 ++++++++++ .../simulation/fscommon/aircraftmapper.cpp | 186 ++++++++++++++ .../simulation/fscommon/aircraftmapper.h | 120 +++++++++ .../simulation/fscommon/bcdconversions.cpp | 53 ++++ .../simulation/fscommon/bcdconversions.h | 54 ++++ src/blackmisc/simulation/fscommon/fscommon.h | 12 + .../simulation/fscommon/fscommonutil.cpp | 52 ++++ .../simulation/fscommon/fscommonutil.h | 41 +++ .../fscommon/vpilotmodelmappings.cpp | 133 ++++++++++ .../simulation/fscommon/vpilotmodelmappings.h | 61 +++++ .../simulation}/fsx/fsx.h | 6 +- .../simulation/fsx/fsxsimulatorsetup.cpp | 41 +++ .../simulation/fsx/fsxsimulatorsetup.h | 51 ++++ .../simulation/fsx/simconnectutilities.cpp | 96 +++++++ .../simulation/fsx/simconnectutilities.h | 176 +++++++++++++ ...wnaircraft.cpp => ownaircraftprovider.cpp} | 2 +- ...essownaircraft.h => ownaircraftprovider.h} | 4 +- ...ircraft.cpp => remoteaircraftprovider.cpp} | 2 +- ...oteaircraft.h => remoteaircraftprovider.h} | 4 +- ...my.cpp => remoteaircraftproviderdummy.cpp} | 2 +- ...tdummy.h => remoteaircraftproviderdummy.h} | 6 +- src/blackmisc/simulation/setsimulator.cpp | 87 +++++++ src/blackmisc/simulation/setsimulator.h | 97 ++++++++ src/blackmisc/simulation/simulatedaircraft.h | 4 +- .../simulation/simulatedaircraftlist.cpp | 13 +- .../simulation/simulatedaircraftlist.h | 4 +- .../simulation/simulatorinfolist.cpp | 44 ++++ src/blackmisc/simulation/simulatorinfolist.h | 54 ++++ .../simulation/simulatormodelmappings.cpp | 54 ++++ .../simulation/simulatormodelmappings.h | 56 +++++ .../simulation/simulatorplugininfo.cpp | 70 ++++++ .../simulation/simulatorplugininfo.h | 105 ++++++++ ...ulationallclasses.h => simulatorsetup.cpp} | 24 +- src/blackmisc/simulation/simulatorsetup.h | 60 +++++ src/blacksim/blacksim.pro | 35 --- src/blacksim/blacksimfreefunctions.cpp | 29 --- src/blacksim/blacksimfreefunctions.h | 23 -- src/blacksim/fscommon/aircraftcfgentries.cpp | 153 ------------ src/blacksim/fscommon/aircraftcfgentries.h | 151 ----------- .../fscommon/aircraftcfgentrieslist.cpp | 232 ----------------- .../fscommon/aircraftcfgentrieslist.h | 133 ---------- src/blacksim/fscommon/aircraftmapper.cpp | 183 -------------- src/blacksim/fscommon/aircraftmapper.h | 117 --------- src/blacksim/fscommon/bcdconversions.cpp | 48 ---- src/blacksim/fscommon/bcdconversions.h | 51 ---- src/blacksim/fscommon/fscommon.h | 12 - src/blacksim/fscommon/fscommonutil.cpp | 49 ---- src/blacksim/fscommon/fscommonutil.h | 38 --- src/blacksim/fscommon/vpilotmodelmappings.cpp | 129 ---------- src/blacksim/fscommon/vpilotmodelmappings.h | 58 ----- src/blacksim/fsx/fsxsimulatorsetup.cpp | 38 --- src/blacksim/fsx/fsxsimulatorsetup.h | 48 ---- src/blacksim/fsx/simconnectutilities.cpp | 93 ------- src/blacksim/fsx/simconnectutilities.h | 173 ------------- src/blacksim/setsimulator.cpp | 95 ------- src/blacksim/setsimulator.h | 94 ------- src/blacksim/simulatorinfolist.cpp | 40 --- src/blacksim/simulatorinfolist.h | 51 ---- src/blacksim/simulatormodelmappings.cpp | 52 ---- src/blacksim/simulatormodelmappings.h | 53 ---- src/blacksim/simulatorplugininfo.cpp | 70 ------ src/blacksim/simulatorplugininfo.h | 96 ------- src/blacksim/simulatorsetup.cpp | 23 -- src/blacksim/simulatorsetup.h | 57 ----- src/plugins/simulator/fs9/callback_wrapper.h | 2 +- src/plugins/simulator/fs9/directplay_peer.h | 1 + src/plugins/simulator/fs9/plugin_fs9.pro | 4 +- src/plugins/simulator/fs9/simulator_fs9.cpp | 4 +- src/plugins/simulator/fs9/simulator_fs9.h | 6 +- src/plugins/simulator/fscommon/fsuipc.cpp | 4 +- .../simulator/fscommon/plugin_fscommon.pro | 2 - .../simulator/fscommon/simulator_fscommon.cpp | 11 +- .../simulator/fscommon/simulator_fscommon.h | 4 +- src/plugins/simulator/fsx/plugin_fsx.pro | 4 +- src/plugins/simulator/fsx/simulator_fsx.cpp | 14 +- src/plugins/simulator/fsx/simulator_fsx.h | 7 +- .../fsx/simulator_fsx_simconnectproc.cpp | 14 +- .../simulator/fsx/simulator_fsxfactory.cpp | 2 +- .../simulator/fsx/simulator_fsxfactory.h | 2 +- .../simulator/xplane/plugin_xplane.pro | 2 +- .../simulator/xplane/simulator_xplane.cpp | 2 +- .../simulator/xplane/simulator_xplane.h | 2 +- src/swiftcore/swiftcore.pro | 6 +- src/swiftgui_standard/main.cpp | 3 +- src/swiftgui_standard/swiftgui_standard.pro | 6 +- swift.pro | 9 +- tests/blackcore/testinterpolator.cpp | 2 +- tests/blackcore/testnetwork.h | 2 +- tests/blackmisc/testblackmiscmain.cpp | 1 + tests/blacksim/main.cpp | 22 -- tests/blacksim/test_blacksim.pro | 27 -- tests/blacksim/testblacksimmain.cpp | 27 -- tests/blacksim/testblacksimmain.h | 38 --- tests/blacksim/testsimcommon.cpp | 26 -- tests/blacksim/testsimcommon.h | 29 --- 148 files changed, 2577 insertions(+), 2792 deletions(-) rename samples/{blackmiscvectorgeo => blackmiscgeo}/main.cpp (100%) rename samples/{blackmiscvectorgeo/sample_vector_geo.pro => blackmiscgeo/sample_geo.pro} (100%) rename samples/{blackmiscvectorgeo => blackmiscgeo}/samplesgeo.cpp (87%) rename samples/{blackmiscvectorgeo => blackmiscgeo}/samplesgeo.h (100%) rename samples/{blacksim => blackmiscsim}/main.cpp (100%) rename samples/{blacksim/sample_blacksim.pro => blackmiscsim/sample_blackmisc_sim.pro} (58%) rename samples/{blacksim => blackmiscsim}/samplesfscommon.cpp (100%) rename samples/{blacksim => blackmiscsim}/samplesfscommon.h (100%) rename samples/{blacksim => blackmiscsim}/samplesfsx.cpp (100%) rename samples/{blacksim => blackmiscsim}/samplesfsx.h (100%) rename samples/{blacksim => blackmiscsim}/samplesmodelmapping.cpp (100%) rename samples/{blacksim => blackmiscsim}/samplesmodelmapping.h (100%) create mode 100644 src/blackmisc/simulation/fscommon/aircraftcfgentries.cpp create mode 100644 src/blackmisc/simulation/fscommon/aircraftcfgentries.h create mode 100644 src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp create mode 100644 src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.h create mode 100644 src/blackmisc/simulation/fscommon/aircraftmapper.cpp create mode 100644 src/blackmisc/simulation/fscommon/aircraftmapper.h create mode 100644 src/blackmisc/simulation/fscommon/bcdconversions.cpp create mode 100644 src/blackmisc/simulation/fscommon/bcdconversions.h create mode 100644 src/blackmisc/simulation/fscommon/fscommon.h create mode 100644 src/blackmisc/simulation/fscommon/fscommonutil.cpp create mode 100644 src/blackmisc/simulation/fscommon/fscommonutil.h create mode 100644 src/blackmisc/simulation/fscommon/vpilotmodelmappings.cpp create mode 100644 src/blackmisc/simulation/fscommon/vpilotmodelmappings.h rename src/{blacksim => blackmisc/simulation}/fsx/fsx.h (77%) create mode 100644 src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp create mode 100644 src/blackmisc/simulation/fsx/fsxsimulatorsetup.h create mode 100644 src/blackmisc/simulation/fsx/simconnectutilities.cpp create mode 100644 src/blackmisc/simulation/fsx/simconnectutilities.h rename src/blackmisc/simulation/{simdirectaccessownaircraft.cpp => ownaircraftprovider.cpp} (98%) rename src/blackmisc/simulation/{simdirectaccessownaircraft.h => ownaircraftprovider.h} (98%) rename src/blackmisc/simulation/{simdirectaccessremoteaircraft.cpp => remoteaircraftprovider.cpp} (98%) rename src/blackmisc/simulation/{simdirectaccessremoteaircraft.h => remoteaircraftprovider.h} (98%) rename src/blackmisc/simulation/{simdirectaccessremoteaircraftdummy.cpp => remoteaircraftproviderdummy.cpp} (98%) rename src/blackmisc/simulation/{simdirectaccessremoteaircraftdummy.h => remoteaircraftproviderdummy.h} (96%) create mode 100644 src/blackmisc/simulation/setsimulator.cpp create mode 100644 src/blackmisc/simulation/setsimulator.h create mode 100644 src/blackmisc/simulation/simulatorinfolist.cpp create mode 100644 src/blackmisc/simulation/simulatorinfolist.h create mode 100644 src/blackmisc/simulation/simulatormodelmappings.cpp create mode 100644 src/blackmisc/simulation/simulatormodelmappings.h create mode 100644 src/blackmisc/simulation/simulatorplugininfo.cpp create mode 100644 src/blackmisc/simulation/simulatorplugininfo.h rename src/blackmisc/simulation/{simulationallclasses.h => simulatorsetup.cpp} (57%) create mode 100644 src/blackmisc/simulation/simulatorsetup.h delete mode 100644 src/blacksim/blacksim.pro delete mode 100644 src/blacksim/blacksimfreefunctions.cpp delete mode 100644 src/blacksim/blacksimfreefunctions.h delete mode 100644 src/blacksim/fscommon/aircraftcfgentries.cpp delete mode 100644 src/blacksim/fscommon/aircraftcfgentries.h delete mode 100644 src/blacksim/fscommon/aircraftcfgentrieslist.cpp delete mode 100644 src/blacksim/fscommon/aircraftcfgentrieslist.h delete mode 100644 src/blacksim/fscommon/aircraftmapper.cpp delete mode 100644 src/blacksim/fscommon/aircraftmapper.h delete mode 100644 src/blacksim/fscommon/bcdconversions.cpp delete mode 100644 src/blacksim/fscommon/bcdconversions.h delete mode 100644 src/blacksim/fscommon/fscommon.h delete mode 100644 src/blacksim/fscommon/fscommonutil.cpp delete mode 100644 src/blacksim/fscommon/fscommonutil.h delete mode 100644 src/blacksim/fscommon/vpilotmodelmappings.cpp delete mode 100644 src/blacksim/fscommon/vpilotmodelmappings.h delete mode 100644 src/blacksim/fsx/fsxsimulatorsetup.cpp delete mode 100644 src/blacksim/fsx/fsxsimulatorsetup.h delete mode 100644 src/blacksim/fsx/simconnectutilities.cpp delete mode 100644 src/blacksim/fsx/simconnectutilities.h delete mode 100644 src/blacksim/setsimulator.cpp delete mode 100644 src/blacksim/setsimulator.h delete mode 100644 src/blacksim/simulatorinfolist.cpp delete mode 100644 src/blacksim/simulatorinfolist.h delete mode 100644 src/blacksim/simulatormodelmappings.cpp delete mode 100644 src/blacksim/simulatormodelmappings.h delete mode 100644 src/blacksim/simulatorplugininfo.cpp delete mode 100644 src/blacksim/simulatorplugininfo.h delete mode 100644 src/blacksim/simulatorsetup.cpp delete mode 100644 src/blacksim/simulatorsetup.h delete mode 100644 tests/blacksim/main.cpp delete mode 100644 tests/blacksim/test_blacksim.pro delete mode 100644 tests/blacksim/testblacksimmain.cpp delete mode 100644 tests/blacksim/testblacksimmain.h delete mode 100644 tests/blacksim/testsimcommon.cpp delete mode 100644 tests/blacksim/testsimcommon.h diff --git a/config.pri b/config.pri index e22599c2d..adcf10198 100644 --- a/config.pri +++ b/config.pri @@ -10,7 +10,7 @@ BLACK_VER_MAJ = 0 BLACK_VER_MIN = 6 -BLACK_VER_PAT = 0 +BLACK_VER_PAT = 1 BLACK_VERSION = $${BLACK_VER_MAJ}.$${BLACK_VER_MIN}.$${BLACK_VER_PAT} DEFINES += BLACK_VERSION=$$BLACK_VERSION @@ -27,7 +27,6 @@ BLACK_CONFIG += BlackCore BLACK_CONFIG += BlackGui BLACK_CONFIG += BlackSound BLACK_CONFIG += BlackInput -BLACK_CONFIG += BlackSim BLACK_CONFIG += Samples BLACK_CONFIG += Unittests BLACK_CONFIG += FS9 diff --git a/libraries.pri b/libraries.pri index c38306ff9..98f9a7970 100644 --- a/libraries.pri +++ b/libraries.pri @@ -29,10 +29,6 @@ blackinput { } } -blacksim { - LIBS += -lblacksim -} - blackmisc { LIBS += -lblackmisc } diff --git a/samples/blackmiscvectorgeo/main.cpp b/samples/blackmiscgeo/main.cpp similarity index 100% rename from samples/blackmiscvectorgeo/main.cpp rename to samples/blackmiscgeo/main.cpp diff --git a/samples/blackmiscvectorgeo/sample_vector_geo.pro b/samples/blackmiscgeo/sample_geo.pro similarity index 100% rename from samples/blackmiscvectorgeo/sample_vector_geo.pro rename to samples/blackmiscgeo/sample_geo.pro diff --git a/samples/blackmiscvectorgeo/samplesgeo.cpp b/samples/blackmiscgeo/samplesgeo.cpp similarity index 87% rename from samples/blackmiscvectorgeo/samplesgeo.cpp rename to samples/blackmiscgeo/samplesgeo.cpp index 151036431..aab57cbc4 100644 --- a/samples/blackmiscvectorgeo/samplesgeo.cpp +++ b/samples/blackmiscgeo/samplesgeo.cpp @@ -29,9 +29,9 @@ namespace BlackMiscTest CLongitude lon1(33.0, CAngleUnit::deg()); qDebug() << lon1 << lat3; -// lat3 += lon1; // must not work -// lat3 = lon1; //must not work -// CGeoLongitude lonx(lat2); // must notwork + // lat3 += lon1; // must not work + // lat3 = lon1; //must not work + // CGeoLongitude lonx(lat2); // must notwork // bye qDebug() << "-----------------------------------------------"; diff --git a/samples/blackmiscvectorgeo/samplesgeo.h b/samples/blackmiscgeo/samplesgeo.h similarity index 100% rename from samples/blackmiscvectorgeo/samplesgeo.h rename to samples/blackmiscgeo/samplesgeo.h diff --git a/samples/blacksim/main.cpp b/samples/blackmiscsim/main.cpp similarity index 100% rename from samples/blacksim/main.cpp rename to samples/blackmiscsim/main.cpp diff --git a/samples/blacksim/sample_blacksim.pro b/samples/blackmiscsim/sample_blackmisc_sim.pro similarity index 58% rename from samples/blacksim/sample_blacksim.pro rename to samples/blackmiscsim/sample_blackmisc_sim.pro index e4f4d01f3..a249ea90e 100644 --- a/samples/blacksim/sample_blacksim.pro +++ b/samples/blackmiscsim/sample_blackmisc_sim.pro @@ -10,11 +10,11 @@ CONFIG += console CONFIG -= app_bundle CONFIG += blackmisc blacksim -DEPENDPATH += . ../../src/blackmisc ../../src/blacksim +DEPENDPATH += . ../../src/blackmisc INCLUDEPATH += . ../../src -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksim.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblacksim.a +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a DESTDIR = ../../bin diff --git a/samples/blacksim/samplesfscommon.cpp b/samples/blackmiscsim/samplesfscommon.cpp similarity index 100% rename from samples/blacksim/samplesfscommon.cpp rename to samples/blackmiscsim/samplesfscommon.cpp diff --git a/samples/blacksim/samplesfscommon.h b/samples/blackmiscsim/samplesfscommon.h similarity index 100% rename from samples/blacksim/samplesfscommon.h rename to samples/blackmiscsim/samplesfscommon.h diff --git a/samples/blacksim/samplesfsx.cpp b/samples/blackmiscsim/samplesfsx.cpp similarity index 100% rename from samples/blacksim/samplesfsx.cpp rename to samples/blackmiscsim/samplesfsx.cpp diff --git a/samples/blacksim/samplesfsx.h b/samples/blackmiscsim/samplesfsx.h similarity index 100% rename from samples/blacksim/samplesfsx.h rename to samples/blackmiscsim/samplesfsx.h diff --git a/samples/blacksim/samplesmodelmapping.cpp b/samples/blackmiscsim/samplesmodelmapping.cpp similarity index 100% rename from samples/blacksim/samplesmodelmapping.cpp rename to samples/blackmiscsim/samplesmodelmapping.cpp diff --git a/samples/blacksim/samplesmodelmapping.h b/samples/blackmiscsim/samplesmodelmapping.h similarity index 100% rename from samples/blacksim/samplesmodelmapping.h rename to samples/blackmiscsim/samplesmodelmapping.h diff --git a/samples/cli_client/client.cpp b/samples/cli_client/client.cpp index 778978511..61bb49bce 100644 --- a/samples/cli_client/client.cpp +++ b/samples/cli_client/client.cpp @@ -9,7 +9,6 @@ #include "client.h" #include "blackcore/network_vatlib.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" #include #include diff --git a/samples/cli_client/client.h b/samples/cli_client/client.h index 1f0ff7b32..088b4ad2f 100644 --- a/samples/cli_client/client.h +++ b/samples/cli_client/client.h @@ -13,7 +13,7 @@ #define BLACKSAMPLE_CLI_CLIENT_H #include "blackcore/network.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" #include #include #include diff --git a/src/blackcore/airspace_monitor.h b/src/blackcore/airspace_monitor.h index adeb58c4b..deb313025 100644 --- a/src/blackcore/airspace_monitor.h +++ b/src/blackcore/airspace_monitor.h @@ -13,8 +13,8 @@ #define BLACKCORE_AIRSPACE_MONITOR_H #include "blackmisc/simulation/simulatedaircraftlist.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" -#include "blackmisc/simulation/simdirectaccessremoteaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" +#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/aviation/aircraftsituationlist.h" #include "blackmisc/nwclientlist.h" diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index de017c417..c736dd81d 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -8,7 +8,7 @@ QT += network dbus xml multimedia TARGET = blackcore TEMPLATE = lib CONFIG += staticlib -CONFIG += blackmisc blackinput blacksim +CONFIG += blackmisc blackinput INCLUDEPATH += .. DEPENDPATH += . .. @@ -25,8 +25,8 @@ DEFINES += LOG_IN_FILE HEADERS += *.h SOURCES += *.cpp -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksound.lib ../../lib/blacksim.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblacksound.a ../../lib/libblacksim.a +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksound.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblacksound.a DESTDIR = ../../lib diff --git a/src/blackcore/context_network_impl.cpp b/src/blackcore/context_network_impl.cpp index 24f910469..00801b39f 100644 --- a/src/blackcore/context_network_impl.cpp +++ b/src/blackcore/context_network_impl.cpp @@ -21,7 +21,7 @@ #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/logmessage.h" #include "blackmisc/simplecommandparser.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" #include #include @@ -33,7 +33,6 @@ using namespace BlackMisc::Network; using namespace BlackMisc::Geo; using namespace BlackMisc::Audio; using namespace BlackMisc::Simulation; -using namespace BlackSim; namespace BlackCore { diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index b2d98304c..8a98513e4 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -15,7 +15,7 @@ #include "blackcore/context_network.h" #include "blackcore/context_settings.h" #include "blackcore/context_runtime.h" -#include "blackmisc/simulation/simdirectaccessremoteaircraft.h" +#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackcore/dbus_server.h" #include "blackcore/network.h" #include "blackcore/airspace_monitor.h" diff --git a/src/blackcore/context_ownaircraft_impl.h b/src/blackcore/context_ownaircraft_impl.h index fc68b2c4b..5de9c0ab8 100644 --- a/src/blackcore/context_ownaircraft_impl.h +++ b/src/blackcore/context_ownaircraft_impl.h @@ -17,7 +17,7 @@ #include "blackcore/context_runtime.h" #include "blackcore/dbus_server.h" #include "blackmisc/aviation/atcstation.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" namespace BlackCore { diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index 4acc5f689..dfae7319b 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -11,7 +11,6 @@ #include "blackcore/context_all_proxies.h" #include "blackcore/context_all_empties.h" #include "blackcore/blackcorefreefunctions.h" -#include "blacksim/blacksimfreefunctions.h" #include "blackmisc/nwserver.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/aviation/aircraft.h" @@ -133,7 +132,7 @@ namespace BlackCore { BlackMisc::registerMetadata(); BlackMisc::initResources(); - BlackSim::registerMetadata(); + BlackMisc::Simulation::registerMetadata(); BlackCore::registerMetadata(); } diff --git a/src/blackcore/context_runtime.h b/src/blackcore/context_runtime.h index 38bb48a3d..f77735d36 100644 --- a/src/blackcore/context_runtime.h +++ b/src/blackcore/context_runtime.h @@ -14,7 +14,7 @@ #include "blackcore/context_runtime_config.h" #include "blackmisc/statusmessagelist.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" #include #include diff --git a/src/blackcore/context_settings.h b/src/blackcore/context_settings.h index 15bdffb74..45f018bb5 100644 --- a/src/blackcore/context_settings.h +++ b/src/blackcore/context_settings.h @@ -136,7 +136,7 @@ namespace BlackCore virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const = 0; //! Audio settings - virtual BlackSim::Settings::CSettingsSimulator getSimulatorSettings() const = 0; + virtual BlackMisc::Simulation::Settings::CSettingsSimulator getSimulatorSettings() const = 0; //! Hotkeys virtual BlackMisc::Settings::CSettingKeyboardHotkeyList getHotkeys() const = 0; diff --git a/src/blackcore/context_settings_impl.cpp b/src/blackcore/context_settings_impl.cpp index 5b2289102..e28c109d2 100644 --- a/src/blackcore/context_settings_impl.cpp +++ b/src/blackcore/context_settings_impl.cpp @@ -16,7 +16,7 @@ using namespace BlackMisc; using namespace BlackMisc::Settings; using namespace BlackMisc::Network; using namespace BlackMisc::Hardware; -using namespace BlackSim::Settings; +using namespace BlackMisc::Simulation::Settings; namespace BlackCore { diff --git a/src/blackcore/context_settings_impl.h b/src/blackcore/context_settings_impl.h index 193e8bd17..4947d52e8 100644 --- a/src/blackcore/context_settings_impl.h +++ b/src/blackcore/context_settings_impl.h @@ -60,7 +60,7 @@ namespace BlackCore virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override; //! \copydoc IContextSettings::getSimulatorSettings() - virtual BlackSim::Settings::CSettingsSimulator getSimulatorSettings() const override; + virtual BlackMisc::Simulation::Settings::CSettingsSimulator getSimulatorSettings() const override; //! \copydoc IContextSettings::getHotkeys() virtual BlackMisc::Settings::CSettingKeyboardHotkeyList getHotkeys() const override; @@ -86,7 +86,7 @@ namespace BlackCore BlackMisc::Settings::CSettingsNetwork m_settingsNetwork; BlackMisc::Settings::CSettingsAudio m_settingsAudio; - BlackSim::Settings::CSettingsSimulator m_settingsSimulator; + BlackMisc::Simulation::Settings::CSettingsSimulator m_settingsSimulator; BlackMisc::Settings::CSettingKeyboardHotkeyList m_hotkeys; QJsonDocument toJsonDocument() const; void emitCompletelyChanged(); diff --git a/src/blackcore/context_settings_proxy.cpp b/src/blackcore/context_settings_proxy.cpp index f255ed15f..1cd18c885 100644 --- a/src/blackcore/context_settings_proxy.cpp +++ b/src/blackcore/context_settings_proxy.cpp @@ -15,7 +15,7 @@ using namespace BlackMisc; using namespace BlackMisc::Settings; using namespace BlackMisc::Network; using namespace BlackMisc::Hardware; -using namespace BlackSim::Settings; +using namespace BlackMisc::Simulation::Settings; namespace BlackCore { diff --git a/src/blackcore/context_settings_proxy.h b/src/blackcore/context_settings_proxy.h index 9574ab41a..8d5f72998 100644 --- a/src/blackcore/context_settings_proxy.h +++ b/src/blackcore/context_settings_proxy.h @@ -50,7 +50,7 @@ namespace BlackCore virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override; //! \copydoc IContextSettings::getSimulatorSettings() - virtual BlackSim::Settings::CSettingsSimulator getSimulatorSettings() const override; + virtual BlackMisc::Simulation::Settings::CSettingsSimulator getSimulatorSettings() const override; //! \copydoc IContextSettings::getHotkeys() virtual BlackMisc::Settings::CSettingKeyboardHotkeyList getHotkeys() const override; diff --git a/src/blackcore/context_simulator.h b/src/blackcore/context_simulator.h index a0046d0af..631657352 100644 --- a/src/blackcore/context_simulator.h +++ b/src/blackcore/context_simulator.h @@ -27,8 +27,8 @@ #include "blackcore/dbus_server.h" #include "blackcore/context_runtime.h" #include "blackmisc/simulation/aircraftmodellist.h" -#include "blacksim/simulatorplugininfo.h" -#include "blacksim/simulatorinfolist.h" +#include "blackmisc/simulation/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorinfolist.h" #include "blackmisc/aviation/aircraft.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/aviation/airportlist.h" @@ -83,7 +83,7 @@ namespace BlackCore public slots: //! Return list of available simulator plugins - virtual BlackSim::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const = 0; + virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const = 0; //! Returns true when simulator is connected //! \sa isSimulating @@ -100,7 +100,7 @@ namespace BlackCore virtual bool isSimulating() const = 0; //! Simulator info - virtual BlackSim::CSimulatorPluginInfo getSimulatorInfo() const = 0; + virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorInfo() const = 0; //! Airports in range virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const = 0; @@ -155,13 +155,13 @@ namespace BlackCore virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const = 0; //! Load specific simulator plugin - virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorPluginInfo &simulatorInfo) = 0; + virtual bool loadSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) = 0; //! Load specific simulator plugin as set in settings virtual bool loadSimulatorPluginFromSettings() = 0; //! Listen for the specific simulator to start, load plugin automatically - virtual void listenForSimulator(const BlackSim::CSimulatorPluginInfo &simulatorInfo) = 0; + virtual void listenForSimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) = 0; //! Listen for all available simulators virtual void listenForAllSimulators() = 0; diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index e4723090b..806f7d717 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -26,8 +26,8 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; using namespace BlackMisc::Geo; -using namespace BlackSim; -using namespace BlackSim::Settings; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::Settings; namespace BlackCore { @@ -122,12 +122,12 @@ namespace BlackCore return m_simulator->simulator->disconnectFrom(); } - BlackSim::CSimulatorPluginInfo CContextSimulator::getSimulatorInfo() const + BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulator::getSimulatorInfo() const { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (!m_simulator) { - return BlackSim::CSimulatorPluginInfo(); + return BlackMisc::Simulation::CSimulatorPluginInfo(); } Q_ASSERT(m_simulator->simulator); diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index 8a6aa49d2..affa6d320 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -15,8 +15,8 @@ #include "blackcore/context_simulator.h" #include "blackcore/simulator.h" #include "blackmisc/worker.h" -#include "blacksim/simulatorplugininfo.h" -#include "blacksim/simulatorinfolist.h" +#include "blackmisc/simulation/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorinfolist.h" #include "blackmisc/nwtextmessagelist.h" #include "blackmisc/pixmap.h" #include "blackmisc/simulation/simulatedaircraftlist.h" @@ -43,12 +43,12 @@ namespace BlackCore //! Lazy-loads the driver, instantiates the factory and returns it. //! \return nullptr if no corresponding driver was found or an error occured during loading it. //! \todo Consider moving to private scope. - ISimulatorFactory* getSimulatorFactory(const BlackSim::CSimulatorPluginInfo& simulator); + ISimulatorFactory* getSimulatorFactory(const BlackMisc::Simulation::CSimulatorPluginInfo& simulator); public slots: //! \copydoc IContextSimulator::getSimulatorPluginList() - virtual BlackSim::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override; + virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override; //! \copydoc IContextSimulator::isConnected() virtual bool isConnected() const override; @@ -66,7 +66,7 @@ namespace BlackCore virtual bool isSimulating() const override; //! \copydoc IContextSimulator::getSimulatorInfo() - virtual BlackSim::CSimulatorPluginInfo getSimulatorInfo() const override; + virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorInfo() const override; //! \copydoc IContextSimulator::getAirportsInRange virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override; @@ -120,13 +120,13 @@ namespace BlackCore virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override; //! \copydoc IContextSimulator::loadSimulatorPlugin() - virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorPluginInfo &simulatorInfo) override; + virtual bool loadSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override; //! \copydoc IContextSimulator::loadSimulatorPluginFromSettings() virtual bool loadSimulatorPluginFromSettings() override; //! \copydoc IContextSimulator::listenForSimulator() - virtual void listenForSimulator(const BlackSim::CSimulatorPluginInfo &simulatorInfo) override; + virtual void listenForSimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override; //! \copydoc IContextSimulator::listenForAllSimulators() virtual void listenForAllSimulators() override; @@ -200,13 +200,13 @@ namespace BlackCore struct PluginData; //! \brief Locate PluginData (linear search) - PluginData* findPlugin(const BlackSim::CSimulatorPluginInfo &info); + PluginData* findPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &info); /*! * A simple struct containing all info about the plugin. */ struct PluginData { - BlackSim::CSimulatorPluginInfo info; + BlackMisc::Simulation::CSimulatorPluginInfo info; ISimulatorFactory *factory; //!< Lazy-loaded, nullptr by default ISimulatorListener *listener; //!< Listener instance, nullptr by default ISimulator *simulator; //!< The simulator itself (always nullptr unless it is the currently working one) diff --git a/src/blackcore/context_simulator_proxy.cpp b/src/blackcore/context_simulator_proxy.cpp index 2118e66da..837b0b5ed 100644 --- a/src/blackcore/context_simulator_proxy.cpp +++ b/src/blackcore/context_simulator_proxy.cpp @@ -18,7 +18,7 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc::Geo; using namespace BlackMisc::Simulation; -using namespace BlackSim; +using namespace BlackMisc::Simulation; namespace BlackCore { @@ -104,9 +104,9 @@ namespace BlackCore return m_dBusInterface->callDBusRet(QLatin1Literal("getIcaoForModelString"), modelString); } - BlackSim::CSimulatorPluginInfo CContextSimulatorProxy::getSimulatorInfo() const + BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulatorProxy::getSimulatorInfo() const { - return m_dBusInterface->callDBusRet(QLatin1Literal("getSimulatorInfo")); + return m_dBusInterface->callDBusRet(QLatin1Literal("getSimulatorInfo")); } bool CContextSimulatorProxy::setTimeSynchronization(bool enable, CTime offset) @@ -164,7 +164,7 @@ namespace BlackCore return m_dBusInterface->callDBusRet(QLatin1Literal("getTimeSynchronizationOffset")); } - bool CContextSimulatorProxy::loadSimulatorPlugin(const BlackSim::CSimulatorPluginInfo &simulatorInfo) + bool CContextSimulatorProxy::loadSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) { return m_dBusInterface->callDBusRet(QLatin1Literal("loadSimulatorPlugin"), simulatorInfo); } diff --git a/src/blackcore/context_simulator_proxy.h b/src/blackcore/context_simulator_proxy.h index 47a1020a7..70c4455df 100644 --- a/src/blackcore/context_simulator_proxy.h +++ b/src/blackcore/context_simulator_proxy.h @@ -45,7 +45,7 @@ namespace BlackCore public slots: //! \copydoc IContextSimulator::getSimulatorPluginList() - virtual BlackSim::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override; + virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override; //! \copydoc IContextSimulator::isConnected() virtual bool isConnected() const override; @@ -81,7 +81,7 @@ namespace BlackCore virtual BlackMisc::Aviation::CAircraftIcao getIcaoForModelString(const QString &modelString) const override; //! \copydoc IContextSimulator::getSimulatorInfo - virtual BlackSim::CSimulatorPluginInfo getSimulatorInfo() const override; + virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorInfo() const override; //! \copydoc IContextSimulator::setTimeSynchronization virtual bool setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override; @@ -117,13 +117,13 @@ namespace BlackCore virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override; //! \copydoc IContextSimulator::loadSimulatorPlugin - virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorPluginInfo &simulatorInfo) override; + virtual bool loadSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override; //! \copydoc IContextSimulator::loadSimulatorPluginFromSettings() virtual bool loadSimulatorPluginFromSettings(); //! \copydoc IContextSimulator::listenForSimulator() - virtual void listenForSimulator(const BlackSim::CSimulatorPluginInfo &simulatorInfo) override; + virtual void listenForSimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override; //! \copydoc IContextSimulator::listenForAllSimulators() virtual void listenForAllSimulators() override; diff --git a/src/blackcore/interpolator.h b/src/blackcore/interpolator.h index 3f54cb4dc..66bf9b357 100644 --- a/src/blackcore/interpolator.h +++ b/src/blackcore/interpolator.h @@ -13,7 +13,7 @@ #define BLACKCORE_INTERPOLATOR_H #include "blackmisc/aviation/aircraftsituation.h" -#include "blackmisc/simulation/simdirectaccessremoteaircraft.h" +#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/worker.h" #include #include diff --git a/src/blackcore/network.h b/src/blackcore/network.h index ba7cc750a..5440f57cd 100644 --- a/src/blackcore/network.h +++ b/src/blackcore/network.h @@ -12,7 +12,7 @@ #ifndef BLACKCORE_NETWORK_H #define BLACKCORE_NETWORK_H -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/aviation/aircraft.h" #include "blackmisc/pqfrequency.h" #include "blackmisc/coordinategeodetic.h" @@ -182,7 +182,7 @@ namespace BlackCore * Set simulator info before connecting. * \pre Network must be disconnected when calling this function. */ - virtual void presetSimulatorInfo(const BlackSim::CSimulatorPluginInfo &simInfo) = 0; + virtual void presetSimulatorInfo(const BlackMisc::Simulation::CSimulatorPluginInfo &simInfo) = 0; /*! * Initiate a connection to the network server. diff --git a/src/blackcore/network_vatlib.cpp b/src/blackcore/network_vatlib.cpp index 36c4319bc..ced770197 100644 --- a/src/blackcore/network_vatlib.cpp +++ b/src/blackcore/network_vatlib.cpp @@ -28,7 +28,7 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; using namespace BlackMisc; -using namespace BlackSim; +using namespace BlackMisc::Simulation; namespace BlackCore { diff --git a/src/blackcore/network_vatlib.h b/src/blackcore/network_vatlib.h index 117f53864..aebbe0add 100644 --- a/src/blackcore/network_vatlib.h +++ b/src/blackcore/network_vatlib.h @@ -13,7 +13,7 @@ #define BLACKCORE_NETWORK_VATLIB_H #include "network.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" #include "token_bucket.h" #include #include @@ -51,7 +51,7 @@ namespace BlackCore virtual void presetServer(const BlackMisc::Network::CServer &server) override; virtual void presetCallsign(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void presetIcaoCodes(const BlackMisc::Aviation::CAircraftIcao &icao) override; - virtual void presetSimulatorInfo(const BlackSim::CSimulatorPluginInfo &simInfo) override; + virtual void presetSimulatorInfo(const BlackMisc::Simulation::CSimulatorPluginInfo &simInfo) override; virtual void initiateConnection() override; virtual void terminateConnection() override; virtual void sendPing(const BlackMisc::Aviation::CCallsign &callsign) override; @@ -131,7 +131,7 @@ namespace BlackCore void changeConnectionStatus(VatConnectionStatus newStatus); bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; } static QString convertToUnicodeEscaped(const QString &str); - static VatSimType convertToSimType(BlackSim::CSimulatorPluginInfo &simInfo); + static VatSimType convertToSimType(BlackMisc::Simulation::CSimulatorPluginInfo &simInfo); static void networkLogHandler(SeverityLevel severity, const char *message); struct JsonPackets @@ -160,7 +160,7 @@ namespace BlackCore LoginMode m_loginMode; VatConnectionStatus m_status; BlackMisc::Network::CServer m_server; - BlackSim::CSimulatorPluginInfo m_simulatorInfo; + BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorInfo; BlackMisc::Aviation::CCallsign m_callsign; //!< "buffered callsign", as this must not change when connected BlackMisc::Aviation::CAircraftIcao m_icaoCode; //!< "buffered icao", as this must not change when connected bool m_sendInterimPositions = false; //!< send interim positions diff --git a/src/blackcore/settingsallclasses.h b/src/blackcore/settingsallclasses.h index e80ade19b..9b0baf8cc 100644 --- a/src/blackcore/settingsallclasses.h +++ b/src/blackcore/settingsallclasses.h @@ -7,6 +7,6 @@ #define BLACKCORE_SETTINGSALLCLASSES_H #include "blackmisc/settingsblackmiscclasses.h" -#include "blacksim/setsimulator.h" +#include "blackmisc/simulation/setsimulator.h" #endif // guard diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 07d5982f8..acf3dda16 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -15,7 +15,7 @@ using namespace BlackMisc; using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; using namespace BlackMisc::PhysicalQuantities; -using namespace BlackSim; +using namespace BlackMisc::Simulation; namespace BlackCore { diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index ba9a9182a..340f6f4a3 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -13,11 +13,11 @@ #define BLACKCORE_SIMULATOR_H #include "blackcore/interpolator.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/simulation/aircraftmodellist.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" -#include "blackmisc/simulation/simdirectaccessremoteaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" +#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/aviation/airportlist.h" #include "blackmisc/nwtextmessage.h" diff --git a/src/blackgui/blackgui.pro b/src/blackgui/blackgui.pro index 49c1bbced..7843ed26d 100644 --- a/src/blackgui/blackgui.pro +++ b/src/blackgui/blackgui.pro @@ -7,7 +7,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = blackgui TEMPLATE = lib CONFIG += staticlib -CONFIG += blackmisc blacksim blackcore +CONFIG += blackmisc blackcore INCLUDEPATH += .. DEPENDPATH += . .. @@ -19,8 +19,8 @@ precompile_header:!isEmpty(PRECOMPILED_HEADER) { DEFINES += LOG_IN_FILE -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksim.lib ../../lib/blackcore.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblacksim.a ../../lib/libblackcore.a +win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blackcore.lib +else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblackcore.a HEADERS += *.h diff --git a/src/blackgui/components/settingsfsxcomponent.cpp b/src/blackgui/components/settingsfsxcomponent.cpp index 037ad3b46..1afb39ed4 100644 --- a/src/blackgui/components/settingsfsxcomponent.cpp +++ b/src/blackgui/components/settingsfsxcomponent.cpp @@ -14,15 +14,15 @@ #include "blackmisc/networkutils.h" #include "blackmisc/statusmessage.h" #include "blackmisc/logmessage.h" -#include "blacksim/fsx/fsxsimulatorsetup.h" -#include "blacksim/fsx/simconnectutilities.h" +#include "blackmisc/simulation/fsx/fsxsimulatorsetup.h" +#include "blackmisc/simulation/fsx/simconnectutilities.h" #include #include #include #include using namespace BlackMisc; -using namespace BlackSim::Fsx; +using namespace BlackMisc::Simulation::Fsx; using namespace BlackMisc::Network; namespace BlackGui @@ -114,7 +114,7 @@ namespace BlackGui // write either local or remote file bool localSimulatorObject = this->getIContextSimulator()->isUsingImplementingObject(); bool success = localSimulatorObject ? - BlackSim::Fsx::CSimConnectUtilities::writeSimConnectCfg(fileName, address, p) : + BlackMisc::Simulation::Fsx::CSimConnectUtilities::writeSimConnectCfg(fileName, address, p) : this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p)); if (success) { @@ -148,7 +148,7 @@ namespace BlackGui else if (sender == this->ui->pb_SettingsFsxDeleteSimconnectCfg) { if (!this->getIContextSimulator()) return; - QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename(); + QString fileName = BlackMisc::Simulation::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename(); QString m = QString("Deleted %1 ").append(fileName); if (this->getIContextSimulator()->isUsingImplementingObject()) { @@ -166,7 +166,7 @@ namespace BlackGui else if (sender == this->ui->pb_SettingsFsxExistsSimconncetCfg) { if (!this->getIContextSimulator()) return; - QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename(); + QString fileName = BlackMisc::Simulation::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename(); bool exists = this->getIContextSimulator()->isUsingImplementingObject() ? QFile::exists(fileName) : this->getIContextApplication()->existsFile(fileName); diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index bdc371bce..3fae68a5f 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -4,8 +4,8 @@ #include "blackcore/context_settings.h" #include "blackcore/context_simulator.h" #include "blackcore/context_network.h" -#include "blacksim/simulatorinfolist.h" -#include "blacksim/setsimulator.h" +#include "blackmisc/simulation/simulatorinfolist.h" +#include "blackmisc/simulation/setsimulator.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/settingutilities.h" #include "blackmisc/logmessage.h" @@ -18,8 +18,8 @@ using namespace BlackMisc::Settings; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Simulation; using namespace BlackMisc::Aviation; -using namespace BlackSim; -using namespace BlackSim::Settings; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::Settings; using namespace BlackCore; namespace BlackGui diff --git a/src/blackgui/components/settingssimulatorcomponent.h b/src/blackgui/components/settingssimulatorcomponent.h index 8fc420522..f36565276 100644 --- a/src/blackgui/components/settingssimulatorcomponent.h +++ b/src/blackgui/components/settingssimulatorcomponent.h @@ -10,7 +10,7 @@ #ifndef BLACKGUI_SETTINGSSIMULATORCOMPONENT_H #define BLACKGUI_SETTINGSSIMULATORCOMPONENT_H -#include "blacksim/setsimulator.h" +#include "blackmisc/simulation/setsimulator.h" #include "enableforruntime.h" #include "enableforruntime.h" #include @@ -65,7 +65,7 @@ namespace BlackGui QScopedPointer ui; //!< UI //! Smarter way to set current driver, avoids unnecessary signals and less formatting dependend - void setCurrentPlugin(const BlackSim::CSimulatorPluginInfo &plugin); + void setCurrentPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &plugin); //! Set the GUI values void setRestrictedValues(); diff --git a/src/blackgui/foreignwindows.h b/src/blackgui/foreignwindows.h index 4a16dd578..cbba2229c 100644 --- a/src/blackgui/foreignwindows.h +++ b/src/blackgui/foreignwindows.h @@ -12,7 +12,7 @@ #ifndef BLACKGUI_FOREIGNWINDOWS_H #define BLACKGUI_FOREIGNWINDOWS_H -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "windowfinder.h" #include #include diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index 59495b8cb..4d9fa0083 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -1,7 +1,7 @@ include (../../config.pri) include (../../build.pri) -QT += network dbus +QT += network dbus xml TARGET = blackmisc TEMPLATE = lib @@ -27,13 +27,15 @@ HEADERS += *.h \ $$PWD/aviation/*.h \ $$PWD/math/*.h \ $$PWD/simulation/*.h \ - + $$PWD/simulation/fscommon\*.h \ + $$PWD/simulation/fsx\*.h SOURCES += *.cpp \ $$PWD/aviation/*.cpp \ $$PWD/math/*.cpp \ $$PWD/simulation/*.cpp \ - + $$PWD/simulation/fscommon\*.cpp \ + $$PWD/simulation/fsx\*.cpp DESTDIR = ../../lib OTHER_FILES += $$TRANSLATIONS readme.txt diff --git a/src/blackmisc/blackmiscfreefunctions_simmeta.cpp b/src/blackmisc/blackmiscfreefunctions_simmeta.cpp index 3623d9056..c04a0fdc9 100644 --- a/src/blackmisc/blackmiscfreefunctions_simmeta.cpp +++ b/src/blackmisc/blackmiscfreefunctions_simmeta.cpp @@ -8,7 +8,18 @@ */ #include "blackmiscfreefunctions.h" -#include "blackmisc/simulation/simulationallclasses.h" +#include "blackmisc/simulation/aircraftmodellist.h" +#include "blackmisc/simulation/simulatedaircraftlist.h" +#include "blackmisc/simulation/simulatorinfolist.h" +#include "blackmisc/simulation/setsimulator.h" +#include "blackmisc/simulation/fsx/simconnectutilities.h" +#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h" + +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::Fsx; +using namespace BlackMisc::Simulation::FsCommon; +using namespace BlackMisc::Simulation::Settings; + /* * Metadata for simulation @@ -18,6 +29,12 @@ */ void BlackMisc::Simulation::registerMetadata() { + CSimulatorPluginInfo::registerMetadata(); + CSimulatorPluginInfoList::registerMetadata(); + CSettingsSimulator::registerMetadata(); + FsCommon::CAircraftCfgEntries::registerMetadata(); + FsCommon::CAircraftCfgEntriesList::registerMetadata(); + Fsx::CSimConnectUtilities::registerMetadata(); CAircraftModel::registerMetadata(); CAircraftModelList::registerMetadata(); CSimulatedAircraft::registerMetadata(); diff --git a/src/blackmisc/nwaircraftmapping.h b/src/blackmisc/nwaircraftmapping.h index d21a7668e..e7936c0d1 100644 --- a/src/blackmisc/nwaircraftmapping.h +++ b/src/blackmisc/nwaircraftmapping.h @@ -76,7 +76,7 @@ namespace BlackMisc BlackMisc::Aviation::CAircraftIcao m_icao; //!< ICAO code BlackMisc::Simulation::CAircraftModel m_model; //!< aircraft model - // BlackSim::CSimulatorPluginInfo m_simulatorInfo; //!< Mapping is for simulator + // BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorInfo; //!< Mapping is for simulator }; } } diff --git a/src/blackmisc/simulation/aircraftmodel.h b/src/blackmisc/simulation/aircraftmodel.h index e764b09a3..1dfe842d6 100644 --- a/src/blackmisc/simulation/aircraftmodel.h +++ b/src/blackmisc/simulation/aircraftmodel.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKMISC_AIRCRAFTMODEL_H -#define BLACKMISC_AIRCRAFTMODEL_H +#ifndef BLACKMISC_SIMULATION_AIRCRAFTMODEL_H +#define BLACKMISC_SIMULATION_AIRCRAFTMODEL_H #include "blackmisc/aviation/aircraft.h" #include "blackmisc/aviation/aircrafticao.h" diff --git a/src/blackmisc/simulation/aircraftmodellist.h b/src/blackmisc/simulation/aircraftmodellist.h index 3991a78d6..106415455 100644 --- a/src/blackmisc/simulation/aircraftmodellist.h +++ b/src/blackmisc/simulation/aircraftmodellist.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKMISC_AIRCRAFTMODELLIST_H -#define BLACKMISC_AIRCRAFTMODELLIST_H +#ifndef BLACKMISC_SIMULATION_AIRCRAFTMODELLIST_H +#define BLACKMISC_SIMULATION_AIRCRAFTMODELLIST_H #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/collection.h" diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgentries.cpp b/src/blackmisc/simulation/fscommon/aircraftcfgentries.cpp new file mode 100644 index 000000000..8fd42a496 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/aircraftcfgentries.cpp @@ -0,0 +1,156 @@ +/* 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 "aircraftcfgentries.h" +#include "blackmisc/blackmiscfreefunctions.h" +#include "blackmisc/variant.h" + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Network; + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + /* + * Constructor + */ + CAircraftCfgEntries::CAircraftCfgEntries(const QString &filePath, qint32 index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode, const QString &description) : + m_index(index), m_fileName(filePath), m_title(title.trimmed()), m_atcType(atcType.trimmed()), + m_atcModel(atcModel.trimmed()), m_atcParkingCode(atcParkingCode.trimmed()), m_description(description.trimmed()) + { + // void + } + + /* + * String representation + */ + QString CAircraftCfgEntries::convertToQString(bool) const + { + QString s = "{%1, %2, %3, %4, %5, %6}"; + s = s.arg(this->m_fileName).arg(this->m_index).arg(this->m_title) + .arg(this->m_atcModel).arg(this->m_atcType).arg(this->m_atcParkingCode); + return s; + } + + /* + * Aircraft model + */ + QString CAircraftCfgEntries::getFileDirectory() const + { + if (this->m_fileName.isEmpty()) { return ""; } + QFileInfo fi(this->m_fileName); + return fi.absolutePath(); + } + + QString CAircraftCfgEntries::getUiCombinedDescription() const + { + QString d(this->m_uiManufacturer); + if (m_uiType.isEmpty()) { return d; } + if (d.isEmpty()) { return m_uiType; } + d += " "; + d += m_uiType; + return d; + } + + /* + * Convert + */ + CAircraftModel CAircraftCfgEntries::toAircraftModel() const + { + CAircraftModel model(this->getTitle(), CAircraftModel::TypeModelMapping); + model.setDescription(this->getUiCombinedDescription()); + model.setFileName(this->getFileName()); + return model; + } + + QString CAircraftCfgEntries::getThumbnailFileName() const + { + if (this->m_texture.isEmpty()) { return ""; } + if (this->m_fileName.isEmpty()) { return ""; } + QString fn = QDir::cleanPath(this->getFileDirectory() + QDir::separator() + "texture." + this->m_texture + QDir::separator() + "thumbnail.jpg"); + return fn; + } + + /* + * Get particular column + */ + CVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const + { + if (index.isMyself()) { return this->toCVariant(); } + ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexFileName: + return CVariant::from(this->m_fileName); + case IndexTitle: + return CVariant::from(this->m_title); + case IndexAtcType: + return CVariant::from(this->m_atcType); + case IndexAtcModel: + return CVariant::from(this->m_atcModel); + case IndexParkingCode: + return CVariant::from(this->m_atcParkingCode); + case IndexEntryIndex: + return CVariant::from(this->m_index); + case IndexTexture: + return CVariant::from(this->m_texture); + case IndexDescription: + return CVariant::from(this->m_description); + default: + return CValueObject::propertyByIndex(index); + } + } + + /* + * Set property as index + */ + void CAircraftCfgEntries::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) + { + if (index.isMyself()) { this->convertFromCVariant(variant); return; } + ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexAtcModel: + this->setAtcModel(variant.toQString()); + break; + case IndexAtcType: + this->setAtcType(variant.toQString()); + break; + case IndexEntryIndex: + this->setIndex(variant.toInt()); + break; + case IndexFileName: + this->setFileName(variant.toQString()); + break; + case IndexParkingCode: + this->setAtcParkingCode(variant.toQString()); + break; + case IndexTitle: + this->setTitle(variant.toQString()); + break; + case IndexDescription: + this->setDescription(variant.toQString()); + break; + case IndexTexture: + this->setTexture(variant.toQString()); + break; + default: + CValueObject::setPropertyByIndex(variant, index); + break; + } + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgentries.h b/src/blackmisc/simulation/fscommon/aircraftcfgentries.h new file mode 100644 index 000000000..d20197a21 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/aircraftcfgentries.h @@ -0,0 +1,154 @@ +/* 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 BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTCFGENTRY_H +#define BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTCFGENTRY_H + +#include "blackmisc/simulation/aircraftmodel.h" +#include "blackmisc/propertyindex.h" +#include "blackmisc/variant.h" + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + /*! + * Set of aircraft.cfg entries representing an aircraft (FSX) + * \remarks an entry in the aircraft.cfg is title, atc type, ... This class already bundles + * relevant entries, hence the class is named Entries (plural) + */ + class CAircraftCfgEntries: public BlackMisc::CValueObject + { + public: + //! Properties by index + enum ColumnIndex + { + IndexEntryIndex = BlackMisc::CPropertyIndex::GlobalIndexCAircraftCfgEntries, + IndexFileName, + IndexTitle, + IndexAtcType, + IndexAtcModel, + IndexParkingCode, + IndexDescription, + IndexTexture + }; + + //! Default constructor + CAircraftCfgEntries() = default; + + //! Entries representing an aircraft + CAircraftCfgEntries(const QString &filePath, int index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode, const QString &description); + + //! File name + QString getFileName() const { return this->m_fileName; } + + //! Directory of entry + QString getFileDirectory() const; + + //! Title + QString getTitle() const { return this->m_title; } + + //! Index + int getIndex() const { return this->m_index; } + + //! ATC model + QString getAtcModel() const { return this->m_atcModel; } + + //! ATC type + QString getAtcType() const { return this->m_atcType; } + + //! Description + QString getDescription() const { return this->m_description; } + + //! ATC parking code + QString getAtcParkingCode() const { return this->m_atcParkingCode; } + + //! UI type (e.g. A321-231 IAE) + QString getUiType() const { return this->m_uiType; } + + //! UI manufacturer (e.g. Airbus) + QString getUiManufacturer() const { return this->m_uiManufacturer; } + + //! Texture + QString getTexture() const { return this->m_texture; } + + //! Manufacturer + type + QString getUiCombinedDescription() const; + + //! Filepath + void setFileName(const QString &filePath) { this->m_fileName = filePath; } + + //! Title + void setTitle(const QString &title) { this->m_title = title; } + + //! Index + void setIndex(int index) { this->m_index = index; } + + //! ATC model + void setAtcModel(const QString &atcModel) { this->m_atcModel = atcModel.trimmed(); } + + //! ATC type + void setAtcType(const QString &atcType) { this->m_atcType = atcType.trimmed(); } + + //! Parking code + void setAtcParkingCode(const QString &parkingCode) { this->m_atcParkingCode = parkingCode.trimmed(); } + + //! Description + void setDescription(const QString &description) { this->m_description = description.trimmed(); } + + //! Texture + void setTexture(const QString &texture) { this->m_texture = texture; } + + //! UI type (e.g. A321-231 IAE) + void setUiType(const QString &type) { this->m_uiType = type.trimmed(); } + + //! UI manufacturer (e.g. Airbus) + void setUiManufacturer(const QString &manufacturer) { this->m_uiManufacturer = manufacturer.trimmed(); } + + //! To aircraft model + BlackMisc::Simulation::CAircraftModel toAircraftModel() const; + + //! Thumbnail.jpg path if possible + QString getThumbnailFileName() const; + + //! \copydoc CValueObject::propertyByIndex + virtual BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override; + + //! \copydoc CValueObject::setPropertyByIndex + virtual void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index) override; + + protected: + //! \copydoc CValueObject::convertToQString + virtual QString convertToQString(bool i18n = false) const override; + + private: + BLACK_ENABLE_TUPLE_CONVERSION(CAircraftCfgEntries) + int m_index; //!< current index in given config + QString m_fileName; //!< file name of aircraft.cfg + QString m_title; //!< Title in aircraft.cfg + QString m_atcType; //!< ATC type + QString m_atcModel; //!< ATC model + QString m_atcParkingCode; //!< ATC parking code + QString m_description; //!< descriptive text + QString m_uiType; //!< e.g. A321-231 IAE + QString m_uiManufacturer; //!< e.g. Airbus + QString m_texture; //!< texture, needed to identify thumbnail.jpg + }; + } + } +} + +BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::FsCommon::CAircraftCfgEntries, (o.m_index, o.m_fileName, o.m_title, o.m_atcType, o.m_atcModel, o.m_atcParkingCode)) +Q_DECLARE_METATYPE(BlackMisc::Simulation::FsCommon::CAircraftCfgEntries) + +#endif // guard diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp b/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp new file mode 100644 index 000000000..f34abcfdd --- /dev/null +++ b/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp @@ -0,0 +1,235 @@ +/* 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 "aircraftcfgentrieslist.h" +#include "blackmisc/predicates.h" +#include "blackmisc/logmessage.h" +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Network; + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + /* + * Does the directory exist? + */ + bool CAircraftCfgEntriesList::existsDir(const QString &directory) const + { + QString d = directory.isEmpty() ? this->m_rootDirectory : directory; + if (d.isEmpty()) { return false; } + QDir dir(d); + //! \todo not available network dir can make this hang here + return dir.exists(); + } + + /* + * Model for title + */ + bool CAircraftCfgEntriesList::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) + { + if (title.isEmpty()) { return false; } + return this->containsBy( + [ = ](const CAircraftCfgEntries & entries) -> bool { return title.compare(entries.getTitle(), caseSensitivity) == 0; } + ); + } + + /* + * Double titles + */ + QStringList CAircraftCfgEntriesList::detectAmbiguousTitles() const + { + QStringList titles = this->getTitles(true); + QStringList ambiguousTitles; + QString last; + for (const QString &title : titles) + { + if (title.isEmpty()) { continue; } + if (title.compare(last, Qt::CaseInsensitive) == 0) + { + if (!ambiguousTitles.contains(title, Qt::CaseInsensitive)) + { + ambiguousTitles.append(title); + } + } + last = title; + } + return ambiguousTitles; + } + + /* + * All titles + */ + QStringList CAircraftCfgEntriesList::getTitles(bool sorted) const + { + QStringList titles = this->transform(Predicates::MemberTransform(&CAircraftCfgEntries::getTitle)); + if (sorted) { titles.sort(Qt::CaseInsensitive); } + return titles; + } + + /* + * As model list + */ + CAircraftModelList CAircraftCfgEntriesList::toAircraftModelList() const + { + CAircraftModelList ml; + for (auto it = this->begin() ; it != this->end(); ++it) + { + ml.push_back(it->toAircraftModel()); + } + return ml; + } + + /* + * Models for title + */ + CAircraftCfgEntriesList CAircraftCfgEntriesList::findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) const + { + return this->findBy([ = ](const CAircraftCfgEntries & entries) -> bool + { return title.compare(entries.getTitle(), caseSensitivity) == 0; }); + } + + /* + * Read all entrities in given directory + */ + int CAircraftCfgEntriesList::read(const QString &directory, const QStringList &excludeDirectories) + { + if (m_cancelRead) { return -1; } + + // excluded? + for (const QString &excludeDir : excludeDirectories) + { + if (directory.contains(excludeDir, Qt::CaseInsensitive)) + { + CLogMessage(this).debug() << "Skipping directory " << directory; + return 0; + } + } + + // set directory with name filters, get aircraft.cfg and sub directories + QDir dir(directory, "aircraft.cfg", QDir::Name, QDir::Files | QDir::AllDirs); + if (!dir.exists()) return 0; // can happen if there are shortcuts or linked dirs not available + + int counter = 0; + QString currentDir = dir.absolutePath(); + + // Dirs last is crucial,since I will break recursion on "aircraft.cfg" level + QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::AllDirs, QDir::DirsLast); + + for (const QFileInfo &file : files) + { + if (m_cancelRead) { return -1; } + if (file.isDir()) + { + QString nextDir = file.absoluteFilePath(); + if (currentDir.startsWith(nextDir, Qt::CaseInsensitive)) continue; // do not go up + if (dir == currentDir) { continue; } // do not recursively call same directory + counter += CAircraftCfgEntriesList::read(nextDir, excludeDirectories); + } + else + { + // due to the filter we expect only "aircraft.cfg" here + QString path = file.absoluteFilePath(); + + // I abuse the QSettings as ini-file reader + QSettings aircraftCfg(path, QSettings::IniFormat); + + // from the general section + const QString atcType = aircraftCfg.value("atc_type").toString(); + const QString atcModel = aircraftCfg.value("atc_model").toString(); + + int index = 0; + while (index >= 0) + { + if (m_cancelRead) { return -1; } + QString group = QString("fltsim.%1").arg(index); + aircraftCfg.beginGroup(group); + + // does group exist? + if (aircraftCfg.contains("title")) + { + QString title = fixedStringContent(aircraftCfg, "title"); + if (!title.isEmpty()) + { + CAircraftCfgEntries entry(path, index, title, atcType, atcModel, "", ""); + entry.setAtcParkingCode(fixedStringContent(aircraftCfg, "atc_parking_codes")); + entry.setDescription(fixedStringContent(aircraftCfg, "description")); + entry.setUiManufacturer(fixedStringContent(aircraftCfg, "ui_manufacturer")); + entry.setUiType(fixedStringContent(aircraftCfg, "ui_type")); + entry.setTexture(fixedStringContent(aircraftCfg, "texture")); + this->push_back(entry); + } + else + { + CLogMessage(this).info("FSX model in %1, index %2 has no title") << path << index; + } + ++index; + ++counter; + } + else + { + // marks end of the "fltsim.x" groups + index = -1; + } + aircraftCfg.endGroup(); + } + break; + } + } + return counter; + } + + QString CAircraftCfgEntriesList::fixedStringContent(const QSettings &settings, const QString &key) + { + return fixedStringContent(settings.value(key)); + } + + QString CAircraftCfgEntriesList::fixedStringContent(const QVariant &qv) + { + if (qv.isNull() || !qv.isValid()) + { + return ""; // normal when there is no settings value + } + else if (static_cast(qv.type()) == QMetaType::QStringList) + { + QStringList l = qv.toStringList(); + return l.join(",").trimmed(); + } + else if (static_cast(qv.type()) == QMetaType::QString) + { + return qv.toString().trimmed(); + } + Q_ASSERT(false); + return ""; + } + + /* + * Register metadata + */ + void CAircraftCfgEntriesList::registerMetadata() + { + qRegisterMetaType>(); + qDBusRegisterMetaType>(); + qRegisterMetaType>(); + qDBusRegisterMetaType>(); + qRegisterMetaType(); + qDBusRegisterMetaType(); + BlackMisc::registerMetaValueType(); + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.h b/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.h new file mode 100644 index 000000000..fe8cfdf3b --- /dev/null +++ b/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.h @@ -0,0 +1,136 @@ +/* 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 BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTCFGLIST_H +#define BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTCFGLIST_H + +#include "blackmisc/simulation/fscommon/aircraftcfgentries.h" +#include "blackmisc/simulation/aircraftmodellist.h" +#include "blackmisc/sequence.h" +#include "blackmisc/collection.h" +#include +#include +#include +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + //! Utility, providing FS aircraft.cfg entries + class CAircraftCfgEntriesList : public BlackMisc::CSequence + { + + public: + + //! Constructor + CAircraftCfgEntriesList(const QString &rootDirectory = "") : m_rootDirectory(rootDirectory) {} + + //! Read all aircraft.cfg files starting from root directory + int read() + { + if (this->m_readForDirectory) { return this->size(); } + + // not read so far, read it + this->clear(); + this->m_readForDirectory = true; + return this->read(this->m_rootDirectory, excludeDirectories()); + } + + //! Change the directory + bool changeDirectory(const QString &directory) + { + if (this->m_rootDirectory != directory) + { + this->m_rootDirectory = directory; + this->m_readForDirectory = false; + } + return (!directory.isEmpty() && this->existsDir(directory)); + } + + //! Virtual destructor + virtual ~CAircraftCfgEntriesList() {} + + //! Does the directory exist? + bool existsDir(const QString &directory = "") const; + + //! Has current directory been read? + bool hasReadDirectory() const { return this->m_readForDirectory; } + + //! Cancel read + void cancelRead() { m_cancelRead = true; } + + //! Current root directory + QString getRootDirectory() const { return this->m_rootDirectory; } + + //! Contains model with title? + bool containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive); + + //! All titles (aka model names) + QStringList getTitles(bool sorted = false) const; + + //! As aircraft models + BlackMisc::Simulation::CAircraftModelList toAircraftModelList() const; + + //! Ambiguous titles + QStringList detectAmbiguousTitles() const; + + //! Find by title + CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const; + + //! \copydoc CValueObject::toQVariant + virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); } + + //! \copydoc CValueObject::convertFromQVariant + virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); } + + //! Do not include the following directories for FS + static const QStringList &excludeDirectories() + { + static const QStringList exclude + { + "SimObjects/Animals", + "SimObjects/Misc", + "SimObjects/GroundVehicles", + "SimObjects/Boats" + }; + return exclude; + } + + //! Register metadata + static void registerMetadata(); + + private: + QString m_rootDirectory; //!< root directory reading aircraft.cfg files + bool m_readForDirectory = false; //!< valid read for given directory + bool m_cancelRead = false; + + //! Read all entries in one directory + int read(const QString &directory, const QStringList &excludeDirectories = QStringList()); + + //! Fix the content read + static QString fixedStringContent(const QVariant &qv); + + //! Value from settings, fixed string + static QString fixedStringContent(const QSettings &settings, const QString &key); + }; + } // namespace + } // namespace +} // namespace + +Q_DECLARE_METATYPE(BlackMisc::Simulation::FsCommon::CAircraftCfgEntriesList) +Q_DECLARE_METATYPE(BlackMisc::CCollection) +Q_DECLARE_METATYPE(BlackMisc::CSequence) + +#endif // guard diff --git a/src/blackmisc/simulation/fscommon/aircraftmapper.cpp b/src/blackmisc/simulation/fscommon/aircraftmapper.cpp new file mode 100644 index 000000000..0ec99e204 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/aircraftmapper.cpp @@ -0,0 +1,186 @@ +/* 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 "aircraftmapper.h" +#include "blackmisc/logmessage.h" +#include "blackmisc/worker.h" +#include + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Network; +using namespace BlackMisc::Aviation; + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + CAircraftMapper::CAircraftMapper(QObject *parent) : QObject(parent) { } + + CAircraftMapper::CAircraftMapper(std::unique_ptr mappings, QObject *parent) : + QObject(parent), m_mappings(mappings.release()) + { } + + CAircraftMapper::CAircraftMapper(std::unique_ptr mappings, const QString &simObjectsDir, QObject *parent) : + QObject(parent), m_mappings(mappings.release()) + { + this->m_entries.changeDirectory(simObjectsDir); + } + + CAircraftMapper::~CAircraftMapper() + { + this->gracefulShutdown(); + } + + int CAircraftMapper::readSimObjects(const QString &simObjectDir) + { + if (!simObjectDir.isEmpty()) { m_entries.changeDirectory(simObjectDir); } + int n = m_entries.read(); + emit entriesRead(n); + return n; + } + + void CAircraftMapper::initCompletelyInBackground(const QString &simObjectDir) + { + if (this->m_initWorker) { return; } + this->m_initWorker = BlackMisc::CWorker::fromTask(this, "CAircraftMapper::initCompletely", [this, simObjectDir]() + { + this->initCompletely(simObjectDir); + }); + } + + bool CAircraftMapper::isInitialized() const + { + return m_init; + } + + CAircraftIcao CAircraftMapper::getIcaoForModelString(const QString &modelString) const + { + if (modelString.isEmpty() || !this->isInitialized()) { return CAircraftIcao(); } + CAircraftMappingList mappings = this->m_mappings->getMappingList().findByModelString(modelString); + if (mappings.isEmpty()) { return CAircraftIcao(); } + return mappings.front().getIcao(); + } + + bool CAircraftMapper::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) + { + return this->m_entries.containsModelWithTitle(title, caseSensitivity); + } + + CAircraftModel CAircraftMapper::getModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) const + { + CAircraftCfgEntriesList el = this->m_entries.findByTitle(title, caseSensitivity); + if (el.isEmpty()) { return CAircraftModel(); } + CAircraftModel model = el.front().toAircraftModel(); + CAircraftIcao icao = this->getIcaoForModelString(model.getModelString()); + model.setIcao(icao); + return model; + } + + int CAircraftMapper::synchronize() + { + Q_ASSERT(this->m_mappings); + if (!this->m_mappings) { return 0; } + return this->m_mappings->synchronizeWithExistingModels(this->m_entries.getTitles(true)); + } + + void CAircraftMapper::gracefulShutdown() + { + // when running, force re-init + this->m_entries.cancelRead(); + this->m_initInProgress = false; + this->m_init = false; + } + + void CAircraftMapper::markUninitialized() + { + this->m_init = false; + } + + const CAircraftModel &CAircraftMapper::getDefaultModel() + { + static const CAircraftModel aircraftModel( + "Boeing 737-800 Paint1", + CAircraftModel::TypeModelMatchingDefaultModel, + "B737-800 default model", + CAircraftIcao("B738", "L2J", "", "", "FFFFFF") + ); + return aircraftModel; + } + + bool CAircraftMapper::initCompletely(QString simObjectDir) + { + if (this->m_init) { return true; } + if (this->m_initInProgress) { return false; } + this->m_initInProgress = true; + if (!this->m_mappings) + { + CLogMessage(this).error("Missing mapping defintions"); + emit initCompleted(false); + this->m_initInProgress = false; + return false; + } + + if (!m_entries.existsDir(simObjectDir)) + { + CLogMessage(this).error("Mapping engine, cannot read Flight Simulator directory: %1") << simObjectDir; + emit initCompleted(false); + this->m_initInProgress = false; + return false; + } + + // read the defintions (if required) + int mappingSize = this->m_mappings->size(); + if (mappingSize < 1) + { + this->m_mappings->read(); + mappingSize = this->m_mappings->size(); + if (mappingSize < 1) + { + CLogMessage(this).error("Reading mapping rules failed or empty"); + emit initCompleted(false); + this->m_initInProgress = false; + return false; + } + } + CLogMessage(this).debug() << "Mapping definitions" << mappingSize; + + // read sim objects, can take a while + int simObjectsSize = this->m_entries.size(); + if (simObjectsSize < 1) + { + simObjectsSize = this->readSimObjects(simObjectDir); + if (simObjectsSize < 1) + { + CLogMessage(this).error("No SimObjects found in %1") << simObjectDir; + emit initCompleted(false); + this->m_initInProgress = false; + return false; + } + } + simObjectsSize = this->m_entries.size(); + CLogMessage(this).info("Read %1 SimObjects from %2") << simObjectsSize << m_entries.getRootDirectory(); + + // sync + this->synchronize(); + CLogMessage(this).debug() << "Mapping definitions after sync" << this->m_mappings->size(); + + // finish + CLogMessage(this).info("Mapping system: %1 definitions for %2 entries") << this->m_mappings->size() << this->m_entries.size(); + emit initCompleted(true); + this->m_initInProgress = false; + this->m_init = true; + return true; + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fscommon/aircraftmapper.h b/src/blackmisc/simulation/fscommon/aircraftmapper.h new file mode 100644 index 000000000..2ca79adfa --- /dev/null +++ b/src/blackmisc/simulation/fscommon/aircraftmapper.h @@ -0,0 +1,120 @@ +/* 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 BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTMAPPER_H +#define BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTMAPPER_H + +#include "aircraftcfgentrieslist.h" +#include "../simulatormodelmappings.h" +#include "blackmisc/worker.h" +#include +#include +#include +#include +#include +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + //! Mapper for all models (works for FS9/FSX). + //! \details Reads all the mapping rules and all the available flight simulator models. + //! Then all rules for models not existing are eliminated ( \sa synchronize ). + //! Thereafter all existing models and mappings can be obtained from here. + //! \sa CAircraftCfgEntries + //! \sa CAircraftCfgEntriesList + class CAircraftMapper : public QObject + { + Q_OBJECT + + signals: + //! Number of entries read + void entriesRead(int number); + + //! Full init completed + void initCompleted(bool success); + + public: + //! Default constructor + CAircraftMapper(QObject *parent = nullptr); + + //! Constructor, handing over ownership or mappings object + CAircraftMapper(std::unique_ptr mappings, QObject *parent = nullptr); + + //! Constructor, handing over ownership or mappings object + CAircraftMapper(std::unique_ptr mappings, const QString &simObjectsDir, QObject *parent = nullptr); + + //! Destructor + ~CAircraftMapper(); + + //! Completely init + bool initCompletely(QString simObjectDir); + + //! Read for directory or re-read + int readSimObjects(const QString &simObjectDir = ""); + + //! Init in background + void initCompletelyInBackground(const QString &simObjectDir = ""); + + //! Init completed? + bool isInitialized() const; + + //! Get all aircraft entries (aka models available) + const CAircraftCfgEntriesList &getAircraftCfgEntriesList() const { return m_entries; } + + //! Get all mappings + const BlackMisc::Network::CAircraftMappingList &getAircraftMappingList() const { return m_mappings->getMappingList(); } + + //! Inverse lookup + BlackMisc::Aviation::CAircraftIcao getIcaoForModelString(const QString &modelString) const; + + //! Number of aircraft entries + int countAircraftCfgEntries() const { return m_entries.size(); } + + //! Number of mapping definitions + int countMappingRules() const { return m_mappings ? m_mappings->size() : 0; } + + //! Set the directory + bool changeCAircraftCfgEntriesDirectory(const QString &directory) { return this->m_entries.changeDirectory(directory); } + + //! Contains model with title? + bool containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive); + + //! Model with title + BlackMisc::Simulation::CAircraftModel getModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const; + + //! Synchronize models and mappings + //! \remarks after this step, we only have mappings for which we have models + int synchronize(); + + //! Shutdown + void gracefulShutdown(); + + //! To force reload + void markUninitialized(); + + //! default model + static const BlackMisc::Simulation::CAircraftModel &getDefaultModel(); + + private: + QScopedPointer m_mappings; //!< all mapping definitions + CAircraftCfgEntriesList m_entries; //!< all entries + bool m_init = false; + bool m_initInProgress = false; + BlackMisc::CWorker *m_initWorker = nullptr; + }; + } // namespace + } // namespace +} // namespace +#endif // guard diff --git a/src/blackmisc/simulation/fscommon/bcdconversions.cpp b/src/blackmisc/simulation/fscommon/bcdconversions.cpp new file mode 100644 index 000000000..49e2bed3d --- /dev/null +++ b/src/blackmisc/simulation/fscommon/bcdconversions.cpp @@ -0,0 +1,53 @@ +/* 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 "bcdconversions.h" + +using namespace BlackMisc::PhysicalQuantities; +using namespace BlackMisc::Aviation; + + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + quint32 CBcdConversions::comFrequencyToBcdHz(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) + { + // FSX documentation is wrong, we need to use kHz + 2 digits, not Hz + quint32 f = comFrequency.valueRounded(CFrequencyUnit::kHz(), 0) / 10; + f = dec2Bcd(f); + return f; + } + + quint32 CBcdConversions::transponderCodeToBcd(const BlackMisc::Aviation::CTransponder &transponder) + { + // FSX documentation is wrong, we need to use kHz + 2 digits, not Hz + quint32 t = transponder.getTransponderCode(); + t = dec2Bcd(t); + return t; + } + + quint32 CBcdConversions::hornerScheme(quint32 num, quint32 divider, quint32 factor) + { + quint32 remainder = 0, quotient = 0, result = 0; + remainder = num % divider; + quotient = num / divider; + if (!(quotient == 0 && remainder == 0)) + { + result += hornerScheme(quotient, divider, factor) * factor + remainder; + } + return result; + } + + } // namespace + } // namespace +} // namespacee diff --git a/src/blackmisc/simulation/fscommon/bcdconversions.h b/src/blackmisc/simulation/fscommon/bcdconversions.h new file mode 100644 index 000000000..fd6680bc0 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/bcdconversions.h @@ -0,0 +1,54 @@ +/* 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 BLACKMISC_SIMULATION_FSCOMMON_BCDCONVERSIONS_H +#define BLACKMISC_SIMULATION_FSCOMMON_BCDCONVERSIONS_H + +#include "blackmisc/pqfrequency.h" +#include "blackmisc/aviation/transponder.h" +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + //! BCD conversions for FS + class CBcdConversions + { + public: + //! BCD -> decimal + static quint32 bcd2Dec(quint32 bcdNum) { return hornerScheme(bcdNum, 0x10, 10); } + + //! Decimal -> BCD + static quint32 dec2Bcd(quint32 decNum) { return hornerScheme(decNum, 10, 0x10); } + + //! COM Frequency to BCD + static quint32 comFrequencyToBcdHz(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency); + + //! Transponder code to BCD + static quint32 transponderCodeToBcd(const BlackMisc::Aviation::CTransponder &transponder); + + private: + //! Constructor, only static methods + CBcdConversions() {} + + //! Horner scheme + static quint32 hornerScheme(quint32 num, quint32 divider, quint32 factor); + }; + + } // ns + } // ns +} // ns + +#endif // guard diff --git a/src/blackmisc/simulation/fscommon/fscommon.h b/src/blackmisc/simulation/fscommon/fscommon.h new file mode 100644 index 000000000..a369d1a57 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/fscommon.h @@ -0,0 +1,12 @@ +#ifndef BLACKMISC_SIMULATION_FSCOMMON_NAMESPACES_H +#define BLACKMISC_SIMULATION_FSCOMMON_NAMESPACES_H + +// just a dummy header, namespace documentation will go here +/*! \file */ + +/*! + * \namespace FsCommon + * \brief Utility classes for FSX, P3D and FS9, OS and driver independent code + */ + +#endif // guard diff --git a/src/blackmisc/simulation/fscommon/fscommonutil.cpp b/src/blackmisc/simulation/fscommon/fscommonutil.cpp new file mode 100644 index 000000000..c2fe26d62 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/fscommonutil.cpp @@ -0,0 +1,52 @@ +/* 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 "blackmisc/project.h" +#include "fscommonutil.h" +#include +#include + +using namespace BlackMisc; + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + QString CFsCommonUtil::fsxDirFromRegistry() + { + QString fsxPath; + if (CProject::isCompiledWithFsxSupport()) + { + // set FSX path + QSettings fsxRegistry("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat); + fsxPath = fsxRegistry.value("AppPath").toString().trimmed(); + if (fsxPath.isEmpty()) + { + // another trial + QSettings fsxRegistry("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat); + fsxPath = fsxRegistry.value("SetupPath").toString().trimmed(); + } + } + return fsxPath; + } + + QString CFsCommonUtil::fsxSimObjectsDirFromRegistry() + { + QString fsxPath = fsxDirFromRegistry(); + if (fsxPath.isEmpty()) { return ""; } + fsxPath = QDir(fsxPath).filePath("SimObjects"); + return fsxPath; + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fscommon/fscommonutil.h b/src/blackmisc/simulation/fscommon/fscommonutil.h new file mode 100644 index 000000000..e6cb389c2 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/fscommonutil.h @@ -0,0 +1,41 @@ +/* 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 BLACKMISC_SIMULATION_FSCOMMONUTIL_H +#define BLACKMISC_SIMULATION_FSCOMMONUTIL_H + +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + //! FS9/X utils + class CFsCommonUtil + { + public: + CFsCommonUtil(); + + //! FSX directory obtained from registry + static QString fsxDirFromRegistry(); + + //! FSX's simObject directory from registry + static QString fsxSimObjectsDirFromRegistry(); + + }; + + } // namespace + } // namespace +} // namespace + +#endif // guard diff --git a/src/blackmisc/simulation/fscommon/vpilotmodelmappings.cpp b/src/blackmisc/simulation/fscommon/vpilotmodelmappings.cpp new file mode 100644 index 000000000..9c8b111e6 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/vpilotmodelmappings.cpp @@ -0,0 +1,133 @@ +/* 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 "vpilotmodelmappings.h" +#include "blackmisc/nwaircraftmapping.h" + +#include +#include +#include +#include + +using namespace BlackMisc::Network; + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + + CVPilotModelMappings::CVPilotModelMappings(bool standardDirectory, QObject *parent) : + ISimulatorModelMappings(parent) + { + if (standardDirectory) { this->addDirectory(CVPilotModelMappings::standardMappingsDirectory()); } + } + + void CVPilotModelMappings::addFilename(const QString &fileName) + { + if (this->m_fileList.contains(fileName)) return; + this->m_fileList.append(fileName); + } + + void CVPilotModelMappings::addDirectory(const QString &directory) + { + QDir dir(directory); + if (!dir.exists()) return; + QStringList nameFilters({"*.vmr"}); + QFileInfoList entries = dir.entryInfoList(nameFilters, QDir::Files | QDir::Readable); + for (const QFileInfo &file : entries) + { + this->addFilename(file.absoluteFilePath()); + } + } + + const QString &CVPilotModelMappings::standardMappingsDirectory() + { + static QString directory; + if (directory.isEmpty()) + { + directory = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first(); + if (!directory.endsWith('/')) directory.append('/'); + directory.append("vPilot Files/Model Matching Rule Sets"); + } + return directory; + } + + bool CVPilotModelMappings::read() + { + bool success = true; + this->m_loadedFiles = 0; + this->m_fileListWithProblems.clear(); + for (const QString &fn : this->m_fileList) + { + this->m_loadedFiles++; + bool s = this->loadFile(fn); + if (!s) { this->m_fileListWithProblems.append(fn); } + success = s && success; + } + return success; + } + + bool CVPilotModelMappings::loadFile(const QString &fileName) + { + QFile f(fileName); + if (!f.exists()) { return false; } + if (!f.open(QFile::ReadOnly | QFile::Text)) { return false; } + QByteArray fc = f.readAll(); + if (fc.isEmpty()) { return false; } + QDomDocument doc; + if (!doc.setContent(fc)) { return false; } + QDomNodeList rules = doc.elementsByTagName("ModelMatchRule"); + if (rules.isEmpty()) { return false; } + + QString folder; + QString updated; + QDomNodeList mmRuleSet = doc.elementsByTagName("ModelMatchRuleSet"); + if (mmRuleSet.size() > 0) + { + QDomNamedNodeMap attributes = mmRuleSet.at(0).attributes(); + folder = attributes.namedItem("Folder").nodeValue(); + updated = attributes.namedItem("UpdatedOn").nodeValue(); + } + int rulesSize = rules.size(); + for (int i = 0; i < rulesSize; i++) + { + QDomNamedNodeMap attributes = rules.at(i).attributes(); + const QString typeCode = attributes.namedItem("TypeCode").nodeValue(); + const QString modelName = attributes.namedItem("ModelName").nodeValue(); + // remark, callsign prefix is airline ICAO code + const QString airlineCode = attributes.namedItem("CallsignPrefix").nodeValue(); + if (modelName.isEmpty()) { continue; } + + // split if we have multiple models + if (modelName.contains("//")) + { + // multiple models + const QStringList models = modelName.split("//"); + for (const QString &model : models) + { + if (model.isEmpty()) { continue; } + CAircraftMapping mapping("vpilot", folder, typeCode, airlineCode, model); + this->m_mappings.push_back(mapping); + } + } + else + { + // single model + CAircraftMapping mapping("vpilot", folder, typeCode, airlineCode, modelName); + this->m_mappings.push_back(mapping); + } + } + return true; + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fscommon/vpilotmodelmappings.h b/src/blackmisc/simulation/fscommon/vpilotmodelmappings.h new file mode 100644 index 000000000..0cce746c9 --- /dev/null +++ b/src/blackmisc/simulation/fscommon/vpilotmodelmappings.h @@ -0,0 +1,61 @@ +/* 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 BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H +#define BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H + +#include "../simulatormodelmappings.h" +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace FsCommon + { + //! Model mappings + class CVPilotModelMappings : public ISimulatorModelMappings + { + public: + //! Constructor + CVPilotModelMappings(bool standardDirectory, QObject *parent = nullptr); + + //! Destructor + virtual ~CVPilotModelMappings() {} + + //! File names + void addFilename(const QString &fileName); + + //! Directory with .vmr files + void addDirectory(const QString &directory); + + //! Loaded files (number) + int countFilesLoaded() const { return m_loadedFiles; } + + //! The standard directory for vPilot mappings + static const QString &standardMappingsDirectory(); + + public slots: + //! Load data + virtual bool read() override; + + private: + QStringList m_fileList; //!< list of file names + QStringList m_fileListWithProblems; //!< problems during parsing + int m_loadedFiles = 0; //!< loaded files + + //! Single file read and parsing + bool loadFile(const QString &fileName); + }; + } // namespace + } // namespace +} // namespace +#endif // guard diff --git a/src/blacksim/fsx/fsx.h b/src/blackmisc/simulation/fsx/fsx.h similarity index 77% rename from src/blacksim/fsx/fsx.h rename to src/blackmisc/simulation/fsx/fsx.h index b223b984b..4ffc2898c 100644 --- a/src/blacksim/fsx/fsx.h +++ b/src/blackmisc/simulation/fsx/fsx.h @@ -7,15 +7,15 @@ * contained in the LICENSE file. */ -#ifndef FSX_NAMESPACES_H -#define FSX_NAMESPACES_H +#ifndef BLACKMISC_SIMULATION_FSX_NAMESPACES_H +#define BLACKMISC_SIMULATION_FSX_NAMESPACES_H // just a dummy header, namespace documentation will go here //! \file /*! * \namespace FSX - * \brief Utility classes for FSX + * \brief Utility classes for FSX, OS and driver independent code */ #endif // guard diff --git a/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp b/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp new file mode 100644 index 000000000..4ffe3e825 --- /dev/null +++ b/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp @@ -0,0 +1,41 @@ +/* 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 "fsxsimulatorsetup.h" + +#include "blackmisc/project.h" +#include "blackmisc/simulation/fscommon/fscommonutil.h" +#include "blackmisc/simulation/fsx/simconnectutilities.h" + +#include + +using namespace BlackMisc; +using namespace BlackMisc::Simulation::FsCommon; + +namespace BlackMisc +{ + namespace Simulation + { + namespace Fsx + { + void CFsxSimulatorSetup::init() + { + CSimulatorSetup::init(); + this->m_setup.addValue(SetupSimConnectCfgFile, CSimConnectUtilities::getLocalSimConnectCfgFilename()); + + if (CProject::isCompiledWithFsxSupport()) + { + // set FSX path + QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); + if (!fsxPath.isEmpty()) this->m_setup.value(CSimulatorSetup::SetupSimPath, CVariant(fsxPath)); + } + } + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fsx/fsxsimulatorsetup.h b/src/blackmisc/simulation/fsx/fsxsimulatorsetup.h new file mode 100644 index 000000000..a5ada7b2b --- /dev/null +++ b/src/blackmisc/simulation/fsx/fsxsimulatorsetup.h @@ -0,0 +1,51 @@ +/* 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 BLACKMISC_SIMULATION_FSX_SIMSETUP_H +#define BLACKMISC_SIMULATION_FSX_SIMSETUP_H + +#include "../simulatorsetup.h" +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace Fsx + { + /*! + * Simulator settings for FSX Flight simulators + */ + class CFsxSimulatorSetup : public BlackMisc::Simulation::CSimulatorSetup + { + + public: + //! Setup values + enum + { + SetupSimConnectCfgFile = (BlackMisc::CPropertyIndex::GlobalIndexAbuseMode + 100), //!< location of simconnect.cfg file + }; + + + //! Default constructor + CFsxSimulatorSetup() : BlackMisc::Simulation::CSimulatorSetup() {} + + //! Constructor + CFsxSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &map) : BlackMisc::Simulation::CSimulatorSetup(map) {} + + //! Init, to be used where FSX runs + void init(); + }; + } // namespace + } // namespace +} // namespace + +#endif // guard diff --git a/src/blackmisc/simulation/fsx/simconnectutilities.cpp b/src/blackmisc/simulation/fsx/simconnectutilities.cpp new file mode 100644 index 000000000..e63fd7c62 --- /dev/null +++ b/src/blackmisc/simulation/fsx/simconnectutilities.cpp @@ -0,0 +1,96 @@ +/* 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 "simconnectutilities.h" +#include +#include +#include + +namespace BlackMisc +{ + namespace Simulation + { + namespace Fsx + { + CSimConnectUtilities::CSimConnectUtilities() { } + + // + // Filename / path of a "local" SimConnect.cfg file + // + QString CSimConnectUtilities::getLocalSimConnectCfgFilename() + { + return QCoreApplication::applicationDirPath() + "/SimConnect.cfg"; + } + + // + // Create a very simple SimConnect.cfg + // + bool CSimConnectUtilities::writeSimConnectCfg(const QString &fileName, const QString &ip, int port) + { + QString sc = CSimConnectUtilities::simConnectCfg(ip, port); + QFile file(fileName); + bool success = false; + if ((success = file.open(QIODevice::WriteOnly | QIODevice::Text))) + { + QTextStream out(&file); + out << sc; + file.close(); + } + return success; + } + + // + // simconnect.cfg file + // + QString CSimConnectUtilities::simConnectCfg(const QString &ip, int port) + { + QString sc = QString("[SimConnect]\nProtocol=Ipv4\nAddress=%1\nPort=%2\n" + "MaxReceiveSize=4096\nDisableNagle=0").arg(ip).arg(port); + return sc; + } + + // + // Resolve enum id to string + // http://labs.qt.nokia.com/2008/10/09/coding-tip-pretty-printing-enum-values/ + // + const QString CSimConnectUtilities::resolveEnumToString(const DWORD id, const char *enumName) + { + int i = CSimConnectUtilities::staticMetaObject.indexOfEnumerator(enumName); + if (i < 0) return QString("No enumerator for %1").arg(enumName); + QMetaEnum m = CSimConnectUtilities::staticMetaObject.enumerator(i); + const char *k = m.valueToKey(id); + return (k) ? QLatin1String(k) : QString("Id %1 not found for %2").arg(id).arg(enumName); + } + + // + // Exception id to something human readible + // + const QString CSimConnectUtilities::simConnectExceptionToString(const DWORD id) + { + return CSimConnectUtilities::resolveEnumToString(id, "SIMCONNECT_EXCEPTION"); + } + + // + // The surface types + // + const QString CSimConnectUtilities::simConnectSurfaceTypeToString(const DWORD type, bool beautify) + { + QString sf = CSimConnectUtilities::resolveEnumToString(type, "SIMCONNECT_SURFACE"); + return beautify ? sf.replace('_', ' ') : sf; + } + + void CSimConnectUtilities::registerMetadata() + { + qRegisterMetaType(); + qRegisterMetaType(); + } + + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/fsx/simconnectutilities.h b/src/blackmisc/simulation/fsx/simconnectutilities.h new file mode 100644 index 000000000..36873d48f --- /dev/null +++ b/src/blackmisc/simulation/fsx/simconnectutilities.h @@ -0,0 +1,176 @@ +/* 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 BLACKMISC_SIMULATION_FSX_SIMCONNECTUTILITIES_H +#define BLACKMISC_SIMULATION_FSX_SIMCONNECTUTILITIES_H + +#include +#include + +// Apart from the below definitions, the following code is OS independent, +// though it does not make sense to be used on non WIN machines. +// But it allows such parts to compile on all platforms. +#ifdef Q_OS_WIN +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +#else +typedef unsigned long DWORD; //!< Fake Windows DWORD +#endif + +namespace BlackMisc +{ + namespace Simulation + { + namespace Fsx + { + //! Utilities for SimConnect + class CSimConnectUtilities : public QObject + { + Q_OBJECT + Q_ENUMS(SIMCONNECT_EXCEPTION) + Q_ENUMS(SIMCONNECT_SURFACE) + + public: + //! Path to local config file + static QString getLocalSimConnectCfgFilename(); + + /*! + * Content for FSX simconnect.cfg file + * \param ip IP address of FSX + * \param port Port of FSX (e.g. 500) + * \return content for simconnect.cfg + */ + static QString simConnectCfg(const QString &ip, int port = 500); + + /*! + * Create a FSX simconnect.cfg file + * \param fileName and path + * \param ip IP address of FSX + * \param port Port of FSX (e.g. 500) + * \return success + */ + static bool writeSimConnectCfg(const QString &fileName, const QString &ip, int port = 500); + + /*! + * Resolve SimConnect exception (based on Qt metadata). + * \param id enum element + * \return enum element's name + */ + static const QString simConnectExceptionToString(const DWORD id); + + /*! + * Resolve SimConnect surface (based on Qt metadata). + * \param type enum element + * \param beautify remove "_" + * \return + */ + static const QString simConnectSurfaceTypeToString(const DWORD type, bool beautify = true); + + //! SimConnect surfaces. + // http://msdn.microsoft.com/en-us/library/cc526981.aspx#AircraftFlightInstrumentationData + enum SIMCONNECT_SURFACE + { + Concrete, + Grass, + Water, + Grass_bumpy, + Asphalt, + Short_grass, + Long_grass, + Hard_turf, + Snow, + Ice, + Urban, + Forest, + Dirt, + Coral, + Gravel, + Oil_treated, + Steel_mats, + Bituminus, + Brick, + Macadam, + Planks, + Sand, + Shale, + Tarmac, + Wright_flyer_track + }; + + //! SimConnect exceptions. + enum SIMCONNECT_EXCEPTION + { + SIMCONNECT_EXCEPTION_NONE, + SIMCONNECT_EXCEPTION_ERROR, + SIMCONNECT_EXCEPTION_SIZE_MISMATCH, + SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID, + SIMCONNECT_EXCEPTION_UNOPENED, + SIMCONNECT_EXCEPTION_VERSION_MISMATCH, + SIMCONNECT_EXCEPTION_TOO_MANY_GROUPS, + SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED, + SIMCONNECT_EXCEPTION_TOO_MANY_EVENT_NAMES, + SIMCONNECT_EXCEPTION_EVENT_ID_DUPLICATE, + SIMCONNECT_EXCEPTION_TOO_MANY_MAPS, + SIMCONNECT_EXCEPTION_TOO_MANY_OBJECTS, + SIMCONNECT_EXCEPTION_TOO_MANY_REQUESTS, + SIMCONNECT_EXCEPTION_WEATHER_INVALID_PORT, + SIMCONNECT_EXCEPTION_WEATHER_INVALID_METAR, + SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_GET_OBSERVATION, + SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_CREATE_STATION, + SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_REMOVE_STATION, + SIMCONNECT_EXCEPTION_INVALID_DATA_TYPE, + SIMCONNECT_EXCEPTION_INVALID_DATA_SIZE, + SIMCONNECT_EXCEPTION_DATA_ERROR, + SIMCONNECT_EXCEPTION_INVALID_ARRAY, + SIMCONNECT_EXCEPTION_CREATE_OBJECT_FAILED, + SIMCONNECT_EXCEPTION_LOAD_FLIGHTPLAN_FAILED, + SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE, + SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION, + SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED, + SIMCONNECT_EXCEPTION_INVALID_ENUM, + SIMCONNECT_EXCEPTION_DEFINITION_ERROR, + SIMCONNECT_EXCEPTION_DUPLICATE_ID, + SIMCONNECT_EXCEPTION_DATUM_ID, + SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS, + SIMCONNECT_EXCEPTION_ALREADY_CREATED, + SIMCONNECT_EXCEPTION_OBJECT_OUTSIDE_REALITY_BUBBLE, + SIMCONNECT_EXCEPTION_OBJECT_CONTAINER, + SIMCONNECT_EXCEPTION_OBJECT_AI, + SIMCONNECT_EXCEPTION_OBJECT_ATC, + SIMCONNECT_EXCEPTION_OBJECT_SCHEDULE + }; + + //! Register metadata + static void registerMetadata(); + + private: + /*! + * Resolve enum value to its cleartext (based on Qt metadata). + * \param id enum element + * \param enumName name of the resolved enum + * \return enum element's name + */ + static const QString resolveEnumToString(const DWORD id, const char *enumName); + + //! Hidden constructor + CSimConnectUtilities(); + + }; + } // namespace + } // namespace +} // namespace + +Q_DECLARE_METATYPE(BlackMisc::Simulation::Fsx::CSimConnectUtilities::SIMCONNECT_EXCEPTION) +Q_DECLARE_METATYPE(BlackMisc::Simulation::Fsx::CSimConnectUtilities::SIMCONNECT_SURFACE) + +#endif // guard diff --git a/src/blackmisc/simulation/simdirectaccessownaircraft.cpp b/src/blackmisc/simulation/ownaircraftprovider.cpp similarity index 98% rename from src/blackmisc/simulation/simdirectaccessownaircraft.cpp rename to src/blackmisc/simulation/ownaircraftprovider.cpp index ac4adbdc4..ed80f9121 100644 --- a/src/blackmisc/simulation/simdirectaccessownaircraft.cpp +++ b/src/blackmisc/simulation/ownaircraftprovider.cpp @@ -7,7 +7,7 @@ * contained in the LICENSE file. */ -#include "simdirectaccessownaircraft.h" +#include "ownaircraftprovider.h" #include "blackmisc/aviation/aircraft.h" using namespace BlackMisc::Aviation; diff --git a/src/blackmisc/simulation/simdirectaccessownaircraft.h b/src/blackmisc/simulation/ownaircraftprovider.h similarity index 98% rename from src/blackmisc/simulation/simdirectaccessownaircraft.h rename to src/blackmisc/simulation/ownaircraftprovider.h index d3baba33b..9e4424e76 100644 --- a/src/blackmisc/simulation/simdirectaccessownaircraft.h +++ b/src/blackmisc/simulation/ownaircraftprovider.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKMISC_SIMDIRECTACCESSOWNAIRCRAFT_H -#define BLACKMISC_SIMDIRECTACCESSOWNAIRCRAFT_H +#ifndef BLACKMISC_SIMULATION_OWNAIRCRAFTPROVIDER_H +#define BLACKMISC_SIMULATION_OWNAIRCRAFTPROVIDER_H #include "blackmisc/simulation/simulatedaircraft.h" diff --git a/src/blackmisc/simulation/simdirectaccessremoteaircraft.cpp b/src/blackmisc/simulation/remoteaircraftprovider.cpp similarity index 98% rename from src/blackmisc/simulation/simdirectaccessremoteaircraft.cpp rename to src/blackmisc/simulation/remoteaircraftprovider.cpp index e073defb8..c42dcfaa8 100644 --- a/src/blackmisc/simulation/simdirectaccessremoteaircraft.cpp +++ b/src/blackmisc/simulation/remoteaircraftprovider.cpp @@ -7,7 +7,7 @@ * contained in the LICENSE file. */ -#include "simdirectaccessremoteaircraft.h" +#include "remoteaircraftprovider.h" using namespace BlackMisc::Aviation; diff --git a/src/blackmisc/simulation/simdirectaccessremoteaircraft.h b/src/blackmisc/simulation/remoteaircraftprovider.h similarity index 98% rename from src/blackmisc/simulation/simdirectaccessremoteaircraft.h rename to src/blackmisc/simulation/remoteaircraftprovider.h index 566d2a6d3..399811103 100644 --- a/src/blackmisc/simulation/simdirectaccessremoteaircraft.h +++ b/src/blackmisc/simulation/remoteaircraftprovider.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKMISC_SIMDIRECTACCESSREMOTEAIRCRAFT_H -#define BLACKMISC_SIMDIRECTACCESSREMOTEAIRCRAFT_H +#ifndef BLACKMISC_SIMULATION_REMOTEAIRCRAFTPROVIDER_H +#define BLACKMISC_SIMULATION_REMOTEAIRCRAFTPROVIDER_H #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/aviation/aircraftsituationlist.h" diff --git a/src/blackmisc/simulation/simdirectaccessremoteaircraftdummy.cpp b/src/blackmisc/simulation/remoteaircraftproviderdummy.cpp similarity index 98% rename from src/blackmisc/simulation/simdirectaccessremoteaircraftdummy.cpp rename to src/blackmisc/simulation/remoteaircraftproviderdummy.cpp index 0345b778c..db89c434c 100644 --- a/src/blackmisc/simulation/simdirectaccessremoteaircraftdummy.cpp +++ b/src/blackmisc/simulation/remoteaircraftproviderdummy.cpp @@ -7,7 +7,7 @@ * contained in the LICENSE file. */ -#include "simdirectaccessremoteaircraftdummy.h" +#include "remoteaircraftproviderdummy.h" using namespace BlackMisc::Aviation; diff --git a/src/blackmisc/simulation/simdirectaccessremoteaircraftdummy.h b/src/blackmisc/simulation/remoteaircraftproviderdummy.h similarity index 96% rename from src/blackmisc/simulation/simdirectaccessremoteaircraftdummy.h rename to src/blackmisc/simulation/remoteaircraftproviderdummy.h index adedf3fc4..082141fb8 100644 --- a/src/blackmisc/simulation/simdirectaccessremoteaircraftdummy.h +++ b/src/blackmisc/simulation/remoteaircraftproviderdummy.h @@ -9,10 +9,10 @@ //! \file -#ifndef BLACKMISC_SIMDIRECTACCESSREMOTEAIRCRAFTDUMMY_H -#define BLACKMISC_SIMDIRECTACCESSREMOTEAIRCRAFTDUMMY_H +#ifndef BLACKMISC_SIMULATION_REMOTEAIRCRAFTPROVIDERDUMMY_H +#define BLACKMISC_SIMULATION_REMOTEAIRCRAFTPROVIDERDUMMY_H -#include "blackmisc/simulation/simdirectaccessremoteaircraft.h" +#include "blackmisc/simulation/remoteaircraftprovider.h" namespace BlackMisc { diff --git a/src/blackmisc/simulation/setsimulator.cpp b/src/blackmisc/simulation/setsimulator.cpp new file mode 100644 index 000000000..3a47bb096 --- /dev/null +++ b/src/blackmisc/simulation/setsimulator.cpp @@ -0,0 +1,87 @@ +/* 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 "setsimulator.h" +#include "blackmisc/logmessage.h" + +using namespace BlackMisc; +using namespace BlackMisc::Settings; +using namespace BlackMisc::PhysicalQuantities; + +namespace BlackMisc +{ + namespace Simulation + { + namespace Settings + { + + CSettingsSimulator::CSettingsSimulator() + { + this->initDefaultValues(); + } + + QString CSettingsSimulator::convertToQString(bool i18n) const + { + Q_UNUSED(i18n); + QString s("Sel.driver:"); + s.append(" ").append(m_selectedPlugin.toQString(i18n)); + return s; + } + + void CSettingsSimulator::initDefaultValues() + { + this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin()); + this->m_timeSync = false; + } + + BlackMisc::CStatusMessage CSettingsSimulator::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag) + { + // TODO: This needs to be refactored to a smarter way to delegate commands + changedFlag = false; + if (path == CSettingsSimulator::ValueSelectedDriver()) + { + if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) + { + CSimulatorPluginInfo v = value.value(); + changedFlag = (v != this->m_selectedPlugin); + this->m_selectedPlugin = v; + return CLogMessage(CLogCategory::settingsUpdate()).info("selected driver%1 changed") << (changedFlag ? "" : " not"); + } + return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; + } + else if (path == CSettingsSimulator::ValueSyncTime()) + { + if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) + { + bool v = value.value(); + changedFlag = (v != this->m_timeSync); + this->m_timeSync = v; + return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization%1 changed") << (changedFlag ? "" : " not"); + } + return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; + } + else if (path == CSettingsSimulator::ValueSyncTimeOffset()) + { + if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) + { + CTime v = value.value(); + changedFlag = (v != this->m_timeSyncOffset); + this->m_timeSyncOffset = v; + return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization offset%1 changed") << (changedFlag ? "" : " not"); + } + return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; + } + else + { + return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; + } + } + } // namespace + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/setsimulator.h b/src/blackmisc/simulation/setsimulator.h new file mode 100644 index 000000000..5d7f4af3d --- /dev/null +++ b/src/blackmisc/simulation/setsimulator.h @@ -0,0 +1,97 @@ +/* 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 BLACKMISC_SETTINGS_SIMULATOR_H +#define BLACKMISC_SETTINGS_SIMULATOR_H + +#include "blackmisc/valueobject.h" +#include "blackmisc/statusmessagelist.h" +#include "blackmisc/settingutilities.h" +#include "blackmisc/pqtime.h" +#include "simulatorplugininfo.h" + +namespace BlackMisc +{ + namespace Simulation + { + namespace Settings + { + //! Value object encapsulating information of simulator related settings. + class CSettingsSimulator : public BlackMisc::CValueObject + { + public: + //! Default constructor. + CSettingsSimulator(); + + //! Path + static const QString &ValueSelectedDriver() + { + static const QString value("selecteddriver"); + return value; + } + + //! Path + static const QString &ValueSyncTimeOffset() + { + static const QString value("synctimeoffset"); + return value; + } + + //! Path + static const QString &ValueSyncTime() + { + static const QString value("synctime"); + return value; + } + + //! Selected driver + const BlackMisc::Simulation::CSimulatorPluginInfo &getSelectedPlugin() const { return this->m_selectedPlugin; } + + //! Selected driver + void setSelectedPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &plugin) { this->m_selectedPlugin = plugin; } + + //! Time synchronization offset time + const BlackMisc::PhysicalQuantities::CTime &getSyncTimeOffset() const { return this->m_timeSyncOffset;} + + //! Set time synchronization offset time + void setSyncTimeOffset(const BlackMisc::PhysicalQuantities::CTime &offset) { this->m_timeSyncOffset = offset; this->m_timeSyncOffset.switchUnit(BlackMisc::PhysicalQuantities::CTimeUnit::hrmin());} + + //! Time syncronization enabled? + bool isTimeSyncEnabled() const { return this->m_timeSync;} + + //! Set time synchronization + void setTimeSyncEnabled(bool enabled) { this->m_timeSync = enabled; } + + //! Init with meaningful default values + void initDefaultValues(); + + //! \copydoc BlackCore::IContextSettings::value + virtual BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag); + + protected: + //! \copydoc CValueObject::convertToQString + virtual QString convertToQString(bool i18n = false) const override; + + private: + BLACK_ENABLE_TUPLE_CONVERSION(CSettingsSimulator) + BlackMisc::Simulation::CSimulatorPluginInfo m_selectedPlugin; + bool m_timeSync = false; + BlackMisc::PhysicalQuantities::CTime m_timeSyncOffset; + }; + + } // namespace + } // namespace +} // namespace + +Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CSettingsSimulator) +BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::Settings::CSettingsSimulator, (o.m_selectedPlugin, o.m_timeSync, o.m_timeSyncOffset)) + +#endif // guard diff --git a/src/blackmisc/simulation/simulatedaircraft.h b/src/blackmisc/simulation/simulatedaircraft.h index 008c23440..04e77ade1 100644 --- a/src/blackmisc/simulation/simulatedaircraft.h +++ b/src/blackmisc/simulation/simulatedaircraft.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKMISC_SIMULATEDAIRCRAFT_H -#define BLACKMISC_SIMULATEDAIRCRAFT_H +#ifndef BLACKMISC_SIMULATION_SIMULATEDAIRCRAFT_H +#define BLACKMISC_SIMULATION_SIMULATEDAIRCRAFT_H #include "blackmisc/aviation/aircraft.h" #include "aircraftmodel.h" diff --git a/src/blackmisc/simulation/simulatedaircraftlist.cpp b/src/blackmisc/simulation/simulatedaircraftlist.cpp index 8df79a971..f17a68e33 100644 --- a/src/blackmisc/simulation/simulatedaircraftlist.cpp +++ b/src/blackmisc/simulation/simulatedaircraftlist.cpp @@ -21,21 +21,13 @@ namespace BlackMisc { namespace Simulation { - /* - * Default constructor - */ + CSimulatedAircraftList::CSimulatedAircraftList() { } - /* - * Construct from base class object - */ CSimulatedAircraftList::CSimulatedAircraftList(const CSequence &other) : CSequence(other) { } - /* - * Register metadata - */ void CSimulatedAircraftList::registerMetadata() { qRegisterMetaType>(); @@ -47,9 +39,6 @@ namespace BlackMisc registerMetaValueType(); } - /* - * All pilots - */ CUserList CSimulatedAircraftList::getPilots() const { return this->findBy(Predicates::MemberValid(&CSimulatedAircraft::getPilot)).transform(Predicates::MemberTransform(&CSimulatedAircraft::getPilot)); diff --git a/src/blackmisc/simulation/simulatedaircraftlist.h b/src/blackmisc/simulation/simulatedaircraftlist.h index 03b22db99..a35bb6337 100644 --- a/src/blackmisc/simulation/simulatedaircraftlist.h +++ b/src/blackmisc/simulation/simulatedaircraftlist.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKMISC_SIMULATEDNAIRCRAFTLIST_H -#define BLACKMISC_SIMULATEDNAIRCRAFTLIST_H +#ifndef BLACKMISC_SIMULATION_SIMULATEDNAIRCRAFTLIST_H +#define BLACKMISC_SIMULATION_SIMULATEDNAIRCRAFTLIST_H #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/aviation/callsignobjectlist.h" diff --git a/src/blackmisc/simulation/simulatorinfolist.cpp b/src/blackmisc/simulation/simulatorinfolist.cpp new file mode 100644 index 000000000..ec1275575 --- /dev/null +++ b/src/blackmisc/simulation/simulatorinfolist.cpp @@ -0,0 +1,44 @@ +/* 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 "simulatorinfolist.h" + +namespace BlackMisc +{ + namespace Simulation + { + + CSimulatorPluginInfoList::CSimulatorPluginInfoList() { } + + bool CSimulatorPluginInfoList::supportsSimulator(const QString &simulator) + { + return std::find_if(begin(), end(), [&simulator](const CSimulatorPluginInfo & info) + { + return info.getSimulator() == simulator; + }) != end(); + } + + QStringList CSimulatorPluginInfoList::toStringList(bool i18n) const + { + return this->transform([i18n](const CSimulatorPluginInfo & info) { return info.toQString(i18n); }); + } + + void CSimulatorPluginInfoList::registerMetadata() + { + qRegisterMetaType>(); + qDBusRegisterMetaType>(); + qRegisterMetaType>(); + qDBusRegisterMetaType>(); + qRegisterMetaType(); + qDBusRegisterMetaType(); + BlackMisc::registerMetaValueType(); + } + + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/simulatorinfolist.h b/src/blackmisc/simulation/simulatorinfolist.h new file mode 100644 index 000000000..61355dd9d --- /dev/null +++ b/src/blackmisc/simulation/simulatorinfolist.h @@ -0,0 +1,54 @@ +/* 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 BLACKMISC_SIMULATION_SIMULATORINFOLIST_H +#define BLACKMISC_SIMULATION_SIMULATORINFOLIST_H + +#include "simulatorplugininfo.h" +#include "blackmisc/sequence.h" +#include "blackmisc/collection.h" +#include + +namespace BlackMisc +{ + namespace Simulation + { + //! Value object encapsulating a list of SimulatorInfo objects. + class CSimulatorPluginInfoList : public BlackMisc::CSequence + { + public: + //! Default constructor + CSimulatorPluginInfoList(); + + //! Construct from a base class object. + CSimulatorPluginInfoList(const CSequence &other); + + //! \copydoc CValueObject::toQVariant + virtual QVariant toQVariant() const { return QVariant::fromValue(*this); } + + //! Is simulator supported + bool supportsSimulator(const QString &simulator); + + //! String list with meaningful representations + QStringList toStringList(bool i18n = false) const; + + //! Register the metatypes + static void registerMetadata(); + + }; + } // ns +} // ns + +Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorPluginInfoList) +Q_DECLARE_METATYPE(BlackMisc::CCollection) +Q_DECLARE_METATYPE(BlackMisc::CSequence) + +#endif // guard diff --git a/src/blackmisc/simulation/simulatormodelmappings.cpp b/src/blackmisc/simulation/simulatormodelmappings.cpp new file mode 100644 index 000000000..59874a522 --- /dev/null +++ b/src/blackmisc/simulation/simulatormodelmappings.cpp @@ -0,0 +1,54 @@ +/* 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 "simulatormodelmappings.h" + +using namespace BlackMisc; +using namespace BlackMisc::Network; + +namespace BlackMisc +{ + namespace Simulation + { + + ISimulatorModelMappings::ISimulatorModelMappings(QObject *parent) : QObject(parent) {} + + int ISimulatorModelMappings::size() const + { + return this->m_mappings.size(); + } + + bool ISimulatorModelMappings::isEmpty() const + { + return this->m_mappings.isEmpty(); + } + + const CAircraftMappingList &ISimulatorModelMappings::getMappingList() const + { + return this->m_mappings; + } + + int ISimulatorModelMappings::synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs) + { + if (modelNames.isEmpty() || this->m_mappings.isEmpty()) { return this->m_mappings.size(); } + CAircraftMappingList newList; + for (const CAircraftMapping &mapping : this->m_mappings) + { + QString modelString = mapping.getModel().getModelString(); + if (modelString.isEmpty()) { continue; } + if (modelNames.contains(modelString, cs)) + { + newList.push_back(mapping); + } + } + this->m_mappings = newList; + return this->m_mappings.size(); + } + } // namespace +} // namespace diff --git a/src/blackmisc/simulation/simulatormodelmappings.h b/src/blackmisc/simulation/simulatormodelmappings.h new file mode 100644 index 000000000..6df7e5676 --- /dev/null +++ b/src/blackmisc/simulation/simulatormodelmappings.h @@ -0,0 +1,56 @@ +/* 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 BLACKMISC_SIMULATION_MODELMAPPINGS_H +#define BLACKMISC_SIMULATION_MODELMAPPINGS_H + +#include "blackmisc/nwaircraftmappinglist.h" +#include + +namespace BlackMisc +{ + namespace Simulation + { + //! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files) + //! can implement this, but provide the same mapping list. + class ISimulatorModelMappings : public QObject + { + Q_OBJECT + + public: + //! Constructor + ISimulatorModelMappings(QObject *parent = nullptr); + + //! Destructor + virtual ~ISimulatorModelMappings() {} + + //! Load data + virtual bool read() = 0; + + //! Empty + bool isEmpty() const; + + //! Size + int size() const; + + //! Get list + const BlackMisc::Network::CAircraftMappingList &getMappingList() const; + + //! Synchronize with existing model names, remove unneeded models + int synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs = Qt::CaseInsensitive); + + protected: + BlackMisc::Network::CAircraftMappingList m_mappings; //!< Mappings + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackmisc/simulation/simulatorplugininfo.cpp b/src/blackmisc/simulation/simulatorplugininfo.cpp new file mode 100644 index 000000000..7c84a9339 --- /dev/null +++ b/src/blackmisc/simulation/simulatorplugininfo.cpp @@ -0,0 +1,70 @@ +/* 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 "simulatorplugininfo.h" +#include "blackmisc/blackmiscfreefunctions.h" + +using namespace BlackMisc; + +namespace BlackMisc +{ + namespace Simulation + { + + void CSimulatorPluginInfo::convertFromJson(const QJsonObject &json) + { + if (json["IID"].toString() != QStringLiteral("org.swift.pilotclient.BlackCore.SimulatorInterface")) + { + return; + } + + if (!json["MetaData"].isObject()) + { + return; + } + + QJsonObject data = json["MetaData"].toObject(); + if (data["name"].isUndefined() || data["simulator"].isUndefined()) + { + return; + } + + CValueObject::convertFromJson(data); + m_valid = true; + } + + bool CSimulatorPluginInfo::isUnspecified() const + { + return m_name.isEmpty(); + } + + CVariant CSimulatorPluginInfo::getSimulatorSetupValue(int index) const + { + return this->m_simsetup.value(index); + } + + QString CSimulatorPluginInfo::getSimulatorSetupValueAsString(int index) const + { + CVariant qv = getSimulatorSetupValue(index); + Q_ASSERT(qv.canConvert()); + return qv.toQString(); + } + + void CSimulatorPluginInfo::setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup) + { + this->m_simsetup = setup; + } + + QString CSimulatorPluginInfo::convertToQString(bool i18n) const + { + Q_UNUSED(i18n); + return QString("%1 (%2)").arg(m_name, m_simulator); + } + } // ns +} // ns diff --git a/src/blackmisc/simulation/simulatorplugininfo.h b/src/blackmisc/simulation/simulatorplugininfo.h new file mode 100644 index 000000000..79dea8166 --- /dev/null +++ b/src/blackmisc/simulation/simulatorplugininfo.h @@ -0,0 +1,105 @@ +/* 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 BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H +#define BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H + +#include "blackmisc/propertyindexvariantmap.h" +#include "blackmisc/valueobject.h" + +namespace BlackMisc +{ + namespace Simulation + { + //! Describing a simulator plugin + class CSimulatorPluginInfo : public BlackMisc::CValueObject + { + /** + * The _name_ property identifies the plugin itself and must be uniqe. + */ + Q_PROPERTY(QString getName READ getName) + + /** + * The _simulator_ property specifies which simulator the plugin handles. + * There cannot be two plugins loaded for the same simulator. + * swift enables some features for particular simulators. Currently recognized are: + * fsx, fs9, xplane + */ + Q_PROPERTY(QString getSimulator READ getSimulator) + + /** + * The _description_ property provides a short, human-readable description of the plugin. + */ + Q_PROPERTY(QString getDescription READ getDescription) + + public: + //! Default constructor + CSimulatorPluginInfo() = default; + + virtual void convertFromJson(const QJsonObject &json) override; + + //! Unspecified simulator + bool isUnspecified() const; + + //! Single setting value + BlackMisc::CVariant getSimulatorSetupValue(int index) const; + + //! Single setting value + QString getSimulatorSetupValueAsString(int index) const; + + //! Set single settings + void setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup); + + //! Check if the provided plugin metadata is valid. + //! Simulator plugin (driver) has to meet the following requirements: + //! * implements org.swift.pilotclient.BlackCore.SimulatorInterface; + //! * provides plugin name; + //! * specifies simulator it handles. + //! Unspecified sim is considered as invalid. + bool isValid() const { return m_valid; } + + //! Equals + bool operator==(const CSimulatorPluginInfo &other) { return getName() == other.getName(); } + + //! Name + const QString &getName() const { return m_name; } + + //! Simulator + const QString &getSimulator() const { return m_simulator; } + + //! Description + const QString &getDescription() const { return m_description; } + + protected: + //! \copydoc CValueObject::convertToQString + virtual QString convertToQString(bool i18n = false) const override; + + private: + BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorPluginInfo) + QString m_name; + QString m_simulator; + QString m_description; + bool m_valid { false }; + BlackMisc::CPropertyIndexVariantMap m_simsetup; //!< allows to access simulator keys requried on remote side + }; + } // ns +} // ns + +BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorPluginInfo, ( + attr(o.m_name), + attr(o.m_simulator), + attr(o.m_description), + attr(o.m_valid), + attr(o.m_simsetup, flags()) + )) +Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorPluginInfo) + +#endif // guard diff --git a/src/blackmisc/simulation/simulationallclasses.h b/src/blackmisc/simulation/simulatorsetup.cpp similarity index 57% rename from src/blackmisc/simulation/simulationallclasses.h rename to src/blackmisc/simulation/simulatorsetup.cpp index 474d30d41..6c8594e06 100644 --- a/src/blackmisc/simulation/simulationallclasses.h +++ b/src/blackmisc/simulation/simulatorsetup.cpp @@ -7,14 +7,20 @@ * contained in the LICENSE file. */ -//! \file +#include "simulatorsetup.h" -#ifndef BLACKMISC_SIMULATIONALLCLASSES_H -#define BLACKMISC_SIMULATIONALLCLASSES_H +namespace BlackMisc +{ + namespace Simulation + { + void CSimulatorSetup::setSettings(const BlackMisc::CPropertyIndexVariantMap &map) + { + this->m_setup = map; + } -#include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/simulation/simulatedaircraftlist.h" -#include "blackmisc/simulation/aircraftmodel.h" -#include "blackmisc/simulation/aircraftmodellist.h" - -#endif // guard + void CSimulatorSetup::init() + { + // void + } + } // ns +} // ns diff --git a/src/blackmisc/simulation/simulatorsetup.h b/src/blackmisc/simulation/simulatorsetup.h new file mode 100644 index 000000000..ec1218d40 --- /dev/null +++ b/src/blackmisc/simulation/simulatorsetup.h @@ -0,0 +1,60 @@ +/* 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 BLACKMISC_SIMULATION_SIMSETUP_H +#define BLACKMISC_SIMULATION_SIMSETUP_H + +#include "blackmisc/propertyindexvariantmap.h" +#include +#include + +namespace BlackMisc +{ + namespace Simulation + { + /*! + * \brief Simulator settings for flight simulators + * \details Represents the generic part of a simulator setup ("common denominator"), + * details kept in specialized classes + */ + class CSimulatorSetup + { + protected: + BlackMisc::CPropertyIndexVariantMap m_setup; //!< values describing the simulator setup (path, config files) + + protected: + //! Default constructor + CSimulatorSetup() {} + + //! Constructor + CSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &map) : m_setup(map) {} + + public: + //! Specific values + enum + { + SetupSimPath = BlackMisc::CPropertyIndex::GlobalIndexAbuseMode + }; + + //! Settings + BlackMisc::CPropertyIndexVariantMap getSettings() const { return this->m_setup;} + + //! Settings + void setSettings(const BlackMisc::CPropertyIndexVariantMap &map); + + //! Init, to be used where simulator runs + void init(); + + }; + } // namespace +} // namespace + +#endif // guard diff --git a/src/blacksim/blacksim.pro b/src/blacksim/blacksim.pro deleted file mode 100644 index 881ec2986..000000000 --- a/src/blacksim/blacksim.pro +++ /dev/null @@ -1,35 +0,0 @@ -include (../../config.pri) -include (../../build.pri) - -QT += network dbus xml - -TARGET = blacksim -TEMPLATE = lib - -CONFIG += staticlib -CONFIG += blackmisc - -INCLUDEPATH += .. -DEPENDPATH += . .. - -# PRECOMPILED_HEADER = stdpch.h -precompile_header:!isEmpty(PRECOMPILED_HEADER) { - DEFINES += USING_PCH -} - -DEFINES += LOG_IN_FILE - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a - -HEADERS += *.h -SOURCES += *.cpp -HEADERS += $$PWD/fscommon/*.h -SOURCES += $$PWD/fscommon/*.cpp - -HEADERS += $$PWD/fsx/*.h -SOURCES += $$PWD/fsx/*.cpp - -DESTDIR = ../../lib - -include (../../libraries.pri) diff --git a/src/blacksim/blacksimfreefunctions.cpp b/src/blacksim/blacksimfreefunctions.cpp deleted file mode 100644 index 92754099b..000000000 --- a/src/blacksim/blacksimfreefunctions.cpp +++ /dev/null @@ -1,29 +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 "blacksimfreefunctions.h" -#include "blacksim/simulatorinfolist.h" -#include "blacksim/setsimulator.h" -#include "fsx/simconnectutilities.h" -#include "fscommon/aircraftcfgentrieslist.h" - -namespace BlackSim -{ - - void registerMetadata() - { - BlackSim::CSimulatorPluginInfo::registerMetadata(); - BlackSim::CSimulatorPluginInfoList::registerMetadata(); - BlackSim::Settings::CSettingsSimulator::registerMetadata(); - BlackSim::FsCommon::CAircraftCfgEntries::registerMetadata(); - BlackSim::FsCommon::CAircraftCfgEntriesList::registerMetadata(); - BlackSim::Fsx::CSimConnectUtilities::registerMetadata(); - } - -} // namespace diff --git a/src/blacksim/blacksimfreefunctions.h b/src/blacksim/blacksimfreefunctions.h deleted file mode 100644 index 7eaab2ee0..000000000 --- a/src/blacksim/blacksimfreefunctions.h +++ /dev/null @@ -1,23 +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 BLACKSIM_FREEFUNCTIONS_H -#define BLACKSIM_FREEFUNCTIONS_H - -//! Free functions in BlackSim -namespace BlackSim -{ - //! Register all relevant metadata in BlackMisc - void registerMetadata(); - -} // namespace - -#endif // guard diff --git a/src/blacksim/fscommon/aircraftcfgentries.cpp b/src/blacksim/fscommon/aircraftcfgentries.cpp deleted file mode 100644 index 38e4cf8d5..000000000 --- a/src/blacksim/fscommon/aircraftcfgentries.cpp +++ /dev/null @@ -1,153 +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 "aircraftcfgentries.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include "blackmisc/variant.h" - -using namespace BlackMisc; -using namespace BlackMisc::Simulation; -using namespace BlackMisc::Network; - -namespace BlackSim -{ - namespace FsCommon - { - - /* - * Constructor - */ - CAircraftCfgEntries::CAircraftCfgEntries(const QString &filePath, qint32 index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode, const QString &description) : - m_index(index), m_fileName(filePath), m_title(title.trimmed()), m_atcType(atcType.trimmed()), - m_atcModel(atcModel.trimmed()), m_atcParkingCode(atcParkingCode.trimmed()), m_description(description.trimmed()) - { - // void - } - - /* - * String representation - */ - QString CAircraftCfgEntries::convertToQString(bool) const - { - QString s = "{%1, %2, %3, %4, %5, %6}"; - s = s.arg(this->m_fileName).arg(this->m_index).arg(this->m_title) - .arg(this->m_atcModel).arg(this->m_atcType).arg(this->m_atcParkingCode); - return s; - } - - /* - * Aircraft model - */ - QString CAircraftCfgEntries::getFileDirectory() const - { - if (this->m_fileName.isEmpty()) { return ""; } - QFileInfo fi(this->m_fileName); - return fi.absolutePath(); - } - - QString CAircraftCfgEntries::getUiCombinedDescription() const - { - QString d(this->m_uiManufacturer); - if (m_uiType.isEmpty()) { return d; } - if (d.isEmpty()) { return m_uiType; } - d += " "; - d += m_uiType; - return d; - } - - /* - * Convert - */ - CAircraftModel CAircraftCfgEntries::toAircraftModel() const - { - CAircraftModel model(this->getTitle(), CAircraftModel::TypeModelMapping); - model.setDescription(this->getUiCombinedDescription()); - model.setFileName(this->getFileName()); - return model; - } - - QString CAircraftCfgEntries::getThumbnailFileName() const - { - if (this->m_texture.isEmpty()) { return ""; } - if (this->m_fileName.isEmpty()) { return ""; } - QString fn = QDir::cleanPath(this->getFileDirectory() + QDir::separator() + "texture." + this->m_texture + QDir::separator() + "thumbnail.jpg"); - return fn; - } - - /* - * Get particular column - */ - CVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return this->toCVariant(); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexFileName: - return CVariant::from(this->m_fileName); - case IndexTitle: - return CVariant::from(this->m_title); - case IndexAtcType: - return CVariant::from(this->m_atcType); - case IndexAtcModel: - return CVariant::from(this->m_atcModel); - case IndexParkingCode: - return CVariant::from(this->m_atcParkingCode); - case IndexEntryIndex: - return CVariant::from(this->m_index); - case IndexTexture: - return CVariant::from(this->m_texture); - case IndexDescription: - return CVariant::from(this->m_description); - default: - return CValueObject::propertyByIndex(index); - } - } - - /* - * Set property as index - */ - void CAircraftCfgEntries::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) - { - if (index.isMyself()) { this->convertFromCVariant(variant); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexAtcModel: - this->setAtcModel(variant.toQString()); - break; - case IndexAtcType: - this->setAtcType(variant.toQString()); - break; - case IndexEntryIndex: - this->setIndex(variant.toInt()); - break; - case IndexFileName: - this->setFileName(variant.toQString()); - break; - case IndexParkingCode: - this->setAtcParkingCode(variant.toQString()); - break; - case IndexTitle: - this->setTitle(variant.toQString()); - break; - case IndexDescription: - this->setDescription(variant.toQString()); - break; - case IndexTexture: - this->setTexture(variant.toQString()); - break; - default: - CValueObject::setPropertyByIndex(variant, index); - break; - } - } - - } // namespace -} // namespace diff --git a/src/blacksim/fscommon/aircraftcfgentries.h b/src/blacksim/fscommon/aircraftcfgentries.h deleted file mode 100644 index 256520fc0..000000000 --- a/src/blacksim/fscommon/aircraftcfgentries.h +++ /dev/null @@ -1,151 +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 BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H -#define BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H - -#include "blackmisc/simulation/aircraftmodel.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/variant.h" - -namespace BlackSim -{ - namespace FsCommon - { - /*! - * Set of aircraft.cfg entries representing an aircraft (FSX) - * \remarks an entry in the aircraft.cfg is title, atc type, ... This class already bundles - * relevant entries, hence the class is named Entries (plural) - */ - class CAircraftCfgEntries: public BlackMisc::CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexEntryIndex = BlackMisc::CPropertyIndex::GlobalIndexCAircraftCfgEntries, - IndexFileName, - IndexTitle, - IndexAtcType, - IndexAtcModel, - IndexParkingCode, - IndexDescription, - IndexTexture - }; - - //! Default constructor - CAircraftCfgEntries() = default; - - //! Entries representing an aircraft - CAircraftCfgEntries(const QString &filePath, int index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode, const QString &description); - - //! File name - QString getFileName() const { return this->m_fileName; } - - //! Directory of entry - QString getFileDirectory() const; - - //! Title - QString getTitle() const { return this->m_title; } - - //! Index - int getIndex() const { return this->m_index; } - - //! ATC model - QString getAtcModel() const { return this->m_atcModel; } - - //! ATC type - QString getAtcType() const { return this->m_atcType; } - - //! Description - QString getDescription() const { return this->m_description; } - - //! ATC parking code - QString getAtcParkingCode() const { return this->m_atcParkingCode; } - - //! UI type (e.g. A321-231 IAE) - QString getUiType() const { return this->m_uiType; } - - //! UI manufacturer (e.g. Airbus) - QString getUiManufacturer() const { return this->m_uiManufacturer; } - - //! Texture - QString getTexture() const { return this->m_texture; } - - //! Manufacturer + type - QString getUiCombinedDescription() const; - - //! Filepath - void setFileName(const QString &filePath) { this->m_fileName = filePath; } - - //! Title - void setTitle(const QString &title) { this->m_title = title; } - - //! Index - void setIndex(int index) { this->m_index = index; } - - //! ATC model - void setAtcModel(const QString &atcModel) { this->m_atcModel = atcModel.trimmed(); } - - //! ATC type - void setAtcType(const QString &atcType) { this->m_atcType = atcType.trimmed(); } - - //! Parking code - void setAtcParkingCode(const QString &parkingCode) { this->m_atcParkingCode = parkingCode.trimmed(); } - - //! Description - void setDescription(const QString &description) { this->m_description = description.trimmed(); } - - //! Texture - void setTexture(const QString &texture) { this->m_texture = texture; } - - //! UI type (e.g. A321-231 IAE) - void setUiType(const QString &type) { this->m_uiType = type.trimmed(); } - - //! UI manufacturer (e.g. Airbus) - void setUiManufacturer(const QString &manufacturer) { this->m_uiManufacturer = manufacturer.trimmed(); } - - //! To aircraft model - BlackMisc::Simulation::CAircraftModel toAircraftModel() const; - - //! Thumbnail.jpg path if possible - QString getThumbnailFileName() const; - - //! \copydoc CValueObject::propertyByIndex - virtual BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override; - - //! \copydoc CValueObject::setPropertyByIndex - virtual void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index) override; - - protected: - //! \copydoc CValueObject::convertToQString - virtual QString convertToQString(bool i18n = false) const override; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CAircraftCfgEntries) - int m_index; //!< current index in given config - QString m_fileName; //!< file name of aircraft.cfg - QString m_title; //!< Title in aircraft.cfg - QString m_atcType; //!< ATC type - QString m_atcModel; //!< ATC model - QString m_atcParkingCode; //!< ATC parking code - QString m_description; //!< descriptive text - QString m_uiType; //!< e.g. A321-231 IAE - QString m_uiManufacturer; //!< e.g. Airbus - QString m_texture; //!< texture, needed to identify thumbnail.jpg - }; - } -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::FsCommon::CAircraftCfgEntries, (o.m_index, o.m_fileName, o.m_title, o.m_atcType, o.m_atcModel, o.m_atcParkingCode)) -Q_DECLARE_METATYPE(BlackSim::FsCommon::CAircraftCfgEntries) - -#endif // guard diff --git a/src/blacksim/fscommon/aircraftcfgentrieslist.cpp b/src/blacksim/fscommon/aircraftcfgentrieslist.cpp deleted file mode 100644 index 2821cf991..000000000 --- a/src/blacksim/fscommon/aircraftcfgentrieslist.cpp +++ /dev/null @@ -1,232 +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 "aircraftcfgentrieslist.h" -#include "blackmisc/predicates.h" -#include "blackmisc/logmessage.h" -#include -#include - -using namespace BlackMisc; -using namespace BlackMisc::Simulation; -using namespace BlackMisc::Network; - -namespace BlackSim -{ - namespace FsCommon - { - - /* - * Does the directory exist? - */ - bool CAircraftCfgEntriesList::existsDir(const QString &directory) const - { - QString d = directory.isEmpty() ? this->m_rootDirectory : directory; - if (d.isEmpty()) { return false; } - QDir dir(d); - //! \todo not available network dir can make this hang here - return dir.exists(); - } - - /* - * Model for title - */ - bool CAircraftCfgEntriesList::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) - { - if (title.isEmpty()) { return false; } - return this->containsBy( - [ = ](const CAircraftCfgEntries & entries) -> bool { return title.compare(entries.getTitle(), caseSensitivity) == 0; } - ); - } - - /* - * Double titles - */ - QStringList CAircraftCfgEntriesList::detectAmbiguousTitles() const - { - QStringList titles = this->getTitles(true); - QStringList ambiguousTitles; - QString last; - for (const QString &title : titles) - { - if (title.isEmpty()) { continue; } - if (title.compare(last, Qt::CaseInsensitive) == 0) - { - if (!ambiguousTitles.contains(title, Qt::CaseInsensitive)) - { - ambiguousTitles.append(title); - } - } - last = title; - } - return ambiguousTitles; - } - - /* - * All titles - */ - QStringList CAircraftCfgEntriesList::getTitles(bool sorted) const - { - QStringList titles = this->transform(Predicates::MemberTransform(&CAircraftCfgEntries::getTitle)); - if (sorted) { titles.sort(Qt::CaseInsensitive); } - return titles; - } - - /* - * As model list - */ - CAircraftModelList CAircraftCfgEntriesList::toAircraftModelList() const - { - CAircraftModelList ml; - for (auto it = this->begin() ; it != this->end(); ++it) - { - ml.push_back(it->toAircraftModel()); - } - return ml; - } - - /* - * Models for title - */ - CAircraftCfgEntriesList CAircraftCfgEntriesList::findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) const - { - return this->findBy([ = ](const CAircraftCfgEntries & entries) -> bool - { return title.compare(entries.getTitle(), caseSensitivity) == 0; }); - } - - /* - * Read all entrities in given directory - */ - int CAircraftCfgEntriesList::read(const QString &directory, const QStringList &excludeDirectories) - { - if (m_cancelRead) { return -1; } - - // excluded? - for (const QString &excludeDir : excludeDirectories) - { - if (directory.contains(excludeDir, Qt::CaseInsensitive)) - { - CLogMessage(this).debug() << "Skipping directory " << directory; - return 0; - } - } - - // set directory with name filters, get aircraft.cfg and sub directories - QDir dir(directory, "aircraft.cfg", QDir::Name, QDir::Files | QDir::AllDirs); - if (!dir.exists()) return 0; // can happen if there are shortcuts or linked dirs not available - - int counter = 0; - QString currentDir = dir.absolutePath(); - - // Dirs last is crucial,since I will break recursion on "aircraft.cfg" level - QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::AllDirs, QDir::DirsLast); - - for (const QFileInfo &file : files) - { - if (m_cancelRead) { return -1; } - if (file.isDir()) - { - QString nextDir = file.absoluteFilePath(); - if (currentDir.startsWith(nextDir, Qt::CaseInsensitive)) continue; // do not go up - if (dir == currentDir) { continue; } // do not recursively call same directory - counter += CAircraftCfgEntriesList::read(nextDir, excludeDirectories); - } - else - { - // due to the filter we expect only "aircraft.cfg" here - QString path = file.absoluteFilePath(); - - // I abuse the QSettings as ini-file reader - QSettings aircraftCfg(path, QSettings::IniFormat); - - // from the general section - const QString atcType = aircraftCfg.value("atc_type").toString(); - const QString atcModel = aircraftCfg.value("atc_model").toString(); - - int index = 0; - while (index >= 0) - { - if (m_cancelRead) { return -1; } - QString group = QString("fltsim.%1").arg(index); - aircraftCfg.beginGroup(group); - - // does group exist? - if (aircraftCfg.contains("title")) - { - QString title = fixedStringContent(aircraftCfg, "title"); - if (!title.isEmpty()) - { - CAircraftCfgEntries entry(path, index, title, atcType, atcModel, "", ""); - entry.setAtcParkingCode(fixedStringContent(aircraftCfg, "atc_parking_codes")); - entry.setDescription(fixedStringContent(aircraftCfg, "description")); - entry.setUiManufacturer(fixedStringContent(aircraftCfg, "ui_manufacturer")); - entry.setUiType(fixedStringContent(aircraftCfg, "ui_type")); - entry.setTexture(fixedStringContent(aircraftCfg, "texture")); - this->push_back(entry); - } - else - { - CLogMessage(this).info("FSX model in %1, index %2 has no title") << path << index; - } - ++index; - ++counter; - } - else - { - // marks end of the "fltsim.x" groups - index = -1; - } - aircraftCfg.endGroup(); - } - break; - } - } - return counter; - } - - QString CAircraftCfgEntriesList::fixedStringContent(const QSettings &settings, const QString &key) - { - return fixedStringContent(settings.value(key)); - } - - QString CAircraftCfgEntriesList::fixedStringContent(const QVariant &qv) - { - if (qv.isNull() || !qv.isValid()) - { - return ""; // normal when there is no settings value - } - else if (static_cast(qv.type()) == QMetaType::QStringList) - { - QStringList l = qv.toStringList(); - return l.join(",").trimmed(); - } - else if (static_cast(qv.type()) == QMetaType::QString) - { - return qv.toString().trimmed(); - } - Q_ASSERT(false); - return ""; - } - - /* - * Register metadata - */ - void CAircraftCfgEntriesList::registerMetadata() - { - qRegisterMetaType>(); - qDBusRegisterMetaType>(); - qRegisterMetaType>(); - qDBusRegisterMetaType>(); - qRegisterMetaType(); - qDBusRegisterMetaType(); - BlackMisc::registerMetaValueType(); - } - - } // namespace -} // namespace diff --git a/src/blacksim/fscommon/aircraftcfgentrieslist.h b/src/blacksim/fscommon/aircraftcfgentrieslist.h deleted file mode 100644 index 4d6afed77..000000000 --- a/src/blacksim/fscommon/aircraftcfgentrieslist.h +++ /dev/null @@ -1,133 +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 BLACKSIM_FSCOMMON_AIRCRAFTCFGLIST_H -#define BLACKSIM_FSCOMMON_AIRCRAFTCFGLIST_H - -#include "blackmisc/simulation/aircraftmodellist.h" -#include "aircraftcfgentries.h" -#include "blackmisc/sequence.h" -#include "blackmisc/collection.h" -#include -#include -#include -#include - -namespace BlackSim -{ - namespace FsCommon - { - - //! Utility, providing FS aircraft.cfg entries - class CAircraftCfgEntriesList : public BlackMisc::CSequence - { - - public: - - //! Constructor - CAircraftCfgEntriesList(const QString &rootDirectory = "") : m_rootDirectory(rootDirectory) {} - - //! Read all aircraft.cfg files starting from root directory - int read() - { - if (this->m_readForDirectory) { return this->size(); } - - // not read so far, read it - this->clear(); - this->m_readForDirectory = true; - return this->read(this->m_rootDirectory, excludeDirectories()); - } - - //! Change the directory - bool changeDirectory(const QString &directory) - { - if (this->m_rootDirectory != directory) - { - this->m_rootDirectory = directory; - this->m_readForDirectory = false; - } - return (!directory.isEmpty() && this->existsDir(directory)); - } - - //! Virtual destructor - virtual ~CAircraftCfgEntriesList() {} - - //! Does the directory exist? - bool existsDir(const QString &directory = "") const; - - //! Has current directory been read? - bool hasReadDirectory() const { return this->m_readForDirectory; } - - //! Cancel read - void cancelRead() { m_cancelRead = true; } - - //! Current root directory - QString getRootDirectory() const { return this->m_rootDirectory; } - - //! Contains model with title? - bool containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive); - - //! All titles (aka model names) - QStringList getTitles(bool sorted = false) const; - - //! As aircraft models - BlackMisc::Simulation::CAircraftModelList toAircraftModelList() const; - - //! Ambiguous titles - QStringList detectAmbiguousTitles() const; - - //! Find by title - CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const; - - //! \copydoc CValueObject::toQVariant - virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); } - - //! \copydoc CValueObject::convertFromQVariant - virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); } - - //! Do not include the following directories for FS - static const QStringList &excludeDirectories() - { - static const QStringList exclude - { - "SimObjects/Animals", - "SimObjects/Misc", - "SimObjects/GroundVehicles", - "SimObjects/Boats" - }; - return exclude; - } - - //! Register metadata - static void registerMetadata(); - - private: - QString m_rootDirectory; //!< root directory reading aircraft.cfg files - bool m_readForDirectory = false; //!< valid read for given directory - bool m_cancelRead = false; - - //! Read all entries in one directory - int read(const QString &directory, const QStringList &excludeDirectories = QStringList()); - - //! Fix the content read - static QString fixedStringContent(const QVariant &qv); - - //! Value from settings, fixed string - static QString fixedStringContent(const QSettings &settings, const QString &key); - }; - } // namespace -} // namespace - -Q_DECLARE_METATYPE(BlackSim::FsCommon::CAircraftCfgEntriesList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif // guard diff --git a/src/blacksim/fscommon/aircraftmapper.cpp b/src/blacksim/fscommon/aircraftmapper.cpp deleted file mode 100644 index 1844acbd7..000000000 --- a/src/blacksim/fscommon/aircraftmapper.cpp +++ /dev/null @@ -1,183 +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 "aircraftmapper.h" -#include "blackmisc/logmessage.h" -#include "blackmisc/worker.h" -#include - -using namespace BlackMisc; -using namespace BlackMisc::Simulation; -using namespace BlackMisc::Network; -using namespace BlackMisc::Aviation; - -namespace BlackSim -{ - namespace FsCommon - { - CAircraftMapper::CAircraftMapper(QObject *parent) : QObject(parent) { } - - CAircraftMapper::CAircraftMapper(std::unique_ptr mappings, QObject *parent) : - QObject(parent), m_mappings(mappings.release()) - { } - - CAircraftMapper::CAircraftMapper(std::unique_ptr mappings, const QString &simObjectsDir, QObject *parent) : - QObject(parent), m_mappings(mappings.release()) - { - this->m_entries.changeDirectory(simObjectsDir); - } - - CAircraftMapper::~CAircraftMapper() - { - this->gracefulShutdown(); - } - - int CAircraftMapper::readSimObjects(const QString &simObjectDir) - { - if (!simObjectDir.isEmpty()) { m_entries.changeDirectory(simObjectDir); } - int n = m_entries.read(); - emit entriesRead(n); - return n; - } - - void CAircraftMapper::initCompletelyInBackground(const QString &simObjectDir) - { - if (this->m_initWorker) { return; } - this->m_initWorker = BlackMisc::CWorker::fromTask(this, "CAircraftMapper::initCompletely", [this, simObjectDir]() - { - this->initCompletely(simObjectDir); - }); - } - - bool CAircraftMapper::isInitialized() const - { - return m_init; - } - - CAircraftIcao CAircraftMapper::getIcaoForModelString(const QString &modelString) const - { - if (modelString.isEmpty() || !this->isInitialized()) { return CAircraftIcao(); } - CAircraftMappingList mappings = this->m_mappings->getMappingList().findByModelString(modelString); - if (mappings.isEmpty()) { return CAircraftIcao(); } - return mappings.front().getIcao(); - } - - bool CAircraftMapper::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) - { - return this->m_entries.containsModelWithTitle(title, caseSensitivity); - } - - CAircraftModel CAircraftMapper::getModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) const - { - CAircraftCfgEntriesList el = this->m_entries.findByTitle(title, caseSensitivity); - if (el.isEmpty()) { return CAircraftModel(); } - CAircraftModel model = el.front().toAircraftModel(); - CAircraftIcao icao = this->getIcaoForModelString(model.getModelString()); - model.setIcao(icao); - return model; - } - - int CAircraftMapper::synchronize() - { - Q_ASSERT(this->m_mappings); - if (!this->m_mappings) { return 0; } - return this->m_mappings->synchronizeWithExistingModels(this->m_entries.getTitles(true)); - } - - void CAircraftMapper::gracefulShutdown() - { - // when running, force re-init - this->m_entries.cancelRead(); - this->m_initInProgress = false; - this->m_init = false; - } - - void CAircraftMapper::markUninitialized() - { - this->m_init = false; - } - - const CAircraftModel &CAircraftMapper::getDefaultModel() - { - static const CAircraftModel aircraftModel( - "Boeing 737-800 Paint1", - CAircraftModel::TypeModelMatchingDefaultModel, - "B737-800 default model", - CAircraftIcao("B738", "L2J", "", "", "FFFFFF") - ); - return aircraftModel; - } - - bool CAircraftMapper::initCompletely(QString simObjectDir) - { - if (this->m_init) { return true; } - if (this->m_initInProgress) { return false; } - this->m_initInProgress = true; - if (!this->m_mappings) - { - CLogMessage(this).error("Missing mapping defintions"); - emit initCompleted(false); - this->m_initInProgress = false; - return false; - } - - if (!m_entries.existsDir(simObjectDir)) - { - CLogMessage(this).error("Mapping engine, cannot read Flight Simulator directory: %1") << simObjectDir; - emit initCompleted(false); - this->m_initInProgress = false; - return false; - } - - // read the defintions (if required) - int mappingSize = this->m_mappings->size(); - if (mappingSize < 1) - { - this->m_mappings->read(); - mappingSize = this->m_mappings->size(); - if (mappingSize < 1) - { - CLogMessage(this).error("Reading mapping rules failed or empty"); - emit initCompleted(false); - this->m_initInProgress = false; - return false; - } - } - CLogMessage(this).debug() << "Mapping definitions" << mappingSize; - - // read sim objects, can take a while - int simObjectsSize = this->m_entries.size(); - if (simObjectsSize < 1) - { - simObjectsSize = this->readSimObjects(simObjectDir); - if (simObjectsSize < 1) - { - CLogMessage(this).error("No SimObjects found in %1") << simObjectDir; - emit initCompleted(false); - this->m_initInProgress = false; - return false; - } - } - simObjectsSize = this->m_entries.size(); - CLogMessage(this).info("Read %1 SimObjects from %2") << simObjectsSize << m_entries.getRootDirectory(); - - // sync - this->synchronize(); - CLogMessage(this).debug() << "Mapping definitions after sync" << this->m_mappings->size(); - - // finish - CLogMessage(this).info("Mapping system: %1 definitions for %2 entries") << this->m_mappings->size() << this->m_entries.size(); - emit initCompleted(true); - this->m_initInProgress = false; - this->m_init = true; - return true; - } - - } // namespace -} // namespace diff --git a/src/blacksim/fscommon/aircraftmapper.h b/src/blacksim/fscommon/aircraftmapper.h deleted file mode 100644 index 794f1fa17..000000000 --- a/src/blacksim/fscommon/aircraftmapper.h +++ /dev/null @@ -1,117 +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 BLACKSIM_FSCOMMON_AIRCRAFTMAPPER_H -#define BLACKSIM_FSCOMMON_AIRCRAFTMAPPER_H - -#include "aircraftcfgentrieslist.h" -#include "../simulatormodelmappings.h" -#include "blackmisc/worker.h" -#include -#include -#include -#include -#include -#include - -namespace BlackSim -{ - namespace FsCommon - { - //! Mapper for all models (works for FS9/FSX). - //! \details Reads all the mapping rules and all the available flight simulator models. - //! Then all rules for models not existing are eliminated ( \sa synchronize ). - //! Thereafter all existing models and mappings can be obtained from here. - //! \sa CAircraftCfgEntries - //! \sa CAircraftCfgEntriesList - class CAircraftMapper : public QObject - { - Q_OBJECT - - signals: - //! Number of entries read - void entriesRead(int number); - - //! Full init completed - void initCompleted(bool success); - - public: - //! Default constructor - CAircraftMapper(QObject *parent = nullptr); - - //! Constructor, handing over ownership or mappings object - CAircraftMapper(std::unique_ptr mappings, QObject *parent = nullptr); - - //! Constructor, handing over ownership or mappings object - CAircraftMapper(std::unique_ptr mappings, const QString &simObjectsDir, QObject *parent = nullptr); - - //! Destructor - ~CAircraftMapper(); - - //! Completely init - bool initCompletely(QString simObjectDir); - - //! Read for directory or re-read - int readSimObjects(const QString &simObjectDir = ""); - - //! Init in background - void initCompletelyInBackground(const QString &simObjectDir = ""); - - //! Init completed? - bool isInitialized() const; - - //! Get all aircraft entries (aka models available) - const CAircraftCfgEntriesList &getAircraftCfgEntriesList() const { return m_entries; } - - //! Get all mappings - const BlackMisc::Network::CAircraftMappingList &getAircraftMappingList() const { return m_mappings->getMappingList(); } - - //! Inverse lookup - BlackMisc::Aviation::CAircraftIcao getIcaoForModelString(const QString &modelString) const; - - //! Number of aircraft entries - int countAircraftCfgEntries() const { return m_entries.size(); } - - //! Number of mapping definitions - int countMappingRules() const { return m_mappings ? m_mappings->size() : 0; } - - //! Set the directory - bool changeCAircraftCfgEntriesDirectory(const QString &directory) { return this->m_entries.changeDirectory(directory); } - - //! Contains model with title? - bool containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive); - - //! Model with title - BlackMisc::Simulation::CAircraftModel getModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const; - - //! Synchronize models and mappings - //! \remarks after this step, we only have mappings for which we have models - int synchronize(); - - //! Shutdown - void gracefulShutdown(); - - //! To force reload - void markUninitialized(); - - //! default model - static const BlackMisc::Simulation::CAircraftModel &getDefaultModel(); - - private: - QScopedPointer m_mappings; //!< all mapping definitions - CAircraftCfgEntriesList m_entries; //!< all entries - bool m_init = false; - bool m_initInProgress = false; - BlackMisc::CWorker *m_initWorker = nullptr; - }; - } // namespace -} // namespace -#endif // guard diff --git a/src/blacksim/fscommon/bcdconversions.cpp b/src/blacksim/fscommon/bcdconversions.cpp deleted file mode 100644 index adfbe1aae..000000000 --- a/src/blacksim/fscommon/bcdconversions.cpp +++ /dev/null @@ -1,48 +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 "bcdconversions.h" - -using namespace BlackMisc::PhysicalQuantities; -using namespace BlackMisc::Aviation; - - -namespace BlackSim -{ - namespace FsCommon - { - - quint32 CBcdConversions::comFrequencyToBcdHz(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) - { - // FSX documentation is wrong, we need to use kHz + 2 digits, not Hz - quint32 f = comFrequency.valueRounded(CFrequencyUnit::kHz(), 0) / 10; - f = dec2Bcd(f); - return f; - } - - quint32 CBcdConversions::transponderCodeToBcd(const BlackMisc::Aviation::CTransponder &transponder) - { - // FSX documentation is wrong, we need to use kHz + 2 digits, not Hz - quint32 t = transponder.getTransponderCode(); - t = dec2Bcd(t); - return t; - } - - quint32 CBcdConversions::hornerScheme(quint32 num, quint32 divider, quint32 factor) - { - quint32 remainder = 0, quotient = 0, result = 0; - remainder = num % divider; - quotient = num / divider; - if (!(quotient == 0 && remainder == 0)) - result += hornerScheme(quotient, divider, factor) * factor + remainder; - return result; - } - - } // namespace -} // namespace diff --git a/src/blacksim/fscommon/bcdconversions.h b/src/blacksim/fscommon/bcdconversions.h deleted file mode 100644 index 57f630665..000000000 --- a/src/blacksim/fscommon/bcdconversions.h +++ /dev/null @@ -1,51 +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 BLACKSIM_FSCOMMON_BCDCONVERSIONS_H -#define BLACKSIM_FSCOMMON_BCDCONVERSIONS_H - -#include "blackmisc/pqfrequency.h" -#include "blackmisc/aviation/transponder.h" -#include - -namespace BlackSim -{ - namespace FsCommon - { - - //! BCD conversions for FS - class CBcdConversions - { - public: - //! BCD -> decimal - static quint32 bcd2Dec(quint32 bcdNum) { return hornerScheme(bcdNum, 0x10, 10); } - - //! Decimal -> BCD - static quint32 dec2Bcd(quint32 decNum) { return hornerScheme(decNum, 10, 0x10); } - - //! COM Frequency to BCD - static quint32 comFrequencyToBcdHz(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency); - - //! Transponder code to BCD - static quint32 transponderCodeToBcd(const BlackMisc::Aviation::CTransponder &transponder); - - private: - //! Constructor, only static methods - CBcdConversions() {} - - //! Horner scheme - static quint32 hornerScheme(quint32 num, quint32 divider, quint32 factor); - }; - - } -} - -#endif // guard diff --git a/src/blacksim/fscommon/fscommon.h b/src/blacksim/fscommon/fscommon.h deleted file mode 100644 index 8c8dbfadd..000000000 --- a/src/blacksim/fscommon/fscommon.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef FSCOMMON_NAMESPACES_H -#define FSCOMMON_NAMESPACES_H - -// just a dummy header, namespace documentation will go here -/*! \file */ - -/*! - * \namespace FsCommon - * \brief Utility classes for FSX, P3D and FS9. - */ - -#endif // guard diff --git a/src/blacksim/fscommon/fscommonutil.cpp b/src/blacksim/fscommon/fscommonutil.cpp deleted file mode 100644 index 1cb559613..000000000 --- a/src/blacksim/fscommon/fscommonutil.cpp +++ /dev/null @@ -1,49 +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 "blackmisc/project.h" -#include "fscommonutil.h" -#include -#include - -using namespace BlackMisc; - -namespace BlackSim -{ - namespace FsCommon - { - - QString CFsCommonUtil::fsxDirFromRegistry() - { - QString fsxPath; - if (CProject::isCompiledWithFsxSupport()) - { - // set FSX path - QSettings fsxRegistry("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat); - fsxPath = fsxRegistry.value("AppPath").toString().trimmed(); - if (fsxPath.isEmpty()) - { - // another trial - QSettings fsxRegistry("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat); - fsxPath = fsxRegistry.value("SetupPath").toString().trimmed(); - } - } - return fsxPath; - } - - QString CFsCommonUtil::fsxSimObjectsDirFromRegistry() - { - QString fsxPath = fsxDirFromRegistry(); - if (fsxPath.isEmpty()) { return ""; } - fsxPath = QDir(fsxPath).filePath("SimObjects"); - return fsxPath; - } - - } // namespace -} // namespace diff --git a/src/blacksim/fscommon/fscommonutil.h b/src/blacksim/fscommon/fscommonutil.h deleted file mode 100644 index 25077f4b6..000000000 --- a/src/blacksim/fscommon/fscommonutil.h +++ /dev/null @@ -1,38 +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 FSCOMMONUTIL_H -#define FSCOMMONUTIL_H - -#include - -namespace BlackSim -{ - namespace FsCommon - { - //! FS9/X utils - class CFsCommonUtil - { - public: - CFsCommonUtil(); - - //! FSX directory obtained from registry - static QString fsxDirFromRegistry(); - - //! FSX's simObject directory from registry - static QString fsxSimObjectsDirFromRegistry(); - - }; - - } // namespace -} // namespace - -#endif // guard diff --git a/src/blacksim/fscommon/vpilotmodelmappings.cpp b/src/blacksim/fscommon/vpilotmodelmappings.cpp deleted file mode 100644 index 7f8d1012c..000000000 --- a/src/blacksim/fscommon/vpilotmodelmappings.cpp +++ /dev/null @@ -1,129 +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 "vpilotmodelmappings.h" -#include "blackmisc/nwaircraftmapping.h" - -#include -#include -#include -#include - -using namespace BlackMisc::Network; - -namespace BlackSim -{ - namespace FsCommon - { - - CVPilotModelMappings::CVPilotModelMappings(bool standardDirectory, QObject *parent) : - ISimulatorModelMappings(parent) - { - if (standardDirectory) { this->addDirectory(CVPilotModelMappings::standardMappingsDirectory()); } - } - - void CVPilotModelMappings::addFilename(const QString &fileName) - { - if (this->m_fileList.contains(fileName)) return; - this->m_fileList.append(fileName); - } - - void CVPilotModelMappings::addDirectory(const QString &directory) - { - QDir dir(directory); - if (!dir.exists()) return; - QStringList nameFilters({"*.vmr"}); - QFileInfoList entries = dir.entryInfoList(nameFilters, QDir::Files | QDir::Readable); - for (const QFileInfo &file : entries) - { - this->addFilename(file.absoluteFilePath()); - } - } - - const QString &CVPilotModelMappings::standardMappingsDirectory() - { - static QString directory; - if (directory.isEmpty()) - { - directory = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first(); - if (!directory.endsWith('/')) directory.append('/'); - directory.append("vPilot Files/Model Matching Rule Sets"); - } - return directory; - } - - bool CVPilotModelMappings::read() - { - bool success = true; - this->m_loadedFiles = 0; - this->m_fileListWithProblems.clear(); - for (const QString &fn : this->m_fileList) - { - this->m_loadedFiles++; - bool s = this->loadFile(fn); - if (!s) { this->m_fileListWithProblems.append(fn); } - success = s && success; - } - return success; - } - - bool CVPilotModelMappings::loadFile(const QString &fileName) - { - QFile f(fileName); - if (!f.exists()) { return false; } - if (!f.open(QFile::ReadOnly | QFile::Text)) { return false; } - QByteArray fc = f.readAll(); - if (fc.isEmpty()) { return false; } - QDomDocument doc; - if (!doc.setContent(fc)) { return false; } - QDomNodeList rules = doc.elementsByTagName("ModelMatchRule"); - if (rules.isEmpty()) { return false; } - - QString folder; - QString updated; - QDomNodeList mmRuleSet = doc.elementsByTagName("ModelMatchRuleSet"); - if (mmRuleSet.size() > 0) - { - QDomNamedNodeMap attributes = mmRuleSet.at(0).attributes(); - folder = attributes.namedItem("Folder").nodeValue(); - updated = attributes.namedItem("UpdatedOn").nodeValue(); - } - int rulesSize = rules.size(); - for (int i = 0; i < rulesSize; i++) - { - QDomNamedNodeMap attributes = rules.at(i).attributes(); - const QString typeCode = attributes.namedItem("TypeCode").nodeValue(); - const QString modelName = attributes.namedItem("ModelName").nodeValue(); - // remark, callsign prefix is airline ICAO code - const QString airlineCode = attributes.namedItem("CallsignPrefix").nodeValue(); - if (modelName.isEmpty()) { continue; } - - // split if we have multiple models - if (modelName.contains("//")) - { - // multiple models - const QStringList models = modelName.split("//"); - for (const QString &model : models) - { - if (model.isEmpty()) { continue; } - CAircraftMapping mapping("vpilot", folder, typeCode, airlineCode, model); - this->m_mappings.push_back(mapping); - } - } - else - { - // single model - CAircraftMapping mapping("vpilot", folder, typeCode, airlineCode, modelName); - this->m_mappings.push_back(mapping); - } - } - return true; - } - } // namespace -} // namespace diff --git a/src/blacksim/fscommon/vpilotmodelmappings.h b/src/blacksim/fscommon/vpilotmodelmappings.h deleted file mode 100644 index 8db5d4692..000000000 --- a/src/blacksim/fscommon/vpilotmodelmappings.h +++ /dev/null @@ -1,58 +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 BLACKSIM_FSCOMMON_VPILOTMODELMAPPINGS_H -#define BLACKSIM_FSCOMMON_VPILOTMODELMAPPINGS_H - -#include "../simulatormodelmappings.h" -#include - -namespace BlackSim -{ - namespace FsCommon - { - //! Model mappings - class CVPilotModelMappings : public ISimulatorModelMappings - { - public: - //! Constructor - CVPilotModelMappings(bool standardDirectory, QObject *parent = nullptr); - - //! Destructor - virtual ~CVPilotModelMappings() {} - - //! File names - void addFilename(const QString &fileName); - - //! Directory with .vmr files - void addDirectory(const QString &directory); - - //! Loaded files (number) - int countFilesLoaded() const { return m_loadedFiles; } - - //! The standard directory for vPilot mappings - static const QString &standardMappingsDirectory(); - - public slots: - //! Load data - virtual bool read() override; - - private: - QStringList m_fileList; //!< list of file names - QStringList m_fileListWithProblems; //!< problems during parsing - int m_loadedFiles = 0; //!< loaded files - - //! Single file read and parsing - bool loadFile(const QString &fileName); - }; - } // namespace -} // namespace -#endif // guard diff --git a/src/blacksim/fsx/fsxsimulatorsetup.cpp b/src/blacksim/fsx/fsxsimulatorsetup.cpp deleted file mode 100644 index 43c82b4db..000000000 --- a/src/blacksim/fsx/fsxsimulatorsetup.cpp +++ /dev/null @@ -1,38 +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 "fsxsimulatorsetup.h" - -#include "../../blackmisc/project.h" -#include "../fscommon/fscommonutil.h" -#include "../fsx/simconnectutilities.h" - -#include - -using namespace BlackMisc; -using namespace BlackSim::FsCommon; - -namespace BlackSim -{ - namespace Fsx - { - void CFsxSimulatorSetup::init() - { - CSimulatorSetup::init(); - this->m_setup.addValue(SetupSimConnectCfgFile, CSimConnectUtilities::getLocalSimConnectCfgFilename()); - - if (CProject::isCompiledWithFsxSupport()) - { - // set FSX path - QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); - if (!fsxPath.isEmpty()) this->m_setup.value(CSimulatorSetup::SetupSimPath, CVariant(fsxPath)); - } - } - } // namespace -} // namespace diff --git a/src/blacksim/fsx/fsxsimulatorsetup.h b/src/blacksim/fsx/fsxsimulatorsetup.h deleted file mode 100644 index c3496080a..000000000 --- a/src/blacksim/fsx/fsxsimulatorsetup.h +++ /dev/null @@ -1,48 +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 BLACKSIM_FSX_SIMSETUP_H -#define BLACKSIM_FSX_SIMSETUP_H - -#include "../simulatorsetup.h" -#include - -namespace BlackSim -{ - namespace Fsx - { - /*! - * Simulator settings for FSX Flight simulators - */ - class CFsxSimulatorSetup : public BlackSim::CSimulatorSetup - { - - public: - //! Setup values - enum - { - SetupSimConnectCfgFile = (BlackMisc::CPropertyIndex::GlobalIndexAbuseMode + 100), //!< location of simconnect.cfg file - }; - - - //! Default constructor - CFsxSimulatorSetup() : BlackSim::CSimulatorSetup() {} - - //! Constructor - CFsxSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &map) : BlackSim::CSimulatorSetup(map) {} - - //! Init, to be used where FSX runs - void init(); - }; - } // namespace -} // namespace - -#endif // guard diff --git a/src/blacksim/fsx/simconnectutilities.cpp b/src/blacksim/fsx/simconnectutilities.cpp deleted file mode 100644 index 0cd8271a3..000000000 --- a/src/blacksim/fsx/simconnectutilities.cpp +++ /dev/null @@ -1,93 +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 "simconnectutilities.h" -#include -#include -#include - -namespace BlackSim -{ - namespace Fsx - { - CSimConnectUtilities::CSimConnectUtilities() { } - - // - // Filename / path of a "local" SimConnect.cfg file - // - QString CSimConnectUtilities::getLocalSimConnectCfgFilename() - { - return QCoreApplication::applicationDirPath() + "/SimConnect.cfg"; - } - - // - // Create a very simple SimConnect.cfg - // - bool CSimConnectUtilities::writeSimConnectCfg(const QString &fileName, const QString &ip, int port) - { - QString sc = CSimConnectUtilities::simConnectCfg(ip, port); - QFile file(fileName); - bool success = false; - if ((success = file.open(QIODevice::WriteOnly | QIODevice::Text))) - { - QTextStream out(&file); - out << sc; - file.close(); - } - return success; - } - - // - // simconnect.cfg file - // - QString CSimConnectUtilities::simConnectCfg(const QString &ip, int port) - { - QString sc = QString("[SimConnect]\nProtocol=Ipv4\nAddress=%1\nPort=%2\n" - "MaxReceiveSize=4096\nDisableNagle=0").arg(ip).arg(port); - return sc; - } - - // - // Resolve enum id to string - // http://labs.qt.nokia.com/2008/10/09/coding-tip-pretty-printing-enum-values/ - // - const QString CSimConnectUtilities::resolveEnumToString(const DWORD id, const char *enumName) - { - int i = CSimConnectUtilities::staticMetaObject.indexOfEnumerator(enumName); - if (i < 0) return QString("No enumerator for %1").arg(enumName); - QMetaEnum m = CSimConnectUtilities::staticMetaObject.enumerator(i); - const char *k = m.valueToKey(id); - return (k) ? QLatin1String(k) : QString("Id %1 not found for %2").arg(id).arg(enumName); - } - - // - // Exception id to something human readible - // - const QString CSimConnectUtilities::simConnectExceptionToString(const DWORD id) - { - return CSimConnectUtilities::resolveEnumToString(id, "SIMCONNECT_EXCEPTION"); - } - - // - // The surface types - // - const QString CSimConnectUtilities::simConnectSurfaceTypeToString(const DWORD type, bool beautify) - { - QString sf = CSimConnectUtilities::resolveEnumToString(type, "SIMCONNECT_SURFACE"); - return beautify ? sf.replace('_', ' ') : sf; - } - - void CSimConnectUtilities::registerMetadata() - { - qRegisterMetaType(); - qRegisterMetaType(); - } - - } // namespace -} // namespace diff --git a/src/blacksim/fsx/simconnectutilities.h b/src/blacksim/fsx/simconnectutilities.h deleted file mode 100644 index ca2697f9b..000000000 --- a/src/blacksim/fsx/simconnectutilities.h +++ /dev/null @@ -1,173 +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 BLACKSIM_FSX_SIMCONNECTUTILITIES_H -#define BLACKSIM_FSX_SIMCONNECTUTILITIES_H - -#include -#include - -// Apart from the below definitions, the following code is OS independent, -// though it does not make sense to be used on non WIN machines. -// But it allows such parts to compile on all platforms. -#ifdef Q_OS_WIN -#ifndef NOMINMAX -#define NOMINMAX -#endif -#include -#else -typedef unsigned long DWORD; //!< Fake Windows DWORD -#endif - -namespace BlackSim -{ - namespace Fsx - { - //! Utilities for SimConnect - class CSimConnectUtilities : public QObject - { - Q_OBJECT - Q_ENUMS(SIMCONNECT_EXCEPTION) - Q_ENUMS(SIMCONNECT_SURFACE) - - public: - //! Path to local config file - static QString getLocalSimConnectCfgFilename(); - - /*! - * Content for FSX simconnect.cfg file - * \param ip IP address of FSX - * \param port Port of FSX (e.g. 500) - * \return content for simconnect.cfg - */ - static QString simConnectCfg(const QString &ip, int port = 500); - - /*! - * Create a FSX simconnect.cfg file - * \param fileName and path - * \param ip IP address of FSX - * \param port Port of FSX (e.g. 500) - * \return success - */ - static bool writeSimConnectCfg(const QString &fileName, const QString &ip, int port = 500); - - /*! - * Resolve SimConnect exception (based on Qt metadata). - * \param id enum element - * \return enum element's name - */ - static const QString simConnectExceptionToString(const DWORD id); - - /*! - * Resolve SimConnect surface (based on Qt metadata). - * \param type enum element - * \param beautify remove "_" - * \return - */ - static const QString simConnectSurfaceTypeToString(const DWORD type, bool beautify = true); - - //! SimConnect surfaces. - // http://msdn.microsoft.com/en-us/library/cc526981.aspx#AircraftFlightInstrumentationData - enum SIMCONNECT_SURFACE - { - Concrete, - Grass, - Water, - Grass_bumpy, - Asphalt, - Short_grass, - Long_grass, - Hard_turf, - Snow, - Ice, - Urban, - Forest, - Dirt, - Coral, - Gravel, - Oil_treated, - Steel_mats, - Bituminus, - Brick, - Macadam, - Planks, - Sand, - Shale, - Tarmac, - Wright_flyer_track - }; - - //! SimConnect exceptions. - enum SIMCONNECT_EXCEPTION - { - SIMCONNECT_EXCEPTION_NONE, - SIMCONNECT_EXCEPTION_ERROR, - SIMCONNECT_EXCEPTION_SIZE_MISMATCH, - SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID, - SIMCONNECT_EXCEPTION_UNOPENED, - SIMCONNECT_EXCEPTION_VERSION_MISMATCH, - SIMCONNECT_EXCEPTION_TOO_MANY_GROUPS, - SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED, - SIMCONNECT_EXCEPTION_TOO_MANY_EVENT_NAMES, - SIMCONNECT_EXCEPTION_EVENT_ID_DUPLICATE, - SIMCONNECT_EXCEPTION_TOO_MANY_MAPS, - SIMCONNECT_EXCEPTION_TOO_MANY_OBJECTS, - SIMCONNECT_EXCEPTION_TOO_MANY_REQUESTS, - SIMCONNECT_EXCEPTION_WEATHER_INVALID_PORT, - SIMCONNECT_EXCEPTION_WEATHER_INVALID_METAR, - SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_GET_OBSERVATION, - SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_CREATE_STATION, - SIMCONNECT_EXCEPTION_WEATHER_UNABLE_TO_REMOVE_STATION, - SIMCONNECT_EXCEPTION_INVALID_DATA_TYPE, - SIMCONNECT_EXCEPTION_INVALID_DATA_SIZE, - SIMCONNECT_EXCEPTION_DATA_ERROR, - SIMCONNECT_EXCEPTION_INVALID_ARRAY, - SIMCONNECT_EXCEPTION_CREATE_OBJECT_FAILED, - SIMCONNECT_EXCEPTION_LOAD_FLIGHTPLAN_FAILED, - SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE, - SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION, - SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED, - SIMCONNECT_EXCEPTION_INVALID_ENUM, - SIMCONNECT_EXCEPTION_DEFINITION_ERROR, - SIMCONNECT_EXCEPTION_DUPLICATE_ID, - SIMCONNECT_EXCEPTION_DATUM_ID, - SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS, - SIMCONNECT_EXCEPTION_ALREADY_CREATED, - SIMCONNECT_EXCEPTION_OBJECT_OUTSIDE_REALITY_BUBBLE, - SIMCONNECT_EXCEPTION_OBJECT_CONTAINER, - SIMCONNECT_EXCEPTION_OBJECT_AI, - SIMCONNECT_EXCEPTION_OBJECT_ATC, - SIMCONNECT_EXCEPTION_OBJECT_SCHEDULE - }; - - //! Register metadata - static void registerMetadata(); - - private: - /*! - * Resolve enum value to its cleartext (based on Qt metadata). - * \param id enum element - * \param enumName name of the resolved enum - * \return enum element's name - */ - static const QString resolveEnumToString(const DWORD id, const char *enumName); - - //! Hidden constructor - CSimConnectUtilities(); - - }; - } -} - -Q_DECLARE_METATYPE(BlackSim::Fsx::CSimConnectUtilities::SIMCONNECT_EXCEPTION) -Q_DECLARE_METATYPE(BlackSim::Fsx::CSimConnectUtilities::SIMCONNECT_SURFACE) - -#endif // guard diff --git a/src/blacksim/setsimulator.cpp b/src/blacksim/setsimulator.cpp deleted file mode 100644 index 62fbeb190..000000000 --- a/src/blacksim/setsimulator.cpp +++ /dev/null @@ -1,95 +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 "setsimulator.h" -#include "blackmisc/logmessage.h" - -using namespace BlackMisc; -using namespace BlackMisc::Settings; -using namespace BlackMisc::PhysicalQuantities; - -namespace BlackSim -{ - namespace Settings - { - /* - * Constructor - */ - CSettingsSimulator::CSettingsSimulator() - { - this->initDefaultValues(); - } - - /* - * Convert to string - */ - QString CSettingsSimulator::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - QString s("Sel.driver:"); - s.append(" ").append(m_selectedPlugin.toQString(i18n)); - return s; - } - - /* - * Default values - */ - void CSettingsSimulator::initDefaultValues() - { - this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin()); - this->m_timeSync = false; - } - - /* - * Value - */ - BlackMisc::CStatusMessage CSettingsSimulator::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag) - { - // TODO: This needs to be refactored to a smarter way to delegate commands - changedFlag = false; - if (path == CSettingsSimulator::ValueSelectedDriver()) - { - if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) - { - CSimulatorPluginInfo v = value.value(); - changedFlag = (v != this->m_selectedPlugin); - this->m_selectedPlugin = v; - return CLogMessage(CLogCategory::settingsUpdate()).info("selected driver%1 changed") << (changedFlag ? "" : " not"); - } - return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; - } - else if (path == CSettingsSimulator::ValueSyncTime()) - { - if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) - { - bool v = value.value(); - changedFlag = (v != this->m_timeSync); - this->m_timeSync = v; - return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization%1 changed") << (changedFlag ? "" : " not"); - } - return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; - } - else if (path == CSettingsSimulator::ValueSyncTimeOffset()) - { - if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) - { - CTime v = value.value(); - changedFlag = (v != this->m_timeSyncOffset); - this->m_timeSyncOffset = v; - return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization offset%1 changed") << (changedFlag ? "" : " not"); - } - return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; - } - else - { - return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; - } - } - } // namespace -} // namespace diff --git a/src/blacksim/setsimulator.h b/src/blacksim/setsimulator.h deleted file mode 100644 index be9a3e398..000000000 --- a/src/blacksim/setsimulator.h +++ /dev/null @@ -1,94 +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 BLACKMISC_SETTINGS_SIMULATOR_H -#define BLACKMISC_SETTINGS_SIMULATOR_H - -#include "blackmisc/valueobject.h" -#include "blackmisc/statusmessagelist.h" -#include "blackmisc/settingutilities.h" -#include "blackmisc/pqtime.h" -#include "simulatorplugininfo.h" - -namespace BlackSim -{ - namespace Settings - { - //! Value object encapsulating information of simulator related settings. - class CSettingsSimulator : public BlackMisc::CValueObject - { - public: - //! Default constructor. - CSettingsSimulator(); - - //! Path - static const QString &ValueSelectedDriver() - { - static const QString value("selecteddriver"); - return value; - } - - //! Path - static const QString &ValueSyncTimeOffset() - { - static const QString value("synctimeoffset"); - return value; - } - - //! Path - static const QString &ValueSyncTime() - { - static const QString value("synctime"); - return value; - } - - //! Selected driver - const BlackSim::CSimulatorPluginInfo &getSelectedPlugin() const { return this->m_selectedPlugin; } - - //! Selected driver - void setSelectedPlugin(const BlackSim::CSimulatorPluginInfo &plugin) { this->m_selectedPlugin = plugin; } - - //! Time synchronization offset time - const BlackMisc::PhysicalQuantities::CTime &getSyncTimeOffset() const { return this->m_timeSyncOffset;} - - //! Set time synchronization offset time - void setSyncTimeOffset(const BlackMisc::PhysicalQuantities::CTime &offset) { this->m_timeSyncOffset = offset; this->m_timeSyncOffset.switchUnit(BlackMisc::PhysicalQuantities::CTimeUnit::hrmin());} - - //! Time syncronization enabled? - bool isTimeSyncEnabled() const { return this->m_timeSync;} - - //! Set time synchronization - void setTimeSyncEnabled(bool enabled) { this->m_timeSync = enabled; } - - //! Init with meaningful default values - void initDefaultValues(); - - //! \copydoc BlackCore::IContextSettings::value - virtual BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag); - - protected: - //! \copydoc CValueObject::convertToQString - virtual QString convertToQString(bool i18n = false) const override; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CSettingsSimulator) - BlackSim::CSimulatorPluginInfo m_selectedPlugin; - bool m_timeSync = false; - BlackMisc::PhysicalQuantities::CTime m_timeSyncOffset; - }; - - } // namespace -} // namespace - -Q_DECLARE_METATYPE(BlackSim::Settings::CSettingsSimulator) -BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::Settings::CSettingsSimulator, (o.m_selectedPlugin, o.m_timeSync, o.m_timeSyncOffset)) - -#endif // guard diff --git a/src/blacksim/simulatorinfolist.cpp b/src/blacksim/simulatorinfolist.cpp deleted file mode 100644 index a7f2691b8..000000000 --- a/src/blacksim/simulatorinfolist.cpp +++ /dev/null @@ -1,40 +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 "simulatorinfolist.h" - -namespace BlackSim -{ - - CSimulatorPluginInfoList::CSimulatorPluginInfoList() { } - - bool CSimulatorPluginInfoList::supportsSimulator(const QString &simulator) - { - return std::find_if(begin(), end(), [&simulator](const CSimulatorPluginInfo &info) { - return info.getSimulator() == simulator; - }) != end(); - } - - QStringList CSimulatorPluginInfoList::toStringList(bool i18n) const - { - return this->transform([i18n](const CSimulatorPluginInfo &info) { return info.toQString(i18n); }); - } - - void CSimulatorPluginInfoList::registerMetadata() - { - qRegisterMetaType>(); - qDBusRegisterMetaType>(); - qRegisterMetaType>(); - qDBusRegisterMetaType>(); - qRegisterMetaType(); - qDBusRegisterMetaType(); - BlackMisc::registerMetaValueType(); - } - -} // namespace BlackSim diff --git a/src/blacksim/simulatorinfolist.h b/src/blacksim/simulatorinfolist.h deleted file mode 100644 index 10d995e89..000000000 --- a/src/blacksim/simulatorinfolist.h +++ /dev/null @@ -1,51 +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 BLACKSIM_SIMULATORINFOLIST_H -#define BLACKSIM_SIMULATORINFOLIST_H - -#include "simulatorplugininfo.h" -#include "blackmisc/sequence.h" -#include "blackmisc/collection.h" -#include - -namespace BlackSim -{ - //! Value object encapsulating a list of SimulatorInfo objects. - class CSimulatorPluginInfoList : public BlackMisc::CSequence - { - public: - //! Default constructor - CSimulatorPluginInfoList(); - - //! Construct from a base class object. - CSimulatorPluginInfoList(const CSequence &other); - - //! \copydoc CValueObject::toQVariant - virtual QVariant toQVariant() const { return QVariant::fromValue(*this); } - - //! Is simulator supported - bool supportsSimulator(const QString &simulator); - - //! String list with meaningful representations - QStringList toStringList(bool i18n = false) const; - - //! Register the metatypes - static void registerMetadata(); - - }; -} - -Q_DECLARE_METATYPE(BlackSim::CSimulatorPluginInfoList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif // guard diff --git a/src/blacksim/simulatormodelmappings.cpp b/src/blacksim/simulatormodelmappings.cpp deleted file mode 100644 index 74466aaec..000000000 --- a/src/blacksim/simulatormodelmappings.cpp +++ /dev/null @@ -1,52 +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 "simulatormodelmappings.h" - -using namespace BlackMisc; -using namespace BlackMisc::Network; - -namespace BlackSim -{ - - ISimulatorModelMappings::ISimulatorModelMappings(QObject *parent) : QObject(parent) {} - - int ISimulatorModelMappings::size() const - { - return this->m_mappings.size(); - } - - bool ISimulatorModelMappings::isEmpty() const - { - return this->m_mappings.isEmpty(); - } - - const CAircraftMappingList &ISimulatorModelMappings::getMappingList() const - { - return this->m_mappings; - } - - int ISimulatorModelMappings::synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs) - { - if (modelNames.isEmpty() || this->m_mappings.isEmpty()) { return this->m_mappings.size(); } - CAircraftMappingList newList; - for (const CAircraftMapping &mapping : this->m_mappings) - { - QString modelString = mapping.getModel().getModelString(); - if (modelString.isEmpty()) { continue; } - if (modelNames.contains(modelString, cs)) - { - newList.push_back(mapping); - } - } - this->m_mappings = newList; - return this->m_mappings.size(); - } - -} // namespace diff --git a/src/blacksim/simulatormodelmappings.h b/src/blacksim/simulatormodelmappings.h deleted file mode 100644 index 63a1d5dc1..000000000 --- a/src/blacksim/simulatormodelmappings.h +++ /dev/null @@ -1,53 +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 BLACKSIM_MODELMAPPINGS_H -#define BLACKSIM_MODELMAPPINGS_H - -#include "blackmisc/nwaircraftmappinglist.h" -#include - -namespace BlackSim -{ - //! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files) - //! can implement this, but provide the same mapping list. - class ISimulatorModelMappings : public QObject - { - Q_OBJECT - - public: - //! Constructor - ISimulatorModelMappings(QObject *parent = nullptr); - - //! Destructor - virtual ~ISimulatorModelMappings() {} - - //! Load data - virtual bool read() = 0; - - //! Empty - bool isEmpty() const; - - //! Size - int size() const; - - //! Get list - const BlackMisc::Network::CAircraftMappingList &getMappingList() const; - - //! Synchronize with existing model names, remove unneeded models - int synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs = Qt::CaseInsensitive); - - protected: - BlackMisc::Network::CAircraftMappingList m_mappings; //!< Mappings - }; -} - -#endif // guard diff --git a/src/blacksim/simulatorplugininfo.cpp b/src/blacksim/simulatorplugininfo.cpp deleted file mode 100644 index f6c878fe8..000000000 --- a/src/blacksim/simulatorplugininfo.cpp +++ /dev/null @@ -1,70 +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 "simulatorplugininfo.h" -#include "blackmisc/blackmiscfreefunctions.h" - -using namespace BlackMisc; - -namespace BlackSim -{ - - void CSimulatorPluginInfo::convertFromJson(const QJsonObject &json) - { - - - if (json["IID"].toString() != QStringLiteral("org.swift.pilotclient.BlackCore.SimulatorInterface")) - { - return; - } - - if (!json["MetaData"].isObject()) - { - return; - } - - QJsonObject data = json["MetaData"].toObject(); - if (data["name"].isUndefined() || data["simulator"].isUndefined()) - { - return; - } - - CValueObject::convertFromJson(data); - - m_valid = true; - } - - bool CSimulatorPluginInfo::isUnspecified() const - { - return m_name.isEmpty(); - } - - CVariant CSimulatorPluginInfo::getSimulatorSetupValue(int index) const - { - return this->m_simsetup.value(index); - } - - QString CSimulatorPluginInfo::getSimulatorSetupValueAsString(int index) const - { - CVariant qv = getSimulatorSetupValue(index); - Q_ASSERT(qv.canConvert()); - return qv.toQString(); - } - - void CSimulatorPluginInfo::setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup) - { - this->m_simsetup = setup; - } - - QString CSimulatorPluginInfo::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - return QString("%1 (%2)").arg(m_name, m_simulator); - } -} diff --git a/src/blacksim/simulatorplugininfo.h b/src/blacksim/simulatorplugininfo.h deleted file mode 100644 index 979ce2b69..000000000 --- a/src/blacksim/simulatorplugininfo.h +++ /dev/null @@ -1,96 +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 BLACKSIM_SIMULATORPLUGININFO_H -#define BLACKSIM_SIMULATORPLUGININFO_H - -#include "blackmisc/propertyindexvariantmap.h" -#include "blackmisc/valueobject.h" - -namespace BlackSim -{ - //! Describing a simulator plugin - class CSimulatorPluginInfo : public BlackMisc::CValueObject - { - /** - * The _name_ property identifies the plugin itself and must be uniqe. - */ - Q_PROPERTY(QString getName READ getName) - - /** - * The _simulator_ property specifies which simulator the plugin handles. - * There cannot be two plugins loaded for the same simulator. - * Swift enables some features for particular simulators. Currently recognized are: - * fsx, fs9, xplane - */ - Q_PROPERTY(QString getSimulator READ getSimulator) - - /** - * The _description_ property provides a short, human-readable description of the plugin. - */ - Q_PROPERTY(QString getDescription READ getDescription) - - public: - //! Default constructor - CSimulatorPluginInfo() = default; - - virtual void convertFromJson(const QJsonObject &json) override; - - //! Unspecified simulator - bool isUnspecified() const; - - //! Single setting value - BlackMisc::CVariant getSimulatorSetupValue(int index) const; - - //! Single setting value - QString getSimulatorSetupValueAsString(int index) const; - - //! Set single settings - void setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup); - - //! Check if the provided plugin metadata is valid. - //! Simulator plugin (driver) has to meet the following requirements: - //! * implements org.swift.pilotclient.BlackCore.SimulatorInterface; - //! * provides plugin name; - //! * specifies simulator it handles. - //! Unspecified sim is considered as invalid. - bool isValid() const { return m_valid; } - - bool operator==(const CSimulatorPluginInfo &other) { return getName() == other.getName(); } - - const QString &getName() const { return m_name; } - const QString &getSimulator() const { return m_simulator; } - const QString &getDescription() const { return m_description; } - - protected: - //! \copydoc CValueObject::convertToQString - virtual QString convertToQString(bool i18n = false) const override; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorPluginInfo) - QString m_name; - QString m_simulator; - QString m_description; - bool m_valid { false }; - BlackMisc::CPropertyIndexVariantMap m_simsetup; //!< allows to access simulator keys requried on remote side - }; -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::CSimulatorPluginInfo, ( - attr(o.m_name), - attr(o.m_simulator), - attr(o.m_description), - attr(o.m_valid), - attr(o.m_simsetup, flags()) - )) -Q_DECLARE_METATYPE(BlackSim::CSimulatorPluginInfo) - -#endif // guard diff --git a/src/blacksim/simulatorsetup.cpp b/src/blacksim/simulatorsetup.cpp deleted file mode 100644 index 2056d26b0..000000000 --- a/src/blacksim/simulatorsetup.cpp +++ /dev/null @@ -1,23 +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 "simulatorsetup.h" - -namespace BlackSim -{ - void CSimulatorSetup::setSettings(const BlackMisc::CPropertyIndexVariantMap &map) - { - this->m_setup = map; - } - - void CSimulatorSetup::init() - { - // void - } -} diff --git a/src/blacksim/simulatorsetup.h b/src/blacksim/simulatorsetup.h deleted file mode 100644 index 70b34ac6c..000000000 --- a/src/blacksim/simulatorsetup.h +++ /dev/null @@ -1,57 +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 BLACKSIM_SIMSETUP_H -#define BLACKSIM_SIMSETUP_H - -#include "blackmisc/propertyindexvariantmap.h" -#include -#include - -namespace BlackSim -{ - /*! - * \brief Simulator settings for flight simulators - * \details Represents the generic part of a simulator setup ("common denominator"), - * details kept in specialized classes - */ - class CSimulatorSetup - { - protected: - BlackMisc::CPropertyIndexVariantMap m_setup; //!< values describing the simulator setup (path, config files) - - protected: - //! Default constructor - CSimulatorSetup() {} - - //! Constructor - CSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &map) : m_setup(map) {} - - public: - //! Specific values - enum - { - SetupSimPath = BlackMisc::CPropertyIndex::GlobalIndexAbuseMode - }; - - //! Settings - BlackMisc::CPropertyIndexVariantMap getSettings() const { return this->m_setup;} - - //! Settings - void setSettings(const BlackMisc::CPropertyIndexVariantMap &map); - - //! Init, to be used where simulator runs - void init(); - - }; -} // namespace - -#endif // guard diff --git a/src/plugins/simulator/fs9/callback_wrapper.h b/src/plugins/simulator/fs9/callback_wrapper.h index 8b2c1d78c..2f6e2c310 100644 --- a/src/plugins/simulator/fs9/callback_wrapper.h +++ b/src/plugins/simulator/fs9/callback_wrapper.h @@ -49,4 +49,4 @@ namespace BlackSimPlugin } } -#endif //BLACKSIMPLUGIN_FS9_CALLBACK_WRAPPER_H +#endif // guard diff --git a/src/plugins/simulator/fs9/directplay_peer.h b/src/plugins/simulator/fs9/directplay_peer.h index bd8938a08..888c14367 100644 --- a/src/plugins/simulator/fs9/directplay_peer.h +++ b/src/plugins/simulator/fs9/directplay_peer.h @@ -48,6 +48,7 @@ namespace BlackSimPlugin //! Send a custom DirectPlay message HRESULT sendMessage(const QByteArray &data); + //! Reset peer void reset(); signals: diff --git a/src/plugins/simulator/fs9/plugin_fs9.pro b/src/plugins/simulator/fs9/plugin_fs9.pro index b3488b7ab..77cf04bde 100644 --- a/src/plugins/simulator/fs9/plugin_fs9.pro +++ b/src/plugins/simulator/fs9/plugin_fs9.pro @@ -7,7 +7,7 @@ TARGET = simulator_fs9 TEMPLATE = lib CONFIG += plugin shared -CONFIG += blackmisc blackcore blacksim +CONFIG += blackmisc blackcore LIBS += -lsimulator_fscommon -lFSUIPC_User -luuid @@ -23,10 +23,8 @@ SOURCES += *.cpp HEADERS += *.h win32:!win32-g++*: PRE_TARGETDEPS += ../../../../lib/blackmisc.lib \ - ../../../../lib/blacksim.lib \ ../../../../lib/blackcore.lib else: PRE_TARGETDEPS += ../../../../lib/libblackmisc.a \ - ../../../../lib/libblacksim.a \ ../../../../lib/libblackcore.a DESTDIR = ../../../../bin/plugins/simulator diff --git a/src/plugins/simulator/fs9/simulator_fs9.cpp b/src/plugins/simulator/fs9/simulator_fs9.cpp index ecf27703c..a2db8f675 100644 --- a/src/plugins/simulator/fs9/simulator_fs9.cpp +++ b/src/plugins/simulator/fs9/simulator_fs9.cpp @@ -15,7 +15,7 @@ #include "multiplayer_packets.h" #include "multiplayer_packet_parser.h" #include "blackcore/interpolator_linear.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/logmessage.h" #include "blackmisc/project.h" #include "blackmisc/logmessage.h" @@ -29,7 +29,7 @@ using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; -using namespace BlackSim; +using namespace BlackMisc::Simulation; using namespace BlackSimPlugin::Fs9; using namespace BlackSimPlugin::FsCommon; diff --git a/src/plugins/simulator/fs9/simulator_fs9.h b/src/plugins/simulator/fs9/simulator_fs9.h index b459ad1b8..62f7f67f4 100644 --- a/src/plugins/simulator/fs9/simulator_fs9.h +++ b/src/plugins/simulator/fs9/simulator_fs9.h @@ -20,7 +20,7 @@ #include "blackcore/interpolator.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/aviation/aircraft.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/pixmap.h" #include #include @@ -141,11 +141,13 @@ namespace BlackSimPlugin Q_INTERFACES(BlackCore::ISimulatorFactory) public: + //! Constructor CSimulatorFs9Factory(QObject* parent = nullptr); + //! Destructor virtual ~CSimulatorFs9Factory(); - //! \copydoc BlackCore::ISimulatorFactory::create() + //! \copydoc BlackCore::ISimulatorFactory::create(ownAircraftProvider, remoteAircraftProvider, parent) virtual BlackCore::ISimulator *create( BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, diff --git a/src/plugins/simulator/fscommon/fsuipc.cpp b/src/plugins/simulator/fscommon/fsuipc.cpp index 00ec73f23..ae48a6bd0 100644 --- a/src/plugins/simulator/fscommon/fsuipc.cpp +++ b/src/plugins/simulator/fscommon/fsuipc.cpp @@ -13,14 +13,14 @@ // bug in FSUIPC_User.h, windows.h not included, so we have to import it first #include "FSUIPC/FSUIPC_User.h" -#include "blacksim/fscommon/bcdconversions.h" +#include "blackmisc/simulation/fscommon/bcdconversions.h" #include "blackmisc/logmessage.h" #include #include #include using namespace BlackMisc; -using namespace BlackSim::FsCommon; +using namespace BlackMisc::Simulation::FsCommon; using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc::Geo; diff --git a/src/plugins/simulator/fscommon/plugin_fscommon.pro b/src/plugins/simulator/fscommon/plugin_fscommon.pro index a136ccf09..5be6fb989 100644 --- a/src/plugins/simulator/fscommon/plugin_fscommon.pro +++ b/src/plugins/simulator/fscommon/plugin_fscommon.pro @@ -21,10 +21,8 @@ SOURCES += *.cpp HEADERS += *.h win32:!win32-g++*: PRE_TARGETDEPS += ../../../../lib/blackmisc.lib \ - ../../../../lib/blacksim.lib \ ../../../../lib/blackcore.lib else: PRE_TARGETDEPS += ../../../../lib/libblackmisc.a \ - ../../../../lib/libblacksim.a \ ../../../../lib/libblackcore.a DESTDIR = ../../lib diff --git a/src/plugins/simulator/fscommon/simulator_fscommon.cpp b/src/plugins/simulator/fscommon/simulator_fscommon.cpp index cae7a067d..2116b21b1 100644 --- a/src/plugins/simulator/fscommon/simulator_fscommon.cpp +++ b/src/plugins/simulator/fscommon/simulator_fscommon.cpp @@ -9,18 +9,17 @@ #include "simulator_fscommon.h" #include "blackmisc/logmessage.h" -#include "blacksim/fscommon/vpilotmodelmappings.h" -#include "blacksim/fscommon/fscommonutil.h" +#include "blackmisc/simulation/fscommon/vpilotmodelmappings.h" +#include "blackmisc/simulation/fscommon/fscommonutil.h" using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Simulation; -using namespace BlackSim::FsCommon; +using namespace BlackMisc::Simulation::FsCommon; using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc; -using namespace BlackSimPlugin::FsCommon; -using namespace BlackSim; -using namespace BlackSim::FsCommon; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::FsCommon; namespace BlackSimPlugin { diff --git a/src/plugins/simulator/fscommon/simulator_fscommon.h b/src/plugins/simulator/fscommon/simulator_fscommon.h index ce5b1ee64..6d6552374 100644 --- a/src/plugins/simulator/fscommon/simulator_fscommon.h +++ b/src/plugins/simulator/fscommon/simulator_fscommon.h @@ -14,7 +14,7 @@ #include "blackcore/simulator.h" #include "blackcore/interpolator.h" -#include "blacksim/fscommon/aircraftmapper.h" +#include "blackmisc/simulation/fscommon/aircraftmapper.h" #include "fsuipc.h" #include @@ -108,7 +108,7 @@ namespace BlackSimPlugin static void reverseLookupIcaoData(BlackMisc::Simulation::CAircraftModel &model); //! Get the mapper singleton - static BlackSim::FsCommon::CAircraftMapper *mapperInstance(); + static BlackMisc::Simulation::FsCommon::CAircraftMapper *mapperInstance(); protected slots: diff --git a/src/plugins/simulator/fsx/plugin_fsx.pro b/src/plugins/simulator/fsx/plugin_fsx.pro index f5e4e1dd8..e9e6db7db 100644 --- a/src/plugins/simulator/fsx/plugin_fsx.pro +++ b/src/plugins/simulator/fsx/plugin_fsx.pro @@ -7,7 +7,7 @@ TARGET = simulator_fsx TEMPLATE = lib CONFIG += plugin shared -CONFIG += blackmisc blackcore blacksim +CONFIG += blackmisc blackcore LIBS += -lsimulator_fscommon -lSimConnect -lFSUIPC_User @@ -23,10 +23,8 @@ SOURCES += *.cpp HEADERS += *.h win32:!win32-g++*: PRE_TARGETDEPS += ../../../../lib/blackmisc.lib \ - ../../../../lib/blacksim.lib \ ../../../../lib/blackcore.lib else: PRE_TARGETDEPS += ../../../../lib/libblackmisc.a \ - ../../../../lib/libblacksim.a \ ../../../../lib/libblackcore.a DESTDIR = ../../../../bin/plugins/simulator diff --git a/src/plugins/simulator/fsx/simulator_fsx.cpp b/src/plugins/simulator/fsx/simulator_fsx.cpp index 26faded6b..81740d3c8 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx.cpp @@ -9,10 +9,10 @@ #include "simulator_fsx.h" #include "simconnect_datadefinition.h" -#include "blacksim/fscommon/bcdconversions.h" -#include "blacksim/fsx/simconnectutilities.h" -#include "blacksim/fsx/fsxsimulatorsetup.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/fscommon/bcdconversions.h" +#include "blackmisc/simulation/fsx/simconnectutilities.h" +#include "blackmisc/simulation/fsx/fsxsimulatorsetup.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/project.h" #include "blackmisc/aviation/airportlist.h" @@ -29,9 +29,9 @@ using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; -using namespace BlackSim; -using namespace BlackSim::FsCommon; -using namespace BlackSim::Fsx; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::FsCommon; +using namespace BlackMisc::Simulation::Fsx; using namespace BlackCore; namespace BlackSimPlugin diff --git a/src/plugins/simulator/fsx/simulator_fsx.h b/src/plugins/simulator/fsx/simulator_fsx.h index f5924e81c..d60cb5fcd 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.h +++ b/src/plugins/simulator/fsx/simulator_fsx.h @@ -17,7 +17,7 @@ #include "../fscommon/simulator_fscommon.h" #include "blackcore/simulator.h" #include "blackcore/interpolator_linear.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/aviation/airportlist.h" @@ -195,7 +195,7 @@ namespace BlackSimPlugin uint m_nextObjID = 1; //!< object ID TODO: also used as request id, where to we place other request ids as for facilities QHash m_simConnectObjects; QFutureWatcher m_watcherConnect; - BlackSim::CSimulatorPluginInfo m_simulatorInfo; + BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorInfo; // statistics qint64 m_statsUpdateAircraftTimeTotal = 0; @@ -203,6 +203,7 @@ namespace BlackSimPlugin int m_statsUpdateAircraftCount = 0; }; + //! Listener for FSX class CSimulatorFsxListener : public BlackCore::ISimulatorListener { Q_OBJECT @@ -223,6 +224,6 @@ namespace BlackSimPlugin }; } -} // namespace BlackCore +} // namespace #endif // guard diff --git a/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp b/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp index fb14be94e..a7d21badb 100644 --- a/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp @@ -9,10 +9,10 @@ #include "simulator_fsx.h" #include "simconnect_datadefinition.h" -#include "blacksim/fscommon/bcdconversions.h" -#include "blacksim/fsx/simconnectutilities.h" -#include "blacksim/fsx/fsxsimulatorsetup.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/fscommon/bcdconversions.h" +#include "blackmisc/simulation/fsx/simconnectutilities.h" +#include "blackmisc/simulation/fsx/fsxsimulatorsetup.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/project.h" #include "blackmisc/aviation/airportlist.h" #include "blackmisc/logmessage.h" @@ -23,9 +23,9 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; using namespace BlackMisc::Network; -using namespace BlackSim; -using namespace BlackSim::FsCommon; -using namespace BlackSim::Fsx; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::FsCommon; +using namespace BlackMisc::Simulation::Fsx; namespace BlackSimPlugin { diff --git a/src/plugins/simulator/fsx/simulator_fsxfactory.cpp b/src/plugins/simulator/fsx/simulator_fsxfactory.cpp index fde27775a..531c7000f 100644 --- a/src/plugins/simulator/fsx/simulator_fsxfactory.cpp +++ b/src/plugins/simulator/fsx/simulator_fsxfactory.cpp @@ -9,7 +9,7 @@ #include "simulator_fsxfactory.h" #include "simulator_fsx.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/project.h" #include #include diff --git a/src/plugins/simulator/fsx/simulator_fsxfactory.h b/src/plugins/simulator/fsx/simulator_fsxfactory.h index c2c08bcd8..564664edf 100644 --- a/src/plugins/simulator/fsx/simulator_fsxfactory.h +++ b/src/plugins/simulator/fsx/simulator_fsxfactory.h @@ -13,7 +13,7 @@ #define BLACKSIMPLUGIN_SIMULATOR_FSXFACTORY_H #include "blackcore/simulator.h" -#include "blacksim/simulatorplugininfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include #include diff --git a/src/plugins/simulator/xplane/plugin_xplane.pro b/src/plugins/simulator/xplane/plugin_xplane.pro index a52554cfd..6a311829c 100644 --- a/src/plugins/simulator/xplane/plugin_xplane.pro +++ b/src/plugins/simulator/xplane/plugin_xplane.pro @@ -7,7 +7,7 @@ TARGET = simulator_xplane TEMPLATE = lib CONFIG += plugin shared -CONFIG += blackmisc blackcore blacksim +CONFIG += blackmisc blackcore DEPENDPATH += . ../../../../src INCLUDEPATH += . ../../../../src diff --git a/src/plugins/simulator/xplane/simulator_xplane.cpp b/src/plugins/simulator/xplane/simulator_xplane.cpp index 7b2149883..43adb821f 100644 --- a/src/plugins/simulator/xplane/simulator_xplane.cpp +++ b/src/plugins/simulator/xplane/simulator_xplane.cpp @@ -22,7 +22,7 @@ using namespace BlackMisc::Network; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Simulation; using namespace BlackMisc::Geo; -using namespace BlackSim; +using namespace BlackMisc::Simulation; namespace { inline QString xbusServiceName() { diff --git a/src/plugins/simulator/xplane/simulator_xplane.h b/src/plugins/simulator/xplane/simulator_xplane.h index 5aab449a3..9e6920686 100644 --- a/src/plugins/simulator/xplane/simulator_xplane.h +++ b/src/plugins/simulator/xplane/simulator_xplane.h @@ -13,7 +13,7 @@ #define BLACKSIMPLUGIN_SIMULATOR_XPLANE_H #include "blackcore/simulator.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" #include "blackmisc/pixmap.h" #include diff --git a/src/swiftcore/swiftcore.pro b/src/swiftcore/swiftcore.pro index 8387839a2..2ebaeb1c1 100644 --- a/src/swiftcore/swiftcore.pro +++ b/src/swiftcore/swiftcore.pro @@ -10,21 +10,19 @@ TEMPLATE = app CONFIG += console CONFIG -= app_bundle -CONFIG += blackmisc blacksound blackinput blackcore blacksim +CONFIG += blackmisc blacksound blackinput blackcore -DEPENDPATH += . ../../src/blackmisc ../../src/blacksound ../../src/blackcore ../../src/blacksim ../../src/blackinput +DEPENDPATH += . ../../src/blackmisc ../../src/blacksound ../../src/blackcore ../../src/blackinput INCLUDEPATH += . ../../src win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ ../../lib/blacksound.lib \ ../../lib/blackcore.lib \ - ../../lib/blacksim.lib \ ../../lib/blackinput.lib else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ ../../lib/libblacksound.a \ ../../lib/libblackcore.a \ - ../../lib/libblacksim.a \ ../../lib/libblackinput.a diff --git a/src/swiftgui_standard/main.cpp b/src/swiftgui_standard/main.cpp index 809f55624..4b04227b4 100644 --- a/src/swiftgui_standard/main.cpp +++ b/src/swiftgui_standard/main.cpp @@ -13,7 +13,6 @@ #include "blackgui/stylesheetutility.h" #include "blackcore/blackcorefreefunctions.h" #include "blackcore/context_runtime_config.h" -#include "blacksim/blacksimfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/logmessage.h" #include "blackmisc/icons.h" @@ -39,7 +38,7 @@ int main(int argc, char *argv[]) // register BlackMisc::initResources(); BlackMisc::registerMetadata(); - BlackSim::registerMetadata(); + BlackMisc::Simulation::registerMetadata(); BlackCore::registerMetadata(); // BlackMisc::displayAllUserMetatypesTypes(); diff --git a/src/swiftgui_standard/swiftgui_standard.pro b/src/swiftgui_standard/swiftgui_standard.pro index 0789c345a..b8410b897 100644 --- a/src/swiftgui_standard/swiftgui_standard.pro +++ b/src/swiftgui_standard/swiftgui_standard.pro @@ -10,24 +10,22 @@ TEMPLATE = app SOURCES += *.cpp HEADERS += *.h FORMS += *.ui -CONFIG += blackmisc blacksound blackinput blackcore blackgui blacksim +CONFIG += blackmisc blacksound blackinput blackcore blackgui CONFIG -= app_bundle -DEPENDPATH += . ../../src/blackmisc ../../src/blackgui ../../src/blacksound ../../src/blacksim ../../src/blackcore ../../src/blackinput +DEPENDPATH += . ../../src/blackmisc ../../src/blackgui ../../src/blacksound ../../src/blackcore ../../src/blackinput INCLUDEPATH += . ../../src DESTDIR = ../../bin win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ ../../lib/blackgui.lib \ - ../../lib/blacksim.lib \ ../../lib/blacksound.lib \ ../../lib/blackcore.lib \ ../../lib/blackinput.lib else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ ../../lib/libblackgui.a \ - ../../lib/libblacksim.a \ ../../lib/libblacksound.a \ ../../lib/libblackcore.a \ ../../lib/libblackinput.a diff --git a/swift.pro b/swift.pro index f0508da3d..6694be942 100644 --- a/swift.pro +++ b/swift.pro @@ -14,10 +14,6 @@ contains(BLACK_CONFIG, BlackInput) { SUBDIRS += src/blackinput } -contains(BLACK_CONFIG, BlackSim) { - SUBDIRS += src/blacksim -} - contains(BLACK_CONFIG, BlackCore) { SUBDIRS += src/blackcore SUBDIRS += src/swiftcore/swiftcore.pro @@ -49,19 +45,18 @@ contains(BLACK_CONFIG, XPlane) { contains(BLACK_CONFIG, Samples) { SUBDIRS += samples/cli_client/sample_cli_client.pro - SUBDIRS += samples/blackmiscvectorgeo/sample_vector_geo.pro + SUBDIRS += samples/blackmiscgeo/sample_geo.pro SUBDIRS += samples/blackmiscquantities/sample_quantities_aviation.pro SUBDIRS += samples/blackmiscdbus/sample_blackmisc_dbus.pro SUBDIRS += samples/blackmisc/sample_blackmisc.pro SUBDIRS += samples/voiceclient/sample_voice_client.pro - SUBDIRS += samples/blacksim/sample_blacksim.pro + SUBDIRS += samples/blackmiscsim/sample_blackmisc_sim.pro SUBDIRS += samples/hotkey/sample_hotkey.pro } contains(BLACK_CONFIG, Unittests) { SUBDIRS += tests/blackmisc/test_blackmisc.pro SUBDIRS += tests/blackcore/test_blackcore.pro - SUBDIRS += tests/blacksim/test_blacksim.pro } contains(BLACK_CONFIG, Doxygen) { diff --git a/tests/blackcore/testinterpolator.cpp b/tests/blackcore/testinterpolator.cpp index b97274535..2daee5a71 100644 --- a/tests/blackcore/testinterpolator.cpp +++ b/tests/blackcore/testinterpolator.cpp @@ -9,7 +9,7 @@ #include "testinterpolator.h" #include "blackcore/interpolator_linear.h" -#include "blackmisc/simulation/simdirectaccessremoteaircraftdummy.h" +#include "blackmisc/simulation/remoteaircraftprovider.h" #include using namespace BlackCore; diff --git a/tests/blackcore/testnetwork.h b/tests/blackcore/testnetwork.h index 7d1c452e2..06d1b85fe 100644 --- a/tests/blackcore/testnetwork.h +++ b/tests/blackcore/testnetwork.h @@ -13,7 +13,7 @@ #define BLACKCORETEST_TESTNETWORK_H #include "blackcore/network_vatlib.h" -#include "blackmisc/simulation/simdirectaccessownaircraft.h" +#include "blackmisc/simulation/ownaircraftprovider.h" #include namespace BlackCoreTest diff --git a/tests/blackmisc/testblackmiscmain.cpp b/tests/blackmisc/testblackmiscmain.cpp index 458596365..07f8dead0 100644 --- a/tests/blackmisc/testblackmiscmain.cpp +++ b/tests/blackmisc/testblackmiscmain.cpp @@ -32,6 +32,7 @@ namespace BlackMiscTest status |= QTest::qExec(&containerTests, argc, argv); status |= QTest::qExec(&variantAndMap, argc, argv); status |= QTest::qExec(&hardwareTests, argc, argv); + status |= QTest::qExec(&hardwareTests, argc, argv); } return status; } diff --git a/tests/blacksim/main.cpp b/tests/blacksim/main.cpp deleted file mode 100644 index de7b30961..000000000 --- a/tests/blacksim/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "testblacksimmain.h" -#include -#include - -using namespace BlackSimTest; - -/*! - * Starter for test cases - * \brief main - * \param argc - * \param argv - * \return - */ -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - CBlackSimTestMain::unitMain(argc, argv); - Q_UNUSED(a); - - // bye - return 0; -} diff --git a/tests/blacksim/test_blacksim.pro b/tests/blacksim/test_blacksim.pro deleted file mode 100644 index 7ab5faff3..000000000 --- a/tests/blacksim/test_blacksim.pro +++ /dev/null @@ -1,27 +0,0 @@ -include (../../config.pri) -include (../../build.pri) - -QT += core testlib dbus network - -TARGET = test_blacksim -TEMPLATE = app - -CONFIG += console -CONFIG -= app_bundle -CONFIG += blackmisc blacksim -CONFIG += testcase - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -HEADERS += *.h -SOURCES += *.cpp - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ - ../../lib/blacksim.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ - ../../lib/libblacksim.a - -DESTDIR = ../../bin - -include (../../libraries.pri) diff --git a/tests/blacksim/testblacksimmain.cpp b/tests/blacksim/testblacksimmain.cpp deleted file mode 100644 index 29fc271e3..000000000 --- a/tests/blacksim/testblacksimmain.cpp +++ /dev/null @@ -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. - */ - -#include "testblacksimmain.h" -#include "testsimcommon.h" - -namespace BlackSimTest -{ - /* - * Starting main, equivalent to QTEST_APPLESS_MAIN for multiple test classes. - */ - int CBlackSimTestMain::unitMain(int argc, char *argv[]) - { - int status = 0; - { - CTestFsCommon fscommon; - status |= QTest::qExec(&fscommon, argc, argv); - } - return status; - } -} // namespace diff --git a/tests/blacksim/testblacksimmain.h b/tests/blacksim/testblacksimmain.h deleted file mode 100644 index 447703883..000000000 --- a/tests/blacksim/testblacksimmain.h +++ /dev/null @@ -1,38 +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 BLACKSIMTEST_TESTMAIN_H -#define BLACKSIMTEST_TESTMAIN_H - -#include - -namespace BlackSimTest -{ - - /*! - * Class firing all unit tests in this namespace. - * Avoids clashes with other main(..) functions and allows to fire the test cases - * simply from any other main. - */ - class CBlackSimTestMain - { - public: - /*! - * \brief Starting all - * \param argc - * \param argv - * \return - */ - static int unitMain(int argc, char *argv[]); - }; -} - -#endif // guard diff --git a/tests/blacksim/testsimcommon.cpp b/tests/blacksim/testsimcommon.cpp deleted file mode 100644 index c172d08bc..000000000 --- a/tests/blacksim/testsimcommon.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -#include "testsimcommon.h" -#include "blacksim/simulatorplugininfo.h" -#include - -using namespace BlackSim; - -namespace BlackSimTest -{ - /* - * Tests - */ - void CTestFsCommon::misc() - { -// CSimulatorInfo si1 = CSimulatorInfo::FSX(); -// CSimulatorInfo si2 = CSimulatorInfo::FS9(); -// CSimulatorInfo si1Copy(si1); -// QVERIFY2(si1.getValueHash() != si2.getValueHash(), "Info objects expect unequal hashs"); -// QVERIFY2(si1.getValueHash() == si1Copy.getValueHash(), "Info objects expect equal hashs"); - } - -} // namespace diff --git a/tests/blacksim/testsimcommon.h b/tests/blacksim/testsimcommon.h deleted file mode 100644 index 869635f15..000000000 --- a/tests/blacksim/testsimcommon.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -#ifndef BLACKSIMTEST_TESTSIMCOMMON_H -#define BLACKSIMTEST_TESTSIMCOMMON_H - -#include - -namespace BlackSimTest -{ - //! Test for simulator common classes - class CTestFsCommon : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestFsCommon(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! FsCommon tests - void misc(); - }; - -} // namespace - -#endif // guard