Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Instance of the UAS plugin
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, ESZS, 2025-04-17
|
||||
*/
|
||||
|
||||
#include "plugin_instance.h"
|
||||
|
||||
#include "from_tab.h"
|
||||
#include "uav_ia_manager.h"
|
||||
|
||||
#include <TrainingAreaBase/send_to_dds.h>
|
||||
#include <TrainingAreaBase/training_area_telegrams.h>
|
||||
#include <CentralEffectSimulation/ces_dtc.h>
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <FileManagement/flm_dtc.h>
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
|
||||
#include <TmsIfAdapter/module_loader.h>
|
||||
#include <TmsIfAdapter/tms_if_adapter.h>
|
||||
#include <TmsIfAdapter/uav_commander.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
namespace UAS
|
||||
{
|
||||
TmsIfModuleHandle::TmsIfModuleHandle()
|
||||
: m_handle(ModuleLoader::load(QString(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/")).toStdString())) // won't work on windows as libs are always inside the bin dir (QCoreApplication::applicationFilePath)
|
||||
{}
|
||||
|
||||
|
||||
TmsIfModuleHandle::~TmsIfModuleHandle()
|
||||
{
|
||||
try
|
||||
{
|
||||
ModuleLoader::unload(m_handle);
|
||||
}
|
||||
catch(std::exception &ex)
|
||||
{
|
||||
qDebug() << "failed to unload tms-if adapter module! " << ex.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PluginInstance::PluginInstance(TrainingAreaBase::Plugin::DataProvider *dataProvider,
|
||||
const std::shared_ptr<TrainingAreaBase::RecvFromTab> &sendToDds,
|
||||
const std::shared_ptr<TrainingAreaBase::DdsHandler> &ddsHandler,
|
||||
NGL::Settings *settings)
|
||||
: m_exerciseId(dataProvider->exerciseId())
|
||||
, m_sendToDds(sendToDds)
|
||||
, m_settings(settings)
|
||||
, m_tmsIfAdapter(ModuleLoader::get(m_tmsIfModuleHandle()))
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_dtcPdm(ProjectDataManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector()))
|
||||
, m_dtcPpm(ParticipantManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector()))
|
||||
, m_uavIAManager(new UAVInterfaceAdapterManager(m_ddsHandler, m_sendToDds, m_tmsIfAdapter, m_exerciseId, this))
|
||||
, m_fromTab(new FromTab(ddsHandler, m_sendToDds, m_uavIAManager, m_exerciseId))
|
||||
, m_logger(getLogger("PluginInstance"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "UAS PluginInstance running!";
|
||||
|
||||
if (!m_dtcPdm)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "m_dtcPdm failed";
|
||||
throw std::runtime_error("m_dtcPdm failed");
|
||||
}
|
||||
m_dtcPdm->enableChargeType(); // for m_dtcPdm->isJamming(..)
|
||||
m_dtcPdm->waitForHistoricalDataChargeType(3000);
|
||||
|
||||
|
||||
if (!m_dtcPpm)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "m_dtcPpm failed";
|
||||
throw std::runtime_error("m_dtcPpm failed");
|
||||
}
|
||||
m_dtcPpm->enableParticipant(); // for looking up and receiving UAV participants to start UAV IA process(es)
|
||||
m_dtcPpm->waitForHistoricalDataParticipant(3000);
|
||||
|
||||
|
||||
// only start interface adapter *instances* when tmsIfAdapter is done setting up the interface adapter itself
|
||||
if (m_tmsIfAdapter.isReady())
|
||||
{
|
||||
m_uavIAManager->init();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tmsIfAdapter.set_isReady_Callback([this]()
|
||||
{
|
||||
m_uavIAManager->init();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PluginInstance::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<TrainingAreaBase::SendToTab> PluginInstance::sendToTab()
|
||||
{
|
||||
return m_fromTab;
|
||||
}
|
||||
|
||||
|
||||
bool PluginInstance::canSendData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} // namespace UAS
|
||||
|
||||
|
||||
//#include <plugin_instance.moc> // temp! for Positions test class
|
||||
Reference in new issue
Block a user