|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.domains.fsm.kernel.RelationList
public class RelationList
A RelationList object contains a list of relations of a guard expression.
Relations are comparison operations, for example "x >= 10", where x is
a variable. This class provides facilities for measuring how far the
expression is from the threshold; for example, if x = 7, then the
distance to the threshold is 3. Moreover, it provides a mechanism
for recording the current distance (via a "commit") and then later
accessing that distance and comparing it against the current distance.
The information
includes relation type and the difference information. (See
ParseTreeEvaluatorForGuardExpression
for the detailed explanation
of relation type and difference.) This attribute is non-persistent and will
not be exported into MoML.
This class is designed to be used with ParseTreeEvaluatorForGuardExpression. The common usage would be like:
Construct a relation list for a transition with the first argument of the constructor as that transition.
_relationList = new RelationList();
Associate the relation list with the an object of ParseTreeEvaluatorForGuardExpression
_parseTreeEvaluator = new ParseTreeEvaluatorForGuardExpression(_relationList, getErrorTolerance());
See Transition
for the detailed usage.
Red (hyzheng) |
Yellow (hyzheng) |
Field Summary | |
---|---|
private int |
_maximumDifferenceIndex
|
private java.util.LinkedList |
_relationList
|
Constructor Summary | |
---|---|
RelationList()
Construct a relation list. |
Method Summary | |
---|---|
void |
addRelation(int type,
double difference)
Construct a relation node with the given type and difference information of a relation, and add it to the end of the relation list. |
void |
commitRelationValues()
Record the current relation values so that when getPreviousMaximumDistance() is called, these recorded values are used. |
void |
destroy()
Destroy the relation list by deleting all the contained elements. |
double |
getMaximumDifference()
Return the maximum current difference of all the relations by iterating the relation list. |
double |
getPreviousMaximumDistance()
Return the previous difference of the relation that has the maximum current difference. |
boolean |
hasEvent()
Return true if there exists an event caused by the type change of any relation. |
boolean |
isEmpty()
Return true if the relation list is empty. |
int |
length()
Return the number of relations in the relation list. |
void |
resetRelationList()
Reset the relation list by resetting each relation node. |
void |
setRelation(int relationIndex,
int type,
double difference)
Update the relation in the relation list referred by the relation index argument with the given type and difference information. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int _maximumDifferenceIndex
private java.util.LinkedList _relationList
Constructor Detail |
---|
public RelationList()
Method Detail |
---|
public void addRelation(int type, double difference)
type
- The relation type of the relation.difference
- The difference of the relation.public void resetRelationList()
public void commitRelationValues()
getPreviousMaximumDistance()
public void destroy()
public double getPreviousMaximumDistance()
commitRelationValues()
public boolean hasEvent()
public boolean isEmpty()
public int length()
public double getMaximumDifference()
public void setRelation(int relationIndex, int type, double difference)
relationIndex
- The position of the relation in the
relation list.type
- The current type of the relation.difference
- The current difference of the relation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |