1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| int Import::connection(QString qipAdress, QString qport, QString qaet){
DcmSCU scu;
OFString host(qipAdress.toAscii());
scu.setPeerHostName(host);
unsigned int port = atoi(qport.toAscii());
scu.setPeerPort(port);
OFString verificationSOP = UID_VerificationSOPClass;
OFList<OFString> ts;
ts.push_back(UID_LittleEndianExplicitTransferSyntax);
ts.push_back(UID_BigEndianExplicitTransferSyntax);
ts.push_back(UID_LittleEndianImplicitTransferSyntax);
scu.addPresentationContext(verificationSOP, ts);
OFString peerAET = qaet.toAscii();
if (peerAET != "")
{
scu.setPeerAETitle(peerAET);
}
OFCondition result = scu.initNetwork();
if (result.bad())
{
std::cerr << "Error setting up SCU: " << result.text() << "\n";
return 2;
}
// Negotiate association
result = scu.negotiateAssociation();
if (result.bad())
{
std::cerr << "Error negotiating association: " << result.text() << "\n";
return 2;
}
// Issue ECHO request and let scu find presentation context itself (0)
result = scu.sendECHORequest(0);
if (result.bad())
{
std::cerr << "Error issuing ECHO request or received rejecting response: " << result.text() << "\n";
return 2;
}
std::cout << "Successfully sent DICOM Echo to host " << host << " on port " << port << "\n";
return 0;
} |