Package astra.lang
Class System
- java.lang.Object
-
- astra.core.Module
-
- astra.lang.System
-
public class System extends Module
The System API contains a number of actions, terms and formulae that help you to manage the operation of the overall multi-agent system.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class astra.core.Module
Module.ACTION, Module.EVENT, Module.FORMULA, Module.SENSOR, Module.SUPPRESS_NOTIFICATIONS, Module.TERM
-
-
Constructor Summary
Constructors Constructor Description System()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEvent(Event event)booleanaddRule(Rule rule)FormulaagentExists(String name)Formula that returns true if the agent exists, false otherwise.ListTermagentRules()booleancreateAgent(String name, String clazz)Action that allows the agent to create another agent.longcurrentTimeMillis()Term that returns the current time in millisecond (delegates to theSystemclass)AgentStatedeconstruct(String name)Term that captures the current state of the specified agent through serialisation of its beliefs and stores that state in anAgentStateobject.booleandisplayTimings()Displays the agent timings tableStringenv(String variable)booleanexit()Action that causes the platform to stopbooleanfail()Action that fails.ListTermgetAgents()Term that returns a list of all the agents on the platform.ListTermgetAgentsOfType(String type)Term that returns a list of all the agents on the platformListTermgetChildren()Term that returns a list of all the agents on that are children of the invoking agentStringgetNameFromState(AgentState state)Term that extracts the name of the agent from anAgentStateobject.StringgetOwner()Term that returns a list of all the agents on that are children of the invoking agentStringgetType()Term that returns the type of the agent.StringgetType(String name)Term that returns the type of the agent with the given name.FormulahasChildren()Formula that returns true if the agent has children (i.e.FormulahasOwner()Formula that returns true if the agent has an owner, false otherwise (this will only return false for the "main" agent.FormulahasType(String type)Formula thet returns true if the given type is available on the agent platformStringname()Term that returns the name of the agent.booleanreconstruct(AgentState state)Action that recreates an agent based on the given state, which is passed in as an instance of theAgentStateclass.voidsetAgent(Agent agent)This internal method associates the agent with the module - this is overridden to store a reference to the agent in the agents mapbooleansetMainGoal(String name, ListTerm args)This method can be used to set the main goal of an agent.booleansetSchedulePoolSize(int size)booleansetSchedulingStrategy(String strategy)Action that allows you to set the scheduling strategy used by the agents...booleansetSleepTime(long time)Sets the sleep time for the scheduler.booleanskip()booleansleep(int time)Action that causes the agent to sleep for a specified period of timebooleanstep()booleanterminate()Action that allows the agent to terminate itself.booleanterminateAgent(String name)Action to terminate another agent (if it exists and the invoking agent is the owner of that agent).booleantrace(boolean trace)
-
-
-
Method Detail
-
skip
public boolean skip()
-
setAgent
public void setAgent(Agent agent)
This internal method associates the agent with the module - this is overridden to store a reference to the agent in the agents map
-
fail
public boolean fail()
Action that fails.- Returns:
- false
-
terminate
public boolean terminate()
Action that allows the agent to terminate itself.- Returns:
- true if the action succeeds, false otherwise
-
createAgent
public boolean createAgent(String name, String clazz)
Action that allows the agent to create another agent.- Parameters:
name- the name of the agent to be createdclazz- the class of the agent (an ASTRA class)- Returns:
- true if the action succeeds, false otherwise
-
setMainGoal
public boolean setMainGoal(String name, ListTerm args)
This method can be used to set the main goal of an agent. It has been added to support the basic debugger...- Parameters:
name- the name of the agentargs- the list of arguments to be passed with the goal- Returns:
- true if the action succeeds, false otherwise
-
terminateAgent
public boolean terminateAgent(String name)
Action to terminate another agent (if it exists and the invoking agent is the owner of that agent).- Parameters:
name- the name of the agent to be terminated- Returns:
- true if the action succeeds, false otherwise
-
getAgents
public ListTerm getAgents()
Term that returns a list of all the agents on the platform.- Returns:
- an ASTRA list containing the names of all agents on the platform
-
getType
public String getType()
Term that returns the type of the agent.- Returns:
- the type of the agent
-
addEvent
public boolean addEvent(Event event)
-
addRule
public boolean addRule(Rule rule)
-
agentRules
public ListTerm agentRules()
-
getType
public String getType(String name)
Term that returns the type of the agent with the given name.- Parameters:
name- the name of the agent- Returns:
- the type of the agent with the given name
-
getAgentsOfType
public ListTerm getAgentsOfType(String type)
Term that returns a list of all the agents on the platform- Parameters:
type- the agent type- Returns:
- an ASTRA list containing the names of all agents on the platform
-
getChildren
public ListTerm getChildren()
Term that returns a list of all the agents on that are children of the invoking agent- Returns:
- an ASTRA list containing the names of all agents on the platform
-
getOwner
public String getOwner()
Term that returns a list of all the agents on that are children of the invoking agent- Returns:
- an ASTRA list containing the names of all agents on the platform
-
hasType
public Formula hasType(String type)
Formula thet returns true if the given type is available on the agent platform- Parameters:
type- the agent type- Returns:
- the formula TRUE if the type exists on the agent platform, the formula FALSE otherwise
-
hasChildren
public Formula hasChildren()
Formula that returns true if the agent has children (i.e. it has created other agents), false otherwise.- Returns:
- the formula TRUE if the agent has children, the formula FALSE otherwise
-
hasOwner
public Formula hasOwner()
Formula that returns true if the agent has an owner, false otherwise (this will only return false for the "main" agent.- Returns:
- the formula TRUE if the agent has an owner, the formula FALSE otherwise
-
exit
public boolean exit()
Action that causes the platform to stop- Returns:
- true if the action succeeds, false otherwise
-
sleep
public boolean sleep(int time)
Action that causes the agent to sleep for a specified period of time- Parameters:
time- the sleep time in milliseconds- Returns:
- true if the action succeeds, false otherwise
-
name
public String name()
Term that returns the name of the agent.- Returns:
- the name of the agent
-
setSchedulePoolSize
public boolean setSchedulePoolSize(int size)
-
setSchedulingStrategy
public boolean setSchedulingStrategy(String strategy)
Action that allows you to set the scheduling strategy used by the agents...- Parameters:
strategy- a fully qualifiedSchedulerStrategyclass name- Returns:
- true if the action succeeds, false otherwise
-
currentTimeMillis
public long currentTimeMillis()
Term that returns the current time in millisecond (delegates to theSystemclass)- Returns:
- the current time in milliseconds
-
agentExists
public Formula agentExists(String name)
Formula that returns true if the agent exists, false otherwise.- Parameters:
name- the name of the agent being checked- Returns:
- the formula TRUE if the agent exists, FALSE otherwise
-
deconstruct
public AgentState deconstruct(String name)
Term that captures the current state of the specified agent through serialisation of its beliefs and stores that state in anAgentStateobject.- Parameters:
name- the name of the agent whose state is to be captured.- Returns:
- an object representing the state of the agent
-
reconstruct
public boolean reconstruct(AgentState state)
Action that recreates an agent based on the given state, which is passed in as an instance of theAgentStateclass.- Parameters:
state- the state of the agent to be recreated.- Returns:
- true if the action succeeeds, false otherwise
-
getNameFromState
public String getNameFromState(AgentState state)
Term that extracts the name of the agent from anAgentStateobject.- Parameters:
state- an agent state- Returns:
- the name of the agent as recorded in the state representation
-
setSleepTime
public boolean setSleepTime(long time)
Sets the sleep time for the scheduler.- Parameters:
time- a duration in milliseconds (ms)- Returns:
- true if the action succeeeds, false otherwise
-
displayTimings
public boolean displayTimings()
Displays the agent timings table- Returns:
- true if the action succeeds, false otherwise
-
trace
public boolean trace(boolean trace)
-
step
public boolean step()
-
-