comparison OrthancServer/OrthancInitialization.cpp @ 617:a24b0161b171 find-move-scp

lookup using aet
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Oct 2013 11:28:02 +0200
parents 60d90e48e809
children 08eca5d86aad
comparison
equal deleted inserted replaced
616:dbecea588ef5 617:a24b0161b171
225 } 225 }
226 226
227 227
228 228
229 229
230 void GetDicomModality(const std::string& name, 230 void GetDicomModalityUsingSymbolicName(const std::string& name,
231 std::string& aet, 231 std::string& aet,
232 std::string& address, 232 std::string& address,
233 int& port, 233 int& port,
234 ModalityManufacturer& manufacturer) 234 ModalityManufacturer& manufacturer)
235 { 235 {
236 boost::mutex::scoped_lock lock(globalMutex_); 236 boost::mutex::scoped_lock lock(globalMutex_);
237 237
238 if (!configuration_->isMember("DicomModalities")) 238 if (!configuration_->isMember("DicomModalities"))
239 { 239 {
470 const std::string& name) 470 const std::string& name)
471 { 471 {
472 std::string aet, address; 472 std::string aet, address;
473 int port; 473 int port;
474 ModalityManufacturer manufacturer; 474 ModalityManufacturer manufacturer;
475 GetDicomModality(name, aet, address, port, manufacturer); 475 GetDicomModalityUsingSymbolicName(name, aet, address, port, manufacturer);
476 476
477 LOG(WARNING) << "Connecting to remote DICOM modality: AET=" << aet << ", address=" << address << ", port=" << port; 477 LOG(WARNING) << "Connecting to remote DICOM modality: AET=" << aet << ", address=" << address << ", port=" << port;
478 478
479 connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); 479 connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC"));
480 connection.SetDistantApplicationEntityTitle(aet); 480 connection.SetDistantApplicationEntityTitle(aet);
483 connection.SetDistantManufacturer(manufacturer); 483 connection.SetDistantManufacturer(manufacturer);
484 connection.Open(); 484 connection.Open();
485 } 485 }
486 486
487 487
488 void ConnectToModalityUsingAETitle(DicomUserConnection& connection, 488 bool LookupDicomModalityUsingAETitle(const std::string& aet,
489 const std::string& aet) 489 std::string& symbolicName,
490 std::string& address,
491 int& port,
492 ModalityManufacturer& manufacturer)
490 { 493 {
491 std::set<std::string> modalities; 494 std::set<std::string> modalities;
492 GetListOfDicomModalities(modalities); 495 GetListOfDicomModalities(modalities);
493 496
494 std::string address;
495 int port;
496 ModalityManufacturer manufacturer;
497 bool found = false;
498
499 for (std::set<std::string>::const_iterator 497 for (std::set<std::string>::const_iterator
500 it = modalities.begin(); it != modalities.end(); it++) 498 it = modalities.begin(); it != modalities.end(); it++)
501 { 499 {
502 try 500 try
503 { 501 {
504 std::string thisAet; 502 std::string thisAet;
505 GetDicomModality(*it, thisAet, address, port, manufacturer); 503 GetDicomModalityUsingSymbolicName(*it, thisAet, address, port, manufacturer);
506 504
507 if (aet == thisAet) 505 if (aet == thisAet)
508 { 506 {
509 found = true; 507 return true;
510 break;
511 } 508 }
512 } 509 }
513 catch (OrthancException&) 510 catch (OrthancException&)
514 { 511 {
515 } 512 }
516 } 513 }
517 514
518 if (!found) 515 return false;
516 }
517
518
519 bool IsKnownAETitle(const std::string& aet)
520 {
521 std::string symbolicName, address;
522 int port;
523 ModalityManufacturer manufacturer;
524
525 return LookupDicomModalityUsingAETitle(aet, symbolicName, address, port, manufacturer);
526 }
527
528
529 void ConnectToModalityUsingAETitle(DicomUserConnection& connection,
530 const std::string& aet)
531 {
532 std::string symbolicName, address;
533 int port;
534 ModalityManufacturer manufacturer;
535
536 if (!LookupDicomModalityUsingAETitle(aet, symbolicName, address, port, manufacturer))
519 { 537 {
520 throw OrthancException("Unknown modality: " + aet); 538 throw OrthancException("Unknown modality: " + aet);
521 } 539 }
522 540
523 LOG(WARNING) << "Connecting to remote DICOM modality: AET=" << aet << ", address=" << address << ", port=" << port; 541 LOG(WARNING) << "Connecting to remote DICOM modality: AET=" << aet << ", address=" << address << ", port=" << port;