Class LevelCrossingDetector

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

    public class LevelCrossingDetector
    extends TypedAtomicActor
    implements ContinuousStepSizeController
    An event detector that converts continuous signals to discrete events when the input trigger signal crosses a threshold specified by the level parameter. The direction parameter can constrain the actor to detect only rising or falling transitions. It has three possible values, "rising", "falling", and "both", where "both" is the default. This actor will produce an output whether the input is continuous or not. That is, if a discontinuity crosses the threshold in the right direction, it produces an output at the time of the discontinuity. If the input is continuous, then the output is generated when the input is within errorTolerance of the level. The value of the output is given by the value parameter, which by default has the value of the level parameter.

    This actor has a one microstep delay before it will produce an output. That is, when a level crossing is detected, the actor requests a refiring in the next microstep at the current time, and only in that refiring produces the output. This ensures that the output satisfies the piecewise continuity constraint. It is always absent at microstep 0.

    This actor will not produce an event at the time of the first firing unless there is a level crossing discontinuity at that time.

    Since:
    Ptolemy II 6.0
    Version:
    $Id$
    Author:
    Edward A. Lee, Haiyang Zheng
    Pt.AcceptedRating:
    Red (hyzheng)
    Pt.ProposedRating:
    Yellow (hyzheng)
    • Field Detail

      • direction

        public StringParameter direction
        A parameter that can be used to limit the detected level crossings to rising or falling. There are three choices: "falling", "rising", and "both". The default value is "both".
      • errorTolerance

        public Parameter errorTolerance
        The error tolerance specifying how close the value of a continuous input needs to be to the specified level to produce the output event. Note that this indirectly affects the accuracy of the time of the output since the output can be produced at any time after the level crossing occurs while it is still within the specified error tolerance of the level. This is a double with default 1e-4.
      • level

        public Parameter level
        The parameter that specifies the level threshold. By default, it contains a double with value 0.0. Note, a change of this parameter at run time will not be applied until the next iteration.
      • value

        public Parameter value
        The output value to produce when a level-crossing is detected. This can be any data type. It defaults to the same value as the level parameter.
      • output

        public TypedIOPort output
        The output port. The type is at least the type of the value parameter.
      • trigger

        public TypedIOPort trigger
        The trigger port. This is an input port with type double.
      • _level

        protected double _level
        The level threshold this actor detects.
    • Constructor Detail

      • LevelCrossingDetector

        public LevelCrossingDetector​(CompositeEntity container,
                                     java.lang.String name)
                              throws IllegalActionException,
                                     NameDuplicationException
        Construct an 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 subsystem that this actor is lived in
        name - The actor's name
        Throws:
        IllegalActionException - If the entity cannot be contained by the proposed container.
        NameDuplicationException - If name coincides with an entity already in the container.