Mercurial > hg > orthanc
comparison Core/DicomNetworking/DicomUserConnection.cpp @ 3605:05872838ebf3 storage-commitment
DicomUserConnection: Opening of a connection for N-EVENT-REPORT
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 16 Jan 2020 18:26:47 +0100 |
parents | bdafff1ce443 |
children | 33ba63637d48 |
comparison
equal
deleted
inserted
replaced
3604:e327b44780bb | 3605:05872838ebf3 |
---|---|
250 presentationContextId += 2; | 250 presentationContextId += 2; |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 | 254 |
255 void DicomUserConnection::SetupPresentationContexts(const std::string& preferredTransferSyntax) | 255 void DicomUserConnection::SetupPresentationContexts(Mode mode, |
256 const std::string& preferredTransferSyntax) | |
256 { | 257 { |
257 // Flatten an array with the preferred transfer syntax | 258 // Flatten an array with the preferred transfer syntax |
258 const char* asPreferred[1] = { preferredTransferSyntax.c_str() }; | 259 const char* asPreferred[1] = { preferredTransferSyntax.c_str() }; |
259 | 260 |
260 // Setup the fallback transfer syntaxes | 261 // Setup the fallback transfer syntaxes |
272 { | 273 { |
273 asFallback.push_back(it->c_str()); | 274 asFallback.push_back(it->c_str()); |
274 } | 275 } |
275 | 276 |
276 CheckStorageSOPClassesInvariant(); | 277 CheckStorageSOPClassesInvariant(); |
277 unsigned int presentationContextId = 1; | 278 |
278 | 279 switch (mode) |
279 for (std::list<std::string>::const_iterator it = reservedStorageSOPClasses_.begin(); | 280 { |
280 it != reservedStorageSOPClasses_.end(); ++it) | 281 case Mode_Generic: |
281 { | 282 { |
282 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, | 283 unsigned int presentationContextId = 1; |
283 *it, asPreferred, asFallback, remoteAet_); | 284 |
284 } | 285 for (std::list<std::string>::const_iterator it = reservedStorageSOPClasses_.begin(); |
285 | 286 it != reservedStorageSOPClasses_.end(); ++it) |
286 for (std::set<std::string>::const_iterator it = storageSOPClasses_.begin(); | 287 { |
287 it != storageSOPClasses_.end(); ++it) | 288 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
288 { | 289 *it, asPreferred, asFallback, remoteAet_); |
289 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, | 290 } |
290 *it, asPreferred, asFallback, remoteAet_); | 291 |
291 } | 292 for (std::set<std::string>::const_iterator it = storageSOPClasses_.begin(); |
292 | 293 it != storageSOPClasses_.end(); ++it) |
293 for (std::set<std::string>::const_iterator it = defaultStorageSOPClasses_.begin(); | 294 { |
294 it != defaultStorageSOPClasses_.end(); ++it) | 295 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
295 { | 296 *it, asPreferred, asFallback, remoteAet_); |
296 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, | 297 } |
297 *it, asPreferred, asFallback, remoteAet_); | 298 |
298 } | 299 for (std::set<std::string>::const_iterator it = defaultStorageSOPClasses_.begin(); |
299 } | 300 it != defaultStorageSOPClasses_.end(); ++it) |
300 | 301 { |
302 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, | |
303 *it, asPreferred, asFallback, remoteAet_); | |
304 } | |
305 | |
306 break; | |
307 } | |
308 | |
309 case Mode_ReportStorageCommitment: | |
310 { | |
311 const char* as = UID_StorageCommitmentPushModelSOPClass; | |
312 | |
313 std::vector<const char*> ts; | |
314 ts.push_back(UID_LittleEndianExplicitTransferSyntax); | |
315 ts.push_back(UID_LittleEndianImplicitTransferSyntax); | |
316 | |
317 Check(ASC_addPresentationContext(pimpl_->params_, 1 /*presentationContextId*/, | |
318 as, &ts[0], ts.size(), ASC_SC_ROLE_SCP), | |
319 remoteAet_, "initializing"); | |
320 | |
321 break; | |
322 } | |
323 | |
324 default: | |
325 throw OrthancException(ErrorCode_InternalError); | |
326 } | |
327 } | |
328 | |
301 | 329 |
302 static bool IsGenericTransferSyntax(const std::string& syntax) | 330 static bool IsGenericTransferSyntax(const std::string& syntax) |
303 { | 331 { |
304 return (syntax == UID_LittleEndianExplicitTransferSyntax || | 332 return (syntax == UID_LittleEndianExplicitTransferSyntax || |
305 syntax == UID_BigEndianExplicitTransferSyntax || | 333 syntax == UID_BigEndianExplicitTransferSyntax || |
992 Close(); | 1020 Close(); |
993 remotePort_ = port; | 1021 remotePort_ = port; |
994 } | 1022 } |
995 } | 1023 } |
996 | 1024 |
997 void DicomUserConnection::Open() | 1025 void DicomUserConnection::OpenInternal(Mode mode) |
998 { | 1026 { |
999 if (IsOpen()) | 1027 if (IsOpen()) |
1000 { | 1028 { |
1001 // Don't reopen the connection | 1029 // Don't reopen the connection |
1002 return; | 1030 return; |
1032 | 1060 |
1033 // Set various options | 1061 // Set various options |
1034 Check(ASC_setTransportLayerType(pimpl_->params_, /*opt_secureConnection*/ false), | 1062 Check(ASC_setTransportLayerType(pimpl_->params_, /*opt_secureConnection*/ false), |
1035 remoteAet_, "connecting"); | 1063 remoteAet_, "connecting"); |
1036 | 1064 |
1037 SetupPresentationContexts(preferredTransferSyntax_); | 1065 SetupPresentationContexts(mode, preferredTransferSyntax_); |
1038 | 1066 |
1039 // Do the association | 1067 // Do the association |
1040 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_), | 1068 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_), |
1041 remoteAet_, "connecting"); | 1069 remoteAet_, "connecting"); |
1042 | 1070 |
1337 remoteAet_ == remote.GetApplicationEntityTitle() && | 1365 remoteAet_ == remote.GetApplicationEntityTitle() && |
1338 remoteHost_ == remote.GetHost() && | 1366 remoteHost_ == remote.GetHost() && |
1339 remotePort_ == remote.GetPortNumber() && | 1367 remotePort_ == remote.GetPortNumber() && |
1340 manufacturer_ == remote.GetManufacturer()); | 1368 manufacturer_ == remote.GetManufacturer()); |
1341 } | 1369 } |
1370 | |
1371 | |
1372 void DicomUserConnection::ReportStorageCommitment() | |
1373 { | |
1374 if (IsOpen()) | |
1375 { | |
1376 Close(); | |
1377 } | |
1378 | |
1379 try | |
1380 { | |
1381 OpenInternal(Mode_ReportStorageCommitment); | |
1382 | |
1383 /** | |
1384 * N-EVENT-REPORT | |
1385 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part04/sect_J.3.3.html | |
1386 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#table_10.1-1 | |
1387 * | |
1388 * Status code: | |
1389 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#sect_10.1.1.1.8 | |
1390 **/ | |
1391 | |
1392 // TODO | |
1393 | |
1394 Close(); | |
1395 } | |
1396 catch (OrthancException&) | |
1397 { | |
1398 Close(); | |
1399 throw; | |
1400 } | |
1401 } | |
1342 } | 1402 } |