public class GiottoTimingManager extends SingletonAttribute implements Decorator
This attribute helps the user to manage and mitigate timing errors in a specification that uses timing but has no mechanisms in its specification for timing error handling. In this context a timing error occurs if the actor takes more than the specified WCET to execute.
The presence of the timing manager indicates a desire to incorporate execution timing as well as error handling into a Giotto specification.
This attribute is a decorator that adds a parameter to each actor at the current level. The parameter is named WCET, which is the Worst Case Execution Time (WCET) for the actor whose initial default value is 0.0. This indicates instantaneous execution, however, for each actor this parameter can also be modified by the user with information gained from an external WCET analysis tool.
This class simulates timing overruns by varying the execution time of each actor. It currently uses the java.util.Random pseudo random number generator to generate a random execution time in the range [0,2*WCET] for each iteration of each actor. The random number generator can be seeded by the seed parameter. The default value of the seed is 0L interpreted as not having a seed. The user also has the option to reset to the seed on each run by selecting the resetOnEachRun parameter. A future modification could include adding a parameter to have the user specify what probability distribution they wish to use.
This attribute checks for two types of errors. First, it does a static check of
(a) the sum of the worst case execution times for the actors and compares
(a) to the GiottoDirector.period
of the Giotto Director. If (a) is larger than the director
period, then the attribute throws an exception notifying the user of the discrepancy
and does not execute the model. Second, during execution the attribute randomly varies
the execution time of the actors. The attribute then compares (b) the sum of the
actors execution times to (a) the sum of the actors worst case execution
times. If (a) < (b) then the attribute calls
NamedObj.handleModelError(NamedObj, IllegalActionException)
,
which throws a model error .
A model error is an exception that is passed up the containment hierarchy rather than being immediately thrown. Any container in the containment hierarchy may choose to handle the error. By default, containers will pass and delegate the error to their container, if they have one, and throw an exception if they don't. But some containers might do more with the error.
The attribute can be instantiated by instantiating an attribute of type
GiottoTimingManager
.
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected double |
_current
The Current value of the randomly generated number.
|
protected long |
_generatorSeed
The current value of the seed parameter.
|
protected boolean |
_needNew
Indicator that a new random number is needed.
|
protected boolean |
_needNewGenerator
Indicator that a new generator is needed.
|
protected java.util.Random |
_random
The Random object.
|
StringParameter |
probabilityDistribution
The value that controls the type of the probability distribution
used for random number generation.
|
SharedParameter |
resetOnEachRun
If true, this parameter specifies that the random number
generator should be reset on each run of the model (in
the initialize() method).
|
SharedParameter |
seed
The seed that controls the random number generation.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
GiottoTimingManager(NamedObj container,
java.lang.String name)
Construct an instance with the specified container and name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_createGenerator()
Create the random number generator using current parameter values.
|
protected void |
_generateRandomNumber()
Generate the next random number.
|
void |
attributeChanged(Attribute attribute)
If the attribute is seed
then create the base random number generator.
|
DecoratorAttributes |
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.
|
java.util.List<NamedObj> |
decoratedObjects()
Return a list of the entities deeply contained by the container
of this resource scheduler.
|
boolean |
isGlobalDecorator()
Return false to indicate that this decorator should not
decorate objects across opaque hierarchy boundaries.
|
void |
setContainer(NamedObj container)
Specify the container.
|
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, 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, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
public SharedParameter resetOnEachRun
public SharedParameter seed
public StringParameter probabilityDistribution
protected long _generatorSeed
protected boolean _needNewGenerator
protected java.util.Random _random
protected boolean _needNew
protected double _current
public GiottoTimingManager(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public DecoratorAttributes createDecoratorAttributes(NamedObj target)
createDecoratorAttributes
in interface Decorator
target
- The NamedObj that will be decorated.public java.util.List<NamedObj> decoratedObjects()
decoratedObjects
in interface Decorator
public boolean isGlobalDecorator()
isGlobalDecorator
in interface Decorator
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException
setContainer
in class SingletonAttribute
container
- The container to attach this attribute to..IllegalActionException
- If this attribute is not of the
expected class for the container, or it has no name,
or the attribute and container are not in the same workspace, or
the proposed container would result in recursive containment.NameDuplicationException
- If the container already has
an attribute with the name of this attribute.Attribute.getContainer()
protected void _createGenerator() throws IllegalActionException
IllegalActionException
- If thrown while reading the
seed Token.protected void _generateRandomNumber() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.