Class SDFDirector

    • Constructor Detail

      • SDFDirector

        public SDFDirector​(SDFDirector sdfDirector)
        Construct the code generator adapter associated with the given SDFDirector.
        Parameters:
        sdfDirector - The associated ptolemy.domains.sdf.kernel.SDFDirector
    • Method Detail

      • generateConstructorCode

        public java.lang.String generateConstructorCode()
                                                 throws IllegalActionException
        Generate the constructor code for the specified director. In this class we initialize the director with its internal parameters and fields as well as with the depths of the actors
        Overrides:
        generateConstructorCode in class Director
        Returns:
        The generated constructor code
        Throws:
        IllegalActionException - Not thrown in this base class.
      • generateFunctionsDeclaration

        public java.lang.String generateFunctionsDeclaration()
                                                      throws IllegalActionException
        Generate The functions' declaration code for this director.
        Returns:
        The functions' declaration function code.
        Throws:
        IllegalActionException - If thrown while generating code.
      • generateInitializeFunctionCode

        public java.lang.String generateInitializeFunctionCode()
                                                        throws IllegalActionException
        Generate the initialize function code for the associated SDF director.
        Returns:
        The generated initialize code.
        Throws:
        IllegalActionException - If the adapter associated with an actor throws it while generating initialize code for the actor.
      • generateMainLoop

        public java.lang.String generateMainLoop()
                                          throws IllegalActionException
        Generate a main loop for an execution under the control of this director. If the associated director has a parameter named iterations with a value greater than zero, then wrap code generated by generateFireCode() in a loop that executes the specified number of iterations. Otherwise, wrap it in a loop that executes forever. In the loop, first get the code returned by generateFireCode(), and follow that with the code produced by the container help for generateModeTransitionCode(). That code will make state transitions in modal models at the conclusion of each iteration. Next, this code calls postfire(), and that returns false, breaks out of the main loop. Finally, if the director has a parameter named period, then increment the variable _currentTime after each pass through the loop.
        Overrides:
        generateMainLoop in class StaticSchedulingDirector
        Returns:
        Code for the main loop of an execution.
        Throws:
        IllegalActionException - If something goes wrong.
      • generatePostFireFunctionCode

        public java.lang.String generatePostFireFunctionCode()
                                                      throws IllegalActionException
        Generate The postfire function code for a SDF director.
        Returns:
        The postfire function code.
        Throws:
        IllegalActionException - If thrown while generating fire code.
      • generatePreFireFunctionCode

        public java.lang.String generatePreFireFunctionCode()
                                                     throws IllegalActionException
        Generate The prefire function code for a SDF director Usually we have to check if all the input ports have enough tokens to fire. In here we also update the time of the director with its container time. If it is top level director, there is no need for that. But in the SDFReceiver we assume that receivers have always enough tokens, therefore the prefire methods always returns true.
        Returns:
        The prefire function code.
        Throws:
        IllegalActionException - If thrown while generating fire code.
      • generatePreinitializeCode

        public java.lang.String generatePreinitializeCode()
                                                   throws IllegalActionException
        Generate the preinitialize code for this director. The preinitialize code for the director is generated by appending the preinitialize code for each actor.
        Overrides:
        generatePreinitializeCode in class SDFDirector
        Returns:
        The generated preinitialize code.
        Throws:
        IllegalActionException - If getting the adapter fails, or if generating the preinitialize code for a adapter fails, or if there is a problem getting the buffer size of a port.
      • generatePreinitializeMethodBodyCode

        public java.lang.String generatePreinitializeMethodBodyCode()
                                                             throws IllegalActionException
        Generate the preinitialize code for this director. The preinitialize code for the director is generated by appending the preinitialize code for each actor.
        Overrides:
        generatePreinitializeMethodBodyCode in class Director
        Returns:
        The generated preinitialize code.
        Throws:
        IllegalActionException - If getting the adapter fails, or if generating the preinitialize code for a adapter fails, or if there is a problem getting the buffer size of a port.
      • generateSchedule

        public java.lang.String generateSchedule()
                                          throws IllegalActionException
        Generate the code representing the schedule statically inferred from the Ptolemy model.
        Returns:
        the code representing the schedule.
        Throws:
        IllegalActionException - if something happens while writing the code
      • generateTransferInputsCode

        public void generateTransferInputsCode​(IOPort inputPort,
                                               java.lang.StringBuffer code)
                                        throws IllegalActionException
        Generate code for transferring enough tokens to complete an internal iteration.
        Overrides:
        generateTransferInputsCode in class Director
        Parameters:
        inputPort - The port to transfer tokens.
        code - The string buffer that the generated code is appended to.
        Throws:
        IllegalActionException - If thrown while transferring tokens.
      • generateTransferOutputsCode

        public void generateTransferOutputsCode​(IOPort outputPort,
                                                java.lang.StringBuffer code)
                                         throws IllegalActionException
        Generate code for transferring enough tokens to fulfill the output production rate.
        Overrides:
        generateTransferOutputsCode in class Director
        Parameters:
        outputPort - The port to transfer tokens.
        code - The string buffer that the generated code is appended to.
        Throws:
        IllegalActionException - If thrown while transferring tokens.
      • _generateVariableDeclaration

        protected java.lang.String _generateVariableDeclaration​(NamedProgramCodeGeneratorAdapter target)
                                                         throws IllegalActionException
        Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
        Overrides:
        _generateVariableDeclaration in class Director
        Parameters:
        target - The ProgramCodeGeneratorAdapter for which code needs to be generated.
        Returns:
        code The generated code.
        Throws:
        IllegalActionException - If the adapter class for the model director cannot be found.