Class DataflowActorInterpreter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected caltrop.interpreter.ast.Actor actor  
      protected caltrop.interpreter.environment.Environment actorEnv  
      protected caltrop.interpreter.Context context  
      protected caltrop.interpreter.environment.Environment env  
      protected caltrop.interpreter.ast.Action envAction  
      protected java.util.Map inputPortMap  
    • Constructor Summary

      Constructors 
      Constructor Description
      DataflowActorInterpreter​(caltrop.interpreter.ast.Actor actor, caltrop.interpreter.Context context, caltrop.interpreter.environment.Environment actorEnv, java.util.Map inputPortMap, java.util.Map outputPortMap)
      Defines a new actor interpreter for the specified actor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionClear()
      Clear action selection.
      void actionComputeOutputs()
      Compute the output tokens and send them to the specified (at construction time) output channels.
      boolean actionEvaluatePrecondition()
      Evaluate the preconditions for the action and return its result.
      void actionSetup​(caltrop.interpreter.ast.Action action)
      Set up the local environment of the specified action.
      void actionStep()
      Execute the action body, potentially changing the value of actor state variables and action-scope variables.
      caltrop.interpreter.ast.Action currentAction()
      Return the current action.
      int nActions()
      Return the number of actions in this actor.
      int nInitializers()
      Return the number of initializers in this actor.
      void setOutputPortMap​(java.util.Map outputPortMap)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • actor

        protected caltrop.interpreter.ast.Actor actor
      • context

        protected caltrop.interpreter.Context context
      • actorEnv

        protected caltrop.interpreter.environment.Environment actorEnv
      • env

        protected caltrop.interpreter.environment.Environment env
      • envAction

        protected caltrop.interpreter.ast.Action envAction
      • inputPortMap

        protected java.util.Map inputPortMap
    • Constructor Detail

      • DataflowActorInterpreter

        public DataflowActorInterpreter​(caltrop.interpreter.ast.Actor actor,
                                        caltrop.interpreter.Context context,
                                        caltrop.interpreter.environment.Environment actorEnv,
                                        java.util.Map inputPortMap,
                                        java.util.Map outputPortMap)
        Defines a new actor interpreter for the specified actor.
        Parameters:
        actor - The actor.
        context - The interpretation context.
        actorEnv - The global environment.
        inputPortMap - Map from input port names to channels.
        outputPortMap - Map from output port names to channels.
        See Also:
        InputChannel, OutputChannel
    • Method Detail

      • actionSetup

        public void actionSetup​(caltrop.interpreter.ast.Action action)
        Set up the local environment of the specified action. This method is the only way a new action may be set up for execution. If completed successfully, the action environment and the action are stored in the state of this interpreter, and other methods may operate on them.
        Parameters:
        action - The action to setup.
      • actionEvaluatePrecondition

        public boolean actionEvaluatePrecondition()
        Evaluate the preconditions for the action and return its result. If this method returns false, some condition required for the successful completion of the action is not satisfied. This might be an insufficient number of input tokens, or some other condition depending on the value of the tokens or state variables.

        Note that the converse need not hold---depending on the model of computation, a true return value does not necessarily imply that the action will successfully execute. It may represent an approximation to a complete precondition, in which case the model of computation is not responsible.

        Returns:
        True, if the action precondition was satisfied.
        Throws:
        caltrop.interpreter.InterpreterException - If the evaluation of the guards could not be successfully completed.
      • actionStep

        public void actionStep()
        Execute the action body, potentially changing the value of actor state variables and action-scope variables.
        Throws:
        caltrop.interpreter.InterpreterException - If the action body could not be executed successfully.
      • actionComputeOutputs

        public void actionComputeOutputs()
        Compute the output tokens and send them to the specified (at construction time) output channels.
        See Also:
        DataflowActorInterpreter
      • actionClear

        public void actionClear()
        Clear action selection. The reference to the environment is cleared, too, allowing the system to reclaim any resources associated with it.
      • currentAction

        public caltrop.interpreter.ast.Action currentAction()
        Return the current action. This is null if none has been selected.
        Returns:
        The current action, null if none.
      • nActions

        public int nActions()
        Return the number of actions in this actor.
        Returns:
        Number of actions.
      • nInitializers

        public int nInitializers()
        Return the number of initializers in this actor.
        Returns:
        Number of initializers.
      • setOutputPortMap

        public void setOutputPortMap​(java.util.Map outputPortMap)