Package hec.rss.model
Class StateVariable
java.lang.Object
java.util.Observable
hec.lang.NamedType
hec.rss.model.RssTSLocationObject
hec.rss.model.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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final StringFields inherited from class hec.lang.NamedType
_description, _ignoreModifiedEvents, _index, _isValid, _modified, _name, defaultDescription, defaultName, DESCRIPTION_CHANGED, NAME_CHANGED, RENAME_EVENTFields inherited from interface hec.rss.model.RssModelVariableConstants
CUMLOC_OUTPUT_DATA, GRPID_DIVERSION, GRPID_JUNCTION, GRPID_REACH, GRPID_RESERVOIR, HINDCAST_IDS, HOLDOUT_OUTPUT_DATA, INPUT_DATA, OUTPUT_DATA, PULSE_OUTPUT_DATA, UNREG_OUTPUT_DATA, VID_ADJPARAM_FLOW, VID_CAPACITY_FACTOR, VID_CTRLOUT_HINDFLW, VID_CTRLOUT_RELEASE, VID_DAM_LEAK, VID_DAM_RELEASE, VID_DIV_FLOW, VID_DIV_FLOW_ROUTED, VID_DIV_HINDFLW, VID_DIV_RELEASE, VID_DIVOUT_FLOW, VID_DIVOUT_FLOW_ROUTED, VID_ENERGYREQUIRED_TSINPUT, VID_FIRST, VID_FOREBAY_ELEV, VID_FOREBAY_HEADLOSS, VID_GATE_OPENING, VID_GATE_PERCENTOPEN, VID_JUNC_ELEV, VID_JUNC_FLOW_CUMLOC, VID_JUNC_FLOW_DIV, VID_JUNC_FLOW_HOLD, VID_JUNC_FLOW_IN, VID_JUNC_FLOW_LIMIT, VID_JUNC_FLOW_LOCAL, VID_JUNC_FLOW_PULSE, VID_JUNC_FLOW_REG, VID_JUNC_FLOW_UNREG, VID_JUNC_FLOW_VIOL, VID_JUNC_HINDFLOW, VID_JUNC_INFLOW, VID_JUNC_INFLOW_LOCAL_TOTAL, VID_JUNC_STAGE, VID_JUNC_STAGE_LIMIT, VID_JUNC_STAGE_REG, VID_JUNC_STAGE_UNREG, VID_JUNC_STAGE_VIOL, VID_LAST, VID_NODE_FLOW, VID_NODE_HINDFLW, VID_NODE_HINDSTG, VID_NODE_KNOWNFLOW, VID_NODE_STAGE, VID_OPCTRL_CONSTRAINTID, VID_OPCTRL_DECISION, VID_OPCTRL_MAXLIMIT, VID_OPCTRL_MINLIMIT, VID_OPCTRL_RULEID, VID_OPCTRL_ZONEID, VID_OPRULE_FLOW_SPACE, VID_OPRULE_MAX, VID_OPRULE_MAX_STAGE, VID_OPRULE_MIN, VID_OPRULE_MIN_STAGE, VID_OPRULE_PRIORITY, VID_OPRULE_ROUTE_LAG, VID_OPRULE_ROUTE_MAXOFFSET, VID_OPRULE_ROUTE_MINOFFSET, VID_OPRULE_SPEC, VID_OPRULE_STOR_BAL, VID_OPRULE_STOR_BAL_INDEX, VID_OPRULE_VIOL_ELEV, VID_OPRULE_VIOL_FLOW, VID_OPRULE_VIOL_STAGE, VID_OPRULE_VIOL_STOR, VID_OPRULE_WQCD_ELEV, VID_OPRULEFL_CUMLOC, VID_OPRULETS_TSINPUT, VID_OPSET_ACTIVEZONE, VID_OPSET_GC_ELEV, VID_OPSET_GC_STOR, VID_OPSET_KNOWNZONEELEV, VID_OPSET_PROJECTEDELEV, VID_OPSET_ZONEELEV, VID_OPSET_ZONESTOR, VID_OUTGRP_RELEASE, VID_POOL_AREA, VID_POOL_ELEV, VID_POOL_ELEV_EST, VID_POOL_ELEVROC, VID_POOL_EVAP, VID_POOL_FLOWINTOSTOR, VID_POOL_HINDELEV, VID_POOL_HINDSTOR, VID_POOL_HOLDOUT, VID_POOL_INFLOW, VID_POOL_INPUTEVAP, VID_POOL_NETINFLOW, VID_POOL_OUTFLOW, VID_POOL_OUTFLOW_EST, VID_POOL_SEEP, VID_POOL_STOR, VID_PULSE_BACKQ, VID_PULSE_PULSEQ, VID_PUMP_FLOWAVG, VID_PUMP_VOL, VID_PUMPRULE_FLOWAVG, VID_PUMPRULE_FLOWAVG_CAP, VID_PUMPRULE_FLOWINST, VID_PUMPRULE_FLOWINST_CAP, VID_PUMPRULE_HOURS, VID_PUMPRULE_HOURS_CAP, VID_PUMPRULE_NUMPUMP, VID_PUMPRULE_NUMPUMP_CAP, VID_PUMPRULE_UNITHOURS, VID_PUMPRULE_UNITHOURS_CAP, VID_PUMPRULE_VOL, VID_PUMPRULE_VOL_CAP, VID_PWR_CAPABILITY, VID_PWR_EFF, VID_PWR_ENGYGEN, VID_PWR_ENGYPATTERN, VID_PWR_ENGYPERGEN, VID_PWR_ENGYPERREQD, VID_PWR_ENGYREQD, VID_PWR_ENGYVIOL, VID_PWR_FLWPWR, VID_PWR_HDPWR, VID_PWR_HYDLSS, VID_PWR_MAXCAPACITY, VID_PWR_PER_BALGEN, VID_PWR_PER_GCGEN, VID_PWR_PER_MINPUMPGEN, VID_PWR_PER_MINRELGEN, VID_PWR_PER_POWGEN, VID_PWR_PER_PUMPGEN, VID_PWR_PLNTFAC, VID_PWR_PWRCAP, VID_PWR_REQUIRED, VID_PWR_SPILL, VID_PWR_VIOL, VID_RCH_SEEP, VID_REACH_FLOW_CUMLOC, VID_REACH_FLOW_IN, VID_REACH_FLOW_REG, VID_REACH_FLOW_UNREG, VID_RES_GCRELEASE, VID_RES_HOLDOUT, VID_RES_RELEASE, VID_SPILL_FLOW, VID_SPILL_HINDFLOW, VID_STATE_VAR, VID_STATE_VAR_HIND, VID_TAIL_ELEV, VID_UNCTOUT_FLOW, VID_UNCTOUT_HINDFLW, VID_WA_ACCOUNT_DEMAND, VID_WA_ACCOUNT_INFLOW, VID_WA_CHARGES, VID_WA_CREDIT, VID_WA_CURRENT_MAX_VOLUME, VID_WA_CURRENT_VOLUME, VID_WA_HINDSTOR, VID_WA_LOSSES, VID_WA_PUMPBACK, VID_WA_RULE_DEMAND, VID_WA_SURPLUS, VID_WA_TRANSFERS, WQID_OFFSETFields inherited from interface hec.rss.model.RssReturnStatusConstants
RTN_CANCELED, RTN_NOPROBLEM, RTN_OPCHANGE, RTN_PROBLEM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplies specific hindcast data for computevoidClears the defined UserObject Listvoidevaluate(RunTimeStep rts) evaluate the state variable during forecastgetActiveTSProxies(Vector vec, int iotype) returns a vector of required input, or generated output TSRecordProxies used in the current alternativebooleanget the StateVariables compute cleanup scriptvoidgetElementDependencies(List<Element> elemList, Element parentElem) Returns the elements that are related to input time series required for calculation of this state variable.getFieldObject(Field fld) This method allows access to java.lang.reflect.Field objects within the implementing class.voidgetHindcastDataList(Vector hvec) adds the hindcast record for total release from this objectget the StateVariable compute initialization scriptGets the path out on disc to the compiled java class that can be used in replace of the jython scriptintget the size of the defined UserObject Listget the Lookback TSRecord that this StateVariable computes.
this is the same as asking for theTSRecordProxyforRssModelVariableConstants.VID_STATE_VAR_HINDand getting the proxy'sTSRecordstatic intget the ResSim network that this StateVariable belongs toget the Parameter Nameget the Parameter Type (ie Elev)doubleget the previous value at the current stepparses script and gets elements referenced by network.getTimeSeries() method calls.get the ResSim network that this StateVariable belongs toget the TSRecord that this StateVariable computes.
this is the same as asking for theTSRecordProxyforRssModelVariableConstants.VID_STATE_VARand getting the proxy'sTSRecordreturns a list that where users can store objects that will be persistent from one call to the state variable script to the next.protected doublegetValue(int step) get the value at the stepdoublegetValue(RunTimeStep rts) get the value at the current stepprotected booleangeneral initialization called at start of compute processbooleanisActive()booleanisSlave()voidAdd Objects to the defined UserObjectList at the specified indexvoidAdd 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.booleanlistContains(Object obj) See if an Object is contained in the defined UserObject ListlistGet(int pos) gets an object in the userObjList from the specified location, if the object exists in the locationbooleanlistRemove(Object obj) Remove the specified Object if it is contained in the defined UserObject Listintclear out the Local TimeSeries variables.booleanlocalTimeSeriesExists(String varName) check to see if the Local TimeSeries put with the name varName existslocalTimeSeriesGet(String varName) return aTSRecordcorresponding tovarName.get aListof the Local TimeSeries.get aListof the Local TimeSeries names.localTimeSeriesNew(String varName) create aTSRecordfor the corresponding tovarName, with the initial values set to undefined.localTimeSeriesNew(String varName, double initialValue) create aTSRecordcorresponding tovarName, with the initial values set to initialValue If thevarNameisnullthen null is returned The TimeSeries will have a size of the entire Run Time WindowlocalTimeSeriesNew(String varName, TimeSeriesContainer tsc) create aTSRecordcorresponding tovarName, with the TSRecord data set to the TimeSeriesContainer.intget the number of Local TimeSeries currently being storedbooleanlocalTimeSeriesWrite(String varName) write the localtimeseries varName out to the simulation's DSS file.booleanwrite all local timeseries out to the simulation's DSS file.protected voidvoidoutputReport(AlternativeInputReport report, org.jdom.Element elem) Alternative Input Report Interface for data.booleanrun the cleanup script for the StateVariableprotected booleanScript initialization code called at start of compute processvoidsetActive(boolean b) voidsetAlwaysCompute(boolean b) voidsetAsSlave(boolean slave) voidsetCleanupScript(String script) set the script called during the compute cleanup.booleansetFieldObject(Field fld, Object fobj) This allows access to fields withing the implementing object to set there data.voidsetInitScript(String script) set the script called during the compute initializationvoidsetJavaClasspath(String path) Sets the path to the compiled java class that can be used in replace of the jython scriptvoidsetParamName(String paramName) voidsetParamType(String paramType) voidvoidvoidsetUseJavaClass(boolean use) voidsetValue(int step, double val) set the value at the current step to valvoidsetValue(RunTimeStep rts, double val) set the value at the current step to valvoidsetValueRange(int step, int numSteps, double val) set the value at the current step for numSteps to valvoidsetValueRange(int step, HecTime start, HecTime end, double val) set the value from start to end to valvoidsetValueRange(RunTimeStep rts, int numSteps, double val) set the value at the current step for numSteps to valvoidsetValueRange(RunTimeStep rts, HecTime start, HecTime end, double val) set the value from start to end to valtoString()return the script representation of the StateVariablevoidRegenerates the list of all TSProxies required for this location.booleanbooleancheck to see if the user variable put with the name varName existsget the user variable associated with the name varName, that was previous added withvarPut()voidsave the user variable usrVar with the associated name varNameremove the user variable that was stored with the name varName.intclear out the user variables.varsList()get aListof the user variables.get aListof the user variable names.intvarsSize()return the number of user variables currently being storedMethods inherited from class hec.rss.model.RssTSLocationObject
addTSRecord, addTSRecordProxy, addTSRecordProxy, addTSRecordProxy, clearTSProxyList, clone, copyInto, getActiveTSRecordProxies, getComputedTSRecordProxies, getTSArray, getTSArray, getTSArray, getTSArray, getTSContainer, getTSContainer, getTSDataSet, getTSRecordProxies, getTSRecordProxy, getTSRecordProxy, getTSRecordProxy, getTSRecordProxy, getTSRecordProxy, getTSRecordProxyVec, removeTSRecord, removeTSRecordProxy, removeTSRecordProxyMethods inherited from class hec.lang.NamedType
addModifiableListener, compareTo, fireModifiedStateChanged, getDescription, getDisplayName, getIgnoreModifiedEvents, getIndex, getName, isModified, isValid, readResolve, removeModifiableListener, rename, set, setDescription, setIgnoreModifiedEvents, setIndex, setModified, setName, setValid, update, useRecursiveModifiedTestMethods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Field Details
-
KNOWN_STATE_CONST
public static final int KNOWN_STATE_CONST- See Also:
-
KNOWN_STATE_TS
public static final int KNOWN_STATE_TS- See Also:
-
ARG_VARIABLE
- See Also:
-
ARG_NETWORK
- See Also:
-
ARG_TIMESTEP
- See Also:
-
METHOD_NETWORK_GETTIMESERIES
- See Also:
-
-
Constructor Details
-
StateVariable
public StateVariable() -
StateVariable
-
-
Method Details
-
nameChanged
protected void nameChanged() -
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
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
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
Add Objects to the defined UserObjectList at the specified index- Parameters:
index-obj-
-
clearList
public void clearList()Clears the defined UserObject List -
listContains
See if an Object is contained in the defined UserObject List- Parameters:
obj-- Returns:
- true if Object is in list
-
listRemove
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
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
Sets the path to the compiled java class that can be used in replace of the jython script -
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
adds the hindcast record for total release from this object -
applyHindcastData
applies specific hindcast data for compute -
getScript
-
setScript
-
getInitScript
get the StateVariable compute initialization script- Returns:
-
setInitScript
set the script called during the compute initialization- Parameters:
script-
-
getCleanupScript
get the StateVariables compute cleanup script- Returns:
-
setCleanupScript
set the script called during the compute cleanup.- Parameters:
script-
-
getParamName
get the Parameter Name- Returns:
- the Parameter name
-
getParamType
get the Parameter Type (ie Elev)- Returns:
- the Parameter Type
-
setParamType
-
setParamName
-
setAsSlave
public void setAsSlave(boolean slave) -
isSlave
public boolean isSlave() -
toString
return the script representation of the StateVariable -
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
evaluate the state variable during forecast -
setValue
set the value at the current step to val- Parameters:
rts- the Compute RunTimeStepval- 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 stepval- the value to set
-
setValueRange
set the value at the current step for numSteps to val- Parameters:
rts- the Compute RunTimeStepnumSteps- the number of steps to set the value to, negative number not allowedval- 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 stepnumSteps- the number of steps to set the value to, negative number not allowedval- the value to set
-
setValueRange
set the value from start to end to val- Parameters:
rts- the Compute RunTimeStepstart- the start timeend- the end timeval- the value to set
-
setValueRange
set the value from start to end to val- Parameters:
step- the Compute run time stepstart- the start timeend- the end timeval- the value to set
-
getValue
get the value at the current step- Parameters:
rts- the Compute RunTimeStep- Returns:
- the value at the current step or
RMAConst.UNDEF_DOUBLEif 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_DOUBLEif the step is invalid or the internal data structures haven't been initialized.
-
getPreviousValue
get the previous value at the current step- Parameters:
rts- the Compute RunTimeStep- Returns:
- the value at the previous step or
RMAConst.UNDEF_DOUBLEif the previous step is invalid or the internal data structures haven't been initialized.
-
getActiveTSProxies
returns a vector of required input, or generated output TSRecordProxies used in the current alternative -
getSystem
get the ResSim network that this StateVariable belongs to- Specified by:
getSystemin classRssTSLocationObject- Returns:
- the RssSystem
-
getNetwork
get the ResSim network that this StateVariable belongs to- Returns:
- the RssSystem
-
setSystem
-
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:
updateTSProxyListin classRssTSLocationObject
-
getTimeSeries
get the TSRecord that this StateVariable computes.
this is the same as asking for theTSRecordProxyforRssModelVariableConstants.VID_STATE_VARand getting the proxy'sTSRecord- Returns:
- the computed TSRecord or null if it can't be found
-
getLookbackTimeSeries
get the Lookback TSRecord that this StateVariable computes.
this is the same as asking for theTSRecordProxyforRssModelVariableConstants.VID_STATE_VAR_HINDand getting the proxy'sTSRecord- Returns:
- the computed TSRecord or null if it can't be found
-
localTimeSeriesNew
create aTSRecordfor the corresponding tovarName, with the initial values set to undefined. If thevarNameisnullthennullis 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
create aTSRecordcorresponding tovarName, with the initial values set to initialValue If thevarNameisnullthen null is returned The TimeSeries will have a size of the entire Run Time Window- Parameters:
varName- the name of the Local TimeSeries. Non-NullinitialValue- the initial value to set the Local TimeSeries to
-
localTimeSeriesNew
create aTSRecordcorresponding tovarName, with the TSRecord data set to the TimeSeriesContainer. If thevarNameor theTimeSeriesContainerisnullthen 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-Nulltsc- 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
get aListof the Local TimeSeries names.- Returns:
- a
Listof the Local TimeSeries names
-
localTimeSeriesList
get aListof the Local TimeSeries. The List is not backed by the internal storage of the Local TimeSeries- Returns:
- a
Listof the Local TimeSeries
-
localTimeSeriesGet
return aTSRecordcorresponding tovarName. If a TSRecord- Parameters:
varName- the name of the Local TimeSeries. Non-Null
-
localTimeSeriesExists
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
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
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
save the user variable usrVar with the associated name varName- Parameters:
varName-usrVar-
-
varGet
get the user variable associated with the name varName, that was previous added withvarPut()- 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
get aListof the user variables. The List is not backed by the iternal storage of the user variables.- Returns:
- a
Listof the user variables
-
varsListKeys
get aListof the user variable names.- Returns:
- a
Listof the user variable names
-
varRemove
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
Description copied from interface:FieldAccessorThis method allows access to java.lang.reflect.Field objects within the implementing class.- Specified by:
getFieldObjectin interfaceFieldAccessor- Overrides:
getFieldObjectin classRssTSLocationObject- Parameters:
fld- The field to get.- Returns:
- The data object that is stored in the given field
-
setFieldObject
Description copied from interface:FieldAccessorThis allows access to fields withing the implementing object to set there data.- Specified by:
setFieldObjectin interfaceFieldAccessor- Overrides:
setFieldObjectin classRssTSLocationObject- Parameters:
fld- The java field object representing the member field to be setfobj- The data to set in that field- Returns:
- returns true if successful
-
outputReport
Description copied from interface:AltInputReportInfcAlternative Input Report Interface for data.- Specified by:
outputReportin interfaceAltInputReportInfc
-
getElementDependencies
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
-