public class ModalModel extends TypedCompositeActor implements ChangeListener
The controller is a finite-state machine (FSM), which consists of states and transitions. One of the states is an initial state. When this actor executes, if the current state has a refinement, then that refinement is executed. Then the guards on all the outgoing transitions of the current state are evaluated, and if one of those guards is true, then the transition is taken. Taking the transition means that the actions associated with the transition are executed (which can result in producing outputs), and the new current state is the state at the destination of the transition. It is an error if more than one of the guards evaluates to true.
To add a state, click on a state button in the toolbar, or drag in a state from the library at the left. To add a transition, position the mouse over the source state, hold the control button, and drag to the destination state. The destination state may be the same state, in which case the transition is used simply to execute its actions.
Adding or removing ports in this actor results in the same ports appearing or disappearing in the FSM controller and in each of the refinements. Similarly, adding or removing ports in the controller or in the refinements results in this actor and the other refinements reflecting the same change to the ports. That is, this actor, the controller, and the refinments all contain the same ports.
There is one subtlety regarding ports however. If you add an output port to a refinement, then the corresponding port in the controller will be both an input and an output. The reason for this is that the controller can access the results of executing a refinement in order to choose a transition.
This class is designed to work closely with ModalController and Refinement, since changes to ports can be initiated in this class or in those. It works with continuous-time as well as discrete-time models.
By default, this actor has a conservative causality interface, which examines the FSMActor controller and all the refinements and defines input/output dependencies that are the oPlus combination of all their dependencies. If the stateDependentCausality is false (the default), then this causality interface in conservative and valid in all states. If it is true, then the causality interface will show different input/output dependencies depending on the state. In each state, only the controller and the current refinement will be considered, and in the controller, only the outgoing transitions from the current state will be considered.
This class also fulfills the CTEventGenerator interface so that it can report events generated inside.
ModalController
,
Refinement
Red (reviewmoderator) |
Red (eal) |
CompositeEntity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected FSMActor |
_controller
The FSM controller.
|
StringParameter |
directorClass
A director class name.
|
Parameter |
stateDependentCausality
Indicate whether input/output dependencies can depend on the
state.
|
_actorFiringListeners, _causalityInterface, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
_levelCrossingLinks
_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 |
---|
ModalModel(CompositeEntity container,
java.lang.String name)
Construct a modal model with a name and a container.
|
ModalModel(Workspace workspace)
Construct a modal model in the specified workspace with
no container and an empty string as a name.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
React to a change of the director or other property.
|
void |
changeExecuted(ChangeRequest change)
React to a change request has been successfully executed.
|
void |
changeFailed(ChangeRequest change,
java.lang.Exception exception)
React to a change request has resulted in an exception.
|
java.lang.Object |
clone(Workspace workspace)
Override the base class to ensure that the _controller private
variable is reset to the controller of the cloned object.
|
void |
exportMoML(java.io.Writer output,
int depth,
java.lang.String name)
Override the base class to remove any unused refinements
before exporting.
|
Attribute |
getAttribute(java.lang.String name)
Get the attribute with the given name.
|
CausalityInterface |
getCausalityInterface()
Get representation of dependencies between input ports and
output ports.
|
FSMActor |
getController()
Get the FSM controller.
|
boolean |
handleModelError(NamedObj context,
IllegalActionException exception)
Handle a model error.
|
void |
initialize()
Initialize the mode controller and all the refinements by
calling the initialize() method in the super class.
|
Port |
newPort(java.lang.String name)
Create a new port with the specified name in this entity, the
controller, and all the refinements.
|
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _destinationTypeConstraints, attributeTypeChanged, isBackwardTypeInferenceEnabled, newRelation, resolveTypes, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, connectionsChanged, createReceivers, createSchedule, fire, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, inputPortList, isFireFunctional, isOpaque, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, preinitialize, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort, wrapup
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, 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, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public StringParameter directorClass
public Parameter stateDependentCausality
protected FSMActor _controller
public ModalModel(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace that will list the actor.IllegalActionException
- If the name has a period in it, or
the director is not compatible with the specified container.NameDuplicationException
- If the container already contains
an entity with the specified name.public ModalModel(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.IllegalActionException
- If the container is incompatible
with this actor.NameDuplicationException
- If the name coincides with
an actor already in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class TypedCompositeActor
attribute
- The attribute that changed.IllegalActionException
- Not thrown in this base class.
Derived classes can throw this exception if type change is not allowed.public void changeExecuted(ChangeRequest change)
changeExecuted
in interface ChangeListener
change
- The change that has been executed, or null if
the change was not done via a ChangeRequest.public void changeFailed(ChangeRequest change, java.lang.Exception exception)
changeFailed
in interface ChangeListener
change
- The change that was attempted or null if
the change was not done via a ChangeRequest.exception
- The exception that resulted.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class CompositeActor
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void exportMoML(java.io.Writer output, int depth, java.lang.String name) throws java.io.IOException
exportMoML
in interface MoMLExportable
exportMoML
in class CompositeEntity
output
- The output stream to write to.depth
- The depth in the hierarchy, to determine indenting.name
- The name to use in the exported MoML.java.io.IOException
- If an I/O error occurs.MoMLExportable
public Attribute getAttribute(java.lang.String name)
getAttribute
in class CompositeEntity
name
- The name of the desired attribute.public CausalityInterface getCausalityInterface()
getCausalityInterface
in interface Actor
getCausalityInterface
in class CompositeActor
public FSMActor getController()
public boolean handleModelError(NamedObj context, IllegalActionException exception) throws IllegalActionException
handleModelError
in interface ModelErrorHandler
handleModelError
in class NamedObj
context
- The object in which the error occurred.exception
- An exception that represents the error.IllegalActionException
- If the handler handles the
error by throwing an exception.NamedObj.setModelErrorHandler(ModelErrorHandler handler)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class CompositeActor
IllegalActionException
- If thrown by the initialize()
method of the super class, or can not find mode
controller, or can not find refinement of the
current state.public Port newPort(java.lang.String name) throws NameDuplicationException
newPort
in class TypedCompositeActor
name
- The name to assign to the newly created port.NameDuplicationException
- If the entity already has a port
with the specified name.