Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
+286
@@ -0,0 +1,286 @@
|
||||
|
||||
|
||||
|
||||
#include "lts_plugin_manager.h"
|
||||
#include "Ui/lts_plugin_manager_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <LtsWidgets/lts_wait_dialog.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
LtsPluginManager::LtsPluginManager()
|
||||
: m_sessionManager(new LtsSession::LtsSessionManager)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsPluginManager"))
|
||||
, m_markedForDeletion(false)
|
||||
{
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalQuit,
|
||||
this, &LtsPluginManager::signalQuit);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalLogout,
|
||||
this, &LtsPluginManager::signalLogout);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationFinished,
|
||||
this, &LtsPluginManager::signalInitializationFinished);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationAborted,
|
||||
this, &LtsPluginManager::signalInitializationAborted);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationFinished,
|
||||
this, &LtsPluginManager::slotInitializationFinished);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::taskSwitch,
|
||||
this, &LtsPluginManager::taskSwitch);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::hideAllOtherBLWs,
|
||||
this, &LtsPluginManager::hideAllOtherBLWs);
|
||||
|
||||
QTimer *t = new QTimer(this);
|
||||
t->setInterval(1000);
|
||||
connect(t, &QTimer::timeout,
|
||||
this, &LtsPluginManager::signalStillAlive);
|
||||
t->start();
|
||||
}
|
||||
|
||||
|
||||
LtsPluginManager::~LtsPluginManager()
|
||||
{
|
||||
|
||||
|
||||
delete m_sessionManager;
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManager::softQuit()
|
||||
{
|
||||
emit signalSoftQuit();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManager::_softQuit()
|
||||
{
|
||||
m_sessionManager->softQuit();
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsSession::LtsSession *> LtsPluginManager::sessions() const
|
||||
{
|
||||
return m_sessionManager->sessions();
|
||||
}
|
||||
|
||||
bool LtsPluginManager::hasSituationMapInstance(const LtsAppDescriptor::AppDescription &appDescription, bool alsoTestForScriptApp)
|
||||
{
|
||||
if (alsoTestForScriptApp && appDescription.id == LtsAppDescriptor::App::Scripts)
|
||||
return true;
|
||||
|
||||
for (const LtsAppDescriptor::PluginInfo &pluginInfo : qAsConst(appDescription.pluginInfos))
|
||||
{
|
||||
if (pluginInfo.flags.testFlag(LtsAppDescriptor::PluginInfo::Flag::ACTIONS) &&
|
||||
(pluginInfo.iid == QStringLiteral("sitmap")))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LtsPluginManager::hasSituationMapInstance() const
|
||||
{
|
||||
return hasSituationMapInstance(m_app);
|
||||
}
|
||||
|
||||
LtsSession::LtsSession *LtsPluginManager::getSession(IDL::PartitionType partitionType, int partitionId)
|
||||
{
|
||||
return m_sessionManager->getSession(partitionType, partitionId);
|
||||
}
|
||||
|
||||
|
||||
bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription &app, bool headless,
|
||||
const LtsSession::DdsConnectionParams &connParams, const QString &workspaceId,
|
||||
bool hidden)
|
||||
{
|
||||
|
||||
|
||||
|
||||
LtsWidgets::LtsWaitDialogContainer wait;
|
||||
|
||||
m_app = app;
|
||||
LtsPluginLoader *pluginLoader = LtsPluginLoader::getInstance();
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
auto cb = [&](const PluginInstance &pi)
|
||||
{
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!pluginLoader->loadPlugins(PluginType::DATA, cb))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "PluginLoader failed to load data plugins - abort!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto cbLoadPlugins = [&](const PluginInstance &pi)
|
||||
{
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!pluginLoader->loadPlugins(PluginType::GUI, cbLoadPlugins))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "PluginLoader failed to load gui plugins - abort!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<AppPluginInstance> dataApiList;
|
||||
for (auto i = dataPlugins.constBegin(); i != dataPlugins.constEnd(); ++i)
|
||||
{
|
||||
const PluginInstance &pi = *i;
|
||||
|
||||
AppPluginInstance api;
|
||||
api.pluginInstance = pi;
|
||||
api.m_appName = m_app.appName;
|
||||
api.m_appId = m_app.id;
|
||||
|
||||
|
||||
dataApiList.append(api);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<AppPluginInstance> guiApiList;
|
||||
for (auto i = guiPlugins.constBegin(); i != guiPlugins.constEnd(); ++i)
|
||||
{
|
||||
const PluginInstance &pi = *i;
|
||||
|
||||
AppPluginInstance api;
|
||||
api.pluginInstance = pi;
|
||||
api.m_appName = m_app.appName;
|
||||
api.m_appId = m_app.id;
|
||||
|
||||
|
||||
|
||||
for (auto i2 = app.pluginInfos.constBegin(); i2 != app.pluginInfos.constEnd(); ++i2)
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo &rp = *i2;
|
||||
|
||||
|
||||
if (rp.type == LtsAppDescriptor::PluginInfo::PluginType::GUI
|
||||
&& rp.iid == pi.pluginName)
|
||||
{
|
||||
|
||||
api.m_flags = rp.flags;
|
||||
api.m_options = rp.options;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
guiApiList.append(api);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LtsSession::DdsConnectionParams connParamsNew(connParams);
|
||||
if (!connParamsNew.isValid())
|
||||
{
|
||||
INFO_LOG(m_logger) << "Invalid connection params given - using default parameter";
|
||||
|
||||
connParamsNew.domainId = LtsSessionData::LtsSessionData::getInstance()->getDomainIdPreset();
|
||||
connParamsNew.partitionId = 0;
|
||||
connParamsNew.exerciseId = 0;
|
||||
connParamsNew.partitionType = IDL::PartitionType::Global;
|
||||
|
||||
|
||||
connParamsNew.tcpConnectionUrl = LtsSessionData::LtsSessionData::getInstance()->getTcpConnectionUrl();
|
||||
}
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->getQosFile().size() > 0 && LtsSessionData::LtsSessionData::getInstance()->getQosFile().at(0).size() > 0)
|
||||
connParamsNew.qos_file = LtsSessionData::LtsSessionData::getInstance()->getQosFile();
|
||||
else
|
||||
connParamsNew.qos_file = QStringList();
|
||||
if (!m_sessionManager->init(connParamsNew,
|
||||
dataApiList,
|
||||
guiApiList,
|
||||
m_app.id,
|
||||
workspaceId,
|
||||
headless,
|
||||
hidden))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create Global Session - abort.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user