157 lines
5.7 KiB
C++
Executable File
157 lines
5.7 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* HMI Plugin for Messaging - Messaging Overview Dialog
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, SLSE, 2016-10-05
|
|
*/
|
|
|
|
#include "alm_participant_show_config.h"
|
|
#include "ui_alm_participant_show_config.h"
|
|
|
|
#include <LtsSession/lts_session_data.h>
|
|
|
|
#include <LtsPrinting/printing.h>
|
|
#include <QTreeView>
|
|
|
|
namespace ParticipantAlarms
|
|
{
|
|
|
|
ParticipantShowConfigView::ParticipantShowConfigView(LtsSession::LtsSession *session, QWidget *parent)
|
|
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
|
, m_configAlarmModel(nullptr)
|
|
, m_alarmHistoryModel(nullptr)
|
|
, m_dtc(nullptr)
|
|
, m_almFtc(nullptr)
|
|
, m_session(session)
|
|
, m_ui(new Ui::ParticipantShowConfigView)
|
|
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
|
, m_logger(AlarmManagement::getLogger("ParticipantShowConfigView"))
|
|
{
|
|
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView Konstruktor() ";
|
|
m_ui->setupUi(this);
|
|
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
// connects fuer Widgetaenderungen
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
|
this, &ParticipantShowConfigView::onSelectionChanged);
|
|
|
|
// Double Clicked
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
|
this, &ParticipantShowConfigView::onShowAlarm);
|
|
|
|
// Create Remove-Button
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ParticipantShowConfigView::onRemoveAlarm);
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantShowConfigView::onPrint);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
|
|
|
setOnlineHelpFilename(QStringLiteral("Situation-Show_Config_Participant_Alarms"));
|
|
|
|
} // end of ctor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
ParticipantShowConfigView::~ParticipantShowConfigView()
|
|
{
|
|
INFO_LOG(m_logger) << "--- ParticipantShowConfigView Destruktor() ";
|
|
delete m_ui;
|
|
} // end of dtor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void ParticipantShowConfigView::retranslate()
|
|
{
|
|
translate(m_ui, tr("Show Config Participant Alarms"));
|
|
}
|
|
|
|
bool ParticipantShowConfigView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
|
const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
|
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
|
{
|
|
INFO_LOG(m_logger) << "--- init() ";
|
|
if (!dtc || !ftc)
|
|
return false;
|
|
|
|
m_dtc = dtc;
|
|
m_almFtc = ftc;
|
|
m_alarmHistoryModel = new AlarmManagement::AlarmHistoryModel(this);
|
|
m_alarmHistoryModel->initModel(dtc, ppmDtc, aesDtc);
|
|
|
|
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView::init ";
|
|
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
|
m_configAlarmModel->initModel(m_dtc, ppmDtc, m_alarmHistoryModel, false);
|
|
m_ui->widget->setModel(m_configAlarmModel);
|
|
return true;
|
|
} // end of init()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void ParticipantShowConfigView::onSelectionChanged()
|
|
{
|
|
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
|
const int cntSelectedRows = selectedRows.size();
|
|
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows == 1);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, cntSelectedRows == 1);
|
|
} // end of onSelectionChanged()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void ParticipantShowConfigView::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
DEBUG_LOG(m_logger)<<"onConfigureAlarmsReply"<<replyObject.str();
|
|
m_requestHelper->requestReply(replyObject);
|
|
} // end of onConfigureAlarmsReply
|
|
|
|
void ParticipantShowConfigView::tableColumnOrganiserSetting()
|
|
{
|
|
//LtsColumnOrganiser
|
|
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
|
}
|
|
|
|
void ParticipantShowConfigView::onShowAlarm()
|
|
{
|
|
INFO_LOG(m_logger) << "--- onShowAlarm() ";
|
|
} // end of onShowAlarm()
|
|
|
|
|
|
// Window to remove an Alarm
|
|
void ParticipantShowConfigView::onRemoveAlarm()
|
|
{
|
|
DEBUG_LOG(m_logger) << "onRemoveAlarm"
|
|
<< " id = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).id()
|
|
<< " eventTypeId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).eventTypeId()
|
|
<< " operatorId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).operatorId()
|
|
<< " participantId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).participantId();
|
|
|
|
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
|
if (!curIdx.isValid())
|
|
return;
|
|
const AlarmManagement::AlarmConfig &rowdata = m_configAlarmModel->getRowData(curIdx.row());
|
|
int operatorId = rowdata.operatorId();
|
|
std::vector<int32_t> ddsParticipantIds;
|
|
ddsParticipantIds.push_back(rowdata.participantId());
|
|
bool globalEvent = true;
|
|
bool remove = true;
|
|
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
|
alarmsDds.resize(1);
|
|
alarmsDds[0].setMarker(false);
|
|
alarmsDds[0].messageWindow(false);
|
|
alarmsDds[0].eventTypeId(rowdata.eventTypeId());
|
|
AlarmManagement::ConfigureAlarmsRequest request(alarmsDds, operatorId, ddsParticipantIds, globalEvent, remove);
|
|
|
|
m_requestHelper->startSingleRequest([request, this]()
|
|
{
|
|
return m_almFtc->configureAlarmsRequest(request, this);
|
|
|
|
});
|
|
|
|
} // end of onRemoveAlarm()
|
|
|
|
// print window items
|
|
void ParticipantShowConfigView::onPrint()
|
|
{
|
|
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
|
}
|
|
|
|
} // namespace ParticipantAlarms
|