casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTMSStateFiller.h
Go to the documentation of this file.
00001 //# GBTMSStateFiller.h: GBTMSStateFiller fills the MSState table for GBT fillers
00002 //# Copyright (C) 2002,2003
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 //#
00027 //# $Id$
00028 
00029 #ifndef NRAO_GBTMSSTATEFILLER_H
00030 #define NRAO_GBTMSSTATEFILLER_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Containers/RecordField.h>
00035 #include <ms/MeasurementSets/MSState.h>
00036 #include <tables/Tables/ScalarColumn.h>
00037 #include <casa/BasicSL/String.h>
00038 
00039 //# Forward Declarations
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 class ColumnsIndex;
00042 class MSStateColumns;
00043 } //# NAMESPACE CASA - END
00044 
00045 #include <casa/namespace.h>
00046 
00047 // <summary>
00048 // GBTMSStateFiller fills the MSState table for GBT fillers
00049 // </summary>
00050 
00051 // <use visibility=local>
00052 
00053 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00054 // </reviewed>
00055 
00056 // <prerequisite>
00057 //   <li> MeasurementSets
00058 //   <li> GBT FITS files
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // This class puts GBT data into (fills) the MSState table.
00063 // </etymology>
00064 //
00065 // <synopsis>
00066 // This class puts the appropriate values for the GBT in an MSState
00067 // table (which has been previously created as part of a MeasurementSet).
00068 // On each fill() any necessary additions to the MSState are made.  
00069 // Existing rows are re-used whenever possible.
00070 //
00071 // The stateIds are available to be used by the
00072 // other GBTMS*Fillers as other subtables are filled in turn.
00073 //
00074 // It is assumed that the non-standard columns NRAO_GBT_PROCNAME,
00075 // NRAO_GBT_PROCSIZE, and NRAO_GBT_PROCSEQN already exist in the 
00076 // MSState table when this class attempts to attach to the MSState
00077 // table.
00078 //
00079 // </synopsis>
00080 //
00081 // <example>
00082 // </example>
00083 //
00084 // <motivation>
00085 // Writing a filler is a daunting task.  There are various dependencies
00086 // between the subtables.  It helps to encapsulate the knowlege and
00087 // task of filling a specific subtable to separate classes.
00088 // </motivation>
00089 //
00090 //#! <thrown>
00091 //#! A list of exceptions thrown if errors are discovered in the function.
00092 //#! This tag will appear in the body of the header file, preceding the
00093 //#! declaration of each function which throws an exception.
00094 //#! </thrown>
00095 
00096 class GBTMSStateFiller
00097 {
00098 public:
00099 
00100     // The default ctor.  No MSState table has been attached yet.
00101     // Calling fill on such a filler will throw an exception.
00102     // It is present so that this object can be instantiated before
00103     // an MSState has been created.
00104     GBTMSStateFiller();
00105 
00106     // A filler attached to an MSState table
00107     GBTMSStateFiller(MSState &msState);
00108 
00109     ~GBTMSStateFiller();
00110 
00111     // attach it to an MSState
00112     void attach(MSState &msState);
00113 
00114     // fill for all of the states given.  sigref and cal must have
00115     // the same length.  New rows are only added when needed (existing
00116     // rows with the same values are re-used). The scalar values are
00117     // constant for all the input states.  Some interpretation is
00118     // done here for the special 2-state case.  In that case, if
00119     // cal is changing then sigref is assumed to not change.  That
00120     // is to accomodate the TPWCALSP mode where the sigref column
00121     // is used trigger lo blanking while doppler tracking.  Due to
00122     // different user interfaces, it is sometimes possible to
00123     // get an unexpected TPWCALSP state table even in other modes.
00124     // This assumption, that sigref=True when cal changes and
00125     // there are only 2 states, should be valid in all cases.
00126     void fill(const Vector<Bool> &sigref, const Vector<Bool> &cal,
00127               const String &procname, Int procsize, Int procseqn,
00128               const String &swstate, const String &swtchsig);
00129 
00130     // The vector state ids most recently filled.
00131     const Vector<Int> &stateIds() const {return stateIds_p;}
00132 
00133     // Return a vector of the SIG column for the states just filled
00134     const Vector<Bool> &sigs() const {return sigs_p;}
00135 
00136     // flush the underlying MS subtable
00137     void flush() {msState_p->flush();}
00138 
00139 private:
00140     ColumnsIndex *index_p;
00141     RecordFieldPtr<Bool> sigKey_p;
00142     RecordFieldPtr<Double> calKey_p;
00143     RecordFieldPtr<Int> subScanKey_p, procSizeKey_p;
00144     RecordFieldPtr<String> obsModeKey_p;
00145     MSState *msState_p;
00146     MSStateColumns *msStateCols_p;
00147     ScalarColumn<String> procnameCol_p;
00148     ScalarColumn<Int> procsizeCol_p, procseqnCol_p;
00149 
00150     Vector<Int> stateIds_p;
00151     Vector<Bool> sigs_p;
00152 
00153     // initialize the above for the first time
00154     void init(MSState &msState);
00155 
00156     // undefined and unavailable
00157     GBTMSStateFiller(const GBTMSStateFiller &other);
00158     void operator=(const GBTMSStateFiller &other);
00159 };
00160 
00161 #endif
00162 
00163