Class GiottoTimingManager
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.kernel.util.SingletonAttribute
-
- ptolemy.domains.giotto.kernel.GiottoTimingManager
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Singleton
public class GiottoTimingManager extends SingletonAttribute implements Decorator
An attribute that varies the WCET values of actors and throws a model error if the sum of the execution times is larger than the sum of the worst case execution times.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 callsNamedObj.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
.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Shanna-Shaye Forbes. Based on the MonitorReceiverContents.java created by Edward A. Lee and RandomSource.java by Edward A. Lee, Steve Neuendorffer, Elaine Cheong
- Pt.AcceptedRating:
- Red (sssf)
- Pt.ProposedRating:
- Red (sssf)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field 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.-
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
-
-
Constructor Summary
Constructors Constructor Description GiottoTimingManager(NamedObj container, java.lang.String name)
Construct an instance with the specified container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, 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, _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
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
resetOnEachRun
public 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). It is a boolean that defaults to false. This is a shared parameter, meaning that changing it somewhere in the model causes it to be changed everywhere in the model.
-
seed
public SharedParameter seed
The seed that controls the random number generation. This is a shared parameter, meaning that all instances of RandomSource or derived classes in the same model share the same value. A seed of zero is interpreted to mean that no seed is specified, which means that each execution of the model could result in distinct data. For the value 0, the seed is set to System.currentTimeMillis() + hashCode(), which means that with extremely high probability, two distinct actors will have distinct seeds. However, current time may not have enough resolution to ensure that two subsequent executions of the same model have distinct seeds. For a value other than zero, the seed is set to that value plus the hashCode() of the full name of the actor. This means that with high probability, two distinct actors will have distinct, but repeatable seeds. This parameter contains a LongToken, initially with value 0.
-
probabilityDistribution
public StringParameter probabilityDistribution
The value that controls the type of the probability distribution used for random number generation. The probability distribution defaults to none, which is interpreted as an equal distribution of numbers between 0 and 1.
-
_generatorSeed
protected long _generatorSeed
The current value of the seed parameter.
-
_needNewGenerator
protected boolean _needNewGenerator
Indicator that a new generator is needed.
-
_random
protected java.util.Random _random
The Random object.
-
_needNew
protected boolean _needNew
Indicator that a new random number is needed.
-
_current
protected double _current
The Current value of the randomly generated number.
-
-
Constructor Detail
-
GiottoTimingManager
public GiottoTimingManager(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an instance with the specified container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute is seed then create the base random number generator.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (not thrown in this base class).
-
createDecoratorAttributes
public DecoratorAttributes createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.- Specified by:
createDecoratorAttributes
in interfaceDecorator
- Parameters:
target
- The NamedObj that will be decorated.- Returns:
- The decorated attributes for the target NamedObj.
-
decoratedObjects
public java.util.List<NamedObj> decoratedObjects()
Return a list of the entities deeply contained by the container of this resource scheduler.- Specified by:
decoratedObjects
in interfaceDecorator
- Returns:
- A list of the objects decorated by this decorator.
-
isGlobalDecorator
public boolean isGlobalDecorator()
Return false to indicate that this decorator should not decorate objects across opaque hierarchy boundaries.- Specified by:
isGlobalDecorator
in interfaceDecorator
- Returns:
- True if decorator is global.
-
setContainer
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException
Specify the container. If the container is not the same as the previous container, then start monitoring the new container.- Overrides:
setContainer
in classSingletonAttribute
- Parameters:
container
- The container to attach this attribute to..- Throws:
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.- See Also:
Attribute.getContainer()
-
_createGenerator
protected void _createGenerator() throws IllegalActionException
Create the random number generator using current parameter values.- Throws:
IllegalActionException
- If thrown while reading the seed Token.
-
_generateRandomNumber
protected void _generateRandomNumber() throws IllegalActionException
Generate the next random number.- Throws:
IllegalActionException
- Not thrown in this base class.
-
-