utils
Class Conveyor
java.lang.Object
utils.Conveyor
public class Conveyor
- extends java.lang.Object
The "Conveyor"-class is a class made to start up all the agents.
Conveyor is made in a very general way to make it easier to use this class in connection with other MAS projects.
Conveyor reads all its instructions from a settings-file.
This settings-file decides which agents should be started and how many should be started of each type, and their priority.
In addition the settings-file contains a list of names for input-variables and output-variables for each agent.
If a variable-name has not been used before, that variable is created and sent to the agent.
When a variable-name has been used before, a reference to that same variable is sent to the agent.
That means that agents called by Conveyor does not have to know of each other's existance.
All they know is that they receive certain input and output variables and they use them as they are supposed to.
Where the messages go and what is done with them is totally up to Conveyor and the rest of the agents.
Conveyor has the following important variables:
"data" - This is a variable that contains all the variables that are used by the agents to send and receive information between themselves.
Since the variables that the agents use are Vectors with DataPackages, then since it is not known how many such variables are needed,
the resulting structure of "data" is Vector>.
This makes sure that it is possible with an unknown number of variables with an unknown number of elements in each.
"index" - This is variable that contains the names of all the variables in "data", so that a name can be linked to the corresponding variable.
"agents" - Is a Vector of Threads. This variable contains all the Threads of the agents.
"finished" - Is a boolean variable, and it is a global static variable that is intended to act as a signal to all agents when they are supposed to finish.
All agents are recommended to check this variable now and then to figure out when to stop.
"agentSettings" - Is a String that stores the location of the settingsfile for Conveyor.
The location for the settingsfile is sent in with the constructor for Conveyor.
This means that you can refer to different settings-files or that you can make some part of the program write the file before sending a reference.
- Author:
- Håvard Rykkelid
Field Summary |
private java.util.Vector<java.lang.Thread> |
agents
|
private java.lang.String |
agentSettings
|
private static java.util.Vector<java.util.Vector<DataPackage>> |
data
|
static boolean |
finished
|
private static java.util.Vector<java.lang.String> |
index
|
Constructor Summary |
Conveyor(java.lang.String agentSettings)
The constructor |
Method Summary |
static java.util.Vector<DataPackage> |
getVectorWithName(java.lang.String name)
This is a method that should only be called after there has been made an instance of Conveyor. |
void |
resetAllData()
A method to reset the system for a new search. |
void |
setAgentSettings(java.lang.String agentSettings)
A method to change the stored location of the settings-file |
void |
start()
This method signals that all the agents should be started and set to work. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
data
private static java.util.Vector<java.util.Vector<DataPackage>> data
finished
public static boolean finished
index
private static java.util.Vector<java.lang.String> index
agents
private java.util.Vector<java.lang.Thread> agents
agentSettings
private java.lang.String agentSettings
Conveyor
public Conveyor(java.lang.String agentSettings)
- The constructor
- Parameters:
agentSettings
- - the filename for the settings that are to be used
setAgentSettings
public void setAgentSettings(java.lang.String agentSettings)
- A method to change the stored location of the settings-file
- Parameters:
agentSettings
- - the filename for the settings that are to be used
resetAllData
public void resetAllData()
- A method to reset the system for a new search.
This method refers to the previously stored name of the settings-file.
getVectorWithName
public static java.util.Vector<DataPackage> getVectorWithName(java.lang.String name)
- This is a method that should only be called after there has been made an instance of Conveyor.
This method will receive a variable-name. It will then check if that name has allready been decleared.
If the name has allready been declared, then this method will return the corresponding variable.
If the name has not been declared, it will now be declared and a new variable will be created, before that variable is returned.
This makes sure that after there has been made an instance of Conveyor you can always send in a name to this method.
This method will then always return a variable, either the corresponding or a new one which then will have that name.
- Parameters:
name
- - the name of the variable you want returned
- Returns:
- a Vector variable with the same name as you sent in
start
public void start()
- This method signals that all the agents should be started and set to work.