public class MatlabExpression extends TypedAtomicActor
Allows the user to input a matlab script to be executed when the actor fires. The following actor takes into consideration differnt startup routines for MatlabSoftware for Unix/Windows os.
Input ports can be added and are automatically loaded into variables in matlab which can be referenced by the port name.
Similarly output can be made by adding output ports to the actor. The output values are taken from variables with the same names as the output ports.
NOTE: windows is a bit more tempermental than unix system. the EXE file must be directly pointed to by the mlCmd property. E.g c:\\matlab7\\bin\\win32\\matlab.exe
Also, windows command line matlab doesn't use the standard in and out, instead it uses it's own command window, which makes it impossible to read and write to the matlab process using the process input and output streams. So instead the actor writes the data to a file and read in the outputs from the file. The file is created with a random integer at the end of the file name to (in theory) allow multiple matlab actors to run at the same time. The file is deleted once it's been read.
TODO: currently this actor only works with standard single value and array results. support for all forms of matlab output needs to be implemented
NOTE: now with java 1.4 complience!! using the ProcessBuilder in java 1.5 makes things a lot easier but since we need to compile under 1.4 here it is.
Changelog 27/04/06: * check for existance of executable under windows * kill matlab process when stop() is called * check to make sure variable for output port name exists if it doesn't, then set it to 0 * changed expression to PortParameter * changed error handling: sends error message to output port for some things
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
PortParameter |
expression
The expression that is evaluated : Matlab Function or Script from the
parameter dialog box or input port.
|
StringParameter |
mlCmd
Path to matlab execuatble. defaults to "matlab"
|
TypedIOPort |
output
The output port.
|
TypedIOPort |
triggerSwitch
The trigger switch ,whether to execute the actor or not.
|
_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 |
---|
MatlabExpression(CompositeEntity container,
java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
fire()
Do nothing.
|
void |
stop()
Request that execution of the current iteration stop as soon
as possible.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stopFire, terminate, wrapup
_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, postfire, prefire, stopFire, terminate
addInitializable, initialize, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public TypedIOPort output
public PortParameter expression
public StringParameter mlCmd
public TypedIOPort triggerSwitch
public MatlabExpression(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
public void fire() throws IllegalActionException
AtomicActor
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown in this base class.public void stop()
AtomicActor
stop
in interface Executable
stop
in class AtomicActor<TypedIOPort>