001    package edu.nrao.sss.model.project.scheduling;
002    
003    import java.util.List;
004    import java.util.Date;
005    
006    import edu.nrao.sss.model.project.SchedulingType;
007    import edu.nrao.sss.model.project.scheduling.constraint.Constraint;
008    import edu.nrao.sss.model.project.scheduling.priority.Priority;
009    
010    import edu.nrao.sss.measure.TimeDuration;
011    import edu.nrao.sss.measure.TimeInterval;
012    
013    import edu.nrao.sss.measure.TimeOfDayInterval;
014    import edu.nrao.sss.util.EventSetStatus;
015    
016    
017    /**
018     * Defines the capabilities expected of scheduling block implementations that can
019     * be used by the scheduler.
020     * @author slovelan
021     *
022     */
023    public interface Schedulable {
024            
025            public static final String OBSERVE_SCRIPT_NOT_FOUND = "This scheduling block does not have an associated observe script.";
026            public static final String NAME_SEPARATOR = ".";
027            
028            /**
029             * Returns a set of requirements that can be used to determine the success of a scheduling
030             * block under current conditions.
031             * @return a set of requirements that can be used to determine the success of this scheduling
032             *         block under current conditions.
033             */
034             public List<Constraint> getConstraints();
035              
036              /**
037                * Sets the requirements that can be used to determine the success of a scheduling
038                * block under current conditions.
039                * @param theConstraints a set of environmental and telescopes constraints such as
040                *        recent calibration accuracies that can be used to determine the success
041                *        of this scheduling block under current conditions.
042                */
043              public void setConstraints( List<Constraint> theConstraints );
044             
045                
046                     /**
047                       * Returns the set of priorities of the scheduling block.
048                       * @return the set of priorities for this <code>ScheduleBlock</code>.
049                       */
050          public List<Priority> getPriorities();
051               
052               /**
053                * Sets the set of priorities of this scheduling block.
054                * @param thePriorities a set of priorities representing the importance of
055                *        this scheduling block with regard to a variety of criteria such
056                *        as scientific rating, etc.
057                */
058    
059          public void setPriorities( List<Priority> thePriorities );
060               
061    
062    
063            
064      //---------------------------------------------------------------------------
065      //                       Internal Scheduling Constraints
066      //---------------------------------------------------------------------------
067      
068      /**
069       * Returns true if there are no internal forces withen the <code>ScheduleBlock</code>
070       * to prevent scheduling such as prerequisites or invalid status.
071       * @return true if there are no internal conditions to prevent scheduling;
072       *         false otherwise.
073       */
074      
075      public boolean canBeScheduled();
076      
077     
078      
079      //--------------------------------------------------------------------------
080      //                      Scheduling Type
081      //--------------------------------------------------------------------------
082      
083      /**
084       * Returns the particular method of scheduling that is appropriate for this
085       * <code>ScheduleBlock</code>.
086       * @return the <code>SchedulingType</code>.
087       */
088      
089      public SchedulingType getType();
090      
091    
092      public abstract void setType( SchedulingType st );
093      
094      
095      //---------------------------------------------------------------------------
096      //                Times
097      //---------------------------------------------------------------------------
098      
099      /**
100       * Returns the preferred date range for execution of this scheduling block.
101       * The returned interval is a copy of the one held internally by this
102       * block.
103       * 
104       * @return the preferred date range for execution of this scheduling block.
105       */
106      public TimeInterval getPreferredDateRange();
107      
108      public void setPreferredDateRange( TimeInterval tInterval );
109    
110      /**
111       * Returns the range of allowable execution start times for this scheduling
112       * block, expressed in local sidereal time.
113       * <p>
114       * The returned range, which is guaranteed to be non-null,
115       * is the actual range held by this block,
116       * so changes made to it will be reflected in this object.</p>
117       * 
118       * @return the allowable LST range for beginning execution of this scheduling
119       *         block.
120       */
121      
122      public TimeOfDayInterval getLstStartRange();
123      
124      public void setLstStartRange( TimeOfDayInterval tInterval );
125      
126    
127      //-------------------------------------------------------------------------------
128      //                   Duration
129      //-------------------------------------------------------------------------------
130      
131      /**
132       * Returns the amount of time allocated for one execution of this scheduling
133       * block.
134       * <p>
135       * The returned duration, which is guaranteed to be non-null,
136       * is the actual duration held by this block,
137       * so changes made to it will be reflected in this object.</p>
138       * 
139       * @return the amount of time allocated for one execution of this scheduling
140       *         block.
141       */
142      
143      public TimeDuration calculateTimePerExecution();
144      
145      
146      
147     
148      /**
149       * Returns the total number of repetitions of this <code>ScheduleBlock</code>
150       * that were originally authorized.
151       * @return the total number of repetitions this <code>ScheduleBlock</code>
152       *         should be scheduled for.
153       */
154       
155      public int getAuthorizedCount();
156      
157      public void setAuthorizedCount(int count);
158     
159      
160      public int getCompletedCount();
161      
162       //---------------------------------------------------------------------------
163      //                   Program Block
164      //----------------------------------------------------------------------------
165     
166      /**
167       * Returns the program block of which this scheduling block is a member of.
168       * @return the program block to which this scheduling block belongs.
169       */
170      
171       public ProgBlock getProgramBlock();
172     
173       //---------------------------------------------------------------------------
174       //                      Observe Script
175       //---------------------------------------------------------------------------
176       
177       /**
178        * Returns a string representation of the observing script for one repetition of
179        * this scheduling block.
180        * @param startingTime the date the executor will be observing
181        *        this scheduling block. If the startingHour is not null, the observe
182        *        script will be returned with the times modified so that the script starts
183        *        at the indicated time.  If the startingHour is null, the observe
184        *        script will be returned with the default starting time.
185        *  
186        */
187       
188       //Note: A date is being used rather than an hour( which is all that the currently
189       //written scheduling tool needs) so that in the future calibration sources can
190       //be selected based on the date.
191       public String toObserveScript( Date startingTime );
192     
193       //TODO:  I thing we are going to need the capability of editing of observe
194       //scripts, validation of the editing, and then writing the scripts back to the
195       //scheduling block.
196       
197      
198       //----------------------------------------------------------------------------
199       //                Naming
200       //----------------------------------------------------------------------------
201       
202       /**
203        * Returns a short descriptive name for this scheduling block.
204        * @return a short descriptive name for this scheduling block.
205        */
206       
207       public String getName();
208       public void setName( String sName );
209       
210     
211      
212       
213       public String getProgramName();
214       
215     
216       
217       
218       public String getProjectName();
219       
220     
221       
222       
223       public String getProposalName();
224             
225       public String getCompleteName();
226     
227     
228       //-----------------------------------------------------------------------------
229       //                   State Machine
230       //-----------------------------------------------------------------------------
231     
232       public EventSetStatus getExecutionStatus();
233    
234    /*
235       @Deprecated public void execute();
236     
237       @Deprecated public void schedule();
238       
239       public boolean cancel();
240       
241       public boolean hold();
242       
243       public boolean release();
244    */  
245      
246    }