Package hec.rss.model

Class StateVariable

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, TSLocation, AltInputReportInfc, RssModelVariableConstants, RssReturnStatusConstants, RssTSLocation, Serializable, Cloneable, Comparable, Observer, rma.lang.Modifiable

public class StateVariable extends RssTSLocationObject implements AsciiSerializable, AltInputReportInfc

Title: General CWMS Framework

Description:

Copyright: Copyright (c) 2002

Company: RMA Inc.

See Also:
  • Field Details

  • Constructor Details

    • StateVariable

      public StateVariable()
    • StateVariable

      public StateVariable(RssSystem network, int idx)
  • Method Details

    • nameChanged

      protected void nameChanged()
    • getUsrObjList

      public List getUsrObjList()
      returns a list that where users can store objects that will be persistent from one call to the state variable script to the next. The list is clear immediately before a compute (and in the future will be cleared following a compute), so objects are not persistent from one compute to the next. The list that is returned is an instance of java.util.ArrayList.
      Returns:
      List that can be used to store user defined objects
    • listGet

      public Object listGet(int pos)
      gets an object in the userObjList from the specified location, if the object exists in the location
      Parameters:
      pos - location of the Object in the userObjList
      Returns:
      the object at the position specified or null.
    • listAdd

      public void listAdd(Object obj)
      Add Objects to the defined UserObject List where users can store objects that will be persistent from one call to the state variable script to the next.
      Parameters:
      obj -
    • listAdd

      public void listAdd(int index, Object obj)
      Add Objects to the defined UserObjectList at the specified index
      Parameters:
      index -
      obj -
    • clearList

      public void clearList()
      Clears the defined UserObject List
    • listContains

      public boolean listContains(Object obj)
      See if an Object is contained in the defined UserObject List
      Parameters:
      obj -
      Returns:
      true if Object is in list
    • listRemove

      public boolean listRemove(Object obj)
      Remove the specified Object if it is contained in the defined UserObject List
      Parameters:
      obj - Object to remove from the list
      Returns:
      true if the object was removed from the list
    • getListSize

      public int getListSize()
      get the size of the defined UserObject List
      Returns:
      size of the UserObjectList
    • getReferencedElements

      public List getReferencedElements()
      parses script and gets elements referenced by network.getTimeSeries() method calls.
      Returns:
      ArrayList of referenced elements
    • getAlwaysCompute

      public boolean getAlwaysCompute()
    • setAlwaysCompute

      public void setAlwaysCompute(boolean b)
    • isActive

      public boolean isActive()
    • setActive

      public void setActive(boolean b)
    • setUseJavaClass

      public void setUseJavaClass(boolean use)
    • useJavaClass

      public boolean useJavaClass()
    • setJavaClasspath

      public void setJavaClasspath(String path)
      Sets the path to the compiled java class that can be used in replace of the jython script
    • getJavaClasspath

      public String getJavaClasspath()
      Gets the path out on disc to the compiled java class that can be used in replace of the jython script
      Returns:
      String path and name of the compiled class
    • getHindcastDataList

      public void getHindcastDataList(Vector hvec)
      adds the hindcast record for total release from this object
    • applyHindcastData

      public void applyHindcastData(HindcastData hd)
      applies specific hindcast data for compute
    • getScript

      public String getScript()
    • setScript

      public void setScript(String script)
    • getInitScript

      public String getInitScript()
      get the StateVariable compute initialization script
      Returns:
    • setInitScript

      public void setInitScript(String script)
      set the script called during the compute initialization
      Parameters:
      script -
    • getCleanupScript

      public String getCleanupScript()
      get the StateVariables compute cleanup script
      Returns:
    • setCleanupScript

      public void setCleanupScript(String script)
      set the script called during the compute cleanup.
      Parameters:
      script -
    • getParamName

      public String getParamName()
      get the Parameter Name
      Returns:
      the Parameter name
    • getParamType

      public String getParamType()
      get the Parameter Type (ie Elev)
      Returns:
      the Parameter Type
    • setParamType

      public void setParamType(String paramType)
    • setParamName

      public void setParamName(String paramName)
    • setAsSlave

      public void setAsSlave(boolean slave)
    • isSlave

      public boolean isSlave()
    • toString

      public String toString()
      return the script representation of the StateVariable
      Overrides:
      toString in class NamedType
      Returns:
      getName()
    • initialize

      protected boolean initialize()
      general initialization called at start of compute process
      Returns:
      true if initialization successful
    • runScripInitialize

      protected boolean runScripInitialize()
      Script initialization code called at start of compute process
      Returns:
      true if initialization successful
    • getMaxScriptLength

      public static int getMaxScriptLength()
    • runCleanupScript

      public boolean runCleanupScript()
      run the cleanup script for the StateVariable
    • evaluate

      public void evaluate(RunTimeStep rts)
      evaluate the state variable during forecast
    • setValue

      public void setValue(RunTimeStep rts, double val)
      set the value at the current step to val
      Parameters:
      rts - the Compute RunTimeStep
      val - the value to set
    • setValue

      public void setValue(int step, double val)
      set the value at the current step to val
      Parameters:
      step - the Compute run time step
      val - the value to set
    • setValueRange

      public void setValueRange(RunTimeStep rts, int numSteps, double val)
      set the value at the current step for numSteps to val
      Parameters:
      rts - the Compute RunTimeStep
      numSteps - the number of steps to set the value to, negative number not allowed
      val - the value to set
    • setValueRange

      public void setValueRange(int step, int numSteps, double val)
      set the value at the current step for numSteps to val
      Parameters:
      step - the Compute run time step
      numSteps - the number of steps to set the value to, negative number not allowed
      val - the value to set
    • setValueRange

      public void setValueRange(RunTimeStep rts, HecTime start, HecTime end, double val)
      set the value from start to end to val
      Parameters:
      rts - the Compute RunTimeStep
      start - the start time
      end - the end time
      val - the value to set
    • setValueRange

      public void setValueRange(int step, HecTime start, HecTime end, double val)
      set the value from start to end to val
      Parameters:
      step - the Compute run time step
      start - the start time
      end - the end time
      val - the value to set
    • getValue

      public double getValue(RunTimeStep rts)
      get the value at the current step
      Parameters:
      rts - the Compute RunTimeStep
      Returns:
      the value at the current step or RMAConst.UNDEF_DOUBLE if the Current step is invalid or the internal data structures haven't been initialized.
    • getValue

      protected double getValue(int step)
      get the value at the step
      Parameters:
      step - the time step
      Returns:
      the value at the step or RMAConst.UNDEF_DOUBLE if the step is invalid or the internal data structures haven't been initialized.
    • getPreviousValue

      public double getPreviousValue(RunTimeStep rts)
      get the previous value at the current step
      Parameters:
      rts - the Compute RunTimeStep
      Returns:
      the value at the previous step or RMAConst.UNDEF_DOUBLE if the previous step is invalid or the internal data structures haven't been initialized.
    • getActiveTSProxies

      public Vector getActiveTSProxies(Vector vec, int iotype)
      returns a vector of required input, or generated output TSRecordProxies used in the current alternative
    • getSystem

      public RssSystem getSystem()
      get the ResSim network that this StateVariable belongs to
      Specified by:
      getSystem in class RssTSLocationObject
      Returns:
      the RssSystem
    • getNetwork

      public RssSystem getNetwork()
      get the ResSim network that this StateVariable belongs to
      Returns:
      the RssSystem
    • setSystem

      public void setSystem(RssSystem system)
    • updateTSProxyList

      public void updateTSProxyList()
      Regenerates the list of all TSProxies required for this location. This list includes all records that are generated by this function even if the records are held in another objects (e.g. RssNode) proxy list
      Specified by:
      updateTSProxyList in class RssTSLocationObject
    • getTimeSeries

      public TSRecord getTimeSeries()
      get the TSRecord that this StateVariable computes.

      this is the same as asking for the TSRecordProxy for RssModelVariableConstants.VID_STATE_VAR and getting the proxy's TSRecord
      Returns:
      the computed TSRecord or null if it can't be found
    • getLookbackTimeSeries

      public TSRecord getLookbackTimeSeries()
      get the Lookback TSRecord that this StateVariable computes.

      this is the same as asking for the TSRecordProxy for RssModelVariableConstants.VID_STATE_VAR_HIND and getting the proxy's TSRecord
      Returns:
      the computed TSRecord or null if it can't be found
    • localTimeSeriesNew

      public TSRecord localTimeSeriesNew(String varName)
      create a TSRecord for the corresponding to varName, with the initial values set to undefined. If the varName is null then null is returned The TimeSeries will have a size of the entire Run Time Window
      Parameters:
      varName - the name of the Local TimeSeries. Non-null
      Returns:
      the LocalTimeSeries.
    • localTimeSeriesNew

      public TSRecord localTimeSeriesNew(String varName, double initialValue)
      create a TSRecord corresponding to varName, with the initial values set to initialValue If the varName is null then null is returned The TimeSeries will have a size of the entire Run Time Window
      Parameters:
      varName - the name of the Local TimeSeries. Non-Null
      initialValue - the initial value to set the Local TimeSeries to
    • localTimeSeriesNew

      public TSRecord localTimeSeriesNew(String varName, TimeSeriesContainer tsc)
      create a TSRecord corresponding to varName, with the TSRecord data set to the TimeSeriesContainer. If the varName or the TimeSeriesContainer is null then null is returned The TimeSeries returned is the size of the TimeSeriesContainer passed in. No attempt to align the returned TimeSeries with the RunTimeWindow is performed.
      Parameters:
      varName - the name of the Local TimeSeries. Non-Null
      tsc - the TimeSeriesContainer to populate the TSRecord with
    • localTimeSeriesSize

      public int localTimeSeriesSize()
      get the number of Local TimeSeries currently being stored
      Returns:
      the number of Local TimeSeries
    • localTimeSeriesClear

      public int localTimeSeriesClear()
      clear out the Local TimeSeries variables.
      Returns:
      the number of Local TimeSeries variables cleared
    • localTimeSeriesListKeys

      public List<String> localTimeSeriesListKeys()
      get a List of the Local TimeSeries names.
      Returns:
      a List of the Local TimeSeries names
    • localTimeSeriesList

      public List<TSRecord> localTimeSeriesList()
      get a List of the Local TimeSeries. The List is not backed by the internal storage of the Local TimeSeries
      Returns:
      a List of the Local TimeSeries
    • localTimeSeriesGet

      public TSRecord localTimeSeriesGet(String varName)
      return a TSRecord corresponding to varName. If a TSRecord
      Parameters:
      varName - the name of the Local TimeSeries. Non-Null
    • localTimeSeriesExists

      public boolean localTimeSeriesExists(String varName)
      check to see if the Local TimeSeries put with the name varName exists
      Parameters:
      varName - the name of the Local TimeSeries
      Returns:
      true if the Local TimeSeries exists
    • localTimeSeriesWrite

      public boolean localTimeSeriesWrite(String varName)
      write the localtimeseries varName out to the simulation's DSS file.
      Parameters:
      varName -
      Returns:
      true if the localtimeseries was written out successfully
    • localTimeSeriesWriteAll

      public boolean localTimeSeriesWriteAll()
      write all local timeseries out to the simulation's DSS file.
      Returns:
      true if all localtimeseries were written successfully
    • varExists

      public boolean varExists(String varName)
      check to see if the user variable put with the name varName exists
      Parameters:
      varName - the name of the user variable
      Returns:
      true if the variable exists
    • varPut

      public void varPut(String varName, Object usrVar)
      save the user variable usrVar with the associated name varName
      Parameters:
      varName -
      usrVar -
    • varGet

      public Object varGet(String varName)
      get the user variable associated with the name varName, that was previous added with varPut()
      Parameters:
      varName - the name of the user variable
      Returns:
      the user variable or null if the user variable doesn't exist
    • varsClear

      public int varsClear()
      clear out the user variables.
      Returns:
      the number of variables cleared
    • varsSize

      public int varsSize()
      return the number of user variables currently being stored
      Returns:
      the number of user variables
    • varsList

      public List<Object> varsList()
      get a List of the user variables. The List is not backed by the iternal storage of the user variables.
      Returns:
      a List of the user variables
    • varsListKeys

      public List<String> varsListKeys()
      get a List of the user variable names.
      Returns:
      a List of the user variable names
    • varRemove

      public Object varRemove(String varName)
      remove the user variable that was stored with the name varName.
      Parameters:
      varName - the name of the user variable
      Returns:
      the user variable or null
    • 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
      Overrides:
      getFieldObject in class RssTSLocationObject
      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
      Overrides:
      setFieldObject in class RssTSLocationObject
      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
    • outputReport

      public void outputReport(AlternativeInputReport report, org.jdom.Element elem)
      Description copied from interface: AltInputReportInfc
      Alternative Input Report Interface for data.
      Specified by:
      outputReport in interface AltInputReportInfc
    • getElementDependencies

      public void getElementDependencies(List<Element> elemList, Element parentElem)
      Returns the elements that are related to input time series required for calculation of this state variable. This method is used to determine element dependencies for compute ordering. Both input and output time series are considered.
      Parameters:
      elemList - List to which required Element objects will be added.
      parentElem - Element containing a reference to this State Variable