feat: Add CECHO test to pacs configuratuon
This commit is contained in:
38
src/src/PACS/Dialog/ConnectionTestDialog.cpp
Normal file
38
src/src/PACS/Dialog/ConnectionTestDialog.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "ConnectionTestDialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#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);
|
||||
}
|
||||
20
src/src/PACS/Dialog/ConnectionTestDialog.h
Normal file
20
src/src/PACS/Dialog/ConnectionTestDialog.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef CONNECTION_TEST_DIALOG
|
||||
#define CONNECTION_TEST_DIALOG
|
||||
|
||||
#include <QMessageBox>
|
||||
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 */
|
||||
65
src/src/PACS/Network/EchoWorker.cpp
Normal file
65
src/src/PACS/Network/EchoWorker.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "EchoWorker.h"
|
||||
|
||||
#include <dcmtk/dcmnet/scu.h>
|
||||
#include <QThreadPool>
|
||||
|
||||
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<OFString> 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;
|
||||
}
|
||||
31
src/src/PACS/Network/EchoWorker.h
Normal file
31
src/src/PACS/Network/EchoWorker.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef _ECHOWORKER_H
|
||||
#define _ECHOWORKER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QRunnable>
|
||||
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
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <QItemSelectionModel>
|
||||
#include <QHeaderView>
|
||||
#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)
|
||||
@@ -130,17 +131,15 @@ void ConfigurationDialog::initUi()
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -111,6 +111,29 @@
|
||||
<translation>PACS配置</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectionTestDialog</name>
|
||||
<message>
|
||||
<location filename="../src/PACS/Dialog/ConnectionTestDialog.cpp" line="9"/>
|
||||
<source>Connection Testing</source>
|
||||
<translation>"连接测试"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/PACS/Dialog/ConnectionTestDialog.cpp" line="9"/>
|
||||
<source>Connecting......</source>
|
||||
<translation>"连接中......"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/PACS/Dialog/ConnectionTestDialog.cpp" line="32"/>
|
||||
<source>Success!</source>
|
||||
<translation >"连接成功!"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/PACS/Dialog/ConnectionTestDialog.cpp" line="35"/>
|
||||
<source>Fail!</source>
|
||||
<translation>"连接失败!"</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Customwindow</name>
|
||||
<message>
|
||||
|
||||
Reference in New Issue
Block a user