com.isti.trinetwatch.collectionAgentSim
Class CollectionAgentSim

java.lang.Object
  extended bycom.isti.trinetwatch.collectionAgentSim.CollectionAgentSim

public class CollectionAgentSim
extends java.lang.Object

CollectionAgentSim is a collection agent simulator to be used in conjunction with the SeisNetWatch NSI Server for testing and as an example of what the SeisNetWatch system is capable of.


Command Line Options

-c, --configFile [path] : The file to use as the configuration file for the Collection Agent. The default file is [baseDir]/conf/CASim.conf
-b, --baseDir [path] : The base directory into which the different program files, configuration files and log files are placed. The directories are [baseDir}/bin, [baseDir]/conf, and [baseDir]/log. Any program executables are place in 'bin', configuration files are placed in 'conf', and any log files are placed in 'log'. The default base directory is '/usr/local/SeisNetWatch'.
-d, --daemon : puts the CASim in daemon mode (run forever). Default is to accept a terminate command on the keyboard to shutdown.
-l, --globalLogFileName [file] : The Collection Agent Sim logs much information. It is all put into a single global log file. The default name of the file is "CASim.log" and it is placed in the directory '[baseDir]/log/'. The option accepts absolute paths, relative paths or just the file name.
-o, --logfileLogLevel [level] :There are six (6) different levels at which logging can be done. They are: 'NO_MSGS', 'INFO', 'WARNING', 'ERROR', 'DEBUG', and 'ALL_MSGS'. One of these must be used as the argument. The default level is ERROR.
-O, --consoleLogLevel [level] : Log messages are also printed to the terminal. This switch tells the Control Agent what level of messages to print to the console. The levels are the same as for logfileLogLevel. The default level is ERROR.
-C, --caSimStationsFileName [file] : The CASimStations file is a file which holds information about how the Collection Agent will treat requests for usage level changes for different stations. The switch accepts absolute paths, relative paths, or just the file name. The default location of this file is '[baseDir]/conf/CASimStations.ini'.
-ORBconfig [file] : The orb.conf file is needed to correctly set up CORBA communications. The switch accepts absolute paths, relative paths, or just the file name. The default location of this file is '[baseDir]/conf/orb.config'.
-n, --caSimName {name_of_server] : This is where the name of the Collection Agent is entered. The default value is an empty string.
-s, --sendIDFlag : Flag set true to have the agent send "ID_MSG" messages to the NSI server. The default value is true.
-f, --fastModeFlag : Flag set true to have the agent send dynamic parameters at a greatly increased pace (for testing). The default value is false.


The CASim.conf file

All the options the user can change on the command line can also be changed in the file 'CASim.conf', except for the option to specify where the file is. The format of the file goes like this: Each item has the format 'name = value'; string values must be enclosed in double quotes (""); 'special' characters must be 'quoted' using a backslash (\), including \n \r \t\ \" \#; and comments begin with '#', '//' or are C-style comments. Following is a list of the configurable parameters which can be specified in this file. They mirror the command line switches and use the same values.

     baseDir = "[path]"
     globalLogFileName = "[filename]"
     logfileLogLevel = "[level]"
     consoleLogLevel = "[level]"
     caSimStationsFileName = "[filename]"
     orbConfig = "[filename]"
     caSimName = "{serverName}"
     daemon = 'true or false'
     sendIDFlag = 'true or false'
     fastModeFlag = 'true or false'
 



Field Summary
static java.lang.String ACK_CA_MSG
           
static java.lang.String[] ID_MSG_STRARR
           
static java.lang.String TERM_ALL_MSG
           
static java.lang.String TERM_CA_MSG
           
 
Constructor Summary
CollectionAgentSim(LogFile log, CfgProperties cfgPropObj)
          Creates a new object instance of CollectionAgentSim.
 
Method Summary
 java.lang.String agentName()
          Returns the name of this agent.
 void createNewStation()
          Creates new dynamically created station.
static java.lang.String doesFileExist(java.lang.String fileName)
          This method checks to see if the file 'fileName' exists.
static java.lang.String doesFileExist(java.lang.String fileName, java.lang.String baseDir, java.lang.String specialDir)
          This method checks to see if the given file exists.
 boolean getFastModeFlag()
          Returns true if the agent is in "fast" mode.
 java.lang.String getOrbCfgFilePath()
          Returns the path to the orb configuration file.
 boolean getSendIDFlag()
          Returns true if the agent is to send "ID_MSG" messages.
 StationTable getStationsTable()
          Returns a handle to the stations table.
static java.lang.String getVersion()
          Returns the version of this agent.
 boolean initCORBAservices(java.lang.String[] args, boolean daemonFlag)
          Initializes CORBA services and connects to the CORBA event channels.
static void main(java.lang.String[] args)
          The method executed to begin the simulated collection agent.
static int propLogLevel(CfgPropItem tmpProp)
          This method looks at the string value of the given property item and returns the integer for the loging level that string represents.
 boolean readConfigFiles(java.lang.String collectFileName)
          Reads in the necessary configuration file(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_MSG_STRARR

public static final java.lang.String[] ID_MSG_STRARR

TERM_ALL_MSG

public static final java.lang.String TERM_ALL_MSG
See Also:
Constant Field Values

TERM_CA_MSG

public static final java.lang.String TERM_CA_MSG
See Also:
Constant Field Values

ACK_CA_MSG

public static final java.lang.String ACK_CA_MSG
See Also:
Constant Field Values
Constructor Detail

CollectionAgentSim

public CollectionAgentSim(LogFile log,
                          CfgProperties cfgPropObj)
Creates a new object instance of CollectionAgentSim.

Parameters:
log - a log file object.
cfgPropObj - an object containing the configuration properties for this collection agent sim.
Method Detail

readConfigFiles

public boolean readConfigFiles(java.lang.String collectFileName)
Reads in the necessary configuration file(s). There is one configuration file needed, 'CASimStations.ini'.

Returns:
true if the file is successfully read in; false if error.

initCORBAservices

public boolean initCORBAservices(java.lang.String[] args,
                                 boolean daemonFlag)
Initializes CORBA services and connects to the CORBA event channels.

Parameters:
args - array of command line argument strings.
Returns:
true if successful, false if error.

getStationsTable

public StationTable getStationsTable()
Returns a handle to the stations table.

Returns:
A handle to an object of type StationTable

getOrbCfgFilePath

public java.lang.String getOrbCfgFilePath()
Returns the path to the orb configuration file.


agentName

public java.lang.String agentName()
Returns the name of this agent.


getSendIDFlag

public boolean getSendIDFlag()
Returns true if the agent is to send "ID_MSG" messages.


getFastModeFlag

public boolean getFastModeFlag()
Returns true if the agent is in "fast" mode.


createNewStation

public void createNewStation()
Creates new dynamically created station.


getVersion

public static java.lang.String getVersion()
Returns the version of this agent.

Returns:
A string holding the version number.

propLogLevel

public static int propLogLevel(CfgPropItem tmpProp)
This method looks at the string value of the given property item and returns the integer for the loging level that string represents.

Parameters:
tmpProp - A CfgPropItem who's string value data represents a logging level.
Returns:
The integer of the log level asscoiated with the string value in the configuration property.

doesFileExist

public static java.lang.String doesFileExist(java.lang.String fileName)
This method checks to see if the file 'fileName' exists. 'fileName' can be either a relative path or a full bath to the file.

Parameters:
fileName - The relative path or full path to a file.
Returns:
If the file was found the path (relative or full) to the file is returned, otherwise an empty string is returned.

doesFileExist

public static java.lang.String doesFileExist(java.lang.String fileName,
                                             java.lang.String baseDir,
                                             java.lang.String specialDir)
This method checks to see if the given file exists. The order of searching goes like this:
1) use just 'fileName' to search for file existence in the current directory (can be a sub-directory path) or from the root directory as a full pathname (must begin with a '/').
2) if searching for 'fileName' fails to find an existing file then the path '[baseDir][specialDir][fileName]' is used to attempt to find an existing file.
If there is no file found by this procedure then an empty string is returned.

Parameters:
fileName - The relative path or full path to a file.
baseDir - A base directory to fall back upon if 'fileName' is a relative path and does not point directly to a file somewhere in the current directory.
specialDir - The special (sub) directory of [baseDir] in which the file should reside. It can be either 'bin', 'conf', or 'log'.
Returns:
If the file was found the path (relative or full) to the file is returned, otherwise an empty string is returned.

main

public static void main(java.lang.String[] args)
The method executed to begin the simulated collection agent.