com.isti.trinetwatch.params
Class ParamHistoryTable

java.lang.Object
  extended by com.isti.trinetwatch.params.ParamHistoryTable
All Implemented Interfaces:
ParamHistory

public class ParamHistoryTable
extends java.lang.Object
implements ParamHistory

Class ParamHistoryTable defines the history table for station parameters.


Field Summary
static java.lang.String ARCHIVE_FNAME_PRESTR
          Archive file-name prefix.
static java.lang.String ARCHIVE_FNAME_SUFSTR
          Archive file-name suffix.
static java.lang.String KEY_VALUE_SEPARATOR
          Key value separator.
 
Constructor Summary
ParamHistoryTable(ParamValues paramValues)
          Constructs a history table.
ParamHistoryTable(ParamValues paramValues, ArchiveParameterFlag archiveParameterFlag)
          Constructs a history table.
 
Method Summary
 void add(DynamicParamHolder paramHolder, Station stationObj, DynamicParameter dParameter, long timeLastChanged, long timeLastReceived, long minTime)
          Adds the item to the history.
protected static java.lang.String addKey(java.lang.String key, java.lang.String str)
          Adds the specified string to the key.
 void closeHistory()
          Closes this history table, releasing resources allocated for its archive manager.
protected  java.lang.String getFileName(java.lang.String key)
          Gets the file name for the specified key.
protected static java.io.File getFileObjForStation(ParamValues paramValuesObj, Station stationObj)
          Returns a 'File' object set to the given station's directory location in the history archive.
 java.util.Vector getHistoryVector(long startTime, long endTime)
          Returns a new Vector containing 'ValueTimeBlock' objects with timestamps in the specified range.
protected static java.lang.String getKey(Station stationObj, DynamicParamHolder paramHolder, DynamicParameter dParameter)
          Gets the key for the specified station and dynamic parameter.
 ValueTimeBlock getNewestHistoryItem()
          Returns the newest item in the history.
static java.util.List getParamsListForStation(ParamValues paramValuesObj, Station stationObj, GroupTable agentsTable)
          Returns a list of dynamic parameters found in the given station's history archive.
protected  java.lang.String getRootDirName(java.lang.String key)
          Gets the root directory name for the specified key.
 boolean isHistoryEnabled()
          Determines if the history is enabled.
static boolean isStationHistoryAvail(ParamValues paramValuesObj, Station stationObj)
          Determines if history for the given station is available (based on whether or not a directory exists in the given station's location in the history archive).
 ArchivableData setupArchiveManager(DynamicParamHolder paramHolder, Station stationObj, DynamicParameter dParameter, long timeLastReceived)
          Sets up the archive manager for this table.
static void terminateArchiveWorkerThreads()
          Terminates the archive-worker threads for all parameter-history tables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_VALUE_SEPARATOR

public static final java.lang.String KEY_VALUE_SEPARATOR
Key value separator.

See Also:
Constant Field Values

ARCHIVE_FNAME_PRESTR

public static final java.lang.String ARCHIVE_FNAME_PRESTR
Archive file-name prefix.

See Also:
Constant Field Values

ARCHIVE_FNAME_SUFSTR

public static final java.lang.String ARCHIVE_FNAME_SUFSTR
Archive file-name suffix.

See Also:
Constant Field Values
Constructor Detail

ParamHistoryTable

public ParamHistoryTable(ParamValues paramValues,
                         ArchiveParameterFlag archiveParameterFlag)
Constructs a history table.

Parameters:
paramValues - the parameter values.
archiveParameterFlag - the archive-parameter flag.

ParamHistoryTable

public ParamHistoryTable(ParamValues paramValues)
Constructs a history table.

Parameters:
paramValues - the parameter values.
Method Detail

getRootDirName

protected java.lang.String getRootDirName(java.lang.String key)
Gets the root directory name for the specified key.

Parameters:
key - the key.
Returns:
the root directory name for the specified key.

getFileName

protected java.lang.String getFileName(java.lang.String key)
Gets the file name for the specified key.

Parameters:
key - the key.
Returns:
the file name for the specified key.

addKey

protected static java.lang.String addKey(java.lang.String key,
                                         java.lang.String str)
Adds the specified string to the key.

Parameters:
key - the current value of the key.
str - the string to add.
Returns:
the updated value of the key.

getKey

protected static java.lang.String getKey(Station stationObj,
                                         DynamicParamHolder paramHolder,
                                         DynamicParameter dParameter)
Gets the key for the specified station and dynamic parameter. The key is safe to use as a filename.

Parameters:
stationObj - the station object.
paramHolder - the parameter holder.
dParameter - the dynamic parameter.
Returns:
the key.

add

public void add(DynamicParamHolder paramHolder,
                Station stationObj,
                DynamicParameter dParameter,
                long timeLastChanged,
                long timeLastReceived,
                long minTime)
Adds the item to the history.

Specified by:
add in interface ParamHistory
Parameters:
paramHolder - the parameter holder.
stationObj - the station object.
dParameter - the dynamic parameter.
timeLastChanged - the time last changed (seconds since 1/1/1970).
timeLastReceived - the time last received (seconds since 1/1/1970).
minTime - the minimum time (seconds since 1/1/1970).

setupArchiveManager

public ArchivableData setupArchiveManager(DynamicParamHolder paramHolder,
                                          Station stationObj,
                                          DynamicParameter dParameter,
                                          long timeLastReceived)
Sets up the archive manager for this table.

Specified by:
setupArchiveManager in interface ParamHistory
Parameters:
paramHolder - the parameter holder.
stationObj - the station object.
dParameter - the dynamic parameter.
timeLastReceived - the time last received (seconds since 1/1/1970).
Returns:
An 'ArchivableData' object created via the given parameter value, or null if an error occurred.

getHistoryVector

public java.util.Vector getHistoryVector(long startTime,
                                         long endTime)
Returns 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".

Specified by:
getHistoryVector in interface ParamHistory
Parameters:
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, an empty Vector if no matching objects were found, or null if no history objects are available.

getNewestHistoryItem

public ValueTimeBlock getNewestHistoryItem()
Returns the newest item in the history.

Specified by:
getNewestHistoryItem in interface ParamHistory
Returns:
A 'ValueTimeBlock' object representing the newest item in the history, or null if no history objects are available.

isHistoryEnabled

public boolean isHistoryEnabled()
Determines if the history is enabled.

Specified by:
isHistoryEnabled in interface ParamHistory
Returns:
true if enabled, false otherwise.

closeHistory

public void closeHistory()
Closes this history table, releasing resources allocated for its archive manager.

Specified by:
closeHistory in interface ParamHistory

terminateArchiveWorkerThreads

public static void terminateArchiveWorkerThreads()
Terminates the archive-worker threads for all parameter-history tables.


getFileObjForStation

protected static java.io.File getFileObjForStation(ParamValues paramValuesObj,
                                                   Station stationObj)
Returns a 'File' object set to the given station's directory location in the history archive.

Parameters:
paramValuesObj - object that implements the parameter-values interface.
stationObj - station object for target station.
Returns:
A new 'File' object set to the given station's directory location in the history archive.

getParamsListForStation

public static java.util.List getParamsListForStation(ParamValues paramValuesObj,
                                                     Station stationObj,
                                                     GroupTable agentsTable)
Returns a list of dynamic parameters found in the given station's history archive. The station's status ("Performance") and usage-level parameters are not included. The given agents-table object will be used to fetch/append the agent objects specified in the parameter entries.

Parameters:
paramValuesObj - object that implements the parameter-values interface.
stationObj - station object for target station.
agentsTable - table of agent objects to use.
Returns:
A list of 'DynamicParamHolder' objects, one for each dynamic parameter found in the station's history archive.

isStationHistoryAvail

public static boolean isStationHistoryAvail(ParamValues paramValuesObj,
                                            Station stationObj)
Determines if history for the given station is available (based on whether or not a directory exists in the given station's location in the history archive).

Parameters:
paramValuesObj - object that implements the parameter-values interface.
stationObj - station object for target station.
Returns:
true if history for the given station is available; false if not.