public class ConstraintMonitor extends Parameter implements Decorator
threshold
and warningEnabled
is true, then this
class will issue a warning when the aggregate value matches or
exceeds the threshold.
The decorator values default to 0.0, so the default total
is 0.0. The default threshold is Infinity, so no warnings will
be issued by default.
If the includeOpaqueContents
parameter is true, then this decorator will
also decorate entities within opaque composite actors. By default,
this is false.
This object is a Parameter
whose value is the total
of the values of all the decorator values. To use it, simply
drag it into a model.
Modifier and Type | Class and Description |
---|---|
static class |
ConstraintMonitor.ConstraintMonitorAttributes
Class containing the decorator attributes that decorate objects.
|
Variable.CircularDependencyError, Variable.VariableScope
NamedObj.ContainedObjectsIterator
Settable.Visibility
Modifier and Type | Field and Description |
---|---|
Parameter |
includeOpaqueContents
If true, then this decorator decorates entities within
opaque composite actors.
|
Parameter |
includeTransparents
If true, then this decorator decorates transparent composite
entities.
|
Parameter |
threshold
Threshold at which this monitor issues a warning, if
warningEnabled is true. |
Parameter |
warningEnabled
If true (the default), then a warning is issued when the
aggregate value equals or exceeds the specified
threshold . |
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _suppressVariableSubstitution, _valueListeners
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
EXPERT, FULL, NONE, NOT_EDITABLE
Constructor and Description |
---|
ConstraintMonitor(CompositeEntity container,
java.lang.String name)
Construct an instance in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addAllContainedEntities(CompositeEntity container,
java.util.List<NamedObj> result,
boolean transparents,
boolean opaques)
Add to the specified list all contained entities of the specified container
that are not class definitions.
|
protected boolean |
_deepContains(CompositeEntity container,
Entity target,
boolean opaques)
Return true if the specified target is deeply contained by the specified container
subject to the constraints given by the opaques parameter.
|
protected void |
_evaluate()
Evaluate the current expression to a token, which in this case means
to sum the values of all the decorated objects.
|
void |
attributeChanged(Attribute attribute)
Override the base class to invalidate if parameters have changed.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
DecoratorAttributes |
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj, or null
if the target is not decorated by this decorator.
|
java.util.List<NamedObj> |
decoratedObjects()
Return a list of the entities deeply contained by the container
of this resource scheduler.
|
Token |
getToken()
Override the base class to check whether the threshold constraint
is satisfied.
|
void |
invalidate()
Override the base class to mark this as needing evaluation even though
there is no expression.
|
boolean |
isGlobalDecorator()
Return the value of
includeOpaqueContents . |
java.util.Collection |
validate()
Override the base class to establish a connection with any
decorated objects it finds in scope in the container.
|
void |
valueChanged(Settable settable)
Override the base class to mark that evaluation is needed regardless
of the current expression.
|
addChoice, exportMoML, getChoices, removeAllChoices, removeChoice
_description, _getCurrentExpression, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, isKnown, isLazy, isStringMode, isSuppressVariableSubstitution, isTypeAcceptable, removeValueListener, reset, setContainer, setExpression, setLazy, setName, setParseTreeEvaluator, setStringMode, setSuppressVariableSubstitution, setToken, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setValueListenerAsWeakDependency, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints
getDefaultExpression
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, 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, uniqueName, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDisplayName
public Parameter includeOpaqueContents
public Parameter includeTransparents
public Parameter threshold
warningEnabled
is true.
This is a double that defaults to Infinity, meaning no
constraint on the sum of the decorator values.public ConstraintMonitor(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container, which contains the objects to be decoratedname
- Name of this constraint monitor.IllegalActionException
- If this object is not compatible
with the specified container.NameDuplicationException
- If the name collides with an
attribute in the container or if there is a name duplication during
initialization.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class Variable
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
public DecoratorAttributes createDecoratorAttributes(NamedObj target) throws IllegalActionException
createDecoratorAttributes
in interface Decorator
target
- The NamedObj that will be decorated.IllegalActionException
- If some object cannot be determined to
be decorated or not (e.g., a parameter cannot be evaluated).public java.util.List<NamedObj> decoratedObjects() throws IllegalActionException
decoratedObjects
in interface Decorator
IllegalActionException
- If some object cannot be determined to
be decorated or not (e.g., a parameter cannot be evaluated).public boolean isGlobalDecorator() throws IllegalActionException
includeOpaqueContents
.
decorate objects across opaque hierarchy boundaries.isGlobalDecorator
in interface Decorator
IllegalActionException
- If there is a problem
getting the boolean valu from the includeOpaqueContents token.public Token getToken() throws IllegalActionException
getToken
in class Variable
IllegalActionException
- If the expression 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.Variable.setToken(String)
,
Variable.setToken(ptolemy.data.Token)
public void invalidate()
invalidate
in class Variable
public java.util.Collection validate() throws IllegalActionException
validate
in interface Settable
validate
in class Variable
IllegalActionException
- If this variable or a
variable dependent on this variable cannot be evaluated (and is
not lazy) and the model error handler throws an exception.
Also thrown if the change is not acceptable to the container.public void valueChanged(Settable settable)
valueChanged
in interface ValueListener
valueChanged
in class Variable
settable
- The object that has changed value.protected void _addAllContainedEntities(CompositeEntity container, java.util.List<NamedObj> result, boolean transparents, boolean opaques)
CompositeEntity.deepEntityList()
.
If includeTransparents
is true, then it also
includes transparent composite entities.
If includeOpaqueContents
is true, then it also
includes the entities contained within opaque composite entities.container
- The container of the entities.result
- The list to which to add the entities.transparents
- Specification of whether to include transparent
composite entities.opaques
- Specification of whether to include the
contents of opaque composite entities.protected boolean _deepContains(CompositeEntity container, Entity target, boolean opaques)
container
- The container.target
- The object that may be contained by the container.opaques
- If true, then allow one or more intervening opaque composite actors
in the hierarchy.protected void _evaluate() throws IllegalActionException
_evaluate
in class Variable
IllegalActionException
- If the expression cannot
be parsed or cannot be evaluated, or if a dependency loop is found.