Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(ScmGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scm_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(ScmDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scm_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcScmCommon
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS ScmDataPlugin MODULE scm_data_plugin.cpp scm_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(ScmDataPlugin
|
||||
Qt5::Core
|
||||
ScmDataPluginInterface
|
||||
svcScmClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
NGL_INSTALL_TARGET(ScmDataPlugin)
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for ServiceManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#include "scm_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc, false ,true))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/ServiceManagement/scm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:scm")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("ServiceManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
explicit DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(ServiceEdit)
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
SET(scm_edit_gui_SRCS
|
||||
scm_edit_gui_plugin.cpp
|
||||
scm_edit_gui_plugin.h
|
||||
scm_dialog.cpp
|
||||
scm_dialog.h
|
||||
scm_dialog_service.cpp
|
||||
scm_dialog_service.h
|
||||
scm_dialog_group.cpp
|
||||
scm_dialog_group.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(scm_edit_gui_SRCS
|
||||
scm_dialog.ui
|
||||
scm_dialog_service.ui
|
||||
scm_dialog_group.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS ScmEditGuiPlugin MODULE ${scm_edit_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(ScmEditGuiPlugin
|
||||
NGLLogger
|
||||
ScmGuiPluginInterface
|
||||
ScmDataPluginInterface
|
||||
LtsSession
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsUtilsGuiDds
|
||||
svcScmCommon
|
||||
svcExmClient
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(ScmEditGuiPlugin)
|
||||
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
|
||||
#include "scm_dialog.h"
|
||||
#include "ui_scm_dialog.h"
|
||||
|
||||
#include "scm_dialog_group.h"
|
||||
#include "scm_dialog_service.h"
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// ServiceManagementDialog
|
||||
//---------------------------------
|
||||
ServiceManagementDialog::ServiceManagementDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ServiceManagementDialog)
|
||||
, m_dtcExm(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_logger(getLogger("ServiceManagementDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// unused yet
|
||||
m_ui->lbGroupsIndicator->hide();
|
||||
m_ui->lbExercise->hide();
|
||||
m_ui->lbServer->hide();
|
||||
m_ui->cbServer->hide();
|
||||
m_ui->cbExercise->hide();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Service_Management"));
|
||||
}
|
||||
|
||||
ServiceManagementDialog::~ServiceManagementDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Service Management"));
|
||||
}
|
||||
|
||||
|
||||
bool ServiceManagementDialog::init(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtcExm = dtcExm;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::groupInformationChanged,
|
||||
this, &ServiceManagementDialog::slotGroupInformationChanged);
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::serviceInformationChanged,
|
||||
this, &ServiceManagementDialog::slotServiceInformationChanged);
|
||||
|
||||
const QMap<qint32, ServiceManagement::GroupInformation> groupInfo = m_dtc->groupInformations();
|
||||
|
||||
if (groupInfo.isEmpty())
|
||||
{
|
||||
INFO_LOG(m_logger) << "initModel - no groups!";
|
||||
return true;
|
||||
}
|
||||
|
||||
m_ui->lbNoServices->hide();
|
||||
|
||||
INFO_LOG(m_logger) << "initModel - #group information: " << groupInfo.size();
|
||||
|
||||
|
||||
// GROUPS
|
||||
QVector<int> servicesList;
|
||||
for (const ServiceManagement::GroupInformation &gi : groupInfo)
|
||||
{
|
||||
// now that all services of that group are represented by a widget, create the group widget which adds all service widgets
|
||||
//const int id = gi.id();
|
||||
const int server = gi.domainId();
|
||||
const int exercise = gi.exercisePartitionId();
|
||||
const int32_t replayPartitionId = gi.replayPartitionId();
|
||||
const QString groupName = groupEnumToGroupName(gi.type()); // QLatin1String("Group Name"); // TODO: get real group name
|
||||
long long timestamp = gi.timestamp();
|
||||
|
||||
servicesList.clear();
|
||||
servicesList.reserve(gi.services().size());
|
||||
for (auto service : gi.services())
|
||||
servicesList.append(service);
|
||||
|
||||
addGroup(gi.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SERVICES
|
||||
auto cbSvc = [this](const ServiceManagement::ServiceInformation & svc) // create widgets for every service in the group
|
||||
{
|
||||
addService(svc);
|
||||
};
|
||||
m_dtc->serviceInformations(cbSvc); // needed to resolve services for the groups
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GroupWidget *ServiceManagementDialog::addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp, const QVector<int> &servicesList)
|
||||
{
|
||||
//qWarning() << "ServiceManagementDialog::addGroup: needed services:" << servicesList;
|
||||
|
||||
QString exName = QString::fromStdString(m_dtcExm.get()->exercise(exercise).name());
|
||||
GroupWidget *group = new GroupWidget(groupType, server, exercise, replayPartitionId, exName, timestamp, servicesList); // memleak!
|
||||
|
||||
QString groupObjectName = craftGroupName(server, exercise, groupName);
|
||||
group->setObjectName(groupObjectName);
|
||||
//qWarning() << "Group Object Name =" << groupObjectName;
|
||||
|
||||
connect(group, &GroupWidget::signalRestartGroup, this, &ServiceManagementDialog::slotRestartGroup); // direct connection for const ref on group type enum
|
||||
connect(group, &GroupWidget::signalStartGroup, this, &ServiceManagementDialog::slotStartGroup); // direct connection for const ref on group type enum
|
||||
connect(group, &GroupWidget::signalStopGroup, this, &ServiceManagementDialog::slotStopGroup); // direct connection for const ref on group type enum
|
||||
|
||||
QVBoxLayout *l = qobject_cast<QVBoxLayout *>(m_ui->groupLayoutWidget->layout());
|
||||
if (!l)
|
||||
WARNING_LOG(m_logger) << "ServiceManagementDialog::addGroup: group layout failed, cannot add group";
|
||||
else
|
||||
l->addWidget(group, 0, Qt::AlignTop);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotRestartService(int serviceID)
|
||||
{
|
||||
const RestartServiceRequest req(serviceID);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->restartServiceRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static int s_requestId = 0;
|
||||
void ServiceManagementDialog::slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->restartGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->startGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->stopGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// DTC Modifications
|
||||
void ServiceManagementDialog::slotGroupInformationChanged(ServiceManagement::GroupInformation info, DataModification mod)
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged";
|
||||
|
||||
// find group
|
||||
int server = info.domainId();
|
||||
int exercise = info.exercisePartitionId();
|
||||
int32_t replayPartitionId = info.replayPartitionId();
|
||||
QString groupName = groupEnumToGroupName(info.type());
|
||||
long long timestamp = info.timestamp();
|
||||
|
||||
QString findGroupName = craftGroupName(server, exercise, groupName);
|
||||
|
||||
GroupWidget *gw = m_ui->groupLayoutWidget->findChild<GroupWidget *>(findGroupName);
|
||||
|
||||
if (!gw) // group does not exist? create it!
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group not found, adding it";
|
||||
|
||||
QVector<int> servicesList;
|
||||
servicesList.reserve(info.services().size());
|
||||
for (auto service : info.services())
|
||||
servicesList << service;
|
||||
|
||||
m_ui->lbNoServices->hide();
|
||||
addGroup(info.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case DataModification::eAdded: // already exists, so it cant be added - but easily change data in existing group
|
||||
case DataModification::eModified:
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group added or modified";
|
||||
|
||||
m_ui->lbNoServices->hide(); // added/modified = there are groups, which show services
|
||||
|
||||
gw->setType(info.type());
|
||||
gw->setServer(server);
|
||||
gw->setExercise(exercise);
|
||||
gw->setTimestamp(timestamp);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group removed";
|
||||
|
||||
if (m_ui->groupLayoutWidget->findChildren<GroupWidget *>().isEmpty()) // no groups to show services in?
|
||||
m_ui->lbNoServices->show();
|
||||
|
||||
delete gw; // then delete gw from layout
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::addService(const ServiceManagement::ServiceInformation &svc)
|
||||
{
|
||||
const int id = svc.id();
|
||||
const long long pid = svc.pid();
|
||||
const QString name(QString::fromStdString(svc.name()));
|
||||
const Core::RunningState &state = svc.state();
|
||||
const QString errorString(QString::fromStdString(svc.errorString()));
|
||||
|
||||
ServiceWidget *service = new ServiceWidget(id, pid, name, state, errorString);
|
||||
service->setObjectName(QLatin1String("service.") + QString::number(id));
|
||||
connect(service, &ServiceWidget::signalRestartService, this, &ServiceManagementDialog::slotRestartService);
|
||||
|
||||
|
||||
const auto groupList = findChildren<GroupWidget *>();
|
||||
for (GroupWidget *gw : groupList)
|
||||
gw->addService(service);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotServiceInformationChanged(ServiceManagement::ServiceInformation info, DataModification mod)
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged";
|
||||
|
||||
// find services (because ONE service can be in MANY groups)
|
||||
|
||||
int32_t serviceId = info.id();
|
||||
QString errorString = QString::fromStdString(info.errorString());
|
||||
QString serviceName = QString::fromStdString(info.name());
|
||||
long long pid = info.pid();
|
||||
const Core::RunningState &state = info.state();
|
||||
long long timestamp = info.timestamp();
|
||||
|
||||
QString findServiceName = QLatin1String("service.") + QString::number(serviceId);
|
||||
|
||||
const auto serviceList = findChildren<ServiceWidget *>(findServiceName);
|
||||
|
||||
if (serviceList.isEmpty() || mod == DataModification::eAdded) // no service found or is going to be added? add it!
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service not found, adding it";
|
||||
|
||||
addService(info);
|
||||
}
|
||||
|
||||
for (ServiceWidget *serviceWidget : serviceList)
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case DataModification::eModified:
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service modified";
|
||||
|
||||
serviceWidget->setErrorString(errorString);
|
||||
serviceWidget->setName(serviceName);
|
||||
serviceWidget->setPid(pid);
|
||||
serviceWidget->setState(state);
|
||||
serviceWidget->setTimestamp(timestamp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service removed";
|
||||
|
||||
delete serviceWidget;
|
||||
serviceWidget = nullptr;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
//qWarning() << "ServiceManagementDialog::slotServiceInformationChanged: unknown or invalid modification!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// tell all groups to set their new statuses (bcuz service states may have changed) !!
|
||||
const auto groupList = findChildren<GroupWidget *>();
|
||||
for (GroupWidget *groupWidget : groupList)
|
||||
groupWidget->checkStatus();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ServiceManagement
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scm_dialog_group.h"
|
||||
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <ServiceManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ServiceManagementDialog;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
//class ExerciseManagementDialogModel;
|
||||
// --------------------------------------------------------
|
||||
// ExerciseManagementDialog
|
||||
// --------------------------------------------------------
|
||||
class ServiceManagementDialog : public LtsWidgets::LtsDialog
|
||||
, protected ServiceManagement::Interface::Ftc::RestartServiceReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::RestartGroupReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::StartGroupReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::StopGroupReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ServiceManagementDialog(QWidget *parent = nullptr);
|
||||
~ServiceManagementDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm);
|
||||
|
||||
virtual void onRestartServiceReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onRestartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onStartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onStopGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
// TODO: raus, String soll gepublished werden
|
||||
static QString groupEnumToGroupName(const Core::ServiceGroupType &type)
|
||||
{
|
||||
QMap<QString, Core::ServiceGroupType_def::type> groupNameMapping;
|
||||
groupNameMapping.insert(QLatin1String("Master"), Core::ServiceGroupType_def::Master);
|
||||
groupNameMapping.insert(QLatin1String("Core"), Core::ServiceGroupType_def::Core);
|
||||
groupNameMapping.insert(QLatin1String("ExercisePreparation"), Core::ServiceGroupType_def::ExercisePreparation);
|
||||
groupNameMapping.insert(QLatin1String("ExerciseExecution"), Core::ServiceGroupType_def::ExerciseExecution);
|
||||
groupNameMapping.insert(QLatin1String("ExercisePaused"), Core::ServiceGroupType_def::ExercisePaused);
|
||||
groupNameMapping.insert(QLatin1String("ExerciseAfterActionReview"), Core::ServiceGroupType_def::ExerciseAfterActionReview);
|
||||
groupNameMapping.insert(QLatin1String("Playback"), Core::ServiceGroupType_def::Playback);
|
||||
|
||||
return groupNameMapping.key(type.underlying());
|
||||
}
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
static QString craftBaseName(const QString &server, const QString &exercise) { return server + QLatin1Char('.') + exercise + QLatin1Char('.'); }
|
||||
|
||||
GroupWidget *addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp, const QVector<int> &servicesList);
|
||||
void addService(const ServiceInformation &svc);
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
public:
|
||||
static QString craftGroupName(int server, int exercise, const QString &groupName) { return craftBaseName(QString::number(server), QString::number(exercise)) + groupName; }
|
||||
static QString craftServiceName(int server, int exercise, const QString &groupName, int serviceId) { return craftGroupName(server, exercise, groupName) + QLatin1Char('.') + QString::number(serviceId); }
|
||||
static QString craftWildcardedServiceName(int serviceId) { return craftBaseName(QLatin1String("*"), QLatin1String("*")) + QString::number(serviceId); }
|
||||
|
||||
Ui::ServiceManagementDialog *m_ui;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void slotRestartService(int serviceID);
|
||||
void slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
void slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
void slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
|
||||
void slotGroupInformationChanged(ServiceManagement::GroupInformation, DataModification);
|
||||
void slotServiceInformationChanged(ServiceManagement::ServiceInformation, DataModification);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ServiceManagementDialog</class>
|
||||
<widget class="QWidget" name="ServiceManagementDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Service Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbServer">
|
||||
<property name="text">
|
||||
<string>Server:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="cbServer">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbExercise">
|
||||
<property name="text">
|
||||
<string>Exercise:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbExercise">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbNoServices">
|
||||
<property name="text">
|
||||
<string>There are no Services available to view.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbGroupsIndicator">
|
||||
<property name="text">
|
||||
<string>Groups of 'Server.Exercise':</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="groupLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>588</width>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,168 @@
|
||||
#include "scm_dialog.h"
|
||||
#include "scm_dialog_group.h"
|
||||
#include "ui_scm_dialog_group.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
GroupWidget::GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
|
||||
int32_t replayPartitionId,
|
||||
const QString &groupName /* TODO: groupName not needed */, long long timestamp,
|
||||
const QVector<int> &neededServices, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::GroupWidget)
|
||||
, m_status(ServiceWidget::UNKNOWN)
|
||||
, m_server(server)
|
||||
, m_exercise(exercise)
|
||||
, m_groupName(groupName)
|
||||
, m_replayPartitionId(replayPartitionId)
|
||||
, m_neededServices(neededServices)
|
||||
{
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbRestart, &QToolButton::clicked, this, &GroupWidget::slotRestartGroup);
|
||||
connect(m_ui->pbStart, &QToolButton::clicked, this, &GroupWidget::slotStartGroup);
|
||||
connect(m_ui->pbStop, &QToolButton::clicked, this, &GroupWidget::slotStopGroup);
|
||||
|
||||
setType(groupType);
|
||||
setServer(server);
|
||||
setExercise(exercise);
|
||||
setTimestamp(timestamp);
|
||||
|
||||
if (getStatus() != ServiceWidget::STOPPED) // when not stopped (but unknown), then set as STARTED
|
||||
setStatus(ServiceWidget::STARTED);
|
||||
}
|
||||
|
||||
|
||||
GroupWidget::~GroupWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::addService(ServiceWidget *service)
|
||||
{
|
||||
m_ui->lbNoServices->hide(); // min. 1 service available
|
||||
|
||||
//qWarning() << "GroupWidget::addService: ";
|
||||
|
||||
if (m_neededServices.contains(service->id())) // does this group need this service?
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: service needed";
|
||||
|
||||
if (!findChild<ServiceWidget *>(service->objectName())) // and the service was not found?
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: service currently not found, adding it";
|
||||
|
||||
m_ui->servicesLayout->addWidget(service);
|
||||
checkStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: I do not need" << service->id() << ", i need" << m_neededServices;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::checkStatus()
|
||||
{
|
||||
// get all service widgets from THIS widget and check our status by their status
|
||||
|
||||
m_status = ServiceWidget::UNKNOWN; // reset status
|
||||
|
||||
|
||||
const QList<ServiceWidget *> serviceList = findChildren<ServiceWidget *>();
|
||||
|
||||
if (serviceList.isEmpty())
|
||||
m_ui->lbNoServices->show(); // no services left (after deleting)
|
||||
|
||||
for (const ServiceWidget *serviceWidget : serviceList)
|
||||
{
|
||||
if (serviceWidget->getStatus() != ServiceWidget::STARTED)
|
||||
setStatus(ServiceWidget::STOPPED); // when a single service is not started, the whole group is stopped (or ERROR?)
|
||||
}
|
||||
|
||||
if (getStatus() != ServiceWidget::STOPPED) // when not stopped (but unknown), then set as STARTED
|
||||
setStatus(ServiceWidget::STARTED);
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::Status GroupWidget::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::setStatus(ServiceWidget::Status status)
|
||||
{
|
||||
m_status = status;
|
||||
|
||||
QString newCss;
|
||||
switch (m_status)
|
||||
{
|
||||
case ServiceWidget::STARTED:
|
||||
newCss = QLatin1String("background-color: rgb(124, 189, 124);");
|
||||
break;
|
||||
case ServiceWidget::STOPPED:
|
||||
newCss = QLatin1String("background-color: rgb(189, 106, 98);");
|
||||
break;
|
||||
case ServiceWidget::STARTING:
|
||||
case ServiceWidget::STOPPING:
|
||||
case ServiceWidget::UNKNOWN:
|
||||
break;
|
||||
}
|
||||
m_ui->frStatus->setStyleSheet(newCss);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotRestartGroup()
|
||||
{
|
||||
emit signalRestartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotStartGroup()
|
||||
{
|
||||
emit signalStartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotStopGroup()
|
||||
{
|
||||
emit signalStopGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::setType(Core::ServiceGroupType type)
|
||||
{
|
||||
m_groupType = type;
|
||||
m_ui->lbGroupName->setText(QStringLiteral("<html><head/><body><p>%1<span style='font-weight:600;'> %2</span></p></body></html>")
|
||||
.arg(tr("Services of %1").arg(ServiceManagement::ServiceManagementDialog::groupEnumToGroupName(type)), m_groupName));
|
||||
}
|
||||
|
||||
void GroupWidget::setServer(int server)
|
||||
{
|
||||
m_server = server;
|
||||
}
|
||||
|
||||
void GroupWidget::setExercise(int exercise)
|
||||
{
|
||||
m_exercise = exercise;
|
||||
}
|
||||
|
||||
void GroupWidget::setTimestamp(long long timestamp)
|
||||
{
|
||||
if (timestamp < 1)
|
||||
{
|
||||
m_ui->lbTimestamp->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
|
||||
}
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "scm_dialog_service.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class GroupWidget;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class GroupWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
|
||||
int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp,
|
||||
const QVector<int> &neededServices, QWidget *parent = nullptr);
|
||||
~GroupWidget();
|
||||
|
||||
void addService(ServiceWidget *service);
|
||||
|
||||
void setType(Core::ServiceGroupType type); // sets group name
|
||||
void setServer(int server);
|
||||
void setExercise(int exercise);
|
||||
void setTimestamp(long long timestamp);
|
||||
|
||||
ServiceWidget::Status getStatus() const;
|
||||
void setStatus(ServiceWidget::Status status);
|
||||
|
||||
void checkStatus();
|
||||
|
||||
private:
|
||||
Ui::GroupWidget *m_ui;
|
||||
ServiceWidget::Status m_status;
|
||||
Core::ServiceGroupType m_groupType;
|
||||
int m_server;
|
||||
int m_exercise;
|
||||
QString m_groupName;
|
||||
int32_t m_replayPartitionId;
|
||||
QVector<int> m_neededServices;
|
||||
|
||||
private slots:
|
||||
void slotRestartGroup();
|
||||
void slotStartGroup();
|
||||
void slotStopGroup();
|
||||
|
||||
signals:
|
||||
void signalRestartGroup(const Core::ServiceGroupType &groupType, int, int, int32_t replayPartitionId);
|
||||
void signalStartGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
|
||||
void signalStopGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
|
||||
};
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GroupWidget</class>
|
||||
<widget class="QWidget" name="GroupWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>55</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbGroupName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTimestamp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbRestart">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Restart this Group of Services (Restarts every Service inside this Group)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbStart">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Start this Group of Services (Starts Services inside this Group, that are currently stopped)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">S</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/media-play-slower.svg</normaloff>:/style/media-play-slower.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbStop">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Stop this Group of Services (Stops Services inside this Group, that are currently running / started)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">E</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/application-exit.svg</normaloff>:/style/application-exit.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="servicesLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbNoServices">
|
||||
<property name="text">
|
||||
<string>No Services available in this Group.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,134 @@
|
||||
#include "scm_dialog_service.h"
|
||||
#include "ui_scm_dialog_service.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
ServiceWidget::ServiceWidget(int32_t id, long long pid, const QString &name,
|
||||
const Core::RunningState &state, const QString &errorString, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ServiceWidget)
|
||||
, m_status(ServiceWidget::UNKNOWN)
|
||||
, m_id(id)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbRestart, &QToolButton::clicked, this, &ServiceWidget::slotRestartService);
|
||||
|
||||
setName(name);
|
||||
setPid(pid);
|
||||
setErrorString(errorString);
|
||||
setState(state);
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::~ServiceWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setName(const QString &name)
|
||||
{
|
||||
m_ui->lbServiceName->setText(name);
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setPid(long long pid)
|
||||
{
|
||||
m_ui->lbPID->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Process ID")).arg(pid));
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setTimestamp(long long timestamp)
|
||||
{
|
||||
if (timestamp < 1)
|
||||
{
|
||||
m_ui->lbTimestamp->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setErrorString(const QString &errorString)
|
||||
{
|
||||
if (errorString.isEmpty())
|
||||
{
|
||||
m_ui->lbError->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbError->setText(QStringLiteral("<html><head/><body><p><span style='color:#aa0000;'>%1:<br/>%2</span></p></body></html>").arg(tr("Error"), errorString));
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setState(Core::RunningState state)
|
||||
{
|
||||
auto status = ServiceWidget::UNKNOWN;
|
||||
switch (state.underlying())
|
||||
{
|
||||
// STARTING
|
||||
case Core::RunningState::inner_enum::Starting:
|
||||
status = ServiceWidget::STARTING;
|
||||
break;
|
||||
|
||||
// STARTED
|
||||
case Core::RunningState::inner_enum::Running:
|
||||
status = ServiceWidget::STARTED;
|
||||
break;
|
||||
|
||||
// STOPPING
|
||||
case Core::RunningState::inner_enum::Stopping:
|
||||
status = ServiceWidget::STOPPING;
|
||||
break;
|
||||
|
||||
// STOPPED
|
||||
case Core::RunningState::inner_enum::StartingError:
|
||||
case Core::RunningState::inner_enum::NotYetStarted:
|
||||
case Core::RunningState::inner_enum::StoppedNormally:
|
||||
case Core::RunningState::inner_enum::StoppedError: // FIXME: how does that look like? was STARTED but is not stoppable and still STARTED?
|
||||
status = ServiceWidget::STOPPED;
|
||||
break;
|
||||
}
|
||||
setStatus(status);
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setStatus(const Status status)
|
||||
{
|
||||
m_status = status;
|
||||
|
||||
switch (m_status)
|
||||
{
|
||||
case ServiceWidget::STARTED:
|
||||
m_ui->frStatus->setStyleSheet(greenStyleSheet());
|
||||
break;
|
||||
|
||||
case ServiceWidget::STOPPED:
|
||||
m_ui->frStatus->setStyleSheet(redStyleSheet());
|
||||
break;
|
||||
|
||||
default:
|
||||
m_ui->frStatus->setStyleSheet(orangeStyleSheet());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::Status ServiceWidget::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::slotRestartService()
|
||||
{
|
||||
emit signalRestartService(m_id);
|
||||
}
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <ServiceManagement/scm_dtc.h> // for Core::RunningState
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ServiceWidget;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class ServiceWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Status
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
STARTING,
|
||||
STARTED,
|
||||
STOPPING,
|
||||
STOPPED,
|
||||
};
|
||||
|
||||
ServiceWidget(int32_t id, long long pid, const QString &name,
|
||||
const Core::RunningState &state, const QString &errorString, QWidget *parent = nullptr);
|
||||
~ServiceWidget();
|
||||
|
||||
void setPid(long long pid);
|
||||
void setName(const QString &name);
|
||||
void setTimestamp(long long timestamp);
|
||||
void setState(Core::RunningState state);
|
||||
void setErrorString(const QString &errorString);
|
||||
|
||||
|
||||
void setStatus(const Status status);
|
||||
Status getStatus() const;
|
||||
int32_t id() const { return m_id; }
|
||||
|
||||
private:
|
||||
Ui::ServiceWidget *m_ui;
|
||||
Status m_status;
|
||||
int32_t m_id;
|
||||
|
||||
static QString greenStyleSheet() { return QLatin1String("background-color: rgb(124, 189, 124);"); }
|
||||
static QString orangeStyleSheet() { return QLatin1String("background-color: rgb(212, 190, 128);"); }
|
||||
static QString redStyleSheet() { return QLatin1String("background-color: rgb(202, 122, 122);"); }
|
||||
|
||||
signals:
|
||||
void signalRestartService(int id);
|
||||
|
||||
private slots:
|
||||
void slotRestartService();
|
||||
};
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ServiceWidget</class>
|
||||
<widget class="QWidget" name="ServiceWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>767</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbServiceName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Service Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbRestart">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>28</horstretch>
|
||||
<verstretch>28</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Restart Service</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTimestamp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbPID">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbError">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#include "scm_edit_gui_plugin.h"
|
||||
#include "scm_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/ServiceManagement/scm_operator_rights.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
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("Plugins.Gui.Scm.Edit"))
|
||||
, m_dtcExm(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ExerciseManagement::DataInterface>(m_dtcExm))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Services");
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Service Management");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:service.svg"));
|
||||
plData.identifier = QLatin1String("scmServiceEdit");
|
||||
plData.operatorRight = OperatorRights::ServicesEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
m_dtc->enableGroupInformation();
|
||||
m_dtc->enableServiceInformation();
|
||||
|
||||
m_ftc->enableRestartService();
|
||||
|
||||
m_ftc->enableStopGroup();
|
||||
m_ftc->enableStartGroup();
|
||||
m_ftc->enableRestartGroup();
|
||||
|
||||
return LtsWidgets::initDialog(new ServiceManagementDialog(parent),
|
||||
m_dtc, m_ftc, m_dtcExm);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <ServiceManagement/logger.h>
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <Plugins/ServiceManagement/scm_data_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:scm")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("ServiceManagement"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Global);
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Global; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() = 0;
|
||||
};
|
||||
|
||||
} // namespace ServiceManagement
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace ServiceManagement
|
||||
Reference in new issue
Block a user