# HG changeset patch # User Alain Mazy # Date 1731506862 -3600 # Node ID 5f5260b5ac5907901acec9c49fed1998b617d8be # Parent 4d932683049d034742275735895f71e125c15073 include scu/scp role in presentation contexts diff -r 4d932683049d -r 5f5260b5ac59 OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp --- a/OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp Tue Oct 29 17:25:49 2024 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp Wed Nov 13 15:07:42 2024 +0100 @@ -173,7 +173,6 @@ DicomAssociation::DicomAssociation() { - role_ = DicomAssociationRole_Default; isOpen_ = false; net_ = NULL; params_ = NULL; @@ -198,16 +197,6 @@ } - void DicomAssociation::SetRole(DicomAssociationRole role) - { - if (role_ != role) - { - Close(); - role_ = role; - } - } - - void DicomAssociation::ClearPresentationContexts() { Close(); @@ -215,7 +204,26 @@ proposed_.reserve(MAX_PROPOSED_PRESENTATIONS); } - + + static T_ASC_SC_ROLE GetDcmtkRole(DicomAssociationRole role) + { + switch (role) + { + case DicomAssociationRole_Default: + return ASC_SC_ROLE_DEFAULT; + + case DicomAssociationRole_Scu: + return ASC_SC_ROLE_SCU; + + case DicomAssociationRole_Scp: + return ASC_SC_ROLE_SCP; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + } + + void DicomAssociation::Open(const DicomAssociationParameters& parameters) { if (isOpen_) @@ -240,24 +248,6 @@ dcmConnectionTimeout.set(acseTimeout); } - T_ASC_SC_ROLE dcmtkRole; - switch (role_) - { - case DicomAssociationRole_Default: - dcmtkRole = ASC_SC_ROLE_DEFAULT; - break; - - case DicomAssociationRole_Scu: - dcmtkRole = ASC_SC_ROLE_SCU; - break; - - case DicomAssociationRole_Scp: - dcmtkRole = ASC_SC_ROLE_SCP; - break; - - default: - throw OrthancException(ErrorCode_ParameterOutOfRange); - } assert(net_ == NULL && params_ == NULL && @@ -365,7 +355,7 @@ assert(!transferSyntaxes.empty()); CheckConnecting(parameters, ASC_addPresentationContext( params_, presentationContextId, abstractSyntax, - &transferSyntaxes[0], transferSyntaxes.size(), dcmtkRole)); + &transferSyntaxes[0], transferSyntaxes.size(), GetDcmtkRole(proposed_[i].role_))); presentationContextId += 2; } @@ -456,36 +446,56 @@ } } - - void DicomAssociation::ProposeGenericPresentationContext(const std::string& abstractSyntax) + void DicomAssociation::ProposeGenericPresentationContext(const std::string& abstractSyntax, + DicomAssociationRole role) { std::set ts; ts.insert(DicomTransferSyntax_LittleEndianImplicit); ts.insert(DicomTransferSyntax_LittleEndianExplicit); ts.insert(DicomTransferSyntax_BigEndianExplicit); // Retired - ProposePresentationContext(abstractSyntax, ts); + ProposePresentationContext(abstractSyntax, ts, role); + } + + void DicomAssociation::ProposeGenericPresentationContext(const std::string& abstractSyntax) + { + ProposeGenericPresentationContext(abstractSyntax, DicomAssociationRole_Default); } void DicomAssociation::ProposePresentationContext(const std::string& abstractSyntax, DicomTransferSyntax transferSyntax) { + ProposePresentationContext(abstractSyntax, transferSyntax, DicomAssociationRole_Default); + } + + + void DicomAssociation::ProposePresentationContext(const std::string& abstractSyntax, + DicomTransferSyntax transferSyntax, + DicomAssociationRole role) + { std::set ts; ts.insert(transferSyntax); - ProposePresentationContext(abstractSyntax, ts); + ProposePresentationContext(abstractSyntax, ts, role); } - size_t DicomAssociation::GetRemainingPropositions() const { assert(proposed_.size() <= MAX_PROPOSED_PRESENTATIONS); return MAX_PROPOSED_PRESENTATIONS - proposed_.size(); } + void DicomAssociation::ProposePresentationContext( + const std::string& abstractSyntax, + const std::set& transferSyntaxes) + { + ProposePresentationContext(abstractSyntax, transferSyntaxes, DicomAssociationRole_Default); + } + void DicomAssociation::ProposePresentationContext( const std::string& abstractSyntax, - const std::set& transferSyntaxes) + const std::set& transferSyntaxes, + DicomAssociationRole role) { if (transferSyntaxes.empty()) { @@ -507,6 +517,7 @@ ProposedPresentationContext context; context.abstractSyntax_ = abstractSyntax; context.transferSyntaxes_ = transferSyntaxes; + context.role_ = role; proposed_.push_back(context); } @@ -682,9 +693,8 @@ transferSyntaxes.insert(DicomTransferSyntax_LittleEndianExplicit); transferSyntaxes.insert(DicomTransferSyntax_LittleEndianImplicit); - association.SetRole(DicomAssociationRole_Scp); association.ProposePresentationContext(UID_StorageCommitmentPushModelSOPClass, - transferSyntaxes); + transferSyntaxes, DicomAssociationRole_Scp); } association.Open(parameters); @@ -861,9 +871,9 @@ transferSyntaxes.insert(DicomTransferSyntax_LittleEndianExplicit); transferSyntaxes.insert(DicomTransferSyntax_LittleEndianImplicit); - association.SetRole(DicomAssociationRole_Default); + // association.SetRole(DicomAssociationRole_Default); association.ProposePresentationContext(UID_StorageCommitmentPushModelSOPClass, - transferSyntaxes); + transferSyntaxes, DicomAssociationRole_Default); } association.Open(parameters); diff -r 4d932683049d -r 5f5260b5ac59 OrthancFramework/Sources/DicomNetworking/DicomAssociation.h --- a/OrthancFramework/Sources/DicomNetworking/DicomAssociation.h Tue Oct 29 17:25:49 2024 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomAssociation.h Wed Nov 13 15:07:42 2024 +0100 @@ -59,12 +59,12 @@ { std::string abstractSyntax_; std::set transferSyntaxes_; + DicomAssociationRole role_; }; typedef std::map > AcceptedPresentationContexts; - DicomAssociationRole role_; bool isOpen_; std::vector proposed_; AcceptedPresentationContexts accepted_; @@ -95,8 +95,6 @@ return isOpen_; } - void SetRole(DicomAssociationRole role); - void ClearPresentationContexts(); void Open(const DicomAssociationParameters& parameters); @@ -109,6 +107,13 @@ void ProposeGenericPresentationContext(const std::string& abstractSyntax); + void ProposeGenericPresentationContext(const std::string& abstractSyntax, + DicomAssociationRole role); + + void ProposePresentationContext(const std::string& abstractSyntax, + DicomTransferSyntax transferSyntax, + DicomAssociationRole role); + void ProposePresentationContext(const std::string& abstractSyntax, DicomTransferSyntax transferSyntax); @@ -117,7 +122,12 @@ void ProposePresentationContext( const std::string& abstractSyntax, const std::set& transferSyntaxes); - + + void ProposePresentationContext( + const std::string& abstractSyntax, + const std::set& transferSyntaxes, + DicomAssociationRole role); + T_ASC_Association& GetDcmtkAssociation() const; T_ASC_Network& GetDcmtkNetwork() const; diff -r 4d932683049d -r 5f5260b5ac59 OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp --- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Tue Oct 29 17:25:49 2024 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Wed Nov 13 15:07:42 2024 +0100 @@ -247,8 +247,8 @@ association_->ProposeGenericPresentationContext(UID_GETPatientRootQueryRetrieveInformationModel); // for C-GET SCU, in order to receive the C-Store message TODO-GET: we need to refine this list based on what we know we are going to retrieve - association_->ProposeGenericPresentationContext(UID_ComputedRadiographyImageStorage); - association_->ProposeGenericPresentationContext(UID_MRImageStorage); + association_->ProposeGenericPresentationContext(UID_ComputedRadiographyImageStorage, DicomAssociationRole_Scp); + association_->ProposeGenericPresentationContext(UID_MRImageStorage, DicomAssociationRole_Scp); }