ptolemy.domains.ptinyos.kernel
Class PtinyOSNodeParameter
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.kernel.util.AbstractSettableAttribute
ptolemy.data.expr.Variable
ptolemy.data.expr.Parameter
ptolemy.actor.parameters.SharedParameter
ptolemy.domains.ptinyos.kernel.PtinyOSNodeParameter
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Initializable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener
public class PtinyOSNodeParameter
- extends SharedParameter
A parameter for coordinated numbering in the PtinyOS domain. This
parameter is shared throughout a model for coordinated management of
node ID's and TOSSIM port numbers (command and event ports for
connecting to TinyViz and other external tools). Changing the
expression of any one instance of the parameter will result in all
instances that are shared being changed. If the value is being set,
then all other non-zero values are set to unique numbers by
incrementing by a value specified by the user (default value of 1)
while iterating through the shared parameters. Note that if the
current value is 0, the value is left unchanged.
An instance elsewhere in the model (within the same top level) is
shared if it has the same type and its container is of the class
specified in the constructor (or of the container class, if no class
is specified in the constructor).
One exception is that if this parameter is (deeply) within an
instance of EntityLibrary, then the parameter is not shared.
Were this not the case, then opening a library containing this
parameter would force expansion of all the sublibraries of
EntityLibrary, which would defeat the lazy instantiation
of EntityLibrary.
This parameter is always of type int.
- Version:
- $Id: PtinyOSNodeParameter.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Elaine Cheong
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Field Summary |
private static int |
_defaultValue
Default value of this parameter. |
private int |
_incrementValue
Value by which to increment other occurrences of this parameter. |
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary |
PtinyOSNodeParameter(NamedObj container,
java.lang.String name)
Construct a parameter with the given container and name. |
PtinyOSNodeParameter(NamedObj container,
java.lang.String name,
java.lang.Class containerClass)
Construct a parameter with the given container, name, and
container class, using the default value. |
PtinyOSNodeParameter(NamedObj container,
java.lang.String name,
java.lang.Class containerClass,
int incrementValue)
Construct a parameter with the given container, name, and
container class, using the default value. |
PtinyOSNodeParameter(NamedObj container,
java.lang.String name,
int incrementValue)
Construct a parameter with the given container and name. |
Method Summary |
void |
inferValueFromContext(java.lang.String defaultValue)
Override the base class to set the declared type before
attempting to infer the value. |
void |
setExpression(java.lang.String expression)
Set the expression of the shared parameters. |
Methods inherited from class ptolemy.actor.parameters.SharedParameter |
_propagateValue, addInitializable, clone, getRoot, getToken, initialize, isFireFunctional, isStrict, isSuppressingPropagation, preinitialize, removeInitializable, setContainer, setName, setSuppressingPropagation, setToken, sharedParameterSet, validate, wrapup |
Methods inherited from class ptolemy.data.expr.Variable |
_description, _evaluate, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _setToken, _setTokenAndNotify, addValueListener, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isTypeAcceptable, removeValueListener, reset, setLazy, setParseTreeEvaluator, setStringMode, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints, valueChanged |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
_incrementValue
private int _incrementValue
- Value by which to increment other occurrences of this parameter.
_defaultValue
private static int _defaultValue
- Default value of this parameter.
PtinyOSNodeParameter
public PtinyOSNodeParameter(NamedObj container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct a parameter with the given container and name.
The container class will be used to determine which other
instances of PtinyOSNodeParameter are shared with this one.
- Parameters:
container
- The container.name
- The name of the parameter.
- Throws:
IllegalActionException
- If the parameter is not of an
acceptable class for the container.
NameDuplicationException
- If the name coincides with
a parameter already in the container.
PtinyOSNodeParameter
public PtinyOSNodeParameter(NamedObj container,
java.lang.String name,
int incrementValue)
throws IllegalActionException,
NameDuplicationException
- Construct a parameter with the given container and name.
The container class will be used to determine which other
instances of PtinyOSNodeParameter are shared with this one.
- Parameters:
container
- The container.name
- The name of the parameter.incrementValue
- The value with which to increment
subsequent parameters.
- Throws:
IllegalActionException
- If the parameter is not of an
acceptable class for the container.
NameDuplicationException
- If the name coincides with
a parameter already in the container.
PtinyOSNodeParameter
public PtinyOSNodeParameter(NamedObj container,
java.lang.String name,
java.lang.Class containerClass)
throws IllegalActionException,
NameDuplicationException
- Construct a parameter with the given container, name, and
container class, using the default value. The specified class
will be used to determine which other instances of
PtinyOSNodeParameter are shared with this one.
- Parameters:
container
- The container.name
- The name of the parameter.containerClass
- The class used to determine shared instances.
- Throws:
IllegalActionException
- If the parameter is not of an
acceptable class for the container.
NameDuplicationException
- If the name coincides with
a parameter already in the container.
PtinyOSNodeParameter
public PtinyOSNodeParameter(NamedObj container,
java.lang.String name,
java.lang.Class containerClass,
int incrementValue)
throws IllegalActionException,
NameDuplicationException
- Construct a parameter with the given container, name, and
container class, using the default value. The specified class
will be used to determine which other instances of
PtinyOSNodeParameter are shared with this one.
- Parameters:
container
- The container.name
- The name of the parameter.containerClass
- The class used to determine shared instances.incrementValue
- The value with which to increment
subsequent parameters.
- Throws:
IllegalActionException
- If the parameter is not of an
acceptable class for the container.
NameDuplicationException
- If the name coincides with
a parameter already in the container.
inferValueFromContext
public void inferValueFromContext(java.lang.String defaultValue)
- Override the base class to set the declared type before
attempting to infer the value. This is necessary because
this method is called in the constructor of the base class,
before the declared type has been set.
- Overrides:
inferValueFromContext
in class SharedParameter
- Parameters:
defaultValue
- The default parameter value to use.
- Throws:
InternalErrorException
- If there are multiple
shared parameters in the model, but their values
do not match.
setExpression
public void setExpression(java.lang.String expression)
- Set the expression of the shared parameters.
- Specified by:
setExpression
in interface Settable
- Overrides:
setExpression
in class SharedParameter
- Parameters:
expression
- The expression.- See Also:
Variable.getExpression()