Use of Interface with Scripts and State Variables in HEC-ResSim

This post will demonstrate the use of the interface for scripts and state variables in HEC-ResSim.  This will be done by obtaining the day of each time step in a model simulation.

The time step in this model is hourly.

To obtain the day, I look at the methods that are available in the HecTime class.  I notice that there is a day() method available.



To get the details of this method, I look at javadocs (available in the installation of the HEC-ResSim software) under hec.heclib.util.  From the figure below, I can see that this method returns the day of the month in integer format.


I now need to look at how to access this method for the current time step.  Under the RunTimeStep class, I see a method termed getHecTime().


I look in hec.model.RunTimeStep in javadocs to get more information on this method and see that I can access the methods under the class HecTime by using this method.


In the code, I ask to get the day() method under the HecTime class by using the getHecTime() method under the RunTimeStep class.  I also add a print statement to test what this is giving me.


I look in the console log to see the result of this code.  Note that the day is repeated several times since this is an hourly time step model and the code is run at each time step.



Comments