00001 /* -*- mode: c++ -*- */ 00002 //# DistributedSynthesisIterBot.h: Parallel imaging iteration control 00003 //# Copyright (C) 2016 00004 //# Associated Universities, Inc. Washington DC, USA. 00005 //# 00006 //# This library is free software; you can redistribute it and/or modify it 00007 //# under the terms of the GNU Library General Public License as published by 00008 //# the Free Software Foundation; either version 2 of the License, or (at your 00009 //# option) any later version. 00010 //# 00011 //# This library is distributed in the hope that it will be useful, but WITHOUT 00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 //# License for more details. 00015 //# 00016 //# You should have received a copy of the GNU Library General Public License 00017 //# along with this library; if not, write to the Free Software Foundation, 00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00019 //# 00020 //# Correspondence concerning AIPS++ should be addressed as follows: 00021 //# Internet email: aips2-request@nrao.edu. 00022 //# Postal address: AIPS++ Project Office 00023 //# National Radio Astronomy Observatory 00024 //# 520 Edgemont Road 00025 //# Charlottesville, VA 22903-2475 USA 00026 //# 00027 #ifndef DISTRIBUTED_SYNTHESIS_SYNTHESISITERBOT_H_ 00028 #define DISTRIBUTED_SYNTHESIS_SYNTHESISITERBOT_H_ 00029 00030 #include <casa/aips.h> 00031 #include <casa/OS/Timer.h> 00032 #include <casa/Containers/Record.h> 00033 #include <ms/MeasurementSets/MeasurementSet.h> 00034 #include <casa/Arrays/IPosition.h> 00035 #include <casa/Quanta/Quantum.h> 00036 #include <measures/Measures/MDirection.h> 00037 #include <synthesis/ImagerObjects/DistSIIterBot.h> 00038 00039 //#include<casa/random.h> 00040 #include <synthesis/ImagerObjects/MPIGlue.h> 00041 #include<synthesis/ImagerObjects/InteractiveMasking.h> 00042 00043 #include <thread> 00044 00045 namespace casa { //# NAMESPACE CASA - BEGIN 00046 00047 // Forward declarations 00048 class MeasurementSet; 00049 class ViewerProxy; 00050 template<class T> class ImageInterface; 00051 00052 // <summary> Class that contains functions needed for imager </summary> 00053 00054 class DistributedSynthesisIterBot 00055 { 00056 public: 00057 // Default constructor 00058 00059 DistributedSynthesisIterBot(MPI_Comm comm); 00060 virtual ~DistributedSynthesisIterBot(); 00061 00062 // Copy constructor and assignment operator 00063 00064 // launch thread which opens DBus connection... 00065 void openDBus(); 00066 00067 // make all pure-inputs const 00068 void setupIteration(Record iterpars); 00069 00070 void setInteractiveMode(Bool interactiveMode); 00071 virtual void setIterationDetails(Record iterpars); 00072 Record getIterationDetails(); 00073 Record getIterationSummary(); 00074 00075 int cleanComplete(); 00076 00077 Record getSubIterBot(); 00078 00079 void startMinorCycle(const Vector<Record> &initializationRecords); 00080 00081 void startMinorCycle(const Record &initializationRecord) { 00082 Vector<Record> v(1); 00083 v[0] = initializationRecord; 00084 startMinorCycle(v); 00085 }; 00086 00087 void endMinorCycle(const Vector<Record> &executionRecords); 00088 00089 void endMinorCycle(const Record &executionRecord) { 00090 Vector<Record> v(1); 00091 v[0] = executionRecord; 00092 endMinorCycle(v); 00093 }; 00094 00095 void endMajorCycle(); 00096 00097 void changeStopFlag( Bool stopflag ); 00098 00099 virtual void pauseForUserInteraction(); 00100 00101 protected: 00103 00104 SHARED_PTR<SIIterBot_callback> actionRequestSync; 00105 SHARED_PTR<DistSIIterBot_state> itsLoopController; 00106 00108 00109 private: 00110 std::thread *dbus_thread; 00111 void dbus_thread_launch_pad( ); 00112 00114 /* Vector<String> itsImageList; 00115 Vector<Int> itsNTermList; 00116 Vector<Int> itsActionCodes; 00117 CountedPtr<InteractiveMasking> itsInteractiveMasker; 00118 */ 00119 }; 00120 00121 00122 class DistributedSynthesisIterBotWithOldGUI 00123 : public DistributedSynthesisIterBot 00124 { 00125 public: 00126 // Default constructor 00127 00128 DistributedSynthesisIterBotWithOldGUI(MPI_Comm comm); 00129 00130 void setIterationDetails(Record iterpars); 00131 void pauseForUserInteraction(); 00132 00133 private: 00134 Vector<String> itsImageList; 00135 Vector<Bool> itsMultiTermList; 00136 Vector<Int> itsActionCodes; 00137 CountedPtr<InteractiveMasking> itsInteractiveMasker; 00138 00139 bool is_root; 00140 }; 00141 00142 00143 } //# NAMESPACE CASA - END 00144 00145 #endif // DISTRIBUTED_SYNTHESIS_SYNTHESISITERBOT_H_