public class Event extends State implements Initializable
An event may schedule another event after a 0 or greater delay of model time. This scheduling relation may be guarded by a Boolean expression. When an event schedules another, processing the first one causes the second one to be placed in the same Ptera controller's event queue. An event may also cancel another event that was previously placed in the same Ptera controller's event queue but has not been processed yet.
If the fireOnInput
parameter of an event is set to true, then the
event is also placed in its Ptera controller's input event queue when
scheduled. When the Ptera controller receives an input at any of its input
ports, all the events in its input event queue are removed and processed. Those
events can use the value of that input in their guards or actions.
An event may also define 0 or more formal parameters. When it is scheduled, on the scheduling relation, values to those parameters must be provided.
When an event is processed, if there are actions defined for it, then those actions are executed. This happens before the refinements of the event is fired, if any.
One or more variable names can be listed in the monitoredVariables
parameter, separated by commas. If any such variable names are specified, when
the model is executed, changes on those variables are captured by the event.
This means, if the event is scheduled in the Ptera controller's event queue and
a change is made on the variable (e.g., by the user or by actors such as SetVariable
), then the event is processed even though its
scheduled time has not arrive yet.
This class extends the State
class in FSM, but it implements a model of
computation whose semantics is completely different from FSM. Extending from
FSM only because this makes it possible to reuse the user interface implemented
for FSM.
Red (tfeng) |
Yellow (tfeng) |
Modifier and Type | Class and Description |
---|---|
static class |
Event.EventParameter
The parameter to store an argument passed on a scheduling relation to this
event.
|
static class |
Event.RefiringData
A data structure to store the model time advance for the refire() method to
be called.
|
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
ActionsAttribute |
actions
The actions for this event.
|
Parameter |
isEndingEvent
A Boolean parameter that determines whether the event is the ending of a
submodel, which means the outgoing scheduling relations from the event
that the submodel is associated with should be evaluated.
|
Parameter |
isFinalEvent
A Boolean parameter to specify whether this event is a final event.
|
Parameter |
isInitialEvent
A Boolean parameter to specify whether this event is an initial
event.
|
ParametersAttribute |
parameters
A list of formal parameters.
|
incomingPort, isFinalState, isInitialState, outgoingPort, refinementName, saveRefinementsInConfigurer
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
Event(CompositeEntity container,
java.lang.String name)
Construct an event with the given name contained by the specified
composite entity.
|
Modifier and Type | Method and Description |
---|---|
protected ParserScope |
_getParserScope()
Return the parser scope used to evaluate the actions and values
associated with scheduling relations.
|
protected boolean |
_isActiveRefinement(TypedActor refinement)
Return whether the refinement is active.
|
void |
addInitializable(Initializable initializable)
Add the specified object to the list of objects whose
preinitialize(), initialize(), and wrapup()
methods should be invoked upon invocation of the corresponding
methods of this object.
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
java.lang.Object |
clone(Workspace workspace)
Clone the event into the specified workspace.
|
Event.RefiringData |
fire(Token arguments)
Process this event with the given arguments.
|
PteraController |
getController()
Return the Ptera controller that contains this event.
|
void |
initialize()
Begin execution of the actor.
|
boolean |
isEndingEvent()
Return whether this event is an ending event.
|
boolean |
isFinalEvent()
Return whether this event is a final event, so that its execution causes
the event queue of the Ptera director to be cleared.
|
boolean |
isInitialEvent()
Return whether this event is an initial event, so that it is
automatically scheduled at model time 0 in the Ptera director's event
queue.
|
void |
preinitialize()
This method should be invoked exactly once per execution
of a model, before any of these other methods are invoked.
|
Event.RefiringData |
refire(Token arguments,
Event.RefiringData data)
Continue the processing of this event with the given arguments from the
previous fire() or refire().
|
void |
removeInitializable(Initializable initializable)
Remove the specified object from the list of objects whose
preinitialize(), initialize(), and wrapup()
methods should be invoked upon invocation of the corresponding
methods of this object.
|
void |
scheduleEvents()
Schedule the next events by evaluating all scheduling relations from
this event.
|
void |
setContainer(CompositeEntity container)
Specify the container, adding the entity to the list
of entities in the container.
|
void |
stop()
Request that the event cease execution altogether.
|
void |
wrapup()
This method is invoked exactly once per execution
of an application.
|
_exportMoMLContents, configure, dropObject, errorTransitionList, getConfigurer, getConfigureSource, getConfigureText, getIncomingPort, getObjectInRefinement, getOutgoingPort, getRefinement, nonErrorNonTerminationTransitionList, nonpreemptiveTransitionList, preemptiveTransitionList, terminationTransitionList
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
_addPort, _description, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, 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, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, 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
getDerivedLevel, getDerivedList, propagateValue
description, getDisplayName, getFullName, getName, getName
public ActionsAttribute actions
public Parameter isEndingEvent
public Parameter isFinalEvent
public Parameter isInitialEvent
public ParametersAttribute parameters
public Event(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the state.IllegalActionException
- If the state cannot be contained
by the proposed container.NameDuplicationException
- If the name coincides with
that of an entity already in the container.public void addInitializable(Initializable initializable)
addInitializable
in interface Initializable
initializable
- The object whose methods should be invoked.removeInitializable(Initializable)
public void attributeChanged(Attribute attribute) throws IllegalActionException
parameters
attribute, update the parser scope for the
actions so that the parameters' names can be referred to in those
actions. If it is monitoredVariables
, register this event
as a value listener of all the monitored variables. If the changed
attribute is isInitialState
, do nothing. This is because
the Ptera controller need not be updated with this attribute is set. If
the changed attribute is among the other attributes, then the superclass
is called.attributeChanged
in class State
attribute
- The attribute that changed.IllegalActionException
- If thrown by the superclass
attributeChanged() method, or the parser scope cannot be updated.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class State
workspace
- The workspace for the new event.java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public Event.RefiringData fire(Token arguments) throws IllegalActionException
arguments
- The arguments used to process this event, which must be
either an ArrayToken or a RecordToken.IllegalActionException
- If the number of the arguments or
their types do not match, the actions cannot be executed, or any
expression (such as guards and arguments to the next events) cannot be
evaluated.refire(Token, RefiringData)
public PteraController getController()
public void initialize() throws IllegalActionException
initialize
in interface Initializable
IllegalActionException
- If execution is not permitted.public boolean isEndingEvent() throws IllegalActionException
The difference between an ending event and a final event is that the latter also clears the submodel's local event queue, whereas the former doesn't. It just triggers the outgoing scheduling relations.
IllegalActionException
- If the expression of the
isEndingEvent parameter cannot be parsed or cannot be evaluated, or if
the result of evaluation violates type constraints, or if the result of
evaluation is null and there are variables that depend on this one.public boolean isFinalEvent() throws IllegalActionException
IllegalActionException
- If the expression of the isFinalEvent
parameter cannot be parsed or cannot be evaluated, or if the result of
evaluation violates type constraints, or if the result of evaluation is
null and there are variables that depend on this one.public boolean isInitialEvent() throws IllegalActionException
IllegalActionException
- If the expression of the
isInitialEvent parameter cannot be parsed or cannot be evaluated, or if
the result of evaluation violates type constraints, or if the result of
evaluation is null and there are variables that depend on this one.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
IllegalActionException
- If initializing is not permitted.public Event.RefiringData refire(Token arguments, Event.RefiringData data) throws IllegalActionException
arguments
- The arguments used to process this event, which must be
either an ArrayToken or a RecordToken.data
- The refiring data structure returned by the previous fire()
or refire().IllegalActionException
- If the number of the arguments or
their types do not match, the actions cannot be executed, or any
expression (such as guards and arguments to the next events) cannot be
evaluated.fire(Token)
public void removeInitializable(Initializable initializable)
removeInitializable
in interface Initializable
initializable
- The object whose methods should no longer be invoked.addInitializable(Initializable)
public void scheduleEvents() throws IllegalActionException
fire(Token)
. If fire(Token)
has never been called, it uses a default scope in which no argument
value has been given.
This method searches for all the events that are scheduled or cancelled by this event. For each scheduling relation from this event, the guard is tested. If it is true, the ending event (which could be the same as this event) is scheduled to occur after the specified amount of delay. Arguments to that event, if any, are also computed at this time. For each cancelling edge from this event, the ending event is cancelled in the containing Ptera controller's event queue, if it is in it.
All the scheduling relations from this events are tested with their guards. If a scheduling relation's guard returns true, then the event that it points to is scheduled to occur after the amount of model time specified by the scheduling relation's delay parameter.
IllegalActionException
- If the scheduling relations cannot be
evaluated.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class ComponentEntity
container
- The proposed container.IllegalActionException
- If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace, or
if the protected method _checkContainer() throws it, or if
a contained Settable becomes invalid and the error handler
throws it.NameDuplicationException
- If the name of this entity
collides with a name already in the container.ComponentEntity.getContainer()
public void stop()
public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
IllegalActionException
- If wrapup is not permitted.protected ParserScope _getParserScope()
protected boolean _isActiveRefinement(TypedActor refinement) throws IllegalActionException
refinement
- The refinement to be tested.IllegalActionException
- Not thrown in this base class.