de.xabsl.jxabsl.engine
Class Engine

java.lang.Object
  extended by de.xabsl.jxabsl.engine.Symbols
      extended by de.xabsl.jxabsl.engine.Engine
Direct Known Subclasses:
ReflectionEngine

public class Engine
extends Symbols

Executes a behavior that was specified in the Xabsl language.


Field Summary
 
Fields inherited from class de.xabsl.jxabsl.engine.Symbols
debug
 
Constructor Summary
Engine(DebugMessages debug, TimeFunction timeFunction)
          Constructor
 
Method Summary
 void createOptionGraph(InputSource input)
          Reads the intermediate code from an input source and creates the option graph.
 void execute()
          Executes the engine for the selected agent starting from the root option.
 java.util.LinkedHashMap<java.lang.String,Agent> getAgents()
           
 BasicBehavior getBasicBehavior(java.lang.String name, java.util.Set<java.lang.String> decimalParameterNames, java.util.Set<java.lang.String> booleanParameterNames, java.util.Set<java.lang.String> enumeratedParameterNames)
          Returns the registered basic behavior given by a name and a set of parameter names
 java.util.LinkedHashMap<java.lang.String,BasicBehavior> getBasicBehaviors()
          For debugging.
 java.util.LinkedHashMap<java.lang.String,Option> getOptions()
           
 ActionBehavior getRootAction()
          Returns the selected root action
 Option getRootOption()
          Returns the selected root option, return 0 if root action is not an option
 java.lang.String getSelectedAgentName()
          Returns the name of the selected agent
 void registerBasicBehavior(BasicBehavior basicBehavior)
          Registers a basic behavior at the engine.
 void reset()
          Resets all active options.
 void setRootAction()
          Sets the root option of the selected agent
 void setRootAction(Behavior behavior)
          Sets the root option to the specified option or basic behavior
 boolean setRootAction(java.lang.String name, boolean isOption)
          Executes the option graph starting from a given option or basic behavior.
 boolean setSelectedAgent(java.lang.String name)
          Sets the selected Agent.
 
Methods inherited from class de.xabsl.jxabsl.engine.Symbols
getBooleanInputSymbol, getBooleanInputSymbols, getBooleanOutputSymbol, getBooleanOutputSymbols, getDecimalInputSymbol, getDecimalInputSymbols, getDecimalOutputSymbol, getDecimalOutputSymbols, getEnumeratedInputSymbol, getEnumeratedInputSymbols, getEnumeratedOutputSymbol, getEnumeratedOutputSymbols, getEnumeration, getEnumerations, registerBooleanInputSymbol, registerBooleanOutputSymbol, registerDecimalInputSymbol, registerDecimalOutputSymbol, registerEnumeratedInputSymbol, registerEnumeratedOutputSymbol, registerEnumeration, registerInternalEnumElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Engine

public Engine(DebugMessages debug,
              TimeFunction timeFunction)
Constructor

Parameters:
debug - Print debuggin information
timeFunction - A function that returns the system time in ms.
Method Detail

execute

public void execute()
Executes the engine for the selected agent starting from the root option. (Including the selected basic behavior)


createOptionGraph

public void createOptionGraph(InputSource input)
                       throws IntermediateCodeMalformedException
Reads the intermediate code from an input source and creates the option graph. Note that the basic behaviors and symbols have to be registered before this function is called.

Throws:
IntermediateCodeMalformedException

registerBasicBehavior

public void registerBasicBehavior(BasicBehavior basicBehavior)
Registers a basic behavior at the engine. This must be done before the intermediate code is read.

Parameters:
basicBehavior - A reference to the basic behavior

setRootAction

public boolean setRootAction(java.lang.String name,
                             boolean isOption)
Executes the option graph starting from a given option or basic behavior. Can be called to test a single option or basic behavior.

Parameters:
name - The name of the option or basic behavior
isOption - True for an option, false for a basic behavior
Returns:
When false, the option is not known to the engine

setRootAction

public void setRootAction()
Sets the root option of the selected agent


setRootAction

public void setRootAction(Behavior behavior)
Sets the root option to the specified option or basic behavior


getRootAction

public ActionBehavior getRootAction()
Returns the selected root action


getRootOption

public Option getRootOption()
Returns the selected root option, return 0 if root action is not an option


getSelectedAgentName

public java.lang.String getSelectedAgentName()
Returns the name of the selected agent


setSelectedAgent

public boolean setSelectedAgent(java.lang.String name)
Sets the selected Agent. If the last selected agent was different from the new one, the root option is changed depending on the new agent.

Parameters:
name - The name of the agent
Returns:
if the requested agent exists

reset

public void reset()
Resets all active options. Next cycle will execute initial state of currently set root option.


getBasicBehavior

public BasicBehavior getBasicBehavior(java.lang.String name,
                                      java.util.Set<java.lang.String> decimalParameterNames,
                                      java.util.Set<java.lang.String> booleanParameterNames,
                                      java.util.Set<java.lang.String> enumeratedParameterNames)
Returns the registered basic behavior given by a name and a set of parameter names


getBasicBehaviors

public java.util.LinkedHashMap<java.lang.String,BasicBehavior> getBasicBehaviors()
For debugging.

Returns:
All basic behaviors of the engine.

getOptions

public java.util.LinkedHashMap<java.lang.String,Option> getOptions()
Returns:
all options of the engine

getAgents

public java.util.LinkedHashMap<java.lang.String,Agent> getAgents()
Returns:
all agents of the engine