annotate OrthancServer/DicomProtocol/DicomUserConnection.cpp @ 2759:0cfab50c1381 Orthanc-0.7.5

close old branch
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 17 Jul 2018 09:41:32 +0200
parents 31cc399c7762
children a811bdf8b8eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
689
2d0a347e8cfc switch to 2014
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 666
diff changeset
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
10 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
11 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
12 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
15 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
19 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
20 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
21 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
766
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
33
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
34 /*=========================================================================
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
35
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
36 This file is based on portions of the following project:
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
37
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
38 Program: DCMTK 3.6.0
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
39 Module: http://dicom.offis.de/dcmtk.php.en
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
40
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
41 Copyright (C) 1994-2011, OFFIS e.V.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
42 All rights reserved.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
43
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
44 This software and supporting documentation were developed by
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
45
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
46 OFFIS e.V.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
47 R&D Division Health
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
48 Escherweg 2
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
49 26121 Oldenburg, Germany
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
50
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
51 Redistribution and use in source and binary forms, with or without
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
52 modification, are permitted provided that the following conditions
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
53 are met:
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
54
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
55 - Redistributions of source code must retain the above copyright
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
56 notice, this list of conditions and the following disclaimer.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
57
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
58 - Redistributions in binary form must reproduce the above copyright
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
59 notice, this list of conditions and the following disclaimer in the
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
60 documentation and/or other materials provided with the distribution.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
61
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
62 - Neither the name of OFFIS nor the names of its contributors may be
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
63 used to endorse or promote products derived from this software
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
64 without specific prior written permission.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
65
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
66 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
67 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
68 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
69 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
70 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
71 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
72 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
73 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
74 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
75 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
76 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
77
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
78 =========================================================================*/
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
79
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
80
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 #include "DicomUserConnection.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
83 #include "../../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 #include "../ToDcmtkBridge.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 #include "../FromDcmtkBridge.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 #include <dcmtk/dcmdata/dcistrmb.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 #include <dcmtk/dcmdata/dcistrmf.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 #include <dcmtk/dcmdata/dcfilefo.h>
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
90 #include <dcmtk/dcmdata/dcmetinf.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 #include <dcmtk/dcmnet/diutil.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 #include <set>
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
94 #include <glog/logging.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 #ifdef _WIN32
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 /**
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 * "The maximum length, in bytes, of the string returned in the buffer
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 * pointed to by the name parameter is dependent on the namespace provider,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 * but this string must be 256 bytes or less.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 * http://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 #define HOST_NAME_MAX 256
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 #endif
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
109 static const char* DEFAULT_PREFERRED_TRANSFER_SYNTAX = UID_LittleEndianImplicitTransferSyntax;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
110
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
111 /**
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
112 * "If we have more than 64 storage SOP classes, tools such as
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
113 * storescu will fail because they attempt to negotiate two
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
114 * presentation contexts for each SOP class, and there is a total
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
115 * limit of 128 contexts for one association."
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
116 **/
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
117 static const unsigned int MAXIMUM_STORAGE_SOP_CLASSES = 64;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
118
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
119
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
120 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 struct DicomUserConnection::PImpl
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 // Connection state
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 T_ASC_Network* net_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 T_ASC_Parameters* params_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 T_ASC_Association* assoc_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 bool IsOpen() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 return assoc_ != NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 void CheckIsOpen() const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
136 void Store(DcmInputStream& is, DicomUserConnection& connection);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 static void Check(const OFCondition& cond)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
144 throw OrthancException("DicomUserConnection: " + std::string(cond.text()));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 void DicomUserConnection::PImpl::CheckIsOpen() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 if (!IsOpen())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
152 throw OrthancException("DicomUserConnection: First open the connection");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 void DicomUserConnection::CheckIsOpen() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 pimpl_->CheckIsOpen();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
163 static void RegisterStorageSOPClass(T_ASC_Parameters* params,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
164 unsigned int& presentationContextId,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
165 const std::string& sopClass,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
166 const char* asPreferred[],
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
167 std::vector<const char*>& asFallback)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 {
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
169 Check(ASC_addPresentationContext(params, presentationContextId,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
170 sopClass.c_str(), asPreferred, 1));
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
171 presentationContextId += 2;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
172
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
173 if (asFallback.size() > 0)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
174 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
175 Check(ASC_addPresentationContext(params, presentationContextId,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
176 sopClass.c_str(), &asFallback[0], asFallback.size()));
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
177 presentationContextId += 2;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
178 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
180
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
181
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
182 void DicomUserConnection::SetupPresentationContexts(const std::string& preferredTransferSyntax)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 {
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
184 // Flatten an array with the preferred transfer syntax
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
185 const char* asPreferred[1] = { preferredTransferSyntax.c_str() };
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
186
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
187 // Setup the fallback transfer syntaxes
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
188 std::set<std::string> fallbackSyntaxes;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
189 fallbackSyntaxes.insert(UID_LittleEndianExplicitTransferSyntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
190 fallbackSyntaxes.insert(UID_BigEndianExplicitTransferSyntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
191 fallbackSyntaxes.insert(UID_LittleEndianImplicitTransferSyntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
192 fallbackSyntaxes.erase(preferredTransferSyntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
193
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
194 // Flatten an array with the fallback transfer syntaxes
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
195 std::vector<const char*> asFallback;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
196 asFallback.reserve(fallbackSyntaxes.size());
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
197 for (std::set<std::string>::const_iterator
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
198 it = fallbackSyntaxes.begin(); it != fallbackSyntaxes.end(); ++it)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
199 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
200 asFallback.push_back(it->c_str());
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
201 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
203 CheckStorageSOPClassesInvariant();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 unsigned int presentationContextId = 1;
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
205
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
206 for (std::list<std::string>::const_iterator it = reservedStorageSOPClasses_.begin();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
207 it != reservedStorageSOPClasses_.end(); it++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
209 RegisterStorageSOPClass(pimpl_->params_, presentationContextId,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
210 *it, asPreferred, asFallback);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
211 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
213 for (std::set<std::string>::const_iterator it = storageSOPClasses_.begin();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
214 it != storageSOPClasses_.end(); it++)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
215 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
216 RegisterStorageSOPClass(pimpl_->params_, presentationContextId,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
217 *it, asPreferred, asFallback);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
218 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
219
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
220 for (std::set<std::string>::const_iterator it = defaultStorageSOPClasses_.begin();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
221 it != defaultStorageSOPClasses_.end(); it++)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
222 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
223 RegisterStorageSOPClass(pimpl_->params_, presentationContextId,
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
224 *it, asPreferred, asFallback);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
229 static bool IsGenericTransferSyntax(const std::string& syntax)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
230 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
231 return (syntax == UID_LittleEndianExplicitTransferSyntax ||
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
232 syntax == UID_BigEndianExplicitTransferSyntax ||
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
233 syntax == UID_LittleEndianImplicitTransferSyntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
234 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
235
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
236
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
237 void DicomUserConnection::PImpl::Store(DcmInputStream& is, DicomUserConnection& connection)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 CheckIsOpen();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 DcmFileFormat dcmff;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
244 // Determine the storage SOP class UID for this instance
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
245 static const DcmTagKey DCM_SOP_CLASS_UID(0x0008, 0x0016);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
246 OFString sopClassUid;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
247 if (dcmff.getDataset()->findAndGetOFString(DCM_SOP_CLASS_UID, sopClassUid).good())
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
248 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
249 connection.AddStorageSOPClass(sopClassUid.c_str());
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
250 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
251
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
252 // Determine whether a new presentation context must be
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
253 // negotiated, depending on the transfer syntax of this instance
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
254 DcmXfer xfer(dcmff.getDataset()->getOriginalXfer());
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
255 const std::string syntax(xfer.getXferID());
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
256 bool isGeneric = IsGenericTransferSyntax(syntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
257
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
258 if (isGeneric ^ IsGenericTransferSyntax(connection.GetPreferredTransferSyntax()))
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
259 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
260 // Making a generic-to-specific or specific-to-generic change of
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
261 // the transfer syntax. Renegotiate the connection.
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
262 LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated";
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
263
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
264 if (isGeneric)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
265 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
266 connection.ResetPreferredTransferSyntax();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
267 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
268 else
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
269 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
270 connection.SetPreferredTransferSyntax(syntax);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
271 }
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
272 }
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
273
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
274 if (!connection.IsOpen())
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
275 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
276 LOG(INFO) << "Renegotiating a C-Store association due to a change in the parameters";
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
277 connection.Open();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
278 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
279
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 // Figure out which SOP class and SOP instance is encapsulated in the file
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 DIC_UI sopClass;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 DIC_UI sopInstance;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
285 throw OrthancException("DicomUserConnection: Unable to find the SOP class and instance");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 // Figure out which of the accepted presentation contexts should be used
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 if (presID == 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 const char *modalityName = dcmSOPClassUIDToModality(sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 if (!modalityName) modalityName = "unknown SOP class";
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
295 throw OrthancException("DicomUserConnection: No presentation context for modality " +
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
296 std::string(modalityName));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 // Prepare the transmission of data
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 T_DIMSE_C_StoreRQ req;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 memset(&req, 0, sizeof(req));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 req.MessageID = assoc_->nextMsgID++;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 strcpy(req.AffectedSOPClassUID, sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 strcpy(req.AffectedSOPInstanceUID, sopInstance);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 req.DataSetType = DIMSE_DATASET_PRESENT;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 req.Priority = DIMSE_PRIORITY_MEDIUM;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 // Finally conduct transmission of data
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 T_DIMSE_C_StoreRSP rsp;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 DcmDataset* statusDetail = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 Check(DIMSE_storeUser(assoc_, presID, &req,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 NULL, dcmff.getDataset(), /*progressCallback*/ NULL, NULL,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 &rsp, &statusDetail, NULL));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 if (statusDetail != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 delete statusDetail;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 static void FindCallback(
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 /* in */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 void *callbackData,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 T_DIMSE_C_FindRQ *request, /* original find request */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 int responseCount,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 T_DIMSE_C_FindRSP *response, /* pending response received */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 DcmDataset *responseIdentifiers /* pending response identifiers */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 )
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 {
657
5425bb6f1ea5 further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
332 DicomFindAnswers& answers = *reinterpret_cast<DicomFindAnswers*>(callbackData);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 if (responseIdentifiers != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 DicomMap m;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 FromDcmtkBridge::Convert(m, *responseIdentifiers);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 answers.Add(m);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 void DicomUserConnection::Find(DicomFindAnswers& result,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 FindRootModel model,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 const DicomMap& fields)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 CheckIsOpen();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 const char* sopClass;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 std::auto_ptr<DcmDataset> dataset(ToDcmtkBridge::Convert(fields));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 switch (model)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 {
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
352 case FindRootModel_Patient:
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
353 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "PATIENT");
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
354 sopClass = UID_FINDPatientRootQueryRetrieveInformationModel;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
356 // Accession number
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
357 if (!fields.HasTag(0x0008, 0x0050))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
358 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
360 // Patient ID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
361 if (!fields.HasTag(0x0010, 0x0020))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
362 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0010, 0x0020), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
364 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
366 case FindRootModel_Study:
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
367 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "STUDY");
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
368 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
370 // Accession number
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
371 if (!fields.HasTag(0x0008, 0x0050))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
372 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
374 // Study instance UID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
375 if (!fields.HasTag(0x0020, 0x000d))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
376 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
378 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
380 case FindRootModel_Series:
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
381 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "SERIES");
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
382 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
384 // Accession number
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
385 if (!fields.HasTag(0x0008, 0x0050))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
386 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
388 // Study instance UID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
389 if (!fields.HasTag(0x0020, 0x000d))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
390 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
392 // Series instance UID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
393 if (!fields.HasTag(0x0020, 0x000e))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
394 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000e), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
396 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
398 case FindRootModel_Instance:
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
399 if (manufacturer_ == ModalityManufacturer_ClearCanvas ||
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
400 manufacturer_ == ModalityManufacturer_Dcm4Chee)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
401 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
402 // This is a particular case for ClearCanvas, thanks to Peter Somlo <peter.somlo@gmail.com>.
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
403 // https://groups.google.com/d/msg/orthanc-users/j-6C3MAVwiw/iolB9hclom8J
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
404 // http://www.clearcanvas.ca/Home/Community/OldForums/tabid/526/aff/11/aft/14670/afv/topic/Default.aspx
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
405 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "IMAGE");
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
406 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
407 else
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
408 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
409 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "INSTANCE");
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
410 }
519
1b2cdc855bd3 Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
411
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
412 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
414 // Accession number
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
415 if (!fields.HasTag(0x0008, 0x0050))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
416 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
418 // Study instance UID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
419 if (!fields.HasTag(0x0020, 0x000d))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
420 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
422 // Series instance UID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
423 if (!fields.HasTag(0x0020, 0x000e))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
424 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000e), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
426 // SOP Instance UID
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
427 if (!fields.HasTag(0x0008, 0x0018))
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
428 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0018), "");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
430 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
432 default:
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
433 throw OrthancException(ErrorCode_ParameterOutOfRange);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 // Figure out which of the accepted presentation contexts should be used
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 if (presID == 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
440 throw OrthancException("DicomUserConnection: The C-FIND command is not supported by the distant AET");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 T_DIMSE_C_FindRQ request;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 memset(&request, 0, sizeof(request));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 request.MessageID = pimpl_->assoc_->nextMsgID++;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 strcpy(request.AffectedSOPClassUID, sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 request.DataSetType = DIMSE_DATASET_PRESENT;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 request.Priority = DIMSE_PRIORITY_MEDIUM;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 T_DIMSE_C_FindRSP response;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 DcmDataset* statusDetail = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 OFCondition cond = DIMSE_findUser(pimpl_->assoc_, presID, &request, dataset.get(),
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 FindCallback, &result,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 &response, &statusDetail);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 if (statusDetail)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 delete statusDetail;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 Check(cond);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 void DicomUserConnection::FindPatient(DicomFindAnswers& result,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 const DicomMap& fields)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 // Only keep the filters from "fields" that are related to the patient
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 DicomMap s;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 fields.ExtractPatientInformation(s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 Find(result, FindRootModel_Patient, s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 void DicomUserConnection::FindStudy(DicomFindAnswers& result,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 const DicomMap& fields)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 // Only keep the filters from "fields" that are related to the study
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 DicomMap s;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 fields.ExtractStudyInformation(s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
482 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
483 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
725
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 692
diff changeset
484 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 Find(result, FindRootModel_Study, s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 void DicomUserConnection::FindSeries(DicomFindAnswers& result,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 const DicomMap& fields)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 // Only keep the filters from "fields" that are related to the series
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 DicomMap s;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 fields.ExtractSeriesInformation(s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
496 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
497 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
498 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 Find(result, FindRootModel_Series, s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 void DicomUserConnection::FindInstance(DicomFindAnswers& result,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 const DicomMap& fields)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 // Only keep the filters from "fields" that are related to the instance
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 DicomMap s;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 fields.ExtractInstanceInformation(s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
510 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
511 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
512 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
513 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 Find(result, FindRootModel_Instance, s);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 void DicomUserConnection::Move(const std::string& targetAet,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 const DicomMap& fields)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 CheckIsOpen();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 const char* sopClass = UID_MOVEStudyRootQueryRetrieveInformationModel;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 std::auto_ptr<DcmDataset> dataset(ToDcmtkBridge::Convert(fields));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 // Figure out which of the accepted presentation contexts should be used
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 if (presID == 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
531 throw OrthancException("DicomUserConnection: The C-MOVE command is not supported by the distant AET");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 T_DIMSE_C_MoveRQ request;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 memset(&request, 0, sizeof(request));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 request.MessageID = pimpl_->assoc_->nextMsgID++;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 strcpy(request.AffectedSOPClassUID, sopClass);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 request.DataSetType = DIMSE_DATASET_PRESENT;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 request.Priority = DIMSE_PRIORITY_MEDIUM;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 strncpy(request.MoveDestination, targetAet.c_str(), sizeof(DIC_AE) / sizeof(char));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 T_DIMSE_C_MoveRSP response;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 DcmDataset* statusDetail = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 DcmDataset* responseIdentifiers = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 OFCondition cond = DIMSE_moveUser(pimpl_->assoc_, presID, &request, dataset.get(),
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 NULL, NULL,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 pimpl_->net_, NULL, NULL,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 &response, &statusDetail, &responseIdentifiers);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 if (statusDetail)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 delete statusDetail;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 if (responseIdentifiers)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 delete responseIdentifiers;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 Check(cond);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
565 void DicomUserConnection::ResetStorageSOPClasses()
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
566 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
567 CheckStorageSOPClassesInvariant();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
568
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
569 storageSOPClasses_.clear();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
570 defaultStorageSOPClasses_.clear();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
571
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
572 // Copy the short list of storage SOP classes from DCMTK, making
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
573 // room for the 4 SOP classes reserved for C-ECHO, C-FIND, C-MOVE.
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
574
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
575 std::set<std::string> uncommon;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
576 uncommon.insert(UID_BlendingSoftcopyPresentationStateStorage);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
577 uncommon.insert(UID_GrayscaleSoftcopyPresentationStateStorage);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
578 uncommon.insert(UID_ColorSoftcopyPresentationStateStorage);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
579 uncommon.insert(UID_PseudoColorSoftcopyPresentationStateStorage);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
580
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
581 // Add the storage syntaxes for C-STORE
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
582 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs - 1; i++)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
583 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
584 if (uncommon.find(dcmShortSCUStorageSOPClassUIDs[i]) == uncommon.end())
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
585 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
586 defaultStorageSOPClasses_.insert(dcmShortSCUStorageSOPClassUIDs[i]);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
587 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
588 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
589
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
590 CheckStorageSOPClassesInvariant();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
591 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
592
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
593
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
594 DicomUserConnection::DicomUserConnection() :
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
595 pimpl_(new PImpl),
666
b8383ac0b227 fix cppcheck warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 662
diff changeset
596 preferredTransferSyntax_(DEFAULT_PREFERRED_TRANSFER_SYNTAX),
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
597 localAet_("STORESCU"),
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
598 distantAet_("ANY-SCP"),
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 519
diff changeset
599 distantHost_("127.0.0.1")
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 distantPort_ = 104;
519
1b2cdc855bd3 Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
602 manufacturer_ = ModalityManufacturer_Generic;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 pimpl_->net_ = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 pimpl_->params_ = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 pimpl_->assoc_ = NULL;
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
607
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
608 // SOP classes for C-ECHO, C-FIND and C-MOVE
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
609 reservedStorageSOPClasses_.push_back(UID_VerificationSOPClass);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
610 reservedStorageSOPClasses_.push_back(UID_FINDPatientRootQueryRetrieveInformationModel);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
611 reservedStorageSOPClasses_.push_back(UID_FINDStudyRootQueryRetrieveInformationModel);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
612 reservedStorageSOPClasses_.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
613
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
614 ResetStorageSOPClasses();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 DicomUserConnection::~DicomUserConnection()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 Close();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
622
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
623 void DicomUserConnection::Connect(const RemoteModalityParameters& parameters)
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
624 {
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
625 SetDistantApplicationEntityTitle(parameters.GetApplicationEntityTitle());
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
626 SetDistantHost(parameters.GetHost());
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
627 SetDistantPort(parameters.GetPort());
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
628 SetDistantManufacturer(parameters.GetManufacturer());
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
629 }
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
630
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 769
diff changeset
631
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 void DicomUserConnection::SetLocalApplicationEntityTitle(const std::string& aet)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
634 if (localAet_ != aet)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
635 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
636 Close();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
637 localAet_ = aet;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
638 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 void DicomUserConnection::SetDistantApplicationEntityTitle(const std::string& aet)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
643 if (distantAet_ != aet)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
644 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
645 Close();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
646 distantAet_ = aet;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
647 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649
519
1b2cdc855bd3 Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
650 void DicomUserConnection::SetDistantManufacturer(ModalityManufacturer manufacturer)
1b2cdc855bd3 Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
651 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
652 if (manufacturer_ != manufacturer)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
653 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
654 Close();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
655 manufacturer_ = manufacturer;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
656 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
657 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
658
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
659 void DicomUserConnection::ResetPreferredTransferSyntax()
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
660 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
661 SetPreferredTransferSyntax(DEFAULT_PREFERRED_TRANSFER_SYNTAX);
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
662 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
663
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
664 void DicomUserConnection::SetPreferredTransferSyntax(const std::string& preferredTransferSyntax)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
665 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
666 if (preferredTransferSyntax_ != preferredTransferSyntax)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
667 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
668 Close();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
669 preferredTransferSyntax_ = preferredTransferSyntax;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
670 }
519
1b2cdc855bd3 Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
671 }
1b2cdc855bd3 Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
672
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 void DicomUserConnection::SetDistantHost(const std::string& host)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
676 if (distantHost_ != host)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
678 if (host.size() > HOST_NAME_MAX - 10)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
679 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
680 throw OrthancException("Distant host name is too long");
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
681 }
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
682
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
683 Close();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
684 distantHost_ = host;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 void DicomUserConnection::SetDistantPort(uint16_t port)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
690 if (distantPort_ != port)
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
691 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
692 Close();
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
693 distantPort_ = port;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
694 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697 void DicomUserConnection::Open()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 {
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
699 if (IsOpen())
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
700 {
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
701 // Don't reopen the connection
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
702 return;
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
703 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704
769
3f946e5c3802 ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 766
diff changeset
705 LOG(INFO) << "Opening a DICOM SCU connection from AET \"" << GetLocalApplicationEntityTitle()
3f946e5c3802 ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 766
diff changeset
706 << "\" to AET \"" << GetDistantApplicationEntityTitle() << "\" on host "
3f946e5c3802 ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 766
diff changeset
707 << GetDistantHost() << ":" << GetDistantPort()
3f946e5c3802 ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 766
diff changeset
708 << " (manufacturer: " << EnumerationToString(GetDistantManufacturer()) << ")";
3f946e5c3802 ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 766
diff changeset
709
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 Check(ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ 30, &pimpl_->net_));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 Check(ASC_createAssociationParameters(&pimpl_->params_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 // Set this application's title and the called application's title in the params
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 Check(ASC_setAPTitles(pimpl_->params_, localAet_.c_str(), distantAet_.c_str(), NULL));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 // Set the network addresses of the local and distant entities
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 char localHost[HOST_NAME_MAX];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 gethostname(localHost, HOST_NAME_MAX - 1);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 char distantHostAndPort[HOST_NAME_MAX];
2
67a6978503b7 fixing Windows build
Jodogne@Laptop
parents: 0
diff changeset
721
67a6978503b7 fixing Windows build
Jodogne@Laptop
parents: 0
diff changeset
722 #ifdef _MSC_VER
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
723 _snprintf
2
67a6978503b7 fixing Windows build
Jodogne@Laptop
parents: 0
diff changeset
724 #else
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
725 snprintf
2
67a6978503b7 fixing Windows build
Jodogne@Laptop
parents: 0
diff changeset
726 #endif
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
727 (distantHostAndPort, HOST_NAME_MAX - 1, "%s:%d", distantHost_.c_str(), distantPort_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 Check(ASC_setPresentationAddresses(pimpl_->params_, localHost, distantHostAndPort));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 // Set various options
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 Check(ASC_setTransportLayerType(pimpl_->params_, /*opt_secureConnection*/ false));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
734 SetupPresentationContexts(preferredTransferSyntax_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 // Do the association
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
741 throw OrthancException("DicomUserConnection: No Acceptable Presentation Contexts");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 void DicomUserConnection::Close()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 if (pimpl_->assoc_ != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 ASC_releaseAssociation(pimpl_->assoc_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 ASC_destroyAssociation(&pimpl_->assoc_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 pimpl_->assoc_ = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 pimpl_->params_ = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 if (pimpl_->params_ != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 ASC_destroyAssociationParameters(&pimpl_->params_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 pimpl_->params_ = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 if (pimpl_->net_ != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 ASC_dropNetwork(&pimpl_->net_);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766 pimpl_->net_ = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 bool DicomUserConnection::IsOpen() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 return pimpl_->IsOpen();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 void DicomUserConnection::Store(const char* buffer, size_t size)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 // Prepare an input stream for the memory buffer
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 DcmInputBufferStream is;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 if (size > 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 is.setBuffer(buffer, size);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 is.setEos();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
783 pimpl_->Store(is, *this);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 void DicomUserConnection::Store(const std::string& buffer)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 if (buffer.size() > 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 Store(reinterpret_cast<const char*>(&buffer[0]), buffer.size());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 Store(NULL, 0);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794 void DicomUserConnection::StoreFile(const std::string& path)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796 // Prepare an input stream for the file
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 DcmInputFileStream is(path.c_str());
662
70161eb45b5c orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 657
diff changeset
798 pimpl_->Store(is, *this);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 bool DicomUserConnection::Echo()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 CheckIsOpen();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 DIC_US status;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 Check(DIMSE_echoUser(pimpl_->assoc_, pimpl_->assoc_->nextMsgID++,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 &status, NULL));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 return status == STATUS_Success;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 void DicomUserConnection::MoveSeries(const std::string& targetAet,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 const DicomMap& findResult)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 DicomMap simplified;
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
816 simplified.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, findResult.GetValue(DICOM_TAG_STUDY_INSTANCE_UID));
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
817 simplified.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, findResult.GetValue(DICOM_TAG_SERIES_INSTANCE_UID));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 Move(targetAet, simplified);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 void DicomUserConnection::MoveSeries(const std::string& targetAet,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 const std::string& studyUid,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 const std::string& seriesUid)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 DicomMap map;
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
826 map.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
827 map.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 Move(targetAet, map);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 void DicomUserConnection::MoveInstance(const std::string& targetAet,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 const DicomMap& findResult)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 DicomMap simplified;
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
835 simplified.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, findResult.GetValue(DICOM_TAG_STUDY_INSTANCE_UID));
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
836 simplified.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, findResult.GetValue(DICOM_TAG_SERIES_INSTANCE_UID));
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
837 simplified.SetValue(DICOM_TAG_SOP_INSTANCE_UID, findResult.GetValue(DICOM_TAG_SOP_INSTANCE_UID));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838 Move(targetAet, simplified);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 void DicomUserConnection::MoveInstance(const std::string& targetAet,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842 const std::string& studyUid,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 const std::string& seriesUid,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 const std::string& instanceUid)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 DicomMap map;
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
847 map.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
848 map.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
849 map.SetValue(DICOM_TAG_SOP_INSTANCE_UID, instanceUid);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 Move(targetAet, map);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 void DicomUserConnection::SetConnectionTimeout(uint32_t seconds)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 dcmConnectionTimeout.set(seconds);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857
763
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
858
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
859 void DicomUserConnection::CheckStorageSOPClassesInvariant() const
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
860 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
861 assert(storageSOPClasses_.size() +
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
862 defaultStorageSOPClasses_.size() +
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
863 reservedStorageSOPClasses_.size() <= MAXIMUM_STORAGE_SOP_CLASSES);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
864 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
865
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
866 void DicomUserConnection::AddStorageSOPClass(const char* sop)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
867 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
868 CheckStorageSOPClassesInvariant();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
869
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
870 if (storageSOPClasses_.find(sop) != storageSOPClasses_.end())
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
871 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
872 // This storage SOP class is already explicitly registered. Do
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
873 // nothing.
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
874 return;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
875 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
876
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
877 if (defaultStorageSOPClasses_.find(sop) != defaultStorageSOPClasses_.end())
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
878 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
879 // This storage SOP class is not explicitly registered, but is
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
880 // used by default. Just register it explicitly.
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
881 defaultStorageSOPClasses_.erase(sop);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
882 storageSOPClasses_.insert(sop);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
883
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
884 CheckStorageSOPClassesInvariant();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
885 return;
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
886 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
887
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
888 // This storage SOP class is neither explicitly, nor implicitly
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
889 // registered. Close the connection and register it explicitly.
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
890
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
891 Close();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
892
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
893 if (reservedStorageSOPClasses_.size() +
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
894 storageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) // (*)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
895 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
896 // The maximum number of SOP classes is reached
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
897 ResetStorageSOPClasses();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
898 defaultStorageSOPClasses_.erase(sop);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
899 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
900 else if (reservedStorageSOPClasses_.size() + storageSOPClasses_.size() +
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
901 defaultStorageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES)
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
902 {
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
903 // Make room in the default storage syntaxes
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
904 assert(defaultStorageSOPClasses_.size() > 0); // Necessarily true because condition (*) is false
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
905 defaultStorageSOPClasses_.erase(*defaultStorageSOPClasses_.rbegin());
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
906 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
907
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
908 // Explicitly register the new storage syntax
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
909 storageSOPClasses_.insert(sop);
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
910
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
911 CheckStorageSOPClassesInvariant();
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
912 }
b5e6d2823115 dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
913
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 }