ImagerControl.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CASADBUS_IMAGERCONTROL_H_
00029 #define CASADBUS_IMAGERCONTROL_H_
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <casadbus/types/variant.h>
00045 #ifdef INTERACTIVE_ITERATION
00046 #include <casadbus/interfaces/SynthImager.proxy.h>
00047 #endif
00048 #include <casadbus/utilities/Conversion.h>
00049
00050 namespace casa {
00051
00052 class ImagerControl
00053 #ifdef INTERACTIVE_ITERATION
00054 : private edu::nrao::casa::SynthesisImager_proxy,
00055 public DBus::IntrospectableProxy,
00056 public DBus::ObjectProxy
00057 #endif
00058 {
00059 public:
00060 static std::string name( ) { return "SynthesisImager"; }
00061 static std::string connection_name( ) { return "edu.nrao.casa.SynthesisImager_001"; }
00062 static std::string interface_name( ) { return "edu.nrao.casa.SynthesisImager"; }
00063 static std::string object_path( ) { return "/casa/synthesis/imager"; }
00064
00065 ImagerControl( const std::string &connection_name_=connection_name( ), const std::string &object_path_=object_path( ) );
00066 ~ImagerControl( );
00067
00068 bool incrementController( ) {
00069 #ifdef INTERACTIVE_ITERATION
00070 return edu::nrao::casa::SynthesisImager_proxy::incrementController( );
00071 #else
00072 return false;
00073 #endif
00074 }
00075 bool decrementController( ) {
00076 #ifdef INTERACTIVE_ITERATION
00077 return edu::nrao::casa::SynthesisImager_proxy::decrementController( );
00078 #else
00079 return false;
00080 #endif
00081 }
00082
00083 void changePauseFlag( const bool &state ) {
00084 #ifdef INTERACTIVE_ITERATION
00085 edu::nrao::casa::SynthesisImager_proxy::changePauseFlag( state );
00086 #else
00087 (void)state;
00088 #endif
00089 }
00090
00091 void changeStopFlag(const bool& state) {
00092 #ifdef INTERACTIVE_ITERATION
00093 edu::nrao::casa::SynthesisImager_proxy::changeStopFlag( state );
00094 #else
00095 (void)state;
00096 #endif
00097 }
00098
00099
00100 void interactionRequired( const bool & ) { }
00101 void detailUpdate( const std::map<std::string, DBus::Variant>& ) { }
00102 void summaryUpdate( const DBus::Variant& ) { }
00103 void disconnect( ) { }
00104
00105 std::string getDescription( ) {
00106 #ifdef INTERACTIVE_ITERATION
00107 return edu::nrao::casa::SynthesisImager_proxy::getDescription( );
00108 #else
00109 return std::string( );
00110 #endif
00111 }
00112 std::map<std::string,dbus::variant> getDetails( )
00113 {
00114 #ifdef INTERACTIVE_ITERATION
00115 return dbus::toStdMap( edu::nrao::casa::SynthesisImager_proxy::getDetails( ) );
00116 #else
00117 return std::map<std::string,dbus::variant>( );
00118 #endif
00119 }
00120
00121 void controlUpdate(const std::map<std::string,dbus::variant>& newParams) {
00122 #ifdef INTERACTIVE_ITERATION
00123 edu::nrao::casa::SynthesisImager_proxy::controlUpdate( dbus::fromStdMap(newParams) );
00124 #else
00125 (void)newParams;
00126 #endif
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 #if 0
00144
00145 void sendInteractionComplete() {
00146 checkDetails = true;
00147
00148 casa::Record record;
00149 record.define( casa::RecordFieldId("niter"), 123);
00150 record.define( casa::RecordFieldId("cycleniter"), 456);
00151 record.define( casa::RecordFieldId("interactiveniter"), 789);
00152
00153 record.define( casa::RecordFieldId("threshold"), 5.67);
00154 record.define( casa::RecordFieldId("cyclethreshold"), 7.89);
00155 record.define( casa::RecordFieldId("interactivethreshold"), 8.91);
00156
00157 record.define( casa::RecordFieldId("cyclefactor"), 4.56);
00158 record.define( casa::RecordFieldId("loopgain"), 6.78);
00159
00160 std::map<std::string, DBus::Variant> map= fromRecord(record);
00161 controlUpdate(map);
00162 interactionComplete();
00163 }
00164
00165
00166 int serviceLoop() {
00167 incrementController();
00168 while (!doneFlag) {
00169 if (interactiveIRQ) {
00170 interactiveIRQ = false;
00171 if (serviceInteractiveFlag) {
00172 sendInteractionComplete();
00173 }
00174 if (exitOnInteractiveFlag) {
00175 doneFlag = true;
00176 }
00177 }
00178 usleep(10000);
00179 }
00180 return exitCondition;
00181 }
00182
00183 protected:
00184
00185 const bool serviceInteractiveFlag;
00186 const bool exitOnInteractiveFlag;
00187 const bool checkDetailsFlag;
00188
00189
00190 bool interactiveIRQ;
00191
00192 bool checkDetails;
00193 bool doneFlag;
00194 int exitCondition;
00195 #endif
00196
00197 };
00198 }
00199
00200 #endif