Class RunnableCodeGenerator

    • Field Detail

      • run

        public Parameter run
        If true, then run the generated code. The default value is a parameter with the value true.
      • runCommand

        public StringParameter runCommand
        The command to use to run the generated code if the useMake parameter is false. The initial default value is "make -f @modelName@.mk run". Various '@' delimited key/value pairs will be automatically substituted. In the default case @modelName@ will be replaced with a sanitized (Java-safe) version of the model name.

        If the string "@help:all@" appears, then all the key/value pairs are echoed at run time, though this may not result in a syntactically correct command.

        If useMake is true, then the value of this parameter is ignored.

      • _runCommandDefault

        protected static final java.lang.String _runCommandDefault
        The initial default value of the runCommand parameter. The constructor of a derived class may compare the value of runCommand and this variable and decide to override the value of the runCommand parameter with a new value.
        See Also:
        Constant Field Values
      • _substituteMap

        protected java.util.Map<java.lang.String,​java.lang.String> _substituteMap
        Map of '@' delimited keys to values.
    • Constructor Detail

      • RunnableCodeGenerator

        public RunnableCodeGenerator​(NamedObj container,
                                     java.lang.String name,
                                     java.lang.String outputFileExtension)
                              throws IllegalActionException,
                                     NameDuplicationException
        Create a new instance of the ProgramCodeGenerator.
        Parameters:
        container - The container.
        name - The name of the ProgramCodeGenerator.
        outputFileExtension - The extension of the output file. (for example c in case of C and java in case of Java)
        Throws:
        IllegalActionException - If the super class throws the exception or error occurs when setting the file path.
        NameDuplicationException - If the super class throws the exception or an error occurs when setting the file path.
    • Method Detail

      • updateCommandOptions

        public java.lang.String[][] updateCommandOptions()
        Return an updated array of command line options.
        Overrides:
        updateCommandOptions in class GenericCodeGenerator
        Returns:
        An array of updated command line options.
      • _executeCommands

        protected int _executeCommands()
                                throws IllegalActionException
        Execute the compile and run commands in the codeDirectory directory.
        Overrides:
        _executeCommands in class GenericCodeGenerator
        Returns:
        The return value of the last subprocess that was executed or -1 if no commands were executed.
        Throws:
        IllegalActionException - If there are problems reading parameters or executing the commands.
      • _setupCommands

        protected java.util.List<java.lang.String> _setupCommands()
                                                           throws IllegalActionException
        Return a list of setup commands to be invoked before the run command.
        Returns:
        The list of commands.
        Throws:
        IllegalActionException - Not thrown in this base class.
      • _updateSubstituteMap

        protected void _updateSubstituteMap()
                                     throws IllegalActionException
        Update the substitute map for the setup and run commands In this base class, @codeDirectory@, @modelName@ and @PTII@ are added to the map.
        Throws:
        IllegalActionException - Not thrown in this base class, Derived classes should throw it if there is a problem parsing a value.