ImagerControl.h

Go to the documentation of this file.
00001 //# ImagerControl.h: connect to synthesis imager task for control
00002 //# Copyright (C) 2013
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef CASADBUS_IMAGERCONTROL_H_
00029 #define CASADBUS_IMAGERCONTROL_H_
00030 
00031 /*******************************************************************************************
00032 ********************************************************************************************
00033 ****  Note: the DBus-C++ header files should be include *BEFORE* the                    ****
00034 ****        Qt header files. Otherwise, the Qt header files (which use                  ****
00035 ****        the c-preprocessor to define "signals" to be "protected"                    ****
00036 ****        cause the following errors for DBus-C++ (and anything else                  ****
00037 ****        that has a variable etc. named "signals":                                   ****
00038 ****        ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----  ****
00039 **** .../dbus-c++/introspection.h:62: error: expected unqualified-id before ?protected? ****
00040 **** .../dbus-c++/introspection.h:62: error: abstract declarator ?const DBus::Intros... ****
00041 **** .../dbus-c++/introspection.h:62: error: expected ?;? before ?protected?            ****
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                         // slots that are required for signals generated by SynthImager_adaptor...
00100                         void interactionRequired( const bool &/*required*/ ) { }
00101                         void detailUpdate( const std::map<std::string, DBus::Variant>& /*updatedParams*/ ) { }
00102                         void summaryUpdate( const DBus::Variant& /*summary*/ ) { }
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                         **********methods*provided*by*SynthesisImager_proxy********************************
00131                         *******************************************************************************
00132                     bool incrementController()
00133                     bool decrementController()
00134                     void interactionComplete()
00135                     void changeInteractiveMode(const bool& interactiveMode)
00136                     std::map< std::string, ::DBus::Variant > getDetails()
00137                     ::DBus::Variant getSummary()
00138                         std::string getDescription( )
00139                         *******************************************************************************
00140                         *******************************************************************************
00141                         ******************************************************************************/
00142 
00143 #if 0
00144                         /***** boilerplate from tSIIterBot.cc *****/
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                         /* Control Flags */
00185                         const bool serviceInteractiveFlag;
00186                         const bool exitOnInteractiveFlag;
00187                         const bool checkDetailsFlag;
00188 
00189                         /* State Flags */
00190                         bool interactiveIRQ;
00191 
00192                         bool checkDetails;
00193                         bool doneFlag;
00194                         int  exitCondition;
00195 #endif
00196 
00197         };
00198 }
00199 
00200 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1