001    package edu.nrao.sss.model.project.scan;
002    
003    import java.util.EnumSet;
004    import java.util.Set;
005    
006    import edu.nrao.sss.util.EnumerationUtility;
007    
008    /**
009     * An enumeration of the kinds of observations that may be performed
010     * on a source.
011     * <p>
012     * <b>Version Info:</b>
013     * <table style="margin-left:2em">
014     *   <tr><td>$Revision: 2150 $</td></tr>
015     *   <tr><td>$Date: 2009-04-02 16:27:10 -0600 (Thu, 02 Apr 2009) $</td></tr>
016     *   <tr><td>$Author: dharland $</td></tr>
017     * </table></p>
018     * 
019     * @author David M. Harland
020     * @since 2006-03-24
021     */
022    public enum ScanMode
023    {
024      STANDARD_OBSERVING("STD",
025                         ScanIntent.CALIBRATE_ABSOLUTE_POSITION,
026                         ScanIntent.CALIBRATE_BANDPASS,
027                         ScanIntent.CALIBRATE_COMPLEX_GAIN,
028                         ScanIntent.CALIBRATE_FLUX_DENSITY_SCALE,
029                         ScanIntent.DETERMINE_AUTOPHASE,
030                         ScanIntent.CALIBRATE_DELAY_PHASE_STYLE,
031                         ScanIntent.CALIBRATE_POLARIZATION_ANGLE,
032                         ScanIntent.CALIBRATE_POLARIZATION_LEAKAGE,
033                         ScanIntent.DETERMINE_RFI,
034                         ScanIntent.OBSERVE_TARGET
035                        ),
036      
037      INTERFEROMETRIC_POINTING("IP", ScanIntent.CALIBRATE_OFFSET_POINTING),
038      
039      SINGLE_DISH_POINTING("SDP", ScanIntent.DETERMINE_SINGLE_DISH_POINTING),
040      
041      REFERENCE_FOCUSING("RF", ScanIntent.CALIBRATE_FOCUS),
042      
043      AMPLITUDE_DELAY_CALIBRATING("DC", ScanIntent.CALIBRATE_DELAY_AMPLITUDE_STYLE),
044      
045      TIPPING("TIP", ScanIntent.DETERMINE_OPACITY_TIPPING_STYLE),
046      
047      HOLOGRAPHY("H", ScanIntent.MAP_ANTENNA_SURFACE),
048      
049      MOSAICKING("M", ScanIntent.OBSERVE_TARGET),
050      
051      FAST_SWITCHING("FS",
052                     ScanIntent.CALIBRATE_ABSOLUTE_POSITION,
053                     ScanIntent.CALIBRATE_BANDPASS,
054                     ScanIntent.CALIBRATE_COMPLEX_GAIN,
055                     ScanIntent.CALIBRATE_FLUX_DENSITY_SCALE,
056                     ScanIntent.CALIBRATE_POLARIZATION_ANGLE,
057                     ScanIntent.CALIBRATE_POLARIZATION_LEAKAGE,
058                     ScanIntent.OBSERVE_TARGET
059                    );
060      
061      private EnumSet<ScanIntent> validIntents;
062    
063      private String abbr;
064      
065      private ScanMode(String abbreviation, ScanIntent... intents)
066      {
067        abbr = abbreviation;
068        
069        validIntents = EnumSet.noneOf(ScanIntent.class);
070        
071        for (ScanIntent intent : intents)
072          validIntents.add(intent);
073      }
074      
075      /**
076       * Returns a set of intents that are valid for this scan mode.
077       * @return a set of intents that are valid for this scan mode.
078       */
079      public Set<ScanIntent> getValidIntents()
080      {
081        return validIntents.clone();
082      }
083      
084      /**
085       * Returns the scan mode to use as a default.
086       * @return a default scan mode.
087       */
088      public static ScanMode getDefault()
089      {
090        return ScanMode.STANDARD_OBSERVING;
091      }
092    
093      /**
094            * @return a short abbreviation of this scan mode. XXX Here to help generate
095            * a short display label for a scan.
096            */
097      public String getAbbreviation()
098      {
099              return this.abbr;
100      }
101      
102      /**
103       * Returns a text representation of this enumeration constant.
104       * @return a text representation of this enumeration constant.
105       */
106      public String toString()
107      {
108        return EnumerationUtility.getSharedInstance().enumToString(this);
109      }
110      
111      /**
112       * Returns the scan mode represented by {@code text}.
113       * <p>
114       * For details about the transformation, see
115       * {@link EnumerationUtility#enumFromString(Class, String)}.</p>
116       * 
117       * @param text a text representation of a scan mode.
118       * 
119       * @return the scan mode represented by {@code text}.
120       */
121      public static ScanMode fromString(String text)
122      {
123        return EnumerationUtility.getSharedInstance()
124                                 .enumFromString(ScanMode.class, text);
125      }
126      /*
127      public static void main(String... args)
128      {
129        for (ScanMode mode : ScanMode.values())
130          System.out.println("variable = " + mode.name() +
131                             ";   abbr = " + mode.abbr +
132                             ";   full = " + mode.toString());
133      }
134      */
135    }