ptolemy.domains.modal.kernel
Class RelationNode

java.lang.Object
  extended by ptolemy.domains.modal.kernel.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 evaluaiton.

Since:
Ptolemy II 8.0
Version:
$Id: RelationNode.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Haiyang Zheng
Accepted Rating:
Red (hyzheng)
Proposed Rating:
Yellow (hyzheng)

Field Summary
private  int _currentType
           
private  double _difference
           
private  double _previousDifference
           
private  int _previousType
           
 
Constructor Summary
RelationNode(int type, double difference)
          Construct a relation node with given type and difference information.
 
Method Summary
 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
 

Field Detail

_currentType

private int _currentType

_difference

private double _difference

_previousDifference

private double _previousDifference

_previousType

private int _previousType
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.