|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
lbnl.actor.lib.SystemCommand
public class SystemCommand
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>
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private int |
_iterationCount
|
private java.util.HashMap<java.lang.String,Token> |
_tokenMap
|
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. |
private static java.lang.String |
LS
System dependent line separator |
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. |
Fields inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
SystemCommand(CompositeEntity container,
java.lang.String name)
Constructs an actor with the given container and name. |
Method Summary | |
---|---|
private void |
_initializeSimulation()
Initializes the simulation program. |
private void |
_startSimulation()
Starts the simulation program. |
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. |
Methods inherited from class ptolemy.actor.TypedAtomicActor |
---|
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, removeInitializable |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
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.
private int _iterationCount
private java.util.HashMap<java.lang.String,Token> _tokenMap
private static final java.lang.String LS
Constructor Detail |
---|
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.Method Detail |
---|
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 AtomicActor
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
IllegalActionException
- Not thrown in this base class.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class AtomicActor
IllegalActionException
- If the parameters of the
actor are invalid.private void _initializeSimulation() throws IllegalActionException
IllegalActionException
- If the simulation process arguments
are invalid.private void _startSimulation() throws IllegalActionException
IllegalActionException
- If the simulation process arguments
are invalid.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor
IllegalActionException
- If the parent class throws it.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor
IllegalActionException
- If the superclass throws it.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class AtomicActor
IllegalActionException
- If the superclass throws it.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class AtomicActor
IllegalActionException
- if the base class throws it.public static java.lang.String cutQuotationMarks(java.lang.String str)
str
- The string.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |