Class SmartSender

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

    public class SmartSender
    extends TypedAtomicActor
    This actor adaptively establishes connections by searching for an unused input port in the model and connecting to it. If the output is connected to something (the width of the output port is greater than zero), then the actor sends an integer on the output port and requests a refiring at a time in the future determined by the firingPeriod parameter. The value of the output is simply the count of the firing, starting at 1.

    If the output is not connected to anything, then the actor will attempt to connect it. It does this by issuing a change request that, when executed, will search for an unused input port (any unused input port) in and actor in the same container as this actor, and then will connect to it.

    Note that getWidth() is used rather than numberOfSinks() to determine whether the output is connected. This way, this actors search for an input port can be silenced by just connecting it to a relation.

    This actor is an illustration of the capability actors can have to affect their environment, to detect faults (in this case, missing connections), and to repair the model. It is designed to be used in the DE domain, or any domain that respects fireAt() calls.

    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    See Also:
    IOPort.getWidth()
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • output

        public TypedIOPort output
        The output port, which has type int.
      • firingPeriod

        public Parameter firingPeriod
        The period at which this actor will execute. This is a double with a default value of 0.1.
    • Constructor Detail

      • SmartSender

        public SmartSender​(CompositeEntity container,
                           java.lang.String name)
                    throws NameDuplicationException,
                           IllegalActionException
        Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
        Parameters:
        container - The container.
        name - The name of this actor within the container.
        Throws:
        IllegalActionException - If this actor cannot be contained by the proposed container (see the setContainer() method).
        NameDuplicationException - If the name coincides with an entity already in the container.