Mercurial > hg > orthanc-stone
comparison UnitTestsSources/UnitTestsMain.cpp @ 70:f73aed014bde wasm
OrthancAsynchronousWebService
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 May 2017 21:43:49 +0200 |
parents | 1553b67b24e5 |
children | 30c768873d47 |
comparison
equal
deleted
inserted
replaced
69:1553b67b24e5 | 70:f73aed014bde |
---|---|
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #include "gtest/gtest.h" | 22 #include "gtest/gtest.h" |
23 | 23 |
24 #include "../Framework/Toolbox/OrthancAsynchronousWebService.h" | |
24 #include "../Resources/Orthanc/Core/Logging.h" | 25 #include "../Resources/Orthanc/Core/Logging.h" |
25 #include "../Framework/Toolbox/OrthancSynchronousWebService.h" | 26 #include "../Framework/Toolbox/OrthancSynchronousWebService.h" |
26 #include "../Framework/Layers/OrthancFrameLayerSource.h" | 27 #include "../Framework/Layers/OrthancFrameLayerSource.h" |
27 #include "../Framework/Widgets/LayerWidget.h" | 28 #include "../Framework/Widgets/LayerWidget.h" |
28 | 29 |
30 #include "../Resources/Orthanc/Core/Images/PngReader.h" | 31 #include "../Resources/Orthanc/Core/Images/PngReader.h" |
31 #include "../Framework/Toolbox/MessagingToolbox.h" | 32 #include "../Framework/Toolbox/MessagingToolbox.h" |
32 #include "../Framework/Toolbox/DicomFrameConverter.h" | 33 #include "../Framework/Toolbox/DicomFrameConverter.h" |
33 | 34 |
34 #include <boost/lexical_cast.hpp> | 35 #include <boost/lexical_cast.hpp> |
36 #include <boost/date_time/posix_time/posix_time.hpp> | |
37 #include <boost/thread/thread.hpp> | |
35 | 38 |
36 namespace OrthancStone | 39 namespace OrthancStone |
37 { | 40 { |
38 class Slice | 41 class Slice |
39 { | 42 { |
397 public: | 400 public: |
398 virtual ~ICallback() | 401 virtual ~ICallback() |
399 { | 402 { |
400 } | 403 } |
401 | 404 |
402 virtual void NotifyGeometryReady(const OrthancSliceLoader& loader) = 0; | 405 virtual void NotifyGeometryReady(OrthancSliceLoader& loader) = 0; |
403 | 406 |
404 virtual void NotifyGeometryError(const OrthancSliceLoader& loader) = 0; | 407 virtual void NotifyGeometryError(OrthancSliceLoader& loader) = 0; |
405 | 408 |
406 virtual void NotifySliceImageReady(const OrthancSliceLoader& loader, | 409 virtual void NotifySliceImageReady(OrthancSliceLoader& loader, |
407 unsigned int sliceIndex, | 410 unsigned int sliceIndex, |
408 const Slice& slice, | 411 const Slice& slice, |
409 Orthanc::ImageAccessor* image) = 0; | 412 Orthanc::ImageAccessor* image) = 0; |
410 | 413 |
411 virtual void NotifySliceImageError(const OrthancSliceLoader& loader, | 414 virtual void NotifySliceImageError(OrthancSliceLoader& loader, |
412 unsigned int sliceIndex, | 415 unsigned int sliceIndex, |
413 const Slice& slice) = 0; | 416 const Slice& slice) = 0; |
414 }; | 417 }; |
415 | 418 |
416 private: | 419 private: |
520 slices_.SetNormal(normal); | 523 slices_.SetNormal(normal); |
521 slices_.Sort(); | 524 slices_.Sort(); |
522 ok = true; | 525 ok = true; |
523 } | 526 } |
524 } | 527 } |
528 | |
529 state_ = State_GeometryReady; | |
525 | 530 |
526 if (ok) | 531 if (ok) |
527 { | 532 { |
528 LOG(INFO) << "Loaded a series with " << slices_.GetSliceCount() << " slice(s)"; | 533 LOG(INFO) << "Loaded a series with " << slices_.GetSliceCount() << " slice(s)"; |
529 callback_.NotifyGeometryReady(*this); | 534 callback_.NotifyGeometryReady(*this); |
660 | 665 |
661 switch (operation->GetMode()) | 666 switch (operation->GetMode()) |
662 { | 667 { |
663 case Mode_SeriesGeometry: | 668 case Mode_SeriesGeometry: |
664 ParseSeriesGeometry(answer, answerSize); | 669 ParseSeriesGeometry(answer, answerSize); |
665 state_ = State_GeometryReady; | |
666 break; | 670 break; |
667 | 671 |
668 case Mode_LoadImage: | 672 case Mode_LoadImage: |
669 ParseSliceImage(*operation, answer, answerSize); | 673 ParseSliceImage(*operation, answer, answerSize); |
670 break; | 674 break; |
699 | 703 |
700 | 704 |
701 class Tata : public OrthancSliceLoader::ICallback | 705 class Tata : public OrthancSliceLoader::ICallback |
702 { | 706 { |
703 public: | 707 public: |
704 virtual void NotifyGeometryReady(const OrthancSliceLoader& loader) | 708 virtual void NotifyGeometryReady(OrthancSliceLoader& loader) |
705 { | 709 { |
706 printf("Done\n"); | 710 printf(">> %d\n", loader.GetSliceCount()); |
707 } | 711 |
708 | 712 for (size_t i = 0; i < loader.GetSliceCount(); i++) |
709 virtual void NotifyGeometryError(const OrthancSliceLoader& loader) | 713 { |
714 loader.ScheduleLoadSliceImage(i); | |
715 } | |
716 } | |
717 | |
718 virtual void NotifyGeometryError(OrthancSliceLoader& loader) | |
710 { | 719 { |
711 printf("Error\n"); | 720 printf("Error\n"); |
712 } | 721 } |
713 | 722 |
714 virtual void NotifySliceImageReady(const OrthancSliceLoader& loader, | 723 virtual void NotifySliceImageReady(OrthancSliceLoader& loader, |
715 unsigned int sliceIndex, | 724 unsigned int sliceIndex, |
716 const Slice& slice, | 725 const Slice& slice, |
717 Orthanc::ImageAccessor* image) | 726 Orthanc::ImageAccessor* image) |
718 { | 727 { |
719 std::auto_ptr<Orthanc::ImageAccessor> tmp(image); | 728 std::auto_ptr<Orthanc::ImageAccessor> tmp(image); |
720 printf("Slice OK\n"); | 729 printf("Slice OK %dx%d\n", tmp->GetWidth(), tmp->GetHeight()); |
721 } | 730 } |
722 | 731 |
723 virtual void NotifySliceImageError(const OrthancSliceLoader& loader, | 732 virtual void NotifySliceImageError(OrthancSliceLoader& loader, |
724 unsigned int sliceIndex, | 733 unsigned int sliceIndex, |
725 const Slice& slice) | 734 const Slice& slice) |
726 { | 735 { |
727 printf("ERROR 2\n"); | 736 printf("ERROR 2\n"); |
728 } | 737 } |
731 | 740 |
732 | 741 |
733 TEST(Toto, Tutu) | 742 TEST(Toto, Tutu) |
734 { | 743 { |
735 Orthanc::WebServiceParameters web; | 744 Orthanc::WebServiceParameters web; |
736 OrthancStone::OrthancSynchronousWebService orthanc(web); | 745 OrthancStone::OrthancAsynchronousWebService orthanc(web, 4); |
746 orthanc.Start(); | |
737 | 747 |
738 OrthancStone::Tata tata; | 748 OrthancStone::Tata tata; |
739 OrthancStone::OrthancSliceLoader loader(tata, orthanc); | 749 OrthancStone::OrthancSliceLoader loader(tata, orthanc); |
740 //loader.ScheduleLoadSeries("c1c4cb95-05e3bd11-8da9f5bb-87278f71-0b2b43f5"); | 750 //loader.ScheduleLoadSeries("c1c4cb95-05e3bd11-8da9f5bb-87278f71-0b2b43f5"); |
741 loader.ScheduleLoadSeries("67f1b334-02c16752-45026e40-a5b60b6b-030ecab5"); | 751 loader.ScheduleLoadSeries("67f1b334-02c16752-45026e40-a5b60b6b-030ecab5"); |
742 | 752 |
743 printf(">> %d\n", loader.GetSliceCount()); | 753 /*printf(">> %d\n", loader.GetSliceCount()); |
744 loader.ScheduleLoadSliceImage(31); | 754 loader.ScheduleLoadSliceImage(31);*/ |
755 | |
756 boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); | |
757 | |
758 orthanc.Stop(); | |
745 } | 759 } |
746 | 760 |
747 | 761 |
748 | 762 |
749 int main(int argc, char **argv) | 763 int main(int argc, char **argv) |