Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Patric Karwat, SLSE, 2016-07-19
|
||||
#
|
||||
|
||||
SET(replay_gui_SRCS
|
||||
replay_management_gui_plugin.h
|
||||
replay_management_gui_plugin.cpp
|
||||
replay_dialog.h
|
||||
replay_dialog.cpp
|
||||
replay_dialog_model.h
|
||||
replay_dialog_model.cpp
|
||||
|
||||
CustomView/srm_replay.h
|
||||
CustomView/srm_replay.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(replay_gui_SRCS
|
||||
replay_dialog.ui
|
||||
CustomView/srm_replay.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS SrmReplayManagementGuiPlugin MODULE ${replay_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(SrmReplayManagementGuiPlugin
|
||||
NGLLogger
|
||||
LtsPrinting
|
||||
SrmGuiPluginInterface
|
||||
SrmDataPluginInterface
|
||||
FltAesGuiPluginInterface
|
||||
ddscore
|
||||
svcCoreClient
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
LtsAppManager # for windows tablet replay hack
|
||||
LtsUtilsCore
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(SrmReplayManagementGuiPlugin)
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for SRM Replay
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "srm_replay.h"
|
||||
#include "ui_srm_replay.h"
|
||||
|
||||
#include "replay_dialog_model.h"
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
CustomViewReplay::CustomViewReplay(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewReplay)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewReplay::~CustomViewReplay()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewReplay::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, SituationReplayManagement::ReplayPartitionDialogModel::Name).toString());
|
||||
m_ui->lbExercise->setText(rowData(idx, SituationReplayManagement::ReplayPartitionDialogModel::Exercise).toString());
|
||||
m_ui->lbWorkstationId->setText(rowData(idx, SituationReplayManagement::ReplayPartitionDialogModel::WorkstationId).toString());
|
||||
return true;
|
||||
}
|
||||
} // namespace SituationReplayManagement
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for SRM Replay
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewReplay;
|
||||
}
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
class CustomViewReplay final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewReplay(QWidget *parent = nullptr);
|
||||
~CustomViewReplay();
|
||||
bool init(const QModelIndex &idx) override;
|
||||
|
||||
private:
|
||||
Ui::CustomViewReplay* m_ui;
|
||||
|
||||
};
|
||||
} // namespace SituationReplayManagement
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewReplay</class>
|
||||
<widget class="QWidget" name="CustomViewReplay">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>70</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbExercise">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Exercise</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Workstation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbWorkstationId">
|
||||
<property name="text">
|
||||
<string notr="true">WorkstationId</string>
|
||||
</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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Partition Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
|
||||
#include "replay_dialog.h"
|
||||
#include "ui_replay_dialog.h"
|
||||
#include "replay_dialog_model.h"
|
||||
#include "CustomView/srm_replay.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
|
||||
#include <QModelIndexList>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// SituationReplayManagementDialog
|
||||
//---------------------------------
|
||||
SituationReplayManagementDialog::SituationReplayManagementDialog(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::SituationReplayManagementDialog)
|
||||
, m_srmForeign(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("SituationReplayManagementDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add,
|
||||
this, &SituationReplayManagementDialog::onAddReplayPartition);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove,
|
||||
this, &SituationReplayManagementDialog::onRemoveReplayPartition);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &SituationReplayManagementDialog::onPrint);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Yes, tr("Start Replay"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Yes, // renamed to "Start"
|
||||
this, &SituationReplayManagementDialog::slotStartReplay);
|
||||
|
||||
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Replay_Management"));
|
||||
}
|
||||
|
||||
|
||||
SituationReplayManagementDialog::~SituationReplayManagementDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Replay Management"));
|
||||
}
|
||||
|
||||
void SituationReplayManagementDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::slotStartReplay()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const Core::ReplayPartition rp = m_model->getRowData(idx.row());
|
||||
|
||||
int replayPartition = rp.id();
|
||||
|
||||
if (replayPartition < 1)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("This Replay Partition is not valid!"), tr("Cannot start Replay"));
|
||||
return;
|
||||
}
|
||||
|
||||
const LtsSession::DdsConnectionParams connParams(rp);
|
||||
m_session->getSessionManager()->createSession(connParams, true, false /* no payloads! */);
|
||||
}
|
||||
|
||||
|
||||
bool SituationReplayManagementDialog::init(const std::shared_ptr<Core::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationReplayManagement::ForeignDataInterface> &srmForeign)
|
||||
{
|
||||
m_srmForeign = srmForeign;
|
||||
m_model = new ReplayPartitionDialogModel(this);
|
||||
m_model->initModel(m_session->exerciseId(), dtc);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewReplay(this); });
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &SituationReplayManagementDialog::enaDisa);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::enaDisa()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (cntSelectedRows > 0));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Yes, (cntSelectedRows == 1));
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::onAddReplayPartition()
|
||||
{
|
||||
if (!m_session)
|
||||
return;
|
||||
|
||||
const int partitionId = m_session->partitionId();
|
||||
try
|
||||
{
|
||||
m_srmForeign->replayPartitionCreateRequest(partitionId,
|
||||
LtsSessionData::LtsSessionData::getInstance()->getWorkstationId(),
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId(),
|
||||
Core::ReplayType::SituationData);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Failed to create replay partition!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::onRemoveReplayPartition()
|
||||
{
|
||||
QVector<QPair<int, int> > toDelete;
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
|
||||
for (auto i = selectedRows.constBegin(); i != selectedRows.constEnd(); ++i)
|
||||
{
|
||||
const Core::ReplayPartition &rp = m_model->getRowData((*i).row());
|
||||
int id = rp.id();
|
||||
int wsId = rp.workstationId();
|
||||
|
||||
if (id < 1 || wsId < 1) // invalid!
|
||||
continue;
|
||||
|
||||
QPair<int, int> p(id, wsId);
|
||||
|
||||
toDelete.append(p);
|
||||
}
|
||||
|
||||
for (auto i = toDelete.constBegin(); i != toDelete.constEnd(); ++i)
|
||||
{
|
||||
QPair<int, int> p = *i;
|
||||
|
||||
try
|
||||
{
|
||||
m_srmForeign->replayPartitionRemoveRequest(p.first, p.second, 0);
|
||||
} // no more remove on error
|
||||
catch(...)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Failed to remove replay partition!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SituationReplayManagementDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
}
|
||||
} // namespace SituationReplayManagement
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SituationReplayManagement - Marker Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/SituationReplayManagement/srm_ftc.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <Services/SituationReplayManagement/logger.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SituationReplayManagementDialog;
|
||||
}
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
class ReplayPartitionDialogModel;
|
||||
// --------------------------------------------------------
|
||||
// SituationReplayManagementDialog
|
||||
// --------------------------------------------------------
|
||||
class SituationReplayManagementDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ReplayPartitionCreateReplyHandler
|
||||
, protected Interface::Ftc::ReplayPartitionRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituationReplayManagementDialog(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~SituationReplayManagementDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Core::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationReplayManagement::ForeignDataInterface> &srmForeign);
|
||||
|
||||
void onReplayPartitionCreateReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onReplayPartitionRemoveReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onAddReplayPartition();
|
||||
void onRemoveReplayPartition();
|
||||
void onPrint();
|
||||
void slotStartReplay();
|
||||
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
ReplayPartitionDialogModel *m_model;
|
||||
Ui::SituationReplayManagementDialog *m_ui;
|
||||
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> m_srmForeign;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SituationReplayManagementDialog</class>
|
||||
<widget class="QWidget" name="SituationReplayManagementDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>268</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Partition Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
#include "replay_dialog_model.h"
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
ReplayPartitionDialogModel::ReplayPartitionDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Core::ReplayPartition>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Exercise"),
|
||||
tr("Workstation"),
|
||||
tr("Connection")},
|
||||
parent)
|
||||
, m_partitionid(-1)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("ReplayPartitionDialogModel"))
|
||||
{}
|
||||
|
||||
ReplayPartitionDialogModel::~ReplayPartitionDialogModel()
|
||||
{}
|
||||
|
||||
bool ReplayPartitionDialogModel::initModel(int partitionId,
|
||||
const std::shared_ptr<Core::Interface::Dtc> &dtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_partitionid = partitionId;
|
||||
|
||||
connect(m_dtc.get(), &Core::Interface::Dtc::replayPartitionChanged,
|
||||
this, &ReplayPartitionDialogModel::onDataChanged);
|
||||
m_dtc->replayPartitions([this](const Core::ReplayPartition &partition) { insertRow(partition); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant ReplayPartitionDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const Core::ReplayPartition &partition = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return partition.id();
|
||||
case Name:
|
||||
return QString::fromStdString(partition.name());
|
||||
case Exercise:
|
||||
return partition.exerciseId(); // TODO: get name from pdm
|
||||
case WorkstationId:
|
||||
return partition.workstationId();
|
||||
case ConnectionString:
|
||||
{
|
||||
if (partition.tcpConnectionUrl().size() == 0)
|
||||
return QString::number(partition.domainId());
|
||||
return QString(QString::fromUtf8(partition.tcpConnectionUrl().c_str()) +
|
||||
QStringLiteral(" - ") +
|
||||
QString::number(partition.domainId()));
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
bool ReplayPartitionDialogModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
//#warning PATRIC!!
|
||||
// int partitionId = m_vecData.at(r).id();
|
||||
// int workstationId = m_vecData.at(r).workstationId();
|
||||
// // TODO: make async / wait dialog
|
||||
// m_ftc->replayPartitionRemoveRequest(ReplayPartitionRemoveRequest(partitionId, workstationId), this);
|
||||
return LtsAbstractTableModel::removeRows(row, count, parent);
|
||||
}
|
||||
} // namespace SituationReplayManagement
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Partition Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplayManagement/srm_dtc.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <SituationReplayManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ReplayPartitionDialogModel
|
||||
// --------------------------------------------------------
|
||||
class ReplayPartitionDialogModel final : public LtsWidgets::LtsAbstractTableModel<Core::ReplayPartition>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Name,
|
||||
Exercise,
|
||||
WorkstationId,
|
||||
ConnectionString
|
||||
};
|
||||
|
||||
explicit ReplayPartitionDialogModel(QObject *parent = nullptr);
|
||||
~ReplayPartitionDialogModel();
|
||||
|
||||
bool initModel(int partitionId,
|
||||
const std::shared_ptr<Core::Interface::Dtc> &dtc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override final;
|
||||
|
||||
protected:
|
||||
bool isFiltered(const Core::ReplayPartition &data, DataModification modType) const override
|
||||
{
|
||||
if (data.exerciseId() != m_partitionid)
|
||||
return true;
|
||||
return LtsWidgets::LtsAbstractTableModel<Core::ReplayPartition>::isFiltered(data, modType);
|
||||
}
|
||||
private:
|
||||
int m_partitionid;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_dtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
Executable
+292
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Management
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwar, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
#include "replay_management_gui_plugin.h"
|
||||
#include "replay_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsUtilsCore/await.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <LtsWidgets/lts_wait_dialog.h>
|
||||
#include <LtsAppManager/lts_app_manager.h>
|
||||
|
||||
#include <FilterManagement/flt_data_plugin_aes_display_filter.h>
|
||||
#include <FilterManagement/flt_symbol_appearance_settings.h>
|
||||
#include <Services/SituationReplayManagement/srm_operator_rights.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
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.Srm.ReplayManagement"))
|
||||
, m_requestHelper(nullptr)
|
||||
{}
|
||||
|
||||
InterfaceImpl::~InterfaceImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<DataInterface>(m_coreDtc))
|
||||
return false;
|
||||
if (!m_session->getForeignDataInterface<DataInterface>(m_sitRepIfc))
|
||||
return false;
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FilterManagement::ForeignFltParticipantGuiInterface>(m_fltParticipantIfc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getForeignGuiInterface for Filter Management Participant Gui failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getForeignGuiInterface<FilterManagement::ForeignAesGuiInterface>(m_fltAesIfc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getForeignGuiInterface for Filter Management Aes Gui failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<FilterManagement::DataInterface>(m_fltFtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getFtc for FilterManagement::Interface failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_coreDtc = nullptr;
|
||||
m_sitRepIfc = nullptr;
|
||||
m_fltParticipantIfc = nullptr;
|
||||
m_fltAesIfc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->debugFlagValue(QStringLiteral("ShowReplayManagementAction")) == QVariant(true))
|
||||
#endif
|
||||
{
|
||||
LtsWidgets::PluginData plData;
|
||||
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plData.menuText = tr("Replay Management");
|
||||
plData.identifier = QLatin1String("ReplayManagement");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:playback_situation.svg"));
|
||||
plData.operatorRight = OperatorRights::ReplayManagement;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
|
||||
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new SituationReplayManagementDialog(m_session, parent),
|
||||
m_coreDtc, m_sitRepIfc);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Situation Playback");
|
||||
plData.identifier = QLatin1String("ReplayManagementStart");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:playback_situation_start.svg"));
|
||||
plData.operatorRight = OperatorRights::ReplayManagement;
|
||||
|
||||
if (m_session->partitionType() == IDL::PartitionType::Exercise)
|
||||
{
|
||||
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
|
||||
plData.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
return startReplay();
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
// Zusaetzlich auch in 'Apps' aufschalten
|
||||
//????? wie kann man das auch in 'Apps' anzeigen die keinen exercisePart haben ?? z.B. RessourcenManagement, Timeline
|
||||
plData.menuGroup = tr("Apps");
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
return startReplay();
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Playbacks");
|
||||
}
|
||||
|
||||
void InterfaceImpl::startReplay() // blocks!
|
||||
{
|
||||
std::unique_ptr<LtsWidgets::LtsWaitDialog> _(new LtsWidgets::LtsWaitDialog(tr("Waiting for Situation Replay app")));
|
||||
|
||||
int replayId;
|
||||
try
|
||||
{
|
||||
replayId = m_sitRepIfc->replayPartitionCreateRequest(m_session->partitionId(),
|
||||
LtsSessionData::LtsSessionData::getInstance()->getWorkstationId(),
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId(),
|
||||
Core::ReplayType::SituationData);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayout(), tr("Failed to start replay partition for replay!"));
|
||||
return;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
Core::ReplayPartition rp;
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
rp = m_coreDtc->replayPartition(replayId);
|
||||
|
||||
if (rp.id() == replayId)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
try{
|
||||
LtsUtils::awaitTimeout(250);
|
||||
}catch(...){}
|
||||
}
|
||||
|
||||
auto rmPartFn = [this, replayId]()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_sitRepIfc->replayPartitionRemoveRequest(replayId, LtsSessionData::LtsSessionData::getInstance()->getWorkstationId(),
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId()); // NOTE: unfortunately waits...
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "[timeout] Failed to remove failed-to-start replay. domainId: " << m_session->domainId()
|
||||
<< " - replay id: " << replayId
|
||||
<< " - url " << m_session->tcpConnectionUrl().toString();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (!found)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), tr("Error trying to create a replay session"));
|
||||
WARNING_LOG(m_logger) << "[timeout] Error while trying to create a replay session: domainId: " << m_session->domainId()
|
||||
<< " - replay partition does not exist - replay id: " << replayId
|
||||
<< " - url " << m_session->tcpConnectionUrl().toString();
|
||||
rmPartFn();
|
||||
return;
|
||||
}
|
||||
|
||||
startReplayApp(rp); // calls done() on global wait dlg
|
||||
}
|
||||
|
||||
void InterfaceImpl::startReplayApp(const Core::ReplayPartition &data)
|
||||
{
|
||||
m_aesTransfered = false;
|
||||
m_symbolAppearanceTransfered = false;
|
||||
m_data = data;
|
||||
|
||||
// could we supply the operator-specific default settings???
|
||||
// available vi opm plugin (OperatorManagement -> defaultFilterPresetId)???
|
||||
|
||||
if (!transferFilter(data))
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " transferFilter failed.";
|
||||
|
||||
|
||||
// to avoid race conditions, continued in 'startReplayAppInternal', called by
|
||||
// onAesFilterUpdateReply / onSymbolAppearanceUpdateReply
|
||||
}
|
||||
|
||||
void InterfaceImpl::startReplayAppInternal()
|
||||
{
|
||||
const LtsSession::DdsConnectionParams connParams(m_data);
|
||||
// what's the difference?
|
||||
// LtsAppManager::LtsAppManager::getInstance()->createApp(static_cast<int>(LtsSession::LtsSession::App::Situation), connParams);
|
||||
m_session->getSessionManager()->createSession(connParams, true, false /* no payloads! */);
|
||||
}
|
||||
|
||||
|
||||
bool InterfaceImpl::transferFilter(const Core::ReplayPartition &data)
|
||||
{
|
||||
if (m_requestHelper == nullptr)
|
||||
m_requestHelper = new LtsUtils::RequestHelper(this);
|
||||
|
||||
// copy last filter from current session to replay:
|
||||
const int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
const QString context = m_session->workspaceId();
|
||||
const QString replayContext = QStringLiteral("replay_%1").arg(data.id());
|
||||
|
||||
// AES:
|
||||
auto fOrig = m_fltAesIfc->aesFilterForOperator(operatorId, context);
|
||||
auto fReplay = m_fltAesIfc->aesFilterForOperator(operatorId, replayContext); // AesDisplayFilter
|
||||
fReplay->setFilterFromData(fOrig->filterToData());
|
||||
|
||||
auto cb1 = [this, fReplay]()
|
||||
{
|
||||
return m_fltFtc->aesFilterUpdateRequest(fReplay->filterToData(), this);
|
||||
};
|
||||
m_requestHelper->addRequest(cb1);
|
||||
|
||||
|
||||
// SymbolAppearance:
|
||||
auto sOrig = m_fltParticipantIfc->symbolAppearanceForOperator(operatorId, context);
|
||||
auto sReplay = m_fltParticipantIfc->symbolAppearanceForOperator(operatorId, replayContext);
|
||||
sReplay->setSettings(sOrig->settings(), FilterManagement::SymbolAppearanceSettings::Part::All);
|
||||
|
||||
auto cb2 = [this, sReplay]()
|
||||
{
|
||||
return m_fltFtc->symbolAppearanceUpdateRequest(sReplay->settingsToData(), this);
|
||||
};
|
||||
m_requestHelper->addRequest(cb2);
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void InterfaceImpl::onAesFilterUpdateReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
|
||||
// the last replay should trigger startReplayAppInternal to continue, but
|
||||
// give flt some time publish data (race condition)
|
||||
m_aesTransfered = true;
|
||||
if (m_aesTransfered && m_symbolAppearanceTransfered)
|
||||
QTimer::singleShot(2000, this, &InterfaceImpl::startReplayAppInternal);
|
||||
}
|
||||
|
||||
void InterfaceImpl::onSymbolAppearanceUpdateReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
|
||||
// the last replay should trigger startReplayAppInternal to continue, but
|
||||
// give flt some time publish data (race condition)
|
||||
m_symbolAppearanceTransfered = true;
|
||||
if (m_aesTransfered && m_symbolAppearanceTransfered)
|
||||
QTimer::singleShot(2000, this, &InterfaceImpl::startReplayAppInternal);
|
||||
}
|
||||
|
||||
} // namespace SituationReplayManagement
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Gui Plugin for SituationReplayManagement - Replay Management
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_gui_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_data_plugin_interface.h>
|
||||
#include <Services/SituationReplayManagement/logger.h>
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:srm")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("SituationReplayManagement"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
, protected SituationReplayManagement::Interface::Ftc::ReplayPartitionCreateReplyHandler
|
||||
, private FilterManagement::Interface::Ftc::AesFilterUpdateReplyHandler
|
||||
, private FilterManagement::Interface::Ftc::SymbolAppearanceUpdateReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
~InterfaceImpl();
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
QString menuGroup() const override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Global;
|
||||
}
|
||||
|
||||
private:
|
||||
void startReplay();
|
||||
void startReplayApp(const Core::ReplayPartition &data);
|
||||
void startReplayAppInternal();
|
||||
|
||||
private:
|
||||
void onReplayPartitionCreateReply(const Core::FunctionReplyObject &reply) override { m_requestHelper->requestReply(reply); }
|
||||
void onAesFilterUpdateReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
void onSymbolAppearanceUpdateReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
|
||||
bool transferFilter(const Core::ReplayPartition &data);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Core::Interface::Dtc> m_coreDtc;
|
||||
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> m_sitRepIfc;
|
||||
|
||||
std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> m_fltParticipantIfc;
|
||||
std::shared_ptr<FilterManagement::ForeignAesGuiInterface> m_fltAesIfc;
|
||||
std::shared_ptr<FilterManagement::Interface::Ftc> m_fltFtc;
|
||||
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
int m_replayPartitionId;
|
||||
|
||||
bool m_aesTransfered = false;
|
||||
bool m_symbolAppearanceTransfered = false;
|
||||
Core::ReplayPartition m_data;
|
||||
};
|
||||
|
||||
} // namespace SituationReplayManagement
|
||||
Reference in new issue
Block a user