Class RelationNode


  • public final class RelationNode
    extends java.lang.Object
    An instance of the RelationNode class stores the type and difference information of a relation. For more details of type, see RelationType. For more details of difference, see ParseTreeEvaluatorForGuardExpression. The instance stores the information of two evaluations of the transition, the current evaluation and the previous evaluation.
    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Haiyang Zheng
    Pt.AcceptedRating:
    Red (hyzheng)
    Pt.ProposedRating:
    Yellow (hyzheng)
    • Constructor Summary

      Constructors 
      Constructor Description
      RelationNode​(int type, double difference)
      Construct a relation node with given type and difference information.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void commit()
      Update the previous type and difference information of this relation node with the current evaluation result.
      double getDifference()
      Return the difference information from the current evaluation of the relation node.
      double getPreviousDifference()
      Return the difference information from the previous evaluation of the relation node.
      boolean hasEvent()
      Return true if the relation node has its type changed, and if the current type is equal/inequal or the current type changes from less_than to bigger_than or bigger_than to less_than.
      void reset()
      Reset the relation node by setting the former type and difference information to RelationType.INVALID and 0.0 respectively.
      void setDifference​(double difference)
      Set the difference information with the current evaluation result of the relation node.
      void setType​(int type)
      Set the type information with the current evaluation result of the relation node.
      boolean typeChanged()
      Return true if the type changed and the previous type information is valid.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RelationNode

        public RelationNode​(int type,
                            double difference)
        Construct a relation node with given type and difference information.
        Parameters:
        type - The type, one of RelationType.
        difference - The difference.
    • Method Detail

      • reset

        public void reset()
        Reset the relation node by setting the former type and difference information to RelationType.INVALID and 0.0 respectively.
      • commit

        public void commit()
        Update the previous type and difference information of this relation node with the current evaluation result.
      • getDifference

        public double getDifference()
        Return the difference information from the current evaluation of the relation node.
        Returns:
        The current difference information.
        See Also:
        setDifference(double)
      • getPreviousDifference

        public double getPreviousDifference()
        Return the difference information from the previous evaluation of the relation node.
        Returns:
        The previous difference information.
      • hasEvent

        public boolean hasEvent()
        Return true if the relation node has its type changed, and if the current type is equal/inequal or the current type changes from less_than to bigger_than or bigger_than to less_than. This is used to detect whether a continuous variable crosses a level.
        Returns:
        True If event has been detected.
      • setType

        public void setType​(int type)
        Set the type information with the current evaluation result of the relation node.
        Parameters:
        type - The current type information.
      • setDifference

        public void setDifference​(double difference)
        Set the difference information with the current evaluation result of the relation node.
        Parameters:
        difference - The current difference information.
        See Also:
        getDifference()
      • typeChanged

        public boolean typeChanged()
        Return true if the type changed and the previous type information is valid.
        Returns:
        True If the type changed and the previous type information is valid.