public class LabVIEWSimulator extends Simulator
This actor communicates the LabVIEW simulation program, as well as synchronizes simulated physical time between these two platforms. This actor assumes the Ptolemy program dictates what time to advance to, while the LabVIEW program proposes times to advance to.
This actor can be invoked in two cases, one, when an input is received from the Ptolemy II simulation; two, when this actor triggers itself to fire at some future time through the use of pure events. In either case, outputs may or may not be produced by this actor. However, since the timeline this actor deals with is the simulated physical time, the outputs produced should not be a response of consumed input at the same time. The LabVIEW program should ensure this behavior.
At initialization, this actor reads input from the LabVIEW program, which proposes a simulated physical time (hereby referred to as "time", unless otherwise stated) to advance to. This actor then produces a pure event (by calling fireAt() of the director, with this time as its timestamp. Notice this time may or may not be different from the current time of the Ptolemy simulation environment.
The director will invoke this actor either when a trigger event arrives at this actor's input port, or when the pure event produced earlier triggers this event. In the first case, the input is consumed, and this data is transmitted into the LabVIEW program. The LabVIEW program should then react to this input and propose the next time to advance to, and send it back to the Ptolemy actor. Also, if a previous input has decided to produce an output at the current time, then an output will be produced by the LabVIEW program at the current time, and that output will be produced by this actor.
The key assumption we make about the LabVIEW program is that it always has information about what is the next time it wants to advance to. Thus at any point in time when the LabVIEW program is invoked, it proposes a new time to advance to, and send that time to the Ptolemy program.
Entity.ContainedObjectsIterator
clientTerminated, cliPro, dblWri, firstFire, isHeadless, LS, outTok, porNo, programArguments, programName, server, showConsoleWindow, simTimPre, simTimReaPre, simulationLogFile, socketConfigurationFile, socketPortNumber, socketTimeout, terminationMessage, tokTim, warWin, worDir, workingDirectory
input, input_tokenConsumptionRate, output, output_tokenInitProduction, output_tokenProductionRate
_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 |
---|
LabVIEWSimulator(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
protected double[] |
_getDoubleArray(Token t)
Get a double array from the Token.
|
protected void |
_outputInitToken()
During initialize, we output one token to startup the co-simulation
between Ptolemy and LabVIEW program.
|
protected void |
_startSimulation()
Start the simulation program.
|
protected void |
_writeToServer()
Write the data to the server instance, which will send it to
the client program.
|
void |
fire()
Send the input token to the client program and send the
output from the client program to the output port.
|
boolean |
prefire()
Return true and do not check the inputs.
|
_readFromServer, clone, cutQuotationMarks, initialize, preinitialize, resolveCommandName, resolveDirectory, wrapup
_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, postfire, 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, postfire, stop, stopFire, terminate
addInitializable, removeInitializable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public LabVIEWSimulator(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 void fire() throws IllegalActionException
fire
in interface Executable
fire
in class Simulator
IllegalActionException
- If the simulation time
between Ptolemy and the client program is not synchronized.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class SDFTransformer
IllegalActionException
- Not thrown in this base class.protected double[] _getDoubleArray(Token t) throws IllegalActionException
_getDoubleArray
in class Simulator
t
- the token which must be a type that can be converted to an ArrayTokenIllegalActionException
- If the base class throws it.protected void _startSimulation() throws IllegalActionException
_startSimulation
in class Simulator
IllegalActionException
- If the simulation process arguments
are invalid.protected void _outputInitToken() throws IllegalActionException
_outputInitToken
in class Simulator
IllegalActionException
protected void _writeToServer() throws IllegalActionException
_writeToServer
in class Simulator
IllegalActionException
- If there was an error when
writing to the server.