Package hec.model

Class RunTimeWindow

java.lang.Object
hec.model.RunTimeWindow
All Implemented Interfaces:
AsciiSerializable, FieldAccessor, Serializable, Cloneable

public class RunTimeWindow extends Object implements Serializable, AsciiSerializable, Cloneable
Contains data that defines the time window for model execution. This object is passed to model alternatives when there compute method is called.
See Also:
  • Field Details

  • Constructor Details

    • RunTimeWindow

      public RunTimeWindow()
      contruct a new RunTimeWindow with values set to undefined
    • RunTimeWindow

      public RunTimeWindow(HecTime start, HecTime end, HecTime lookback)
      contruct a new RunTimeWindow with the specified times.
      Parameters:
      start - the start time
      end - the end time
      lookback - the lookback time
    • RunTimeWindow

      public RunTimeWindow(RunTimeWindow rtw)
      contruct a new RunTimeWindow from the specified RunTimeWindow
      Parameters:
      rtw - the RunTimeWindow to initialize from
  • Method Details

    • setShowTimeAsBeginningOfDay

      public void setShowTimeAsBeginningOfDay(boolean b)
    • isPerAvgTimeStep

      public boolean isPerAvgTimeStep()
    • setPeriodAvgTimeStep

      public void setPeriodAvgTimeStep(boolean b)
    • getTimeBlockIndex

      public int getTimeBlockIndex()
    • setTimeBlockIndex

      public void setTimeBlockIndex(int index)
    • getNumRoutingSteps

      public int getNumRoutingSteps()
      return the number of routing steps
      Returns:
      integer number of routing steps
    • setNumRoutingSteps

      public void setNumRoutingSteps(int numSteps)
      set the number of routing steps
      Parameters:
      numSteps -
    • isValid

      public boolean isValid()
      check to see if the RunTimeWindow is value
      Returns:
      false if the RunTimeWindow is not valid
    • getNumSteps

      public int getNumSteps()
      get the number of steps in the RunTimeWindow
      Returns:
      the number of step or RMAConst.UNDEF_INT if the RunTimeWindow isn't valid
    • setNumLookbackSteps

      public void setNumLookbackSteps(int numSteps)
      set the number of lookback steps
      Parameters:
      numSteps - the number of lookback steps
    • getNumLookbackSteps

      public int getNumLookbackSteps()
      get the number of lookback steps in the RunTimeWindow
      Returns:
      the number of lookback steps or RMAConst.UNDEF_INT if the RunTimeWindow isn't valid
    • getForecastSteps

      public int getForecastSteps()
    • computeSteps

      public boolean computeSteps()
    • setTimeStep

      public void setTimeStep(int dt, int inc)
      set the time step
      Parameters:
      dt - the timestep
      inc - the time increment one of HecTime.SECOND_INCREMENT, HecTime.MINUTE_INCREMENT, HecTime.HOUR_INCREMENT, or HecTime.DAY_INCREMENT
    • setTimeStep

      public void setTimeStep(String str)
      set the time step and time increment by a string
    • getTimeStep

      public static int[] getTimeStep(String str)
      get the time step and time step increment for the timestep string
      Parameters:
      str - the timestep string i.e. 1 HOUR or 1HOUR
      Returns:
      [0] the time step, [1] the time step increment
    • getTimeStepSeconds

      public static int getTimeStepSeconds(int timeStep, int timeStepIncrement)
      given the time step and time step increment return the time step in seconds
      Parameters:
      timeStep - the time step
      timeStepIncrement - the time step increment (i.e. HecTime.HOUR_INCREMENT)
      Returns:
      the time step in seconds
    • getTimeStep

      public int getTimeStep()
      get the time step
      Returns:
      the time step
    • getTimeStepSeconds

      public int getTimeStepSeconds()
      get the time step in seconds
      Returns:
      the time step in seconds
    • getTimeStepMinutes

      public int getTimeStepMinutes()
      get the time step in seconds
      Returns:
      the time step in minutes
    • getTimeIncrement

      public int getTimeIncrement()
      get the time increment, one of HecTime.SECOND_INCREMENT, HecTime.MINUTE_INCREMENT, HecTime.HOUR_INCREMENT, or HecTime.DAY_INCREMENT
      Returns:
      the time increment
    • getTimeIncrementString

      public String getTimeIncrementString()
      return the string representation of the time increment.
      Returns:
      the time increment string or the empty string
    • getTimeStepString

      public String getTimeStepString(int format)
      get the time step value and units as a string (for example 1HOUR)
      Parameters:
      format - 0 no space between time step and time increment (1HOUR) 1 space between time step and time increment (1 HOUR)
      Returns:
      the time step/time increment
    • getTimeWindowString

      public String getTimeWindowString()
      get a string representation of the time window from lookback to end time.
      Returns:
      the time window as a string (lookback end);
    • setStartTime

      public void setStartTime(HecTime start)
      set the start time
      Parameters:
      start - the new start time
    • setStartTime

      public void setStartTime(String timestr)
      set the start time
      Parameters:
      timestr - a date time string that is parsable be HecTime
    • getStartTime

      public HecTime getStartTime()
      get the start time
      Returns:
      the start time
    • getStartDateString

      public String getStartDateString()
      get the start date as a String
      Returns:
      the start date String
    • getStartHrMinString

      public String getStartHrMinString()
      get the start time (hour minutes) as a String
      Returns:
      the start time String
    • getStartTimeString

      public String getStartTimeString()
      get the start date time as a String
      Returns:
      the start date time String
    • setEndTime

      public void setEndTime(HecTime end)
      set the end time
      Parameters:
      end - the new end time
    • setEndTime

      public void setEndTime(String timestr)
      set the end time
      Parameters:
      timestr - a date time string that is parsable by HecTime
    • getEndTime

      public HecTime getEndTime()
      get the end time
      Returns:
      the end time
    • getEndDateString

      public String getEndDateString()
      get the end date (no time) as a String
      Returns:
      the end date
    • getEndHrMinString

      public String getEndHrMinString()
      get the end time (hour and minutes) as a String
      Returns:
      the end time
    • getEndTimeString

      public String getEndTimeString()
      get the end date and time as a String
      Returns:
      the date and time
    • setLookbackTime

      public void setLookbackTime(HecTime lookback)
      set the lookback time
      Parameters:
      lookback - the new lookback time
    • setLookbackTime

      public void setLookbackTime(String timestr)
      set the lookback time
      Parameters:
      timestr - a date time string that is parsable by HecTime
    • getLookbackTime

      public HecTime getLookbackTime()
      get the look back time
      Returns:
      the lookback time
    • getLookbackDateString

      public String getLookbackDateString()
      get the lookback date (no time) as a String
      Returns:
      the look back date
    • getLookbackHrMinString

      public String getLookbackHrMinString()
      get the look back time (hours and minutes) as a String
      Returns:
      the look back time
    • getLookbackTimeString

      public String getLookbackTimeString()
      get the lookback date and time as a String
      Returns:
      the lookback date and time
    • getRunTimeStepAtTime

      public RunTimeStep getRunTimeStepAtTime(HecTime time)
      get the RunTimeStep at time for this RunTimeWindow
      Parameters:
      time - the time to get the RunTimeStep for
      Returns:
      the RunTimeStep for time or null if time is null or undefined
    • getTimeAtStep

      public HecTime getTimeAtStep(int i)
      gets the time at step i
      Parameters:
      i - the time step to get the time at
      Returns:
      the time at step or null if the RunTimeWindow isn't valid
    • getStepAtTime

      public int getStepAtTime(HecTime time)
      get the step at time. This could return a negative step if the step is before this RunTimeWindow
      Parameters:
      time - the HecTime to get the step for
      Returns:
      the step at time.
    • getTimeStringAtStep

      public String getTimeStringAtStep(int timeStep)
      get the time at step timeStep as a String
      Parameters:
      timeStep - the timeStep to get the time for
      Returns:
      the time at timeStep or if not valid timeStep as a String
    • toString

      public String toString()
      return the string representation of the RunTimeWindow
      Overrides:
      toString in class Object
      Returns:
      the String representation
    • getFieldObject

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      Specified by:
      getFieldObject in interface FieldAccessor
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      Specified by:
      setFieldObject in interface FieldAccessor
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful
    • main

      public static void main(String[] args)
    • getTimeStepString

      public static String getTimeStepString(int timeStep, int timeIncrement)
    • set

      public void set(String times)
      set the times of the runtimewindow. times should be 1 or more HecTime compatible strings separated by semicolons. i.e. 20Jan1999 1400; the order of parsing is if there are 3 times then the first is the lookback then the start and then the end if there are 2 times then its considered the start and end if there is just 1 time then its considered the start time.
      Parameters:
      times -
    • getNumberOfYears

      public int getNumberOfYears()
      return the number of whole years in the runtimewindow
      Returns:
      the number of whole years
    • getNumberOfYearsWithFraction

      public double getNumberOfYearsWithFraction()
      return the number of years in the runtimewindow with any fractional part in the decimal
      Returns:
      the number of years
    • getExtractStartTime

      public HecTime getExtractStartTime()
      get the extract start time
      Returns:
      null by default. Its here for subclasses to use
    • clone

      public RunTimeWindow clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object