Class SystemCommand

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class SystemCommand
    extends TypedAtomicActor
    Actor that calls a system command. This actor fires a system command that is defined by the parameter programName with arguments programArguments. It waits unit the command terminates. The output of the actor are the exit flag, the standard output and standard error of the command

    The parameters programName and programArguments can have references to the port name that will be replaced by the token value of the respective port. For example, a user may add an input port called inPort and enter as the programArguments the string 1 $inPort 3. Then, if at the current firing, the input port is inPort=2, then the program argument will be 1 2 3. In addition to port names, you can also use the variable $time and $iteration, which will be replaced by the current simulation time and the iteration count. To use this class, instantiate it, then add ports (instances of TypedIOPort). In vergil, you can add ports by right clicking on the icon and selecting "Configure Ports". In MoML you can add ports by just including ports of class TypedIOPort, set to be inputs, as in the following example:

     <entity name="exp" class="lbnl.actor.lib.SystemCommand">
     <port name="in" class="ptolemy.actor.TypedIOPort">
     <property name="input"/>
     </port>
     </entity>
     
    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Michael Wetter
    • Field Detail

      • output

        public TypedIOPort output
        The port that outputs the standard output stream of the program.
      • error

        public TypedIOPort error
        The port that outputs the standard error stream of the program.
      • exitValue

        public TypedIOPort exitValue
        The port that outputs the exit value of the program.
      • programName

        public FileParameter programName
        Name of program that starts the simulation.
      • simulationLogFile

        public FileParameter simulationLogFile
        File name to which this actor writes the simulation log.
      • workingDirectory

        public FileParameter workingDirectory
        Working directory of the simulation.
      • showConsoleWindow

        public Parameter showConsoleWindow
        If true (the default), a window will be created that shows the console output.
      • programArguments

        protected Parameter programArguments
        Arguments of program that starts the simulation.
      • cliPro

        protected ClientProcess cliPro
        Thread that runs the simulation.
      • commandList

        protected java.util.ArrayList<java.lang.String> commandList
        List with the command and the arguments. This list is stored as it may contain references to input ports that will be substituted prior to the simulation
      • worDir

        protected java.lang.String worDir
        Working directory of the subprocess.
      • isHeadless

        protected boolean isHeadless
        Flag, set the true if Ptolemy is run without any graphical interface If isHeadless=true, this actor will not open any windows for reporting outputs or warnings.