public class SystemCommand extends TypedAtomicActor
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>
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected ClientProcess |
cliPro
Thread that runs the simulation.
|
protected java.util.ArrayList<java.lang.String> |
commandList
List with the command and the arguments.
|
TypedIOPort |
error
The port that outputs the standard error stream of the program.
|
TypedIOPort |
exitValue
The port that outputs the exit value of the program.
|
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. |
TypedIOPort |
output
The port that outputs the standard output stream of the program.
|
protected Parameter |
programArguments
Arguments of program that starts the simulation.
|
FileParameter |
programName
Name of program that starts the simulation.
|
Parameter |
showConsoleWindow
If true (the default), a window will be created that
shows the console output.
|
FileParameter |
simulationLogFile
File name to which this actor writes the simulation log.
|
protected java.lang.String |
worDir
Working directory of the subprocess.
|
FileParameter |
workingDirectory
Working directory of the simulation.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
SystemCommand(CompositeEntity container,
java.lang.String name)
Constructs an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace.
|
static java.lang.String |
cutQuotationMarks(java.lang.String str)
Cut the leading and terminating quotation marks if present.
|
void |
fire()
Read the input token, update the program name and program arguments,
start the program and wait unit it terminates.
|
void |
initialize()
Initialize actor.
|
boolean |
postfire()
Increment the iteration count.
|
boolean |
prefire()
Prefire this actor.
|
void |
preinitialize()
Initializes the data members and checks if the parameters of
the actor are valid.
|
void |
wrapup()
Wraps up the base class.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
addInitializable, removeInitializable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public TypedIOPort output
public TypedIOPort error
public TypedIOPort exitValue
public FileParameter programName
public FileParameter simulationLogFile
public FileParameter workingDirectory
public Parameter showConsoleWindow
protected Parameter programArguments
protected ClientProcess cliPro
protected java.util.ArrayList<java.lang.String> commandList
protected java.lang.String worDir
protected boolean isHeadless
true
if Ptolemy is run without any graphical
interface
If isHeadless=true
, this actor will not open any windows for
reporting outputs or warnings.public SystemCommand(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this actor.IllegalActionException
- If the actor cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
init
and step
public members to the parameters of the new actor.clone
in class TypedAtomicActor
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown in this base class.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the parameters of the
actor are invalid.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the parent class throws it.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the superclass throws it.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the superclass throws it.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class AtomicActor<TypedIOPort>
IllegalActionException
- if the base class throws it.public static java.lang.String cutQuotationMarks(java.lang.String str)
str
- The string.