Files
qt5-legatus-legacy/Lts/Plugins/OcBaseDownload/Gui/BaseDownloader/obd_base_downloader.h
T
2026-08-13 18:33:10 +02:00

110 lines
2.8 KiB
C++
Executable File

/**
* @RDE_HEADER@
* HMI Plugin for Observer Controller - Base Downloader Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2018-03-17
*/
#pragma once
#include "obd_base_downloader_message.h"
#include <LtsWidgets/lts_dialog.h>
#include <LtsSession/lts_session.h>
#include <LtsUtilsGuiDds/request_helper.h>
#include <OcBaseDownload/logger.h>
#include <Plugins/OcBaseDownload/obd_data_plugin_interface.h>
#include "obd_ex_model.h"
#include <ExerciseManagement/exm_data_plugin_interface.h>
#include <AssetManagement/asm_data_plugin_interface.h>
#include <FileManagement/flm_data_plugin_interface.h>
#include <QtNetwork/QAbstractSocket>
class QWebSocket;
namespace Ui
{
class BaseDownloader;
}
namespace OcBaseDownload
{
enum class ConnectionState
{
Start = 0,
ConnectedToExternalServer,
ConnectedToExerciseManagement,
Finished
};
class BaseDownloader : public LtsWidgets::LtsDialog
, protected OcBaseDownload::Interface::Ftc::StartBaseDownloadReplyHandler
, protected OcBaseDownload::Interface::Ftc::StartPdfDownloadReplyHandler
, protected OcBaseDownload::Interface::Ftc::OcPdfDownloadReplyHandler
{
Q_OBJECT
public:
explicit BaseDownloader(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
~BaseDownloader();
bool init();
//ftc
void onStartBaseDownloadReply(const BaseDownloadReply &replyObject) override final;
void onStartPdfDownloadReply(const PdfDownloadReply &reply) override final;
void onOcPdfDownloadReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject);}
private Q_SLOTS:
void startBaseDownload();
void selectionChanged();
void downloadExercises();
void onNewSocketState(QAbstractSocket::SocketState state);
void onNewTextMessageFromSocket(const QString &message);
void onTimerTimeout();
void onFtcTimerTimeout();
void onPdfDownloadClicked();
void onOcPdfDownloadClicked();
private:
void retranslate() override;
void doConnectToExerciseManagement(const QString &message);
QUrl getUrl(const QString &adress, unsigned short port) const;
void sendProcessListRequest();
void sendExerciseListRequest();
void fillExerciseModel(const QString &exerciseList);
private:
QString m_menuGroup;
QString m_errorMsg;
ExModel *m_model;
ExProxyModel *m_proxyModel;
LtsSession::LtsSession *m_session;
BaseDownloaderMessage *m_messageDlg;
ConnectionState m_state;
QWebSocket *m_socket;
QTimer *m_timer;
QTimer *m_ftcTimer;
std::shared_ptr<OcBaseDownload::Interface::Ftc> m_ftc;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
LtsUtils::RequestHelper *m_requestHelper{nullptr};
int m_exerciseId = 0;
Ui::BaseDownloader *m_ui;
LOGGER_T m_logger;
};
} // namespace OcBaseDownload