Class StaticSchedulingDirector

    • Field Detail

      • CURRENTTIME_DECLARATION

        public static final java.lang.String CURRENTTIME_DECLARATION
        The declaration for the _currentTime variable.
    • Constructor Detail

      • StaticSchedulingDirector

        public StaticSchedulingDirector​(StaticSchedulingDirector staticSchedulingDirector)
        Construct the code generator adapter associated with the given StaticSchedulingDirector.
        Parameters:
        staticSchedulingDirector - The associated ptolemy.actor.sched.StaticSchedulingDirector
    • Method Detail

      • allowDynamicMultiportReference

        public final java.lang.Boolean allowDynamicMultiportReference()
                                                               throws IllegalActionException
        Return whether the channels in multiports can be dynamically referenced using the $ref macro.
        Specified by:
        allowDynamicMultiportReference in class PortDirector
        Returns:
        True when the channels in multiports can be dynamically referenced using the $ref macro.
        Throws:
        IllegalActionException - If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
      • createDecoratorAttributes

        public DecoratorAttributes createDecoratorAttributes​(NamedObj target,
                                                             GenericCodeGenerator genericCodeGenerator)
        Create and return the decorated attributes for the corresponding Ptolemy component.
        Overrides:
        createDecoratorAttributes in class CodeGeneratorAdapter
        Parameters:
        target - The corresponding Ptolemy Component.
        genericCodeGenerator - The code generator that is the decorator for the corresponding Ptolemy Component.
        Returns:
        The decorated attributes.
      • generateFireCode

        public java.lang.String generateFireCode()
                                          throws IllegalActionException
        Generate the code for the firing of actors according to the SDF schedule.
        Overrides:
        generateFireCode in class Director
        Returns:
        The generated fire code.
        Throws:
        IllegalActionException - If the SDF director does not have an attribute called "iterations" or a valid schedule, or the actor to be fired cannot find its associated adapter.
      • generateInitializeCode

        public java.lang.String generateInitializeCode()
                                                throws IllegalActionException
        Generate the initialize code for this director. The initialize code for the director is generated by appending the initialize code for each actor.
        Overrides:
        generateInitializeCode in class 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 NamedProgramCodeGeneratorAdapter
        Returns:
        Code for the main loop of an execution.
        Throws:
        IllegalActionException - If something goes wrong.
      • generatePortName

        public java.lang.String generatePortName​(TypedIOPort port)
                                          throws IllegalActionException
        Generate sanitized name for the given named object. Remove all underscores to avoid conflicts with systems functions.
        Specified by:
        generatePortName in class PortDirector
        Parameters:
        port - The port for which the name is generated.
        Returns:
        The sanitized name.
        Throws:
        IllegalActionException - If the variablesAsArrays parameter cannot be read or if the buffer size of the port cannot be read.
      • 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 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.
      • padBuffers

        public final java.lang.Boolean padBuffers()
                                           throws IllegalActionException
        Return whether we need to pad buffers or not.
        Specified by:
        padBuffers in class PortDirector
        Returns:
        True when we need to pad buffers.
        Throws:
        IllegalActionException - If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
      • _generateUpdatePortOffsetCode

        protected void _generateUpdatePortOffsetCode​(java.lang.StringBuffer code,
                                                     Actor actor)
                                              throws IllegalActionException
        Generate the code that updates the input/output port offset.
        Parameters:
        code - The given code buffer.
        actor - The given actor.
        Throws:
        IllegalActionException - Thrown if _updatePortOffset(IOPort, StringBuffer, int) or getRate(IOPort) throw it.
      • _getParameter

        protected java.lang.String _getParameter​(NamedProgramCodeGeneratorAdapter target,
                                                 Attribute attribute,
                                                 java.lang.String[] channelAndOffset)
                                          throws IllegalActionException
        Return an unique label for the given attribute referenced by the given adapter. Subclass should override this method to generate the desire label according to the given parameters.
        Overrides:
        _getParameter in class Director
        Parameters:
        target - The ProgramCodeGeneratorAdapter for which code needs to be generated.
        attribute - The given attribute.
        channelAndOffset - The given channel and offset.
        Returns:
        an unique label for the given attribute.
        Throws:
        IllegalActionException - If the adapter throws it while generating the label.
      • _updateConnectedPortsOffset

        protected final void _updateConnectedPortsOffset​(IOPort port,
                                                         java.lang.StringBuffer code,
                                                         int rate)
                                                  throws IllegalActionException
        Update the offsets of the buffers associated with the ports connected with the given port in its downstream.
        Parameters:
        port - The port whose directly connected downstream actors update their write offsets.
        code - The string buffer that the generated code is appended to.
        rate - The rate, which must be greater than or equal to 0.
        Throws:
        IllegalActionException - If thrown while reading or writing offsets, or getting the buffer size, or if the rate is less than 0.
      • _updatePortOffset

        protected void _updatePortOffset​(IOPort port,
                                         java.lang.StringBuffer code,
                                         int rate)
                                  throws IllegalActionException
        Update the read offsets of the buffer associated with the given port.
        Parameters:
        port - The port whose read offset is to be updated.
        code - The string buffer that the generated code is appended to.
        rate - The rate, which must be greater than or equal to 0.
        Throws:
        IllegalActionException - If thrown while reading or writing offsets, or getting the buffer size, or if the rate is less than 0.