com.isti.trinetwatch.params
Class DynamicParamTable

java.lang.Object
  extended by com.isti.trinetwatch.params.DynamicParamTable

public class DynamicParamTable
extends java.lang.Object

Class DynamicParamTable manages a hash table of 'DynamicParamHolder' objects. All functions are thread-synchronized to allow only one thread access at a time.


Constructor Summary
DynamicParamTable(RuleSet ruleSetObj, UsageLevelTag tableUsageLevel, long timeVal)
          Creates table to hold DynamicParamHolder objects.
 
Method Summary
 void changeRuleSet(RuleSet ruleSetObj)
          Changes the rule set for this table.
 void closeParamHistories()
          Closes the history tracking for the parameters in this table, releasing resources allocated by their archive managers.
 boolean containsKey(java.lang.String str)
          Determines if the specified parameter-name key exists in the table.
 boolean containsValue(DynamicParamHolder dParam)
          Determines if the specified parameter object exists in the table.
 DynamicParamHolder get(java.lang.String str)
          Returns the parameter object associated with the given key.
 DynamicParamHolder get(java.lang.String str, AgentInfo agentObj)
          Returns parameter object associated with the given key.
 StatusLevelTag getMinStatusLevel()
          Returns the minimum status level found in the table of dynamic parameters.
 long getStatusUsageTimeValue()
          Returns the time of the last change to the status or usage level for the parameter table.
 java.util.Vector getTableVec(long timeVal)
          Returns a Vector of dynamic parameter objects in the table that have been updated.
 void setTableUsageLevel(UsageLevelTag uLevel)
          Sets the usage level used to determine status levels for parameters in the table.
 int size()
          Returns the number of parameter objects in the table.
 boolean updateParameter(Station stationObj, ParamValues paramValues, DynamicParamHolder dParamHolderObj)
          Updates or adds a dynamic parameter to the table.
protected  boolean updateParameter(Station stationObj, ParamValues paramValues, java.lang.String nameStr, java.lang.Object dataObj, long timeVal, AgentInfo agentObj, DynamicParamHolder dParamHolderObj)
          Updates or adds a dynamic parameter to the table, with a timestamp.
 boolean updateParameter(Station stationObj, ParamValues paramValues, java.lang.String nameStr, java.lang.String dataStr, long timeVal, AgentInfo agentObj)
          Updates or adds a dynamic parameter to the table, with a timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicParamTable

public DynamicParamTable(RuleSet ruleSetObj,
                         UsageLevelTag tableUsageLevel,
                         long timeVal)
Creates table to hold DynamicParamHolder objects.

Parameters:
ruleSetObj - rule-set for table.
tableUsageLevel - initial usage level for table.
timeVal - the initial time value for the time of last change to the status/usage level of the table.
Method Detail

get

public DynamicParamHolder get(java.lang.String str)
Returns the parameter object associated with the given key.

Parameters:
str - a string matching the contents of the 'name' field of the desired parameter object. The 'name' field should include the agent name.
Returns:
The handle of the parameter object or null if no matching object was found.

get

public DynamicParamHolder get(java.lang.String str,
                              AgentInfo agentObj)
Returns parameter object associated with the given key.

Parameters:
str - a string matching the contents of the 'name' field of the desired parameter object. The 'name' field should not include the agent name.
agentObj - the agent information block object associated with the source agent for this parameter.
Returns:
The handle of the parameter object or null if no matching object was found.

setTableUsageLevel

public void setTableUsageLevel(UsageLevelTag uLevel)
Sets the usage level used to determine status levels for parameters in the table.

Parameters:
uLevel - the usage level.

updateParameter

protected boolean updateParameter(Station stationObj,
                                  ParamValues paramValues,
                                  java.lang.String nameStr,
                                  java.lang.Object dataObj,
                                  long timeVal,
                                  AgentInfo agentObj,
                                  DynamicParamHolder dParamHolderObj)
Updates or adds a dynamic parameter to the table, with a timestamp. The data string is interpreted and converted to a numeric or boolean type when appropriate, otherwise it is used as a literal string. If the literal string is surrounded by quotes (""), they are removed. If the parameter name matches one in the rule-set then the data object must be of the correct matching type. If the parameter name is not in the rule-set then a new parameter is created using the given data object, and all future updates to the parameter must use the same data type. Error-warning and debug messages are sent to the global log file.

Parameters:
stationObj - the station object.
paramValues - parameter values.
nameStr - the name of the dynamic parameter.
dataObj - the data object for the dynamic parameter.
timeVal - the timestamp value for this update of the parameter.
agentObj - the agent information block object associated with the source agent for this parameter.
dParamHolderObj - dynamic-parameter holder object to use, or null to create a new one (if needed).
Returns:
true if successful, false if error (log message generated).

updateParameter

public boolean updateParameter(Station stationObj,
                               ParamValues paramValues,
                               java.lang.String nameStr,
                               java.lang.String dataStr,
                               long timeVal,
                               AgentInfo agentObj)
Updates or adds a dynamic parameter to the table, with a timestamp. The data string is interpreted and converted to a numeric or boolean type when appropriate, otherwise it is used as a literal string. If the literal string is surrounded by quotes (""), they are removed. If the parameter name matches one in the rule-set then the data object must be of the correct matching type. If the parameter name is not in the rule-set then a new parameter is created using the given data object, and all future updates to the parameter must use the same data type. Error-warning and debug messages are sent to the global log file.

Parameters:
stationObj - the station object.
paramValues - parameter values.
nameStr - the name of the dynamic parameter.
dataStr - the data string for the dynamic parameter.
timeVal - the timestamp value for this update of the parameter.
agentObj - the agent information block object associated with the source agent for this parameter.
Returns:
true if successful, false if error (log message generated).

updateParameter

public boolean updateParameter(Station stationObj,
                               ParamValues paramValues,
                               DynamicParamHolder dParamHolderObj)
Updates or adds a dynamic parameter to the table. Error-warning and debug messages are sent to the global log file.

Parameters:
stationObj - the station object.
paramValues - parameter values.
dParamHolderObj - dynamic-parameter holder object to use.
Returns:
true if successful, false if error (log message generated).

getMinStatusLevel

public StatusLevelTag getMinStatusLevel()
Returns the minimum status level found in the table of dynamic parameters.

Returns:
The minimum StatusLevelTag object found in the table, or null if a status level has not been generated.

changeRuleSet

public void changeRuleSet(RuleSet ruleSetObj)
Changes the rule set for this table.

Parameters:
ruleSetObj - the new rule set object to use.

containsKey

public boolean containsKey(java.lang.String str)
Determines if the specified parameter-name key exists in the table.

Parameters:
str - the parameter-name key.
Returns:
true if the specified parameter-name key exists in the table, false otherwise.

containsValue

public boolean containsValue(DynamicParamHolder dParam)
Determines if the specified parameter object exists in the table.

Parameters:
dParam - the dynamic parameter.
Returns:
true if the specified parameter object exists in the table, false otherwise.

getTableVec

public java.util.Vector getTableVec(long timeVal)
Returns a Vector of dynamic parameter objects in the table that have been updated.

Parameters:
timeVal - only dynamic parameter objects with timestamps greater than or equal to this value are returned.
Returns:
a Vector of DynamicParamHolder objects.

size

public int size()
Returns the number of parameter objects in the table.

Returns:
the number of parameter objects in the table.

getStatusUsageTimeValue

public long getStatusUsageTimeValue()
Returns the time of the last change to the status or usage level for the parameter table. (In seconds since January 1, 1970.)

Returns:
the time of the last change to the status or usage level for the parameter table. (In seconds since January 1, 1970.)

closeParamHistories

public void closeParamHistories()
Closes the history tracking for the parameters in this table, releasing resources allocated by their archive managers.