Closed lwrage closed 5 years ago
The CacheThe default compares the objects. To fix some problems we added content comparison for certain cases (references and list of references and literals. Need to add comparisons for int, real, range of int/real.
We had overridden the equals method in property value classes to make this work. However this caused bug #524. In the fix we renamed the equals to sameAs(). This one needs to be used when checking property consistency.
Values with units need to be converted to the same unit before comparison. Currently 2s != 2000ms.
Look in org.osate.alisa.common.typing.InterpreterUtil
for inspiration.
This checking occurs in CachePropertyAssociationsSwitch.cacheConnectionPropertyAssociation()
.
Need to update RealLiteralImpl.sameAs()
and IntegerLiteralImpl.sameAs()
Fixed the sameAs()
methods to use this
final UnitLiteral myUnit = getUnit();
final UnitLiteral otherUnit = other.getUnit();
final UnitLiteral smallerUnit = NumberValueOperations.smallerUnit(myUnit, otherUnit);
if (smallerUnit == null) { // no units at all
return value == other.value;
} else {
return NumberValueOperations.getScaledValue(this, smallerUnit) == NumberValueOperations
.getScaledValue(other, smallerUnit);
}
It seems that the base
attribute of IntegerLiteral
is useless. It is always zero.
I'm concerned that this technique may cause problems at some point due to loss of information in floating point operations, but we will have to wait and see. Can always switch to using java.lang.math.BigDecimal
.
Example model: AutonomousVehicleSystem from https://github.com/bisc/collision_detection_aadl.git Instantiate system implementation
avoidance_subsystem.impl
inavoidance_subsystem.aadl
Connection instances have error markers about inconsistent latency value, but all values in the declarative model are identical.