794 lines
31 KiB
C++
Executable File
794 lines
31 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* GUI Plugin for ResourceManangement
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2016-11-02
|
|
*/
|
|
|
|
#include "ism_resource_gui_plugin.h"
|
|
#include "ism_plan_dialog.h"
|
|
#include "ism_building_mount_point_dialog.h"
|
|
#include "Overview/ism_overview_dialog.h"
|
|
#include "AssetList/ism_asset_list_dialog.h"
|
|
#include "MountingPointInfo/ism_mounting_point_info_dialog.h"
|
|
#include "MountingPointList/ism_mounting_point_list_dialog.h"
|
|
#include "PlanChooser/plan_chooser.h"
|
|
#include "PlanChooser/new_plan_dialog.h"
|
|
#include "ApproachingPoints/ism_approaching_point_list_dialog.h"
|
|
//#include "Timeline/ism_plan_tln_dialog.h"
|
|
#include "ism_plan_edit_dialog.h"
|
|
#include "Overview/ism_overview_mounting_point_list_dialog.h"
|
|
#include "ExerciseAssignment/ism_exercise_assignment_dialog.h"
|
|
|
|
#include <LtsSession/lts_session.h>
|
|
#include <LtsSession/lts_session_data.h>
|
|
#include <LtsWidgets/lts_background_widget.h>
|
|
#include <LtsWidgets/lts_base_layout_widget.h>
|
|
#include <LtsWidgets/lts_global_wait_dialog.h>
|
|
#include <LtsUtilsGuiDds/request_helper.h>
|
|
#include <MountingPointMapSelection/ism_selector.h>
|
|
#include <InfrastructureManagement/ism_operator_rights.h>
|
|
#include <InfrastructureManagement/logger.h>
|
|
#include <LtsUtilsSettings/settings.h>
|
|
#include <LtsNotification/lts_notification.h>
|
|
#include <Viewer/SituationMap/Map/map.h>
|
|
|
|
namespace InfrastructureManagement
|
|
{
|
|
|
|
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
|
{
|
|
return std::make_shared<InterfaceImpl>(session);
|
|
}
|
|
|
|
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
|
: GuiPluginBase::Interface(session, getLogger("ResourceManagement"))
|
|
// , m_dtc(nullptr)
|
|
// , m_ftc(nullptr)
|
|
//, m_ismIfc(nullptr)
|
|
, m_avmIfc(nullptr)
|
|
, m_sitmapGuiIfc(nullptr)
|
|
, m_planId(-1)
|
|
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
|
, m_mountingPointSelector(nullptr)
|
|
{
|
|
connect(m_session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
|
this, &InterfaceImpl::slotOnSessionReady);
|
|
}
|
|
|
|
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
|
{
|
|
QVector<LtsWidgets::PluginData> ret;
|
|
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableResPlanDialog")).toBool())
|
|
{
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Add Instrumentation Plan");
|
|
plData.identifier = QLatin1String("IsmResPlanAddDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:plan_new.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansEdit;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotAddPlanDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Instrumentation Plans");
|
|
plData.identifier = QLatin1String("IsmResPlanDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:plans.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowPlanDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
/*
|
|
{
|
|
// Append Time Line view dialog
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Timeline");
|
|
plData.identifier = QLatin1String("IsmTimelineView");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:timeline.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowPlanTimeLineDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
*/
|
|
}
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableOverviewDialog")).toBool())
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Overview");
|
|
plData.identifier = QLatin1String("IsmOverviewDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:evaluate.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowOverviewDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableAssetListDialog")).toBool())
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Asset List");
|
|
plData.identifier = QLatin1String("IsmAssetListDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:choose_audio_video_menu.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowAssetListDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableMpListDialog")).toBool())
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Mounting Point List");
|
|
plData.identifier = QLatin1String("IsmMpListDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:fixed_video_announcement.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowMountingPointListDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableBuildingListDialog")).toBool())
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Building List");
|
|
plData.identifier = QLatin1String("IsmBuildingListDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:show_building_configuration.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent) -> LtsWidgets::LtsDialog *
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Building List"));
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new BuildingMountPointDialog(parent),
|
|
ismDtc, ismFtc, this);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableApproachingPointsDialog")).toBool())
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Approaching Points");
|
|
plData.identifier = QLatin1String("IsmApproachingPointsDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:karte.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowApproachingPointsDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
if (ps->value(QStringLiteral("ism"), QStringLiteral("enableOverviewMountedPointDialog")).toBool())
|
|
{
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = menuGroup();
|
|
plData.menuText = tr("Completeness Check");
|
|
plData.identifier = QLatin1String("IsmOverviewMountedPointDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:completeness_check_enabled.svg"));
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.operatorRight = OperatorRights::InfrastructurePlansShow;
|
|
plData.createWidgetFunc = [this](QWidget *parent)
|
|
{
|
|
return slotShowMntpCompletenessCheckDialog(parent);
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
|
|
LtsWidgets::PluginData plData;
|
|
plData.menuGroup = tr("Exercise Assignment");
|
|
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
plData.menuText = tr("Exercise Assignment");
|
|
plData.identifier = QLatin1String("IsmAvcExerciseAssignmentDialog");
|
|
plData.menuIcon = QIcon(QLatin1String("icon:set_exercise_process.svg"));
|
|
plData.createWidgetFunc = [this](QWidget *) -> LtsWidgets::LtsDialog *
|
|
{
|
|
try {
|
|
return new ExerciseAssignmentDialog(m_session);
|
|
}catch(...){return nullptr;}
|
|
};
|
|
ret.append(plData);
|
|
|
|
if (m_session->app() == LtsAppDescriptor::App::ResourceManager)
|
|
{
|
|
// Toggle Planungsansicht/KomponentenÜberwachung
|
|
// Toggle PlanView/Component Monitor
|
|
LtsWidgets::PluginData plData;
|
|
plData.identifier = QStringLiteral("PlanView/Componentmonitor");
|
|
plData.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
|
plData.directFunc = [this](const LtsWidgets::PluginData &)
|
|
{
|
|
if (!m_sitmapGuiIfc)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " no sitmapGuiIfc";
|
|
return;
|
|
}
|
|
m_notiResourceManagerMode = m_session->createNotification(QStringLiteral("PlanView/ComponentMonitor"));
|
|
m_notiResourceManagerMode->setIcon(QIcon(QStringLiteral("icon:plans.svg")));
|
|
m_notiResourceManagerMode->setEnabled(false);
|
|
|
|
// "icon:status_infrastructure.svg" <> "icon:plans.svg"
|
|
|
|
m_notiResourceManagerMode->setAction([this]()
|
|
{
|
|
|
|
m_notiResourceManagerMode->setBackground(-1, -1, -1); // Set back to default
|
|
if (!m_sitmapGuiIfc || !m_sitmapGuiIfc->isMapReady())
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " sitmapGuiIfc no ready yet";
|
|
return;
|
|
}
|
|
|
|
const SituationMap::ResourceManagerMode rmm = m_sitmapGuiIfc->resourceManagerMode();
|
|
|
|
// toogle between RMM_PlanActivityView and RMM_ComponentMonitor:
|
|
// not towards RMM_PlanDefinitionView!!
|
|
|
|
switch (rmm) {
|
|
case SituationMap::ResourceManagerMode::Undefined:
|
|
// empty
|
|
break;
|
|
case SituationMap::ResourceManagerMode::RMM_PlanActivityView:
|
|
|
|
m_notiResourceManagerMode->setBackground(60, 209, 54); //Timeline green
|
|
m_sitmapGuiIfc->setResourceManagerMode(SituationMap::ResourceManagerMode::RMM_ComponentMonitor);
|
|
break;
|
|
case SituationMap::ResourceManagerMode::RMM_PlanDefinitionView:
|
|
|
|
// RMM_PlanDefinitionView is only available by open "MountingPointListDialog" / "Anbringungspunkte"
|
|
// do nothing:
|
|
// // m_sitmapGuiIfc->setResourceManagerMode(SituationMap::ResourceManagerMode::RMM_PlanActivityView);
|
|
break;
|
|
case SituationMap::ResourceManagerMode::RMM_ComponentMonitor:
|
|
m_sitmapGuiIfc->setResourceManagerMode(SituationMap::ResourceManagerMode::RMM_PlanActivityView);
|
|
break;
|
|
default:
|
|
//empty
|
|
break;
|
|
} //switch
|
|
});
|
|
|
|
};
|
|
ret.append(plData);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
void InterfaceImpl::slotOnSessionReady()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
|
|
|
disconnect(m_session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
|
this, &InterfaceImpl::slotOnSessionReady);
|
|
|
|
if (m_sitmapGuiIfc->isMapReady())
|
|
{
|
|
slotOnMapReady();
|
|
} else {
|
|
auto onMapIsReadyFn = [this]() {
|
|
slotOnMapReady();
|
|
};
|
|
if (!m_sitmapGuiIfc->setMapReadyCallback(this, onMapIsReadyFn))
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << ", setMapReadyCallback failed";
|
|
}
|
|
}
|
|
|
|
void InterfaceImpl::slotOnMapReady()
|
|
{
|
|
INFO_LOG(m_logger) << LOGFUNCTION << "START";
|
|
|
|
//
|
|
// update icon and tooltip according current ResourceManagerMode:
|
|
// 'connect' via callback :
|
|
//
|
|
auto onChanged = [this]() {
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " update... onResourceManagerModeChanged";
|
|
const SituationMap::ResourceManagerMode rmm = m_sitmapGuiIfc->resourceManagerMode();
|
|
this->onResourceManagerModeChanged(rmm);
|
|
};
|
|
m_sitmapGuiIfc->setResourceManagerModeChangedCallback(this, onChanged);
|
|
// : 'connect' via callback
|
|
|
|
const SituationMap::ResourceManagerMode rmm = m_sitmapGuiIfc->resourceManagerMode();
|
|
this->onResourceManagerModeChanged(rmm);
|
|
}
|
|
|
|
void InterfaceImpl::onResourceManagerModeChanged(SituationMap::ResourceManagerMode newMode)
|
|
{
|
|
INFO_LOG(m_logger) << " new ResourceManagerMode: newMode = " << (int)newMode;
|
|
|
|
|
|
// update icon etc. of m_notiResourceManagerMode:
|
|
if (!m_notiResourceManagerMode)
|
|
return;
|
|
|
|
if (!m_sitmapGuiIfc)
|
|
return;
|
|
|
|
switch (newMode) {
|
|
case SituationMap::ResourceManagerMode::Undefined:
|
|
m_notiResourceManagerMode->setEnabled(false);
|
|
// disable...
|
|
break;
|
|
case SituationMap::ResourceManagerMode::RMM_PlanActivityView:
|
|
m_notiResourceManagerMode->setBackground(-1, -1, -1); // Set back to default
|
|
|
|
m_notiResourceManagerMode->setIcon(QIcon(QStringLiteral("icon:completeness_check_enabled.svg"))); // maybe icon:about.svg or icon:arrow_front_back.svg
|
|
m_notiResourceManagerMode->setToolTip(tr("Plan Activity View"));
|
|
m_notiResourceManagerMode->setEnabled(true);
|
|
break;
|
|
case SituationMap::ResourceManagerMode::RMM_PlanDefinitionView:
|
|
m_notiResourceManagerMode->setBackground(-1, -1, -1); // Set back to default
|
|
|
|
m_notiResourceManagerMode->setIcon(QIcon(QStringLiteral("icon:plan_new.svg")));
|
|
m_notiResourceManagerMode->setToolTip(tr("Plan Definition View"));
|
|
m_notiResourceManagerMode->setEnabled(false);
|
|
break;
|
|
case SituationMap::ResourceManagerMode::RMM_ComponentMonitor:
|
|
m_notiResourceManagerMode->setBackground(60, 209, 54); //Timeline green
|
|
m_notiResourceManagerMode->setIcon(QIcon(QStringLiteral("icon:status_infrastructure.svg")));
|
|
m_notiResourceManagerMode->setToolTip(tr("Component View"));
|
|
m_notiResourceManagerMode->setEnabled(true);
|
|
break;
|
|
default:
|
|
// empty
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
bool InterfaceImpl::fetchInterfaces()
|
|
{
|
|
if (/*!m_session->getDtc<InfrastructureManagement::DataInterface>(m_dtc) ||
|
|
!m_session->getFtc<InfrastructureManagement::DataInterface>(m_ftc) ||
|
|
!m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(m_ismIfc) ||*/
|
|
!m_session->getForeignDataInterface_NEW<AudioVideoManagement::ForeignDataInterface>(m_avmIfc) ||
|
|
!m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitmapGuiIfc))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void InterfaceImpl::clearInterfaces()
|
|
{
|
|
m_sitmapGuiIfc = nullptr;
|
|
// m_ismIfc = nullptr;
|
|
m_avmIfc = nullptr;
|
|
// m_ftc = nullptr;
|
|
// m_dtc = nullptr;
|
|
}
|
|
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowPlanDialog(QWidget *parent)
|
|
{
|
|
DEBUG_LOG(m_logger) << "slotShowPlanDialog: m_planId = " << m_planId;
|
|
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignGuiComboboxInterface> ismCbx;
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismIfc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(ismCbx)
|
|
|| !m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(ismIfc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Plan Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new PlanDialog(menuGroup(), m_session, parent),
|
|
m_planId, ismDtc, ismFtc, ismCbx, ismIfc, this);
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowOverviewDialog(QWidget *parent)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismIfc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(ismIfc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Plan Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new OverviewDialog(menuGroup(), m_session, parent),
|
|
m_planId, ismDtc,ismFtc, ismIfc);
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowAssetListDialog(QWidget *parent)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<ComponentMonitor::Interface::Dtc> cmoDtc; // CMO ComponentMonitor
|
|
std::shared_ptr<ComponentMonitor::Interface::Ftc> cmoFtc; // CMO ComponentMonitor
|
|
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getDtc<ComponentMonitor::DataInterface>(cmoDtc)
|
|
|| !m_session->getFtc<ComponentMonitor::DataInterface>(cmoFtc)
|
|
)
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Plan Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new AssetListDialog(menuGroup(), m_session, parent),
|
|
ismDtc, ismFtc, cmoDtc, cmoFtc);
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowMountingPointListDialog(QWidget *parent)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismIfc;
|
|
std::shared_ptr<FilterManagement::ForeignFltBuildingComponentGuiInterface> fltBuildingComponentIfc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(ismIfc)
|
|
|
|
// Nachtrag zu GUEZE-1769: since fltBuildingComponentIfc is optional:
|
|
// for this dialog fltBuildingComponentIfc is not optional, is required, so get it (NT, 09.08.2023)
|
|
|| !m_session->getForeignGuiInterface<FilterManagement::ForeignFltBuildingComponentGuiInterface>(fltBuildingComponentIfc)
|
|
)
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Mounting Point List"));
|
|
return nullptr;
|
|
}
|
|
|
|
// Maybe there is a lot of data to load:
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait(tr("Open Mounting Point List ..."));
|
|
MountingPointListDialog *dlg = LtsWidgets::initDialog(new MountingPointListDialog(menuGroup(), parent),
|
|
m_session, ismDtc, ismFtc, ismIfc, this, m_sitmapGuiIfc, fltBuildingComponentIfc);
|
|
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
|
|
|
return dlg;
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowApproachingPointsDialog(QWidget *parent)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Approaching Points Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new ApproachingPointsDialog(menuGroup(), m_session, parent),
|
|
ismDtc, ismFtc, m_sitmapGuiIfc);
|
|
}
|
|
|
|
/*
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowPlanTimeLineDialog(QWidget *parent)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismDataIfc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(ismDataIfc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Plan timeline Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new PlanTimeLineDialog(m_session, menuGroup(), parent),
|
|
ismDtc,ismFtc, ismDataIfc, this);
|
|
}
|
|
*/
|
|
|
|
void InterfaceImpl::onMainScheduleModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
m_requestHelper->requestReply(replyObject);
|
|
}
|
|
|
|
void InterfaceImpl::showMountingPointInfoWindows(const QVector<int32_t> &entityIds, bool /*force*/)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> dtc;
|
|
std::shared_ptr<ForeignDataInterface> ismDataIfc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(dtc)
|
|
|| !m_session->getForeignDataInterface<DataInterface>(ismDataIfc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Mounting Point Info"));
|
|
return;
|
|
}
|
|
|
|
|
|
// int len = entityIds.length();
|
|
// if (len > 10 && !force)
|
|
// {
|
|
// auto x = new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(),
|
|
// tr("Are you sure that you want to open more than 10 (%1) Mounting Point Info dialogs?").arg(len),
|
|
// tr("Mounting Point Info"),
|
|
// LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes | LtsWidgets::Button::Cancel);
|
|
|
|
// connect(x, &LtsWidgets::LtsMessageDialogNew::yes,
|
|
// this, [this, entityIds]()
|
|
// {
|
|
// showMountingPointInfoWindows(entityIds, true); // force if user really wants to open more than 10 windows
|
|
// });
|
|
|
|
// return;
|
|
// }
|
|
|
|
|
|
for (int32_t entityId : entityIds)
|
|
{
|
|
MountingPointInfoDialog *dialog = new MountingPointInfoDialog(entityId, m_planId, menuGroup());
|
|
dialog->init(dtc, ismDataIfc, m_avmIfc);
|
|
m_session->addWidget(dialog, menuGroup(), QStringLiteral("MP info %1").arg(entityId), LtsWidgets::LayoutArea::eInfoTab);
|
|
}
|
|
}
|
|
|
|
void InterfaceImpl::slotNewPlan()
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::ForeignGuiComboboxInterface> ismCbx;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
if (!m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(ismCbx))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open New Plan"));
|
|
return;
|
|
}
|
|
|
|
// enable mainScheduleModifyRequest
|
|
if (!ismFtc->enableMainScheduleModify())
|
|
{
|
|
ERROR_LOG(m_logger) << "Could not enable FT MainScheduleModify of ISM";
|
|
return;
|
|
}
|
|
|
|
PlanChooser *planChooser = qobject_cast<PlanChooser *>(sender());
|
|
|
|
if (!planChooser)
|
|
{
|
|
WARNING_LOG(m_logger) << "cannot create new plan, plan chooser payload dialog not found!";
|
|
return;
|
|
}
|
|
|
|
std::unique_ptr<NewPlanDialog> npd(new NewPlanDialog(m_session, planChooser));
|
|
npd->init(ismCbx);
|
|
if (!LtsSessionData::LtsSessionData::getInstance()->isTablet())
|
|
npd->setModal(true);
|
|
int status = 0;
|
|
QString name;
|
|
qint64 tbegin = 0;
|
|
qint64 tend = 0;
|
|
if (!npd->getData(name, tbegin, tend, status))
|
|
return; // user rejected the dialog, do nothing
|
|
|
|
if (name.length() < 3)
|
|
{
|
|
LtsWidgets::LtsMessageDialog::showMessage(planChooser,
|
|
tr("The name for a new plan must have 3 characters or more. Please try again."),
|
|
tr("Error creating new plan"));
|
|
return;
|
|
}
|
|
|
|
MainScheduleModifyRequest req;
|
|
req.name(name.toStdString());
|
|
//req.description(tr("No description").toStdString());
|
|
//req.exerciseId(); // not used
|
|
req.id(0);
|
|
req.statusId(static_cast<ScheduleStatus::inner_enum>(status));
|
|
req.timeCreated(QDateTime::currentDateTime().toMSecsSinceEpoch());
|
|
if(tbegin > 0)
|
|
req.timeStart(tbegin);
|
|
req.timeEnd(tend);
|
|
if (m_requestHelper->startSingleRequest([req, ismFtc, this]()
|
|
{
|
|
return ismFtc->mainScheduleModifyRequest(req, this);
|
|
}))
|
|
{
|
|
m_planId = m_requestHelper->getRepliedId();
|
|
ERROR_LOG(m_logger) << "New Instrumentation Plan with id " << m_planId << " created!";
|
|
planChooser->selectPlan(m_planId);
|
|
}
|
|
else
|
|
{
|
|
WARNING_LOG(m_logger) << "Creating new Instrumentation Plan failed!";
|
|
}
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotAddPlanDialog(QWidget *parent)
|
|
{
|
|
DEBUG_LOG(m_logger) << "slotAddPlanDialog";
|
|
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignGuiComboboxInterface> ismCbx;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc) ||
|
|
!m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc) ||
|
|
!m_session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(ismCbx))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Plan Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
// enable mainScheduleModifyRequest
|
|
if (!ismFtc->enableMainScheduleModify())
|
|
{
|
|
ERROR_LOG(m_logger) << "Could not enable FT MainScheduleModify of ISM";
|
|
return nullptr;
|
|
}
|
|
|
|
return LtsWidgets::initDialog(new PlanEditDialog(parent),
|
|
m_session, 0, ismDtc, ismFtc, ismCbx);
|
|
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::slotShowMntpCompletenessCheckDialog(QWidget *parent)
|
|
{
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismDataIfc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
|
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc)
|
|
|| !m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(ismDataIfc)
|
|
)
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Mounting Point Completeness check Dialog"));
|
|
return nullptr;
|
|
}
|
|
|
|
const int32_t scheduleId = ismDataIfc->scheduleId();
|
|
return LtsWidgets::initDialog(new OverviewMountingPointListDialog(menuGroup(), parent),
|
|
m_session, ismDtc, ismFtc, ismDataIfc, scheduleId);
|
|
}
|
|
|
|
void InterfaceImpl::setPlanId(const int planId)
|
|
{
|
|
m_planId = planId;
|
|
m_session->setBaseLayoutVisible();
|
|
|
|
DEBUG_LOG(m_logger) << "setPlanId = " << planId;
|
|
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismIfc;
|
|
if (!m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(ismIfc))
|
|
{
|
|
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot set Plan Id"));
|
|
return;
|
|
}
|
|
|
|
ismIfc->setScheduleId(m_planId);
|
|
|
|
// set name to "title":
|
|
MainSchedule ms = ismIfc->mainSchedule(m_planId);
|
|
QString msName = QString::fromStdString(ms.name());
|
|
connect(m_session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
|
this, [this, msName] ()
|
|
{
|
|
disconnect(m_session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
|
this, nullptr);
|
|
|
|
if (m_session && m_session->baseLayout())
|
|
m_session->baseLayout()->setCustomText(tr("Instrumentation Plan: '%1'").arg(msName));
|
|
});
|
|
}
|
|
|
|
|
|
int InterfaceImpl::getPlanId() const
|
|
{
|
|
return m_planId;
|
|
}
|
|
|
|
bool InterfaceImpl::isInSelectionMode() const
|
|
{
|
|
return m_mountingPointSelector;
|
|
}
|
|
|
|
void InterfaceImpl::setSelector(MountingPointSelector *selector)
|
|
{
|
|
m_mountingPointSelector = selector;
|
|
}
|
|
|
|
void InterfaceImpl::addToSelection(int32_t mountingPointId)
|
|
{
|
|
addToSelection(QVector<int32_t>() << mountingPointId);
|
|
}
|
|
|
|
void InterfaceImpl::addToSelection(const QVector<int32_t> &simIds)
|
|
{
|
|
//TODO
|
|
if (m_mountingPointSelector)
|
|
m_mountingPointSelector->addMountingPoints(simIds, QMap<int32_t, MountingPointState>(), m_session->baseLayoutWidget());
|
|
}
|
|
|
|
void InterfaceImpl::executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground) // TODO: doc: as few d-/ftc passes as possible, better make a signal/slot to the underlying class (like here)
|
|
{
|
|
DEBUG_LOG(m_logger) << "executePayload";
|
|
|
|
connect(this, &InterfaceImpl::signalSuccess,
|
|
m_session, &LtsSession::LtsSession::slotExecuteNextPayload, Qt::QueuedConnection);
|
|
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
|
{
|
|
auto x = new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot start Application Payload"));
|
|
connect(x, &LtsWidgets::LtsMessageDialogNew::destroyed,
|
|
this, [this]()
|
|
{
|
|
emit signalSuccess();
|
|
});
|
|
return;
|
|
}
|
|
|
|
PlanChooser *planChooser = new PlanChooser(ismDtc, mainBackground);
|
|
planChooser->init(m_session);
|
|
planChooser->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
connect(planChooser, &PlanChooser::signalSelectPlan,
|
|
this, &InterfaceImpl::slotSelectPlan, Qt::QueuedConnection); // queue!!
|
|
|
|
connect(planChooser, &PlanChooser::signalNewPlan,
|
|
this, &InterfaceImpl::slotNewPlan, Qt::QueuedConnection); // queue!!
|
|
|
|
connect(planChooser, &PlanChooser::signalQuit,
|
|
m_session, &LtsSession::LtsSession::signalQuit);
|
|
|
|
// TODO: connect to deleteLater?
|
|
|
|
// no presets
|
|
if (!LtsSessionData::LtsSessionData::getInstance()->isTablet())
|
|
planChooser->setModal(true);
|
|
planChooser->show();
|
|
}
|
|
|
|
|
|
void InterfaceImpl::slotSelectPlan(int planId)
|
|
{
|
|
DEBUG_LOG(m_logger) << "Instrumentation Plan id = " << planId;
|
|
setPlanId(planId);
|
|
emit signalSuccess();
|
|
}
|
|
|
|
} // namespace InfrastructureManagement
|