com.isti.trinetwatch.station
Class Station

java.lang.Object
  extended bycom.isti.trinetwatch.station.Station

public class Station
extends java.lang.Object

Class Station manages station-specific information.


Field Summary
static java.lang.String statusParamName
          Name of server-generated parameter for station status level.
static java.lang.String usageParamName
          Name of server-generated parameter for station usage level.
 
Constructor Summary
Station(java.lang.String shortName, RuleSet ruleSetObj)
          Creates a new station object.
Station(java.lang.String shortName, RuleSet ruleSetObj, java.lang.String longName, java.lang.String helpString, java.util.Vector groupNamesVec)
          Creates a new station object.
Station(java.lang.String shortName, RuleSet ruleSetObj, java.lang.String longName, java.lang.String helpString, java.util.Vector groupNamesVec, StaticParamTable cfgParams)
          Creates a new station object.
 
Method Summary
 boolean addCfgParam(StaticParameter param)
          Adds the given static parameter object to the configuration parameter table for the station.
 boolean addCfgParam(java.lang.String nameStr, java.lang.String dataStr)
          Creates a new StaticParameter object and adds it to the configuration parameter table for the station.
 boolean addStaticParam(StaticParameter param)
          Adds the given static parameter object to the static parameter table for the station.
 boolean addStaticParam(java.lang.String nameStr, java.lang.String dataStr)
          Creates a new StaticParameter object and adds it to the static parameter table for the station.
 void changeRuleSet(RuleSet ruleSetObj)
          Changes the rule set for this station.
 boolean checkSetControlFlag()
          Attempts to set the control flag to indicate that a control operation is in progress.
 void clearControlFlag(java.lang.String message)
          Clears the control flag to indicate that a control operation is no longer in progress.
 boolean compRuleSetName(java.lang.String name)
          Compares the name associated with the current rule set for this station against the given name.
 boolean containsCfgParamKey(java.lang.String str)
          Determines if the given parameter name key exists in the configuration parameter table.
 boolean containsDynamicParam(DynamicParamHolder dParam)
          Determines if the given dynamic parameter holder object is held by this station.
 boolean containsStaticParamKey(java.lang.String str)
          Determines if the given parameter name key exists in the static parameter table.
 void enterStationInfo(Station srcStationObj)
          Enters updated information from the given 'Station' object into this object.
 StaticParameter getCfgParam(java.lang.String str)
          Returns the static parameter object associated with the given key in the configuration parameter table.
 StaticParamTable getCfgParams()
          Returns the configuration parameters for the station.
 java.util.Enumeration getCfgParamsEnum()
          Returns an enumeration of configuration parameters for the station.
 boolean getControlFlag()
          Returns the control flag for the station.
 int getControlTimeoutSec()
          Returns the timeout value (in seconds) associated with the usage control change operation in progress.
 java.lang.String getDisplayString()
          Returns a display string containing information about the station and its basic fields.
 java.lang.String getDisplayString(boolean cfgParamsFlag)
          Returns a display string containing information about the station and its various fields.
 boolean getDynamicCreatedFlag()
          Determines if this station was dynamically created.
 DynamicParamHolder getDynamicParamHolder(java.lang.String str)
          Returns the dynamic parameter holder object associated with the given key.
 java.util.Vector getDynamicParamsVec(long timeVal)
          Returns a Vector of dynamic parameter objects for the station that have been updated.
 java.lang.String getGroupNamesString()
          Returns a string of group names for the station.
 java.util.Vector getGroupNamesVec()
          Returns the group names Vector for the station.
 java.lang.String getHelpString()
          Returns the help string for the station.
 java.lang.String getLongName()
          Returns the long name for the station.
 java.util.Vector getParamHistoryVec(java.lang.String paramName, long startTime, long endTime)
          Returns (for the given parameter) a new Vector containing 'ValueTimeBlock' objects with timestamps in the specified range.
 StatusLevelTag getRawStatusLevel()
          Returns the "raw" status level for this station.
 java.lang.String getShortName()
          Returns the short name for the station.
 StaticParameter getStaticParam(java.lang.String str)
          Returns the static parameter object associated with the given key in the static parameter table.
 java.util.Enumeration getStaticParamsEnum()
          Returns an enumeration of static parameters for the station.
 long getStationTimeValue()
          Returns the time of the last change to the station.
 StatusLevelTag getStatusLevel()
          Returns the status level for the station.
 StatusLevelTag getStatusLevel(java.lang.String agentName)
          Returns the status level for the station.
 DynamicParamHolder getStatusParamHolder()
          Returns the parameter-holder object used to track status-level history.
 long getStatusUsageTimeValue()
          Returns the time of the last change to the status or usage level for the station.
 long getStatusUsageTimeValue(java.lang.String agentName)
          Returns the time of the last change to the status or usage level for this station's table of parameters for the given agent name.
 UsageLevelTag getUsageLevel()
          Returns the usage level for the station.
 DynamicParamHolder getUsageParamHolder()
          Returns the parameter-holder object used to track usage-level history.
 java.lang.String getUsageResultMsg()
          Returns a message string for the client reporting the result of the last usage-control change request for this station.
 boolean hasHelpString()
          Determines if the help string is available for the station.
 boolean hasLongName()
          Determines if the long name is available for the station.
 boolean hasRuleSet()
          Determines if the rule set is available for the station.
 StaticParameter removeCfgParam(java.lang.String str)
          Removes the static parameter object associated with the given key in the static parameter table.
 StaticParameter removeStaticParam(java.lang.String str)
          Removes the static parameter object associated with the given key in the static parameter table.
 void setControlTimeoutSec(int val)
          Sets the timeout value (in seconds) associated with the usage control change operation in progress.
 void setDynamicCreatedFlag()
          Sets the dynamically-created-station flag to true.
 void setGroupNamesVec(java.util.Vector vec)
          Sets the group names Vector for the station.
 void setHelpString(java.lang.String str)
          Sets the help string for the station.
 void setLongName(java.lang.String str)
          Sets the long name for the station.
 void setUsageLevel(ParamValues paramValues, UsageLevelTag uLevel)
          Sets the usage level variable for this station.
 java.lang.String toString()
          Returns the short station name.
 boolean updateDynamicParam(ParamValues paramValues, java.lang.String nameStr, java.lang.String dataStr, AgentInfo agentObj)
          Updates or adds a parameter to the dynamic parameter table for the station.
protected  void updateTimeValues()
          Updates the time values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

statusParamName

public static final java.lang.String statusParamName
Name of server-generated parameter for station status level.

See Also:
Constant Field Values

usageParamName

public static final java.lang.String usageParamName
Name of server-generated parameter for station usage level.

See Also:
Constant Field Values
Constructor Detail

Station

public Station(java.lang.String shortName,
               RuleSet ruleSetObj,
               java.lang.String longName,
               java.lang.String helpString,
               java.util.Vector groupNamesVec,
               StaticParamTable cfgParams)
Creates a new station object.

Parameters:
shortName - short name for station (such as "ABC").
ruleSetObj - rule-set object for station.
longName - long name for station.
helpString - help string for station.
groupNamesVec - a vector of String objects containing the group names associated with the station.
cfgParams - a table of configuration parameters read from the "stations_info.ini" file.

Station

public Station(java.lang.String shortName,
               RuleSet ruleSetObj,
               java.lang.String longName,
               java.lang.String helpString,
               java.util.Vector groupNamesVec)
Creates a new station object.

Parameters:
shortName - short name for station (such as "ABC").
ruleSetObj - rule-set object for station.
longName - long name for station.
helpString - help string for station.
groupNamesVec - a vector of String objects containing the group names associated with the station.

Station

public Station(java.lang.String shortName,
               RuleSet ruleSetObj)
Creates a new station object.

Parameters:
shortName - short name for station (such as "ABC").
ruleSetObj - rule-set object for station.
Method Detail

enterStationInfo

public void enterStationInfo(Station srcStationObj)
Enters updated information from the given 'Station' object into this object.

Parameters:
srcStationObj - source 'Station' object to use.

addCfgParam

public boolean addCfgParam(java.lang.String nameStr,
                           java.lang.String dataStr)
Creates a new StaticParameter object and adds it to the configuration parameter table for the station.

Parameters:
nameStr - the name of the parameter.
dataStr - the data string for the parameter.
Returns:
true if successful, false if a parameter with the same name already exists in table or if an invalid parameter is detected.

addCfgParam

public boolean addCfgParam(StaticParameter param)
Adds the given static parameter object to the configuration parameter table for the station.

Parameters:
param - the parameter.
Returns:
true if successful, false if a parameter with the same name already exists in table or if an invalid parameter is detected.

getCfgParam

public StaticParameter getCfgParam(java.lang.String str)
Returns the static parameter object associated with the given key in the configuration parameter table.

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

containsCfgParamKey

public boolean containsCfgParamKey(java.lang.String str)
Determines if the given parameter name key exists in the configuration parameter table.

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

removeCfgParam

public StaticParameter removeCfgParam(java.lang.String str)
Removes the static parameter object associated with the given key in the static parameter table.

Parameters:
str - a string matching the contents of the 'name' field of the parameter object to be removed.
Returns:
The handle of the parameter object which was removed or null if no matching object was found.

getCfgParams

public StaticParamTable getCfgParams()
Returns the configuration parameters for the station.

Returns:
the configuration parameters for the station.

getCfgParamsEnum

public java.util.Enumeration getCfgParamsEnum()
Returns an enumeration of configuration parameters for the station.

Returns:
enumeration of configuration parameters for the station.

addStaticParam

public boolean addStaticParam(java.lang.String nameStr,
                              java.lang.String dataStr)
Creates a new StaticParameter object and adds it to the static parameter table for the station.

Parameters:
nameStr - the name of the parameter.
dataStr - the data string for the parameter.
Returns:
true if successful, false if a parameter with the same name already exists in table or if an invalid parameter is detected.

addStaticParam

public boolean addStaticParam(StaticParameter param)
Adds the given static parameter object to the static parameter table for the station.

Parameters:
param - the parameter.
Returns:
true if successful, false if a parameter with the same name already exists in table or if an invalid parameter is detected.

getStaticParam

public StaticParameter getStaticParam(java.lang.String str)
Returns the static parameter object associated with the given key in the static parameter table.

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

containsStaticParamKey

public boolean containsStaticParamKey(java.lang.String str)
Determines if the given parameter name key exists in the static parameter table.

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

removeStaticParam

public StaticParameter removeStaticParam(java.lang.String str)
Removes the static parameter object associated with the given key in the static parameter table.

Parameters:
str - a string matching the contents of the 'name' field of the parameter object to be removed.
Returns:
The handle of the parameter object which was removed or null if no matching object was found.

getStaticParamsEnum

public java.util.Enumeration getStaticParamsEnum()
Returns an enumeration of static parameters for the station.

Returns:
an enumeration of static parameters for the station.

updateDynamicParam

public boolean updateDynamicParam(ParamValues paramValues,
                                  java.lang.String nameStr,
                                  java.lang.String dataStr,
                                  AgentInfo agentObj)
Updates or adds a parameter to the dynamic parameter table for the station. 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. Error-warning and debug messages are sent to the global log file.

Parameters:
paramValues - parameter values.
nameStr - the name of the dynamic parameter.
dataStr - the data string for the dynamic 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).

getDynamicParamHolder

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

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

containsDynamicParam

public boolean containsDynamicParam(DynamicParamHolder dParam)
Determines if the given dynamic parameter holder object is held by this station.

Parameters:
dParam - the dynamic parameter.
Returns:
true if the given dynamic parameter holder object is held by this station, false otherwise.

getStatusLevel

public StatusLevelTag getStatusLevel(java.lang.String agentName)
Returns the status level for the station.

Parameters:
agentName - the name of agent use to fetch the status level, or null to fetch the status level for the station.
Returns:
The minimum status level found in the table of dynamic parameters for the station (or agent), or the "Unknown" status level tag if a status level cannot be fetched.

getStatusLevel

public StatusLevelTag getStatusLevel()
Returns the status level for the station.

Returns:
The minimum status level found in the table of dynamic parameters for the station, or the "Unknown" status level tag if a status level cannot be generated.

getRawStatusLevel

public StatusLevelTag getRawStatusLevel()
Returns the "raw" status level for this station. No warning is generated if the usage level for the station is not set, and 'null' will be returned if the status level cannot be fetched.

Returns:
the "raw" status level for this station.

compRuleSetName

public boolean compRuleSetName(java.lang.String name)
Compares the name associated with the current rule set for this station against the given name.

Parameters:
name - the name to compare against.
Returns:
true if the given name is the same as the name associated with the current rule set for this station.

changeRuleSet

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

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

getDynamicParamsVec

public java.util.Vector getDynamicParamsVec(long timeVal)
Returns a Vector of dynamic parameter objects for the station that have been updated.

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

getParamHistoryVec

public java.util.Vector getParamHistoryVec(java.lang.String paramName,
                                           long startTime,
                                           long endTime)
Returns (for the given parameter) a new Vector containing 'ValueTimeBlock' objects with timestamps in the specified range. The start and end time parameter values are in seconds since 1/1/1970, and are "inclusive".

Parameters:
paramName - the name of specified parameter.
startTime - the start time for the range, or 0 for the beginning of the history.
endTime - the end time for the range, or 0 for the end of the history.
Returns:
A Vector of 'ValueTimeBlock' objects with timestamps in the specified range, or an empty Vector if no matching objects were found, or null if no matching parameter was found.

getStatusParamHolder

public DynamicParamHolder getStatusParamHolder()
Returns the parameter-holder object used to track status-level history.

Returns:
the parameter-holder object used to track status-level history, or null if none available.

getUsageParamHolder

public DynamicParamHolder getUsageParamHolder()
Returns the parameter-holder object used to track usage-level history.

Returns:
the parameter-holder object used to track usage-level history, or null if none available.

updateTimeValues

protected void updateTimeValues()
Updates the time values.


getStationTimeValue

public long getStationTimeValue()
Returns the time of the last change to the station. (In seconds since January 1, 1970.)

Returns:
the time of the last change to the station. (In seconds since January 1, 1970.)

getStatusUsageTimeValue

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

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

getStatusUsageTimeValue

public long getStatusUsageTimeValue(java.lang.String agentName)
Returns the time of the last change to the status or usage level for this station's table of parameters for the given agent name. (In seconds since January 1, 1970.) If the agent name is null or is not matched then the change value for the station as a whole is returned.

Parameters:
agentName - the agent name.
Returns:
the time of the last change to the status or usage level for this station's table of parameters for the given agent name.

getShortName

public java.lang.String getShortName()
Returns the short name for the station.

Returns:
the short name for the station.

getLongName

public java.lang.String getLongName()
Returns the long name for the station.

Returns:
the long name for the station.

hasHelpString

public boolean hasHelpString()
Determines if the help string is available for the station.

Returns:
true if it is available, false otherwise.

hasLongName

public boolean hasLongName()
Determines if the long name is available for the station.

Returns:
true if it is available, false otherwise.

hasRuleSet

public boolean hasRuleSet()
Determines if the rule set is available for the station.

Returns:
true if it is available, false otherwise.

setLongName

public void setLongName(java.lang.String str)
Sets the long name for the station.

Parameters:
str - the long name.

getHelpString

public java.lang.String getHelpString()
Returns the help string for the station.

Returns:
the help string for the station.

setHelpString

public void setHelpString(java.lang.String str)
Sets the help string for the station.

Parameters:
str - the help string.

getGroupNamesVec

public java.util.Vector getGroupNamesVec()
Returns the group names Vector for the station.

Returns:
the group names Vector for the station.

setGroupNamesVec

public void setGroupNamesVec(java.util.Vector vec)
Sets the group names Vector for the station.

Parameters:
vec - vector of grup names.

getGroupNamesString

public java.lang.String getGroupNamesString()
Returns a string of group names for the station. Each name is enclosed in double-quotes ("") and separated by a comma and space.

Returns:
a string of group names for the station.

getUsageLevel

public UsageLevelTag getUsageLevel()
Returns the usage level for the station. If no usage has been set then the "Undefined" usage level tag is returned.

Returns:
the usage level for the station.

setUsageLevel

public void setUsageLevel(ParamValues paramValues,
                          UsageLevelTag uLevel)
Sets the usage level variable for this station. This function is thread synchronized.

Parameters:
paramValues - parameter values.
uLevel - the new usage level for this station; a value of 'null' is translated to 'UsageLevelTag.undefinedUsageTag'.

setControlTimeoutSec

public void setControlTimeoutSec(int val)
Sets the timeout value (in seconds) associated with the usage control change operation in progress.

Parameters:
val - the timeout value.

getControlTimeoutSec

public int getControlTimeoutSec()
Returns the timeout value (in seconds) associated with the usage control change operation in progress. If the timeout value has not been set (not yet received from the control agent) then the returned value will be -1.

Returns:
the timeout value.

getControlFlag

public boolean getControlFlag()
Returns the control flag for the station.

Returns:
true if a control operation is in progress, false if not.

checkSetControlFlag

public boolean checkSetControlFlag()
Attempts to set the control flag to indicate that a control operation is in progress. This function is thread synchronized. If the control request is granted (function returns 'true'), then the message string returned by 'getUsageResultMsg()' is cleared.

Returns:
true if the control flag was not previously set and is now set, false if the control flag is already set (meaning that another thread is performing a control operation.)

clearControlFlag

public void clearControlFlag(java.lang.String message)
Clears the control flag to indicate that a control operation is no longer in progress. This function is thread synchronized.

Parameters:
message - a message string for the client reporting the result of the usage-control change request. This string is returned by the 'getUsageResultMsg()' method.

getUsageResultMsg

public java.lang.String getUsageResultMsg()
Returns a message string for the client reporting the result of the last usage-control change request for this station. If the request is still in progress then an empty string is returned. This function is thread synchronized.

Returns:
usage result message.

toString

public java.lang.String toString()
Returns the short station name.

Returns:
the short station name.

setDynamicCreatedFlag

public void setDynamicCreatedFlag()
Sets the dynamically-created-station flag to true.


getDynamicCreatedFlag

public boolean getDynamicCreatedFlag()
Determines if this station was dynamically created.

Returns:
true if this station was dynamically created, false otherwise.

getDisplayString

public java.lang.String getDisplayString(boolean cfgParamsFlag)
Returns a display string containing information about the station and its various fields.

Parameters:
cfgParamsFlag - if true then information from the table of configuration file parameters is also included.
Returns:
a display string containing information about the station and its various fields.

getDisplayString

public java.lang.String getDisplayString()
Returns a display string containing information about the station and its basic fields. Information from the table of configuration file parameters is not included.

Returns:
a display string containing information about the station and its basic fields.