comparison Core/DicomNetworking/DicomUserConnection.cpp @ 2580:055d7d4a823f jobs

avoid unecessary openings of DICOM connection for C-Store
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 May 2018 09:35:17 +0200
parents 878b59270859
children bf14b037731f
comparison
equal deleted inserted replaced
2577:6783a7c02990 2580:055d7d4a823f
262 void DicomUserConnection::PImpl::Store(DcmInputStream& is, 262 void DicomUserConnection::PImpl::Store(DcmInputStream& is,
263 DicomUserConnection& connection, 263 DicomUserConnection& connection,
264 const std::string& moveOriginatorAET, 264 const std::string& moveOriginatorAET,
265 uint16_t moveOriginatorID) 265 uint16_t moveOriginatorID)
266 { 266 {
267 CheckIsOpen();
268
269 DcmFileFormat dcmff; 267 DcmFileFormat dcmff;
270 Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength)); 268 Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength));
271 269
272 // Determine the storage SOP class UID for this instance 270 // Determine the storage SOP class UID for this instance
273 static const DcmTagKey DCM_SOP_CLASS_UID(0x0008, 0x0016); 271 static const DcmTagKey DCM_SOP_CLASS_UID(0x0008, 0x0016);
282 DcmXfer xfer(dcmff.getDataset()->getOriginalXfer()); 280 DcmXfer xfer(dcmff.getDataset()->getOriginalXfer());
283 const std::string syntax(xfer.getXferID()); 281 const std::string syntax(xfer.getXferID());
284 bool isGeneric = IsGenericTransferSyntax(syntax); 282 bool isGeneric = IsGenericTransferSyntax(syntax);
285 283
286 bool renegotiate; 284 bool renegotiate;
287 if (isGeneric) 285
286 if (!IsOpen())
287 {
288 renegotiate = true;
289 }
290 else if (isGeneric)
288 { 291 {
289 // Are we making a generic-to-specific or specific-to-generic change of 292 // Are we making a generic-to-specific or specific-to-generic change of
290 // the transfer syntax? If this is the case, renegotiate the connection. 293 // the transfer syntax? If this is the case, renegotiate the connection.
291 renegotiate = !IsGenericTransferSyntax(connection.GetPreferredTransferSyntax()); 294 renegotiate = !IsGenericTransferSyntax(connection.GetPreferredTransferSyntax());
295
296 if (renegotiate)
297 {
298 LOG(INFO) << "Use of non-generic transfer syntax: the C-Store associated must be renegotiated";
299 }
292 } 300 }
293 else 301 else
294 { 302 {
295 // We are using a specific transfer syntax. Renegotiate if the 303 // We are using a specific transfer syntax. Renegotiate if the
296 // current connection does not match this transfer syntax. 304 // current connection does not match this transfer syntax.
297 renegotiate = (syntax != connection.GetPreferredTransferSyntax()); 305 renegotiate = (syntax != connection.GetPreferredTransferSyntax());
306
307 if (renegotiate)
308 {
309 LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated";
310 }
298 } 311 }
299 312
300 if (renegotiate) 313 if (renegotiate)
301 { 314 {
302 LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated";
303
304 if (isGeneric) 315 if (isGeneric)
305 { 316 {
306 connection.ResetPreferredTransferSyntax(); 317 connection.ResetPreferredTransferSyntax();
307 } 318 }
308 else 319 else
311 } 322 }
312 } 323 }
313 324
314 if (!connection.IsOpen()) 325 if (!connection.IsOpen())
315 { 326 {
316 LOG(INFO) << "Renegotiating a C-Store association due to a change in the parameters";
317 connection.Open(); 327 connection.Open();
318 } 328 }
319 329
320 // Figure out which SOP class and SOP instance is encapsulated in the file 330 // Figure out which SOP class and SOP instance is encapsulated in the file
321 DIC_UI sopClass; 331 DIC_UI sopClass;