Class FSMActor

    • Field Detail

      • _scope

        protected FSMActor.PortScope _scope
        The scope to generate code for guard expression, choice action and commit action.
    • Method Detail

      • generateInitializeCode

        public java.lang.String generateInitializeCode()
                                                throws IllegalActionException
        Generate the initialize code of the associated FSMActor. It generates code for initializing current state with initial state, and initializing current configuration of the container when it applies (i.e., when this FSMActor works as a modal controller for a MultirateFSMDirector).
        Overrides:
        generateInitializeCode in class NamedProgramCodeGeneratorAdapter
        Returns:
        The initialize code of the associated FSMActor.
        Throws:
        IllegalActionException - If initial state cannot be found, configuration number cannot be updated or code cannot be processed.
      • generatePreinitializeCode

        public java.lang.String generatePreinitializeCode()
                                                   throws IllegalActionException
        Generate the preinitialize code of the associated FSMActor. It declares two variables for this actor: currentState and transitionFlag. currentState is an int representing this actor's current state. transitionFlag is an unsigned char to indicate if a preemptive transition is taken. It also defines a symbolic constant to each state.
        Overrides:
        generatePreinitializeCode in class NamedProgramCodeGeneratorAdapter
        Returns:
        The preinitialize code of the associated FSMActor.
        Throws:
        IllegalActionException - If thrown when creating buffer size and offset map or processing code.
      • generateTransitionCode

        public void generateTransitionCode​(java.lang.StringBuffer code,
                                           FSMActor.TransitionRetriever transitionRetriever)
                                    throws IllegalActionException
        Generate code for making transition. It generates code for both choice action and commit action.
        Parameters:
        code - The string buffer that the generated code is appended to.
        transitionRetriever - An instance of a class implementing a method. which returns an iterator of all, preemptive or non-preemptive transitions of the current state.
        Throws:
        IllegalActionException - If thrown while generating transition code.
      • _generateFireCode

        protected java.lang.String _generateFireCode()
                                              throws IllegalActionException
        Generate the fire code of the associated FSMActor. It provides generateTransitionCode(StringBuffer, TransitionRetriever) with an anonymous class implementing a method which returns an iterator of all outgoing transitions of the current state.
        Overrides:
        _generateFireCode in class NamedProgramCodeGeneratorAdapter
        Returns:
        The generated fire code.
        Throws:
        IllegalActionException - If thrown while generating firing code.
      • _updateCurrentState

        protected void _updateCurrentState​(java.lang.StringBuffer codeBuffer,
                                           State state)
                                    throws IllegalActionException
        Generate code for updating current state of this FSMActor. The states are numbered according to the order in the list returned by entityList().
        Parameters:
        codeBuffer - The string buffer that the generated code is appended to.
        state - The current state.
        Throws:
        IllegalActionException - Thrown if the corresponding code block cannot be fetched.
      • _generateStateConstantLabel

        protected java.lang.Object _generateStateConstantLabel​(State state)
        Generate a label for a state constant.
        Parameters:
        state - The state.
        Returns:
        The label.