The Meta-Environment API

toolbus.atom
Class Atom

java.lang.Object
  extended by toolbus.process.ProcessExpression
      extended by toolbus.atom.Atom
All Implemented Interfaces:
StateElement
Direct Known Subclasses:
AckEvent, Assign, Connect, Create, Delta, DisConnect, Do, Eval, Event, Execute, GetPerfStats, MsgAtom, NoNote, Print, RecNote, RecPerfStats, RecRequest, RecVal, ShutDown, SndKill, SndNote, SndResponse, Subscribe, Tau, Terminate, UnSubscribe

public abstract class Atom
extends ProcessExpression
implements StateElement

The class Atom forms the basic building block of Tscripts. Instances of Atom are both the most primitive elements of process expressions and the elements of the states to which process exprssions are being compiled.


Nested Class Summary
private static class Atom.EmptyProcessInstanceArrayHolder
          This class holds static reference to an empty process instance array, which can be used as return value in the debugExecute method.
private static class Atom.Test
          This class represents a test associated with an atom.
 
Field Summary
private  long activateTime
           
private  Ref[] atomArgs
           
private  int delay
           
private  long enabledTime
           
private  Environment env
           
protected  java.lang.String externalNameAsReceivedByTool
           
private static java.lang.String MSECS
           
private static Ref[] NOATOMARGS
           
private  ProcessInstance processInstance
           
private static java.lang.String SECS
           
private  java.util.List<Atom.Test> tests
           
private  boolean timeExpr
           
private  int timeout
           
private  long timeoutTime
           
 
Fields inherited from class toolbus.process.ProcessExpression
posInfo, tbfactory
 
Constructor Summary
Atom(TBTermFactory tbfactory, PositionInformation posInfo)
           
 
Method Summary
 void activate()
          Activate the StateElement, i.e.
 void compile(ProcessInstance pi, java.util.Stack<java.lang.String> calls, State follow)
           
 void computeFirst()
           
 boolean contains(StateElement b)
          Check whether a StateElement contains another StateElement.
 void copyAtomAttributes(Atom a)
           
 ProcessInstance[] debugExecute()
          Executes the state element in debug mode.
 void destroy()
           
 aterm.ATerm getAtomArgValue(int i)
           
 AtomList getAtoms()
           
 int getDelay()
           
 Environment getEnv()
           
 ProcessInstance getProcess()
           
 java.util.List<aterm.ATerm> getTests()
          Returns a collection containing all tests that are associated with this state element.
 int getTimeout()
           
 ToolBus getToolBus()
           
 State gotoNextStateAndActivate()
           
 State gotoNextStateAndActivate(StateElement b)
          Get the successor of the StateElement for a given other StateElement elem.
 boolean isEnabled()
          Is this StateElelement enabled for execution, i.e., are its associated tests all true? If enabled, the StateElement is ready for execution.
 void replaceFormals(Environment e)
           
 void setAbsoluteDelay(aterm.ATermList delay)
           
 void setAbsoluteTimeout(aterm.ATermList timeout)
           
 void setAtomArgs(Ref[] refs)
           
 void setDelay(aterm.ATerm delay)
           
protected  void setEnv(Environment env)
           
 void setTest(aterm.ATerm test, Environment e)
          Add a test to this state element.
 void setTimeout(aterm.ATerm timeout)
           
private  java.lang.String shortName()
           
 aterm.ATermAppl toATerm()
           
 java.lang.String toString()
           
 
Methods inherited from class toolbus.process.ProcessExpression
addToFirst, addToFollow, copy, getFirst, getFollow, getPosInfo, setFirst, setFollow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface toolbus.StateElement
execute, getFollow, getPosInfo
 

Field Detail

SECS

private static final java.lang.String SECS
See Also:
Constant Field Values

MSECS

private static final java.lang.String MSECS
See Also:
Constant Field Values

NOATOMARGS

private static final Ref[] NOATOMARGS

processInstance

private ProcessInstance processInstance

env

private Environment env

tests

private java.util.List<Atom.Test> tests

atomArgs

private Ref[] atomArgs

delay

private int delay

timeout

private int timeout

timeExpr

private boolean timeExpr

activateTime

private long activateTime

enabledTime

private long enabledTime

timeoutTime

private long timeoutTime

externalNameAsReceivedByTool

protected java.lang.String externalNameAsReceivedByTool
Constructor Detail

Atom

public Atom(TBTermFactory tbfactory,
            PositionInformation posInfo)
Method Detail

destroy

public void destroy()

setAtomArgs

public void setAtomArgs(Ref[] refs)

getAtomArgValue

public aterm.ATerm getAtomArgValue(int i)

copyAtomAttributes

public void copyAtomAttributes(Atom a)

setEnv

protected void setEnv(Environment env)

getEnv

public Environment getEnv()

setTest

public void setTest(aterm.ATerm test,
                    Environment e)
             throws ToolBusException
Description copied from interface: StateElement
Add a test to this state element. Tests implement conditionals but not delays / timeouts.

Specified by:
setTest in interface StateElement
e - to be used for executing the test
Throws:
ToolBusException

getTests

public java.util.List<aterm.ATerm> getTests()
Description copied from interface: StateElement
Returns a collection containing all tests that are associated with this state element.

Specified by:
getTests in interface StateElement
Returns:
A collection containing all tests that are associated with this state element.

setDelay

public void setDelay(aterm.ATerm delay)

setAbsoluteDelay

public void setAbsoluteDelay(aterm.ATermList delay)

getDelay

public int getDelay()

setTimeout

public void setTimeout(aterm.ATerm timeout)

setAbsoluteTimeout

public void setAbsoluteTimeout(aterm.ATermList timeout)

getTimeout

public int getTimeout()

getToolBus

public ToolBus getToolBus()

getAtoms

public AtomList getAtoms()
Specified by:
getAtoms in class ProcessExpression

shortName

private java.lang.String shortName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toATerm

public aterm.ATermAppl toATerm()

computeFirst

public void computeFirst()
Specified by:
computeFirst in class ProcessExpression

replaceFormals

public void replaceFormals(Environment e)
                    throws ToolBusException
Specified by:
replaceFormals in class ProcessExpression
Throws:
ToolBusException

compile

public void compile(ProcessInstance pi,
                    java.util.Stack<java.lang.String> calls,
                    State follow)
             throws ToolBusException
Specified by:
compile in class ProcessExpression
Throws:
ToolBusException

isEnabled

public boolean isEnabled()
                  throws ToolBusException
Description copied from interface: StateElement
Is this StateElelement enabled for execution, i.e., are its associated tests all true? If enabled, the StateElement is ready for execution.

Specified by:
isEnabled in interface StateElement
Returns:
true (enabled) or false (not enabled).
Throws:
ToolBusException

contains

public boolean contains(StateElement b)
Description copied from interface: StateElement
Check whether a StateElement contains another StateElement. In the simplest case of Atom this is just an identity test. In composite cases (e.g. Merge), it requires a recursive search.

Specified by:
contains in interface StateElement
Parameters:
b - the StateElement
Returns:
true (contained in) or false (not contained in)

getProcess

public ProcessInstance getProcess()
Specified by:
getProcess in interface StateElement
Returns:
the ProcessInstance to which the StateElement belongs

gotoNextStateAndActivate

public State gotoNextStateAndActivate()
Specified by:
gotoNextStateAndActivate in interface StateElement
Returns:
the successor State of the StateElement

gotoNextStateAndActivate

public State gotoNextStateAndActivate(StateElement b)
Description copied from interface: StateElement
Get the successor of the StateElement for a given other StateElement elem. This typically used for a composite StateElement to get a specific successor. TODO: Probably this method should be combined with the previous one.

Specified by:
gotoNextStateAndActivate in interface StateElement
Returns:
the successor State of the StateElement

activate

public void activate()
Description copied from interface: StateElement
Activate the StateElement, i.e. make it ready for execution. This may involve initialization and the setting of timers.

Specified by:
activate in interface StateElement

debugExecute

public ProcessInstance[] debugExecute()
                               throws ToolBusException
Description copied from interface: StateElement
Executes the state element in debug mode.

Specified by:
debugExecute in interface StateElement
Returns:
The collection of partners that cooperated with the execution of the state element. Null if the execution did not complete.
Throws:
ToolBusException

The Meta-Environment API