- All Implemented Interfaces:
public class MetroIIDEDirector extends DEDirector implements GetFirableMetroIIDEDirector is a Discrete Event (DE) director that adapts to MetroII semantics. This MoC is mainly used to design the functional model, in which some actors can be mapped to an architectural models. This allows users to explore choices about how the model can be implemented.
In DE director, events are totally ordered and executed. In MetroIIDEDirector, these events are called Ptolemy events that are still totally ordered. But the execution of Ptolemy events has some variances. Typically, a Ptolemy event is associated with a fire() action of an actor. Executing the Ptolemy event triggers the firing of the actor. In MetroIIDEDirector, the firing has two variances, depending on the types of the actor:
- If the actor is a normal Ptolemy actor, the execution of the event instantly triggers fire() of the actor.
- If the actor is an actor with a MetroII wrapper (@see BlockingFire or @see ResumableFire), the execution of the event will trigger a MetroII event to be PROPOSED. The firing will not be executed until the MetroII event is NOTIFIED.
A MetroII actor is a Ptolemy actor that implements GetFirable interface, which includes MetroIICompositeActor. To understand MetroII event and its states (e.g. PROPOSED, WAITING, NOTIFIED), please @see MetroIIDirector.
By using a MetroII actor under the MetroIIDEDirector, the user understands the firing of the MetroII actor might be delayed because the scheduling is not solely determined by the MetroIIDEDirector but also determined by MetroIIDirector on the upper level and the architectural model which the MetroII actor is mapped onto. This introduces some non-determinisms. But these non-determinisms are desirable and can be used to optimize the architectures.
It is highly recommend not to place MetroIIDEDirector in a MetroIICompositeActor under another MetroIIDEDirector because there would be a semantic conflict if the enclosed MetroIIDEDirector directs a normal Ptolemy actor.
- Ptolemy II 11.0
- Liangpeng Guo
- Red (glp)
- Red (glp)
Fields Modifier and Type Field Description
printTraceTrue if the trace information is printed.
Fields inherited from class ptolemy.domains.de.kernel.DEDirector
_actorsFinished, _actorsInExecution, _disabledActors, _eventQueue, _eventQueueLock, _isInitializing, _microstep, _noMoreActorsToFire, _stopFireRequested, binCountFactor, enforceMicrostepSemantics, isCQAdaptive, minBinCount, stopWhenQueueIsEmpty, synchronizeToRealTime
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
_checkForNextEvent()Enforce a firing of a DE director only handles events with the same tag.
_checkNextActorToFire()Return the actor that is about to fire and its state.
adapter()Since the MetroIIDEDirector is always used inside a MetroIICompositeActor, the adapter() in MetroIICompositeActor is responsible for creating the iterator of getfire(), this adapter() should never be called.
clone(Workspace workspace)Clone the object into the specified workspace.
getfire(net.jimblackler.Utils.ResultHandler<java.lang.Iterable<metroIIcomm.Event.Builder>> resultHandler)Fire actors according to events in the event queue.
initialize()Initialize the model controlled by this director.
stop()Request the execution of the current iteration to stop.
Methods inherited from class ptolemy.domains.de.kernel.DEDirector
_actorFired, _disableActor, _enqueueEvent, _enqueueTriggerEvent, _fire, _getDepthOfActor, _getDepthOfIOPort, _getNextActorToFire, _issueExecutionAspectWarning, _noActorToFire, _requestFiring, _schedule, addDebugListener, attributeChanged, cancelFireAt, cancelFireAt, describePriorities, fire, fireAt, fireAt, fireAtCurrentTime, fireAtRelativeTime, getCausalityInterface, getIndex, getMicrostep, getModelNextIterationTime, getNextEventTime, getStartTime, getStopTime, invalidateSchedule, mutexLockObject, newReceiver, postfire, prefire, preinitialize, removeDebugListener, resumeActor, setIndex, stopFire, suggestedModalModelDirectors, transferInputs, wrapup
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireContainerAt, fireContainerAt, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, supportMultirateFiring, suspend, terminate, transferOutputs, transferOutputs
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public Parameter printTraceTrue if the trace information is printed.
public MetroIIDEDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationExceptionConstruct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.
container- Container of the director.
name- Name of this director.
IllegalActionException- If the director is not compatible with the specified container. May be thrown in a derived class.
NameDuplicationException- If the container is not a CompositeActor and the name collides with an entity in the container.
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedExceptionClone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there).
public void initialize() throws IllegalActionExceptionInitialize the model controlled by this director. Call the initialize() of super class and then wrap each actor that is controlled by this director.
This method should typically be invoked once per execution, after the preinitialization phase, but before any iteration. It may be invoked in the middle of an execution, if reinitialization is desired.
This method is not synchronized on the workspace, so the caller should be.
public void stop()Request the execution of the current iteration to stop. This is similar to stopFire(), except that the current iteration is not allowed to complete.
protected Pair<Actor,java.lang.Integer> _checkNextActorToFire() throws IllegalActionExceptionReturn the actor that is about to fire and its state.
- 0 if firing can be executed, and the next event in event queue should be checked for processing; -1 if there's no actor to fire, and we should not keep firing; 1 if there's no actor to fire, but the next event should be checked for processing.
IllegalActionException- If the firing actor throws it, or event queue is not ready, or an event is missed, or time is set backwards.
protected boolean _checkForNextEvent() throws IllegalActionExceptionEnforce a firing of a DE director only handles events with the same tag. Checks what is the model time of the earliest event in the event queue.
public void getfire(net.jimblackler.Utils.ResultHandler<java.lang.Iterable<metroIIcomm.Event.Builder>> resultHandler) throws net.jimblackler.Utils.CollectionAbortedException, IllegalActionExceptionFire actors according to events in the event queue. Whether the actual firing of an actor can be done also depend on the MetroII events associated with the actor if the actor is a MetroII actor. Only when the associated MetroII event is NOTIFIED, the firing can be executed. Otherwise the state of the MetroII event will be checked again along with 'the next event'. Note that 'the next event' is the next event globally, which could be either the next event in the event queue of MetroIIDEDirector or the event in architectural model which this model is mapped to.
The time advancing is via proposing a MetroII event with time tag as its quantity, see
public net.jimblackler.Utils.YieldAdapterIterable<java.lang.Iterable<metroIIcomm.Event.Builder>> adapter()Since the MetroIIDEDirector is always used inside a MetroIICompositeActor, the adapter() in MetroIICompositeActor is responsible for creating the iterator of getfire(), this adapter() should never be called.