osate / osate2

Open Source AADL2 Tool Environment
http://osate.org
Eclipse Public License 2.0
36 stars 8 forks source link

Checking property consistency along connection instance does not work correctly #665

Closed lwrage closed 5 years ago

lwrage commented 8 years ago

Example model: AutonomousVehicleSystem from https://github.com/bisc/collision_detection_aadl.git Instantiate system implementation avoidance_subsystem.impl in avoidance_subsystem.aadl Connection instances have error markers about inconsistent latency value, but all values in the declarative model are identical.

reteprelief commented 8 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.

lwrage commented 8 years ago

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.

lwrage commented 7 years ago

Values with units need to be converted to the same unit before comparison. Currently 2s != 2000ms.

AaronGreenhouse commented 5 years ago

Look in org.osate.alisa.common.typing.InterpreterUtil for inspiration.

AaronGreenhouse commented 5 years ago

This checking occurs in CachePropertyAssociationsSwitch.cacheConnectionPropertyAssociation().

AaronGreenhouse commented 5 years ago

Need to update RealLiteralImpl.sameAs() and IntegerLiteralImpl.sameAs()

AaronGreenhouse commented 5 years ago

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.