Mercurial > hg > orthanc
comparison Core/DicomNetworking/DicomUserConnection.cpp @ 3608:7ae553d9c366 storage-commitment
created DicomUserConnection::RequestStorageCommitment()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 Jan 2020 18:44:47 +0100 |
parents | d0ecb355db33 |
children | f7ade98d8229 |
comparison
equal
deleted
inserted
replaced
3607:d0ecb355db33 | 3608:7ae553d9c366 |
---|---|
304 } | 304 } |
305 | 305 |
306 break; | 306 break; |
307 } | 307 } |
308 | 308 |
309 case Mode_RequestStorageCommitment: | |
309 case Mode_ReportStorageCommitment: | 310 case Mode_ReportStorageCommitment: |
310 { | 311 { |
311 const char* as = UID_StorageCommitmentPushModelSOPClass; | 312 const char* as = UID_StorageCommitmentPushModelSOPClass; |
312 | 313 |
313 std::vector<const char*> ts; | 314 std::vector<const char*> ts; |
314 ts.push_back(UID_LittleEndianExplicitTransferSyntax); | 315 ts.push_back(UID_LittleEndianExplicitTransferSyntax); |
315 ts.push_back(UID_LittleEndianImplicitTransferSyntax); | 316 ts.push_back(UID_LittleEndianImplicitTransferSyntax); |
316 | 317 |
318 T_ASC_SC_ROLE role; | |
319 switch (mode) | |
320 { | |
321 case Mode_RequestStorageCommitment: | |
322 role = ASC_SC_ROLE_DEFAULT; | |
323 break; | |
324 | |
325 case Mode_ReportStorageCommitment: | |
326 role = ASC_SC_ROLE_SCP; | |
327 break; | |
328 | |
329 default: | |
330 throw OrthancException(ErrorCode_InternalError); | |
331 } | |
332 | |
317 Check(ASC_addPresentationContext(pimpl_->params_, 1 /*presentationContextId*/, | 333 Check(ASC_addPresentationContext(pimpl_->params_, 1 /*presentationContextId*/, |
318 as, &ts[0], ts.size(), ASC_SC_ROLE_SCP), | 334 as, &ts[0], ts.size(), role), |
319 remoteAet_, "initializing"); | 335 remoteAet_, "initializing"); |
320 | 336 |
321 break; | 337 break; |
322 } | 338 } |
323 | 339 |
1426 | 1442 |
1427 LOG(INFO) << "Reporting modality \"" << remoteAet_ | 1443 LOG(INFO) << "Reporting modality \"" << remoteAet_ |
1428 << "\" about storage commitment transaction: " << transactionUid | 1444 << "\" about storage commitment transaction: " << transactionUid |
1429 << " (" << successSopClassUids.size() << " successes, " | 1445 << " (" << successSopClassUids.size() << " successes, " |
1430 << failureSopClassUids.size() << " failures)"; | 1446 << failureSopClassUids.size() << " failures)"; |
1431 DIC_US messageId = pimpl_->assoc_->nextMsgID; | 1447 const DIC_US messageId = pimpl_->assoc_->nextMsgID++; |
1432 | 1448 |
1433 { | 1449 { |
1434 T_DIMSE_Message message; | 1450 T_DIMSE_Message message; |
1435 memset(&message, 0, sizeof(message)); | 1451 memset(&message, 0, sizeof(message)); |
1436 message.CommandField = DIMSE_N_EVENT_REPORT_RQ; | 1452 message.CommandField = DIMSE_N_EVENT_REPORT_RQ; |
1519 { | 1535 { |
1520 Close(); | 1536 Close(); |
1521 throw; | 1537 throw; |
1522 } | 1538 } |
1523 } | 1539 } |
1540 | |
1541 | |
1542 | |
1543 void DicomUserConnection::RequestStorageCommitment( | |
1544 std::string& transactionUid, | |
1545 const std::vector<std::string>& sopClassUids, | |
1546 const std::vector<std::string>& sopInstanceUids) | |
1547 { | |
1548 if (sopClassUids.size() != sopInstanceUids.size()) | |
1549 { | |
1550 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1551 } | |
1552 | |
1553 if (IsOpen()) | |
1554 { | |
1555 Close(); | |
1556 } | |
1557 | |
1558 try | |
1559 { | |
1560 OpenInternal(Mode_RequestStorageCommitment); | |
1561 | |
1562 /** | |
1563 * N-ACTION | |
1564 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part04/sect_J.3.2.html | |
1565 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#table_10.1-4 | |
1566 * | |
1567 * Status code: | |
1568 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#sect_10.1.1.1.8 | |
1569 **/ | |
1570 | |
1571 /** | |
1572 * Send the "N_ACTION_RQ" request | |
1573 **/ | |
1574 | |
1575 printf("ICI\n"); | |
1576 | |
1577 LOG(INFO) << "Request to modality \"" << remoteAet_ | |
1578 << "\" about storage commitment for " << sopClassUids.size() << " instances"; | |
1579 const DIC_US messageId = pimpl_->assoc_->nextMsgID++; | |
1580 | |
1581 { | |
1582 T_DIMSE_Message message; | |
1583 memset(&message, 0, sizeof(message)); | |
1584 message.CommandField = DIMSE_N_ACTION_RQ; | |
1585 | |
1586 T_DIMSE_N_ActionRQ& content = message.msg.NActionRQ; | |
1587 content.MessageID = messageId; | |
1588 strncpy(content.RequestedSOPClassUID, UID_StorageCommitmentPushModelSOPClass, DIC_UI_LEN); | |
1589 strncpy(content.RequestedSOPInstanceUID, UID_StorageCommitmentPushModelSOPInstance, DIC_UI_LEN); | |
1590 content.ActionTypeID = 1; // "Request Storage Commitment" | |
1591 content.DataSetType = DIMSE_DATASET_PRESENT; | |
1592 | |
1593 DcmDataset dataset; | |
1594 if (!dataset.putAndInsertString(DCM_TransactionUID, transactionUid.c_str()).good()) | |
1595 { | |
1596 throw OrthancException(ErrorCode_InternalError); | |
1597 } | |
1598 | |
1599 FillSopSequence(dataset, DCM_ReferencedSOPSequence, sopClassUids, sopInstanceUids); | |
1600 | |
1601 int presID = ASC_findAcceptedPresentationContextID( | |
1602 pimpl_->assoc_, UID_StorageCommitmentPushModelSOPClass); | |
1603 if (presID == 0) | |
1604 { | |
1605 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - " | |
1606 "Unable to send N-EVENT-REPORT request to AET: " + remoteAet_); | |
1607 } | |
1608 | |
1609 if (!DIMSE_sendMessageUsingMemoryData( | |
1610 pimpl_->assoc_, presID, &message, NULL /* status detail */, | |
1611 &dataset, NULL /* callback */, NULL /* callback context */, | |
1612 NULL /* commandSet */).good()) | |
1613 { | |
1614 throw OrthancException(ErrorCode_NetworkProtocol); | |
1615 } | |
1616 } | |
1617 | |
1618 /** | |
1619 * Read the "N_ACTION_RSP" response | |
1620 **/ | |
1621 | |
1622 // TODO | |
1623 | |
1624 Close(); | |
1625 } | |
1626 catch (OrthancException&) | |
1627 { | |
1628 Close(); | |
1629 throw; | |
1630 } | |
1631 } | |
1524 } | 1632 } |