- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
217 lines
7.3 KiB
C++
Executable File
217 lines
7.3 KiB
C++
Executable File
/**
|
|
* MainHandler for MessageDataManagement
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by hjl, SLSE, 2016-09-21
|
|
*/
|
|
|
|
#include "main_handler.h"
|
|
#include "settings.h"
|
|
|
|
#include <DDS/Core/pacemaker.h>
|
|
#include <LtsPluginManager/lts_plugin_loader.h>
|
|
|
|
#include <LtsElevation/lts_elevation_manager.h>
|
|
#include <LtsCoordinate/lts_coordinate.h>
|
|
|
|
|
|
namespace CentralEffectSimulation
|
|
{
|
|
|
|
MainHandler::MainHandler(QObject *parent)
|
|
: QObject(parent)
|
|
, m_logger(CentralEffectSimulation::getLogger("MainHandler"))
|
|
{
|
|
INFO_LOG() << "MainHandler::MainHandler";
|
|
} // end of ctor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
MainHandler::~MainHandler()
|
|
{
|
|
m_ddsHandler.reset();
|
|
m_db.reset();
|
|
m_handlerParticipant.reset();
|
|
m_handlerBuildingData.reset();
|
|
|
|
INFO_LOG() << "MainHandler::~MainHandler";
|
|
} // end of dtor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
bool MainHandler::loadPlugin(const LtsPluginManager::PluginInstance &pi)
|
|
{
|
|
DEBUG_LOG() << "Trying to load ces plugin '" << pi.fullFileName << "'...";
|
|
|
|
Plugin::Plugin *cesPlugin = qobject_cast<Plugin::Plugin *>(pi.plugin);
|
|
if (!cesPlugin)
|
|
{
|
|
WARNING_LOG() << "failed loading a ces plugin - not a CentralEffectSimulation object!";
|
|
return false;
|
|
}
|
|
DEBUG_LOG() << "... success";
|
|
std::shared_ptr<Plugin::Interface> ifc = cesPlugin->createInterface(this,
|
|
// m_ddsHandler->dds(),
|
|
nullptr,
|
|
Settings::settings(),
|
|
this);
|
|
|
|
DEBUG_LOG() << "Vorher: m_interfaces.size=" << m_interfaces.size();
|
|
|
|
|
|
if (!ifc || !ifc->init(m_domainId, m_exerciseId))
|
|
{
|
|
WARNING_LOG() << "Could not initialize CentralEffectSimulation plugin";
|
|
return false;
|
|
}
|
|
|
|
static int counter = 0;
|
|
INFO_LOG() << "Loading and init of ces_plugin successfull: "
|
|
<< ++counter
|
|
<< " pluginName = '" << pi.pluginName << "'"
|
|
<< ", filename '" << pi.fullFileName << "'";
|
|
|
|
m_interfaces.push_back(ifc);
|
|
DEBUG_LOG() << "Nachher: m_interfaces.size=" << m_interfaces.size();
|
|
|
|
DEBUG_LOG() << "ECHO!" << ifc->echo(QStringLiteral("TEST"));
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MainHandler::init(int domainId, int exerciseId)
|
|
{
|
|
m_domainId = domainId;
|
|
m_exerciseId = exerciseId;
|
|
INFO_LOG() << "Start MessageDataManagement MainHandler. domainId =" << domainId
|
|
<< " exerciseId=" << exerciseId;
|
|
|
|
// initialize database
|
|
m_dbHandler = std::make_shared<DbHandler>();
|
|
|
|
if (!m_dbHandler->init(exerciseId, Settings::settings()))
|
|
{
|
|
ERROR_LOG() << "Initialisation DbHandler failed.";
|
|
return false;
|
|
}
|
|
m_db = m_dbHandler->db();
|
|
INFO_LOG() << "MainHandler::init DbHandler initialized. ";
|
|
|
|
|
|
// initialize DDS
|
|
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
|
if (!m_ddsHandler->init())
|
|
{
|
|
ERROR_LOG() << "Initialisation DdsHandler failed.";
|
|
if (m_ddsHandler->pacemaker())
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
|
return false;
|
|
}
|
|
|
|
|
|
NOTICE_LOG(m_logger) << Q_FUNC_INFO << " LtsElevationManager... ";
|
|
|
|
LtsElevation::LTS_ELEVATION_MANAGER_TYPE ltsElevationManager = LtsElevation::LtsElevationManager::createInstance(exerciseId,
|
|
dds()->exmDtc(),
|
|
dds()->asmDtc());
|
|
if (ltsElevationManager)
|
|
{
|
|
// waitForInitialization,
|
|
// ElevationFile is read in a workerThread and waitForInitialization is used via QFutureWatcher
|
|
// So the logMsg 'Finished reading elevation map of file' will be shown with a delay.
|
|
// This is no error.
|
|
ltsElevationManager->waitForInitialization();
|
|
DEBUG_LOG() << Q_FUNC_INFO << " LtsElevationManager... waitForInitialization DONE";
|
|
|
|
// using elevationCbFunc = std::function<double(double, double, double, bool*)>;
|
|
using namespace std::placeholders;
|
|
LtsCoordTrans::LtsCoordinate::elevationCbFunc elevationCB = std::bind(&LtsElevation::LtsElevationManager::elevation,
|
|
ltsElevationManager.data(), _1, _2, _3, _4);
|
|
LtsCoordTrans::LtsCoordinate::setElevationCallback(elevationCB);
|
|
|
|
NOTICE_LOG(m_logger) << Q_FUNC_INFO << " LtsElevationManager... LtsCoordinate::setElevationCallback DONE";
|
|
}
|
|
|
|
|
|
DEBUG_LOG() << Q_FUNC_INFO << " LtsElevationManager... DONE ";
|
|
|
|
|
|
|
|
// initialize handlerBuildingData do this before init AesDataHandler
|
|
m_handlerBuildingData = std::make_shared<HandlerBuildingData>(m_ddsHandler, this);
|
|
|
|
if (!m_handlerBuildingData->init())
|
|
{
|
|
ERROR_LOG() << "Initialisation HandlerBuildingData failed.";
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
|
return false;
|
|
}
|
|
|
|
|
|
// initialize handlerParticipant
|
|
//m_handlerParticipant = std::make_shared<HandlerParticipant>(m_ddsHandler,
|
|
// this);
|
|
|
|
int cheatingDistanceVehicle = Settings::cesCheatingDistanceVehicle();
|
|
int cheatingDistanceSoldier = Settings::cesCheatingDistanceSoldier();
|
|
|
|
m_handlerParticipant = std::make_shared<HandlerParticipant>(m_ddsHandler,
|
|
m_handlerBuildingData,
|
|
cheatingDistanceVehicle,
|
|
cheatingDistanceSoldier,
|
|
this);
|
|
|
|
if (!m_handlerParticipant->init())
|
|
{
|
|
ERROR_LOG() << "Initialisation HandlerParticipant failed.";
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
|
return false;
|
|
}
|
|
|
|
|
|
///////////////
|
|
/// Plugins ///
|
|
///////////////
|
|
|
|
// ProxyBuilding:
|
|
// some plugins need access to other plugins (siblings)
|
|
// If a plugin would like to offer a function, the ProxyXY could be used;
|
|
m_proxyBuilding = std::make_shared<ProxyBuilding>();
|
|
|
|
|
|
|
|
|
|
auto cb = [&](const LtsPluginManager::PluginInstance &pi) { return loadPlugin(pi); };
|
|
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::SPECIAL,
|
|
cb,
|
|
QStringList(),
|
|
QStringLiteral("ces"));
|
|
|
|
if (m_interfaces.empty())
|
|
{
|
|
WARNING_LOG() << "Could not load any Central Effect Simulation plugin";
|
|
return false;
|
|
}
|
|
INFO_LOG() << "m_interfaces size=" << m_interfaces.size();
|
|
|
|
// for (/*std::shared_ptr<*/Plugin::EchoInterface/*> &*/ *ifc : m_interfaces)
|
|
// INFO_LOG() << "ECHO! " << ifc->echo(QStringLiteral("TEST"));
|
|
//m_txHandler->addTxHandler(ifc->sendToTab());
|
|
///////////////////
|
|
/// End Plugins ///
|
|
///////////////////
|
|
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
|
|
|
|
return true;
|
|
} // end of init()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
} // namespace
|
|
|