diff --git a/src/src/PACS/Dialog/ConnectionTestDialog.cpp b/src/src/PACS/Dialog/ConnectionTestDialog.cpp new file mode 100644 index 0000000..1d4b254 --- /dev/null +++ b/src/src/PACS/Dialog/ConnectionTestDialog.cpp @@ -0,0 +1,38 @@ +#include "ConnectionTestDialog.h" + +#include + +#include "PACS/Network/EchoWorker.h" + + +ConnectionTestDialog::ConnectionTestDialog(QWidget *aParent) + :QMessageBox(QMessageBox::Icon::Information,tr("Connection Testing"),tr("Connecting......"),QMessageBox::StandardButton::Ok,aParent) + ,mWorker(new EchoWorker()) +{ + setDefaultButton(QMessageBox::Ok); + defaultButton()->setEnabled(false); +} + +ConnectionTestDialog::~ConnectionTestDialog() +{ + +} + +void ConnectionTestDialog::startTest(const QString &aLocalAE, const QString &aRemoteAE, const QString &aRemoteIP, unsigned long aPort) +{ + mWorker->setPacsInfo(aLocalAE.toStdString(), aRemoteAE.toStdString(), aRemoteIP.toStdString(), aPort); + connect(mWorker, &EchoWorker::notifyDone,this,&ConnectionTestDialog::processResult,Qt::QueuedConnection); + mWorker->execute(); +} + +void ConnectionTestDialog::processResult(int aResult) +{ + if (aResult) + { + setText(tr("Success!")); + } + else{ + setText(tr("Fail!")); + } + defaultButton()->setEnabled(true); +} diff --git a/src/src/PACS/Dialog/ConnectionTestDialog.h b/src/src/PACS/Dialog/ConnectionTestDialog.h new file mode 100644 index 0000000..1813096 --- /dev/null +++ b/src/src/PACS/Dialog/ConnectionTestDialog.h @@ -0,0 +1,20 @@ +#ifndef CONNECTION_TEST_DIALOG +#define CONNECTION_TEST_DIALOG + +#include +class EchoWorker; +class ConnectionTestDialog: public QMessageBox +{ + Q_OBJECT + + public: + explicit ConnectionTestDialog(QWidget* aParent); + ~ConnectionTestDialog(); + void startTest(const QString& aLocalAE, const QString& aRemoteAE, const QString& aRemoteIP, unsigned long aPort); + private: + void processResult(int); + EchoWorker* mWorker; +}; + + +#endif /* AC8F73C3_2A4E_4858_A81B_42D2D87198A3 */ diff --git a/src/src/PACS/Network/EchoWorker.cpp b/src/src/PACS/Network/EchoWorker.cpp new file mode 100644 index 0000000..3d6c5ca --- /dev/null +++ b/src/src/PACS/Network/EchoWorker.cpp @@ -0,0 +1,65 @@ +#include "EchoWorker.h" + +#include +#include + +EchoWorker::EchoWorker(QObject *parent) + : QObject(parent) + , QRunnable() +{ +} + +EchoWorker::~EchoWorker() +{ + delete mScu; +} + +void EchoWorker::setPacsInfo(const std::string &aAETitle, const std::string &aRemoteTitle, const std::string &aRemoteIP, unsigned long aRemotePort) +{ + mAETitle = aAETitle; + mRemoteAETitle = aRemoteTitle; + mRemoteIP = aRemoteIP; + mRemotePort = aRemotePort; +} + +void EchoWorker::execute() +{ + QThreadPool::globalInstance()->start(this); +} + +void EchoWorker::run() +{ + mScu = new DcmSCU(); + mScu->setMaxReceivePDULength(ASC_DEFAULTMAXPDU); + mScu->setACSETimeout(3); + mScu->setDIMSEBlockingMode(DIMSE_BLOCKING); + mScu->setDIMSETimeout(3); + mScu->setAETitle(mAETitle); + mScu->setPeerHostName(mRemoteIP); + mScu->setPeerPort(OFstatic_cast(Uint16, mRemotePort)); + mScu->setPeerAETitle(mRemoteAETitle); + mScu->setConnectionTimeout(3); + OFList syntaxes; + syntaxes.push_back(UID_LittleEndianExplicitTransferSyntax); + mScu->addPresentationContext(UID_VerificationSOPClass, syntaxes); + OFCondition cond = mScu->initNetwork(); + if (cond.bad()) + { + emit notifyDone(0); + return; + } + cond = mScu->negotiateAssociation(); + if (cond.bad()) + { + emit notifyDone(0); + return; + } + cond = mScu->sendECHORequest(mScu->findPresentationContextID(UID_VerificationSOPClass,"")); + if (cond.bad()){ + emit notifyDone(0); + return; + } + mScu->releaseAssociation(); + emit notifyDone(1); + return; +} \ No newline at end of file diff --git a/src/src/PACS/Network/EchoWorker.h b/src/src/PACS/Network/EchoWorker.h new file mode 100644 index 0000000..2027ee6 --- /dev/null +++ b/src/src/PACS/Network/EchoWorker.h @@ -0,0 +1,31 @@ +#ifndef _ECHOWORKER_H +#define _ECHOWORKER_H + +#include +#include +class DcmSCU; + +class EchoWorker : public QObject, QRunnable +{ + Q_OBJECT + +public: + explicit EchoWorker(QObject *parent = Q_NULLPTR); + ~EchoWorker(); + void setPacsInfo(const std::string& aAETitle, const std::string& aRemoteTitle, const std::string& aRemoteIP, unsigned long aRemotePort); + void execute(); + void run() override; +signals: + void notifyDone(int); + + +private: + std::string mRemoteIP; + unsigned long mRemotePort; + std::string mRemoteAETitle; + unsigned long mLocalPort; + std::string mAETitle; + DcmSCU* mScu; +}; + +#endif // ECHOCLIENT_H diff --git a/src/src/PACS/Widget/pacsconfiguration.cpp b/src/src/PACS/Widget/pacsconfiguration.cpp index 8a6ba9f..95f39e1 100644 --- a/src/src/PACS/Widget/pacsconfiguration.cpp +++ b/src/src/PACS/Widget/pacsconfiguration.cpp @@ -13,6 +13,7 @@ #include #include #include "PACS/Dialog/promptdialog.h" +#include "PACS/Dialog/ConnectionTestDialog.h" ConfigurationDialog::ConfigurationDialog(QWidget *parent) : QDialog(parent) @@ -31,7 +32,7 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent) , m_pDelButton(nullptr) , m_pPacsInfo(nullptr) , m_pPacsMenu(nullptr) - , m_pRetriveProtocolMenu(nullptr) + , m_TestConnectionMenu(nullptr) , m_pEditWidget(nullptr) , m_pEditLayout(nullptr) , m_pPeerIpAddressLabel(nullptr) @@ -127,20 +128,18 @@ void ConfigurationDialog::initUi() m_pPacsInfo->setSelectionBehavior(QAbstractItemView::SelectRows); m_pPacsInfo->setModel(m_pPacsModel); m_pPacsInfo->setMinimumHeight(123); - connect(m_pPacsInfo,&QTableView::customContextMenuRequested,this,&ConfigurationDialog::pacsMenuRequest); + connect(m_pPacsInfo,&QTableView::customContextMenuRequested,this,&ConfigurationDialog::pacsMenuRequest); m_pMainLayout->addWidget(m_pPacsInfo); m_pPacsMenu = new QMenu(m_pPacsInfo); - m_pRetriveProtocolMenu = new QMenu(tr("Retrieval Protocol"),m_pPacsMenu); - QAction* cGetAction = new QAction("C-GET",m_pRetriveProtocolMenu); - cGetAction->setCheckable(true); - connect(cGetAction,&QAction::triggered,this,&ConfigurationDialog::changeHostProtocol); - QAction* cMoveAction = new QAction("C-MOVE",m_pRetriveProtocolMenu); - cMoveAction->setCheckable(true); - connect(cMoveAction,&QAction::triggered,this,&ConfigurationDialog::changeHostProtocol); - m_pRetriveProtocolMenu->addAction(cGetAction); - m_pRetriveProtocolMenu->addAction(cMoveAction); - - m_pPacsMenu->addMenu(m_pRetriveProtocolMenu); + QAction* cTestAction = new QAction("Test connection",m_pPacsMenu); + connect(cTestAction, &QAction::triggered,[=](){ + ConnectionTestDialog testDialog(this); + // testDialog.setModal(true); + testDialog.startTest(m_pOurTitleEdit->text(), m_pPeerTitleEdit->text(), m_pPeerIpAddressEdit->text(), + m_pPeerPortEdit->text().toULong()); + testDialog.exec(); + }); + m_pPacsMenu->addAction(cTestAction); m_pEditWidget = new QWidget(this); m_pEditLayout = new QGridLayout(this); diff --git a/src/src/PACS/Widget/pacsconfiguration.h b/src/src/PACS/Widget/pacsconfiguration.h index b67d263..2301ab9 100644 --- a/src/src/PACS/Widget/pacsconfiguration.h +++ b/src/src/PACS/Widget/pacsconfiguration.h @@ -73,7 +73,7 @@ private: QPushButton *m_pDelButton; QTableView *m_pPacsInfo; QMenu* m_pPacsMenu; - QMenu* m_pRetriveProtocolMenu; + QMenu* m_TestConnectionMenu; QWidget *m_pEditWidget; QGridLayout *m_pEditLayout; QLabel *m_pPeerIpAddressLabel; diff --git a/src/translations/zh_CN.ts b/src/translations/zh_CN.ts index 6e10fc5..6b4a36f 100644 --- a/src/translations/zh_CN.ts +++ b/src/translations/zh_CN.ts @@ -111,6 +111,29 @@ PACS配置 + + ConnectionTestDialog + + + Connection Testing + "连接测试" + + + + Connecting...... + "连接中......" + + + + Success! + "连接成功!" + + + + Fail! + "连接失败!" + + Customwindow