Class Commutator

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

    public class Commutator
    extends Transformer
    implements SequenceActor
    A polymorphic commutator, which merges a set of input sequences into a single output sequence. The commutator has an input port (a multiport) and an output port (a single port). The types of the ports are undeclared and will be resolved by the type resolution mechanism, with the constraint that the output type must be greater than or equal to the input type. On each call to the fire method, the actor reads N tokens from each input channel and sends the tokens to the output port, where N is the value of blockSize. The order in which the tokens are produced is the order of the channels in the input multiport. If any input channel has no tokens, then the fire method returns without producing output. In the next iteration, the actor will begin reading at the channel that had no input token in the previous iteration. If no input token is available on the first channel being read, then no output is produced.

    For the benefit of domains like SDF, which need to know the token consumption or production rate for all ports before they can construct a firing schedule, this actor sets the tokenProductionRate parameter for the output port to equal the number of input channels times the value of the blockSize parameter. This parameter is set each time that a link is established with the input port, or when a link is removed. The director is notified that the schedule is invalid, so that if the link is modified at run time, the schedule will be recalculated if necessary.

    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Mudit Goel, Edward A. Lee
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Yellow (mudit)
    • Field Detail

      • blockSize

        public Parameter blockSize
        The number of tokens read from each input channel on each firing. This is an integer that defaults to 1.
      • input_tokenConsumptionRate

        public Parameter input_tokenConsumptionRate
        The parameter controlling the input port consumption rate. This parameter contains an IntToken, initially with a value of 1.
      • output_tokenProductionRate

        public Parameter output_tokenProductionRate
        The parameter controlling the output port production rate. This parameter contains an IntToken, initially with a value of 0. When connections are made and/or the blockSize parameter is set, this is changed to the width of the input times the value of the blockSize parameter.
    • Constructor Detail

      • Commutator

        public Commutator​(CompositeEntity container,
                          java.lang.String name)
                   throws NameDuplicationException,
                          IllegalActionException
        Construct an actor in the specified container with the specified name. Create ports and make the input port a multiport. Create the actor parameters.
        Parameters:
        container - The container.
        name - This is the name of this commutator within the container.
        Throws:
        NameDuplicationException - If an actor with an identical name already exists in the container.
        IllegalActionException - If the actor cannot be contained by the proposed container.