/** * 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 #include #include #include #include #include #include #include #include #include #include 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 &sendToDds, const std::shared_ptr &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 PluginInstance::sendToTab() { return m_fromTab; } bool PluginInstance::canSendData() const { return true; } } // namespace UAS //#include // temp! for Positions test class