Class ParameterSet

  • All Implemented Interfaces:
    java.lang.Cloneable, Executable, Initializable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, ScopeExtender

    public class ParameterSet
    extends ScopeExtendingAttribute
    implements Executable
    An attribute that reads multiple values from a file and sets corresponding parameters in the container. The values are in the form:
     attributeName = value
     
    where variableName is the name of the attribute in a format suitable for NamedObj.setName(String) (i.e., does not contain periods) and value is the expression in the Ptolemy expression language. Comments are lines that begin with the # character. Each line in the file is interpreted as a separate assignment.

    The attributes that are created will have the same visibility as parameters of the container of the attribute. They are shadowed, however, by parameters of the container. That is, if the container has a parameter with the same name as one in the parameter set, the one in the container provides the value to any observer.

    If the file is modified during execution of a model, by default this will not be noticed until the next run. If you set the checkForFileUpdates parameter to true, then on each prefiring of the enclosing opaque composite actor, this parameter will check for updates of the file. Otherwise, it will only check between runs of the model or when the file name or URL gets changed.

    Note that the order the parameters are created is arbitrary, this is because we read the file in using java.util.Properties.load(), which uses a HashMap to store the properties. We use a Properties.load() because it provides a nice parser for the files and can read and write values in both text and XML.

    Since:
    Ptolemy II 5.2
    Version:
    $Id$
    Author:
    Christopher Brooks, contributor: Edward A. Lee
    See Also:
    Variable
    • Field Detail

      • checkForFileUpdates

        public Parameter checkForFileUpdates
        If this parameter is set to true, then the specified file or URL will be checked for updates on every prefiring of the enclosing opaque composite actor. Otherwise, it will check for updates only between runs. This is a boolean that defaults to false.
      • fileOrURL

        public FileParameter fileOrURL
        A parameter naming the file or URL to be read that contains attribute names and values. The file should be in a format suitable for java.util.Properties.load(), see the class comment of this class for details. This initial default value is the empty string "", which means that no file will be read and no parameter values will be defined.
    • Constructor Detail

      • ParameterSet

        public ParameterSet​(NamedObj container,
                            java.lang.String name)
                     throws IllegalActionException,
                            NameDuplicationException
        Construct an attribute with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
        Parameters:
        container - The container.
        name - The name of this attribute.
        Throws:
        IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
        NameDuplicationException - If the name coincides with an attribute already in the container.