Class BinarySwitch

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

    public class BinarySwitch
    extends TypedAtomicActor
    An actor that calls Thread.sleep() on the current thread the first time fire() is called. The sleep delays the inputs for a certain amount of real time, specified by the sleepTime parameter.

    Note that one way to slow down the execution of a model while running inside vergil is to turn on animation.

    If the width of the output port is less than that of the input port, the tokens in the extra channels are lost.

    Since:
    Ptolemy II 2.2
    Version:
    $Id$
    Author:
    Yang Zhao, based on Sleep by Jie Liu, Christopher Hylands
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Yellow (cxh)
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        Call Thread.sleep() the first time fire is called and then transfer tokens from inputs to outputs, one token from each channel. If fire() is called twice in a row without an intervening call to either postfire() or prefire(), then no output is produced.

        If the width of the output port is less than that of the input port, the tokens in the extra channels are lost.

        Specified by:
        fire in interface Executable
        Overrides:
        fire in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - Not thrown in this base class
      • preinitialize

        public void preinitialize()
                           throws IllegalActionException
        Description copied from class: AtomicActor
        Create receivers and declare delay dependencies. Derived classes can override this method to perform additional initialization functions, but they should call this base class methods or create the receivers themselves. This method gets executed exactly once prior to any other action methods. It cannot produce output data since type resolution is typically not yet done. It also gets invoked prior to any static scheduling that might occur in the domain, so it can change scheduling information.
        Specified by:
        preinitialize in interface Initializable
        Overrides:
        preinitialize in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - Not thrown in this base class.