Class SequencedSharedMemoryActor

    • Field Detail

      • initialVariableName

        public StringAttribute initialVariableName
        The name of the initial value variable in the container to set.
      • _sharedName

        protected java.lang.String _sharedName
        The name shared by a set of messages. This is not directly settable by the user; rather, it is derived from the actor name.
      • _scope

        protected ptolemy.domains.sequence.lib.SequencedSharedMemoryActor.Scope _scope
        The scope of the actor. See enumeration above. Global by default.
    • Constructor Detail

      • SequencedSharedMemoryActor

        public SequencedSharedMemoryActor​(CompositeEntity container,
                                          java.lang.String name)
                                   throws NameDuplicationException,
                                          IllegalActionException
        Create a new SequencedSharedMemoryActor with the given name and container.
        Parameters:
        container - The container for the new actor.
        name - The name of the new actor.
        Throws:
        NameDuplicationException - Thrown if the chosen name matches the name of an already existing actor in the model.
        IllegalActionException - Thrown if there is a problem instantiating the actor.
    • Method Detail

      • checkForAttributes

        public void checkForAttributes()
                                throws IllegalActionException
        Check to see if the parameters exist in the workspace. Similar to SetVariable getAttribute(). If not, create them, and assign them a null token. This is needed for (for example) when the actor is dragged and dropped from the menu, since the parameters will be created but do not have any user defined values. Subclasses can override this method, or can use checkForVariables(Token) FIXME Any way to get these to display to the user?
        Throws:
        IllegalActionException - If there is a problem with the attributes.
      • checkForAttributes

        public void checkForAttributes​(Token value1,
                                       Token value2)
                                throws IllegalActionException
        Check to see if both the variable and initial value variable exist. If not, create them, and set their tokens to the arguments.
        Parameters:
        value1 - The value to assign to the variable.
        value2 - The value to assign to the initial value variable.
        Throws:
        IllegalActionException - If the attributes cannot be created.
      • fire

        public void fire()
                  throws IllegalActionException
        Fire the SequencedSharedMemoryActor. If the input is not connected, do not try to read a value from it. It is OK not to read any value, since SequencedSharedMemoryActors always have an initial value.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class SetVariable
        Throws:
        IllegalActionException - If the actor cannot be fired.
      • getInitialVariable

        public Variable getInitialVariable()
                                    throws IllegalActionException
        Return the initial variable. Create it if it's not present.
        Returns:
        The initial variable. Returns null if the variable name is not assigned or is the empty string.
        Throws:
        IllegalActionException - If the variable cannot be found.
      • getInitialVariableName

        public java.lang.String getInitialVariableName()
        Returns the initial variable's name.
        Returns:
        The initial variable name.
      • getModifiedVariable

        public Attribute getModifiedVariable()
                                      throws IllegalActionException
        From superclass. Overridden to return checkSingleVariable for the variable (i.e. not the initial value variable). This will create the variable if not present.
        Overrides:
        getModifiedVariable in class SetVariable
        Returns:
        The attribute that was found or created.
        Throws:
        IllegalActionException - If the container is null, or the name is invalid (from checkSingleAttribute).
      • getModifiedVariable

        public Variable getModifiedVariable​(java.lang.String name)
                                     throws IllegalActionException
        Similar to superclass getModifiedVariable(), but takes a name as an argument and does not used cached variables, and checks only in the proper scope. Also, it returns a variable (not an attribute). This makes more sense but is inconsistent with superclass function. Subclasses should use this function. Also, uses the default value if the variable is created.
        Parameters:
        name - The name of the variable to get.
        Returns:
        The attribute that was found or created
        Throws:
        IllegalActionException - If the container is null, or the name is invalid (from checkSingleAttribute)
      • getSharedName

        public java.lang.String getSharedName()
        Return the sharedName.
        Returns:
        Name shared by set of messages
      • getVariable

        public Variable getVariable()
                             throws IllegalActionException
        Return the modified variable. Create it if it's not present. Different from getModifiedVariable, in that it returns a Variable, not an attribute.
        Returns:
        The modified variable. Returns null if the variable name is not assigned or is the empty string.
        Throws:
        IllegalActionException - If there is a problem with the variable referenced by this actor.
      • getVariableName

        public java.lang.String getVariableName()
        Returns the variable's name.
        Returns:
        The variable name.
      • setName

        public void setName​(java.lang.String name)
                     throws IllegalActionException,
                            NameDuplicationException
        When the actor name is changed, update the referenced variables to point to the new parameters and check to see if these parameters exist. This is also called when the actor is created, so don't need it in constructor. Previously, the code for the ASCETArray would allow direct changes in the variable name, in attributeChanged(). This is no longer allowed. The user should change the name of the actor; then, the variable name change will follow.
        Specified by:
        setName in interface Nameable
        Overrides:
        setName in class ComponentEntity<TypedIOPort>
        Parameters:
        name - The new name of the actor
        Throws:
        IllegalActionException - If the name cannot be changed.
        NameDuplicationException - If there is another actor with the same name in the actor's container
        See Also:
        NamedObj.getName(), NamedObj.getName(NamedObj)
      • _getDefaultValue

        protected Token _getDefaultValue()
                                  throws IllegalActionException
        Supplies a default value for the variable, in the case that there is no initial value. Subclasses should override getDefaultValue() to return an appropriate token. If there is no appropriate token, the actor should throw an exception stating that a default value is required.
        Returns:
        A token containing the default value
        Throws:
        IllegalActionException - Subclasses should throw an exception if an explicit initial value is required.
      • _setValue

        protected void _setValue​(Attribute variable,
                                 java.lang.String value)
                          throws IllegalActionException
        Set the value of the associated container's variable. Added a name here, to set the variable with this name. Override base class function, since the base class function does not set the value if the tokens are equal. This causes problems for the token solver.
        Parameters:
        variable - The variable whose value will be set.
        value - The new value as a string.
        Throws:
        IllegalActionException - If the variable cannot be set.
      • _setValue

        protected void _setValue​(Attribute variable,
                                 Token value)
                          throws IllegalActionException
        Set the value of the associated container's variable. Added a name here, to set the variable with this name. Override base class function, since the base class function does not set the value if the tokens are equal. This causes problems for the token solver.
        Parameters:
        variable - The variable whose value will be set.
        value - The new value as a token.
        Throws:
        IllegalActionException - If the variable cannot be set.