Search in sources :

Example 11 with AadlInteger

use of org.osate.aadl2.AadlInteger in project osate2 by osate.

the class PropertyUtils method createIntegerValue.

/**
 * Creates a PropertyValue for an aadlinteger with units.
 *
 * @throws IllegalArgumentException Thrown if unit is null.
 */
public static IntegerLiteral createIntegerValue(long intValue, UnitLiteral unit) throws IllegalArgumentException {
    if (unit == null) {
        throw new IllegalArgumentException("UnitLiteral unit cannot be null.");
    }
    IntegerLiteral newPropertyValue = createIntegerValue(intValue);
    newPropertyValue.setUnit(unit);
    return newPropertyValue;
}
Also used : IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 12 with AadlInteger

use of org.osate.aadl2.AadlInteger in project osate2 by osate.

the class PropertyUtils method createIntegerRangeValue.

/**
 * Creates a PropertyValue for a range of aadlinteger with units.
 *
 * @throws IllegalArgumentException Thrown if minUnits, maxUnits, or
 *             deltaUnits is null, if minUnits, maxUnits, and deltaUnits are
 *             not of the same UnitType, or if min is greater than max.
 */
public static RangeValue createIntegerRangeValue(long min, UnitLiteral minUnits, long max, UnitLiteral maxUnits, long delta, UnitLiteral deltaUnits) throws IllegalArgumentException {
    RangeValue newPropertyValue = createIntegerRangeValue(min, minUnits, max, maxUnits);
    if (deltaUnits == null) {
        throw new IllegalArgumentException("deltaUnits cannot be null.");
    }
    if (!minUnits.eContainer().equals(deltaUnits.eContainer())) {
        throw new IllegalArgumentException("minUnits, maxUnits, and deltaUnits are not of the same type.");
    }
    newPropertyValue.setDelta(createIntegerValue(delta, deltaUnits));
    return newPropertyValue;
}
Also used : RangeValue(org.osate.aadl2.RangeValue)

Example 13 with AadlInteger

use of org.osate.aadl2.AadlInteger in project AGREE by loonwerks.

the class AgreeASTBuilder method gatherUnspecifiedAadlProperties.

private void gatherUnspecifiedAadlProperties(Map<String, GetPropertyExpr> unspecifiedAadlProperties, List<AgreeVar> inputs, List<AgreeStatement> assumptions, List<AgreeStatement> guarantees) {
    for (Entry<String, GetPropertyExpr> entry : unspecifiedAadlProperties.entrySet()) {
        String propInputName = entry.getKey();
        GetPropertyExpr expr = entry.getValue();
        Property prop = (Property) expr.getProp();
        Expr propInputIdExpr = new IdExpr(propInputName);
        Type type;
        Expr bound = null;
        if (prop.getReferencedPropertyType() instanceof AadlBoolean) {
            type = NamedType.BOOL;
        } else if (prop.getReferencedPropertyType() instanceof AadlInteger) {
            AadlInteger aadlInteger = (AadlInteger) prop.getReferencedPropertyType();
            type = NamedType.INT;
            if (aadlInteger.getRange() != null) {
                PropertyExpression lowerBound = aadlInteger.getRange().getLowerBound();
                PropertyExpression upperBound = aadlInteger.getRange().getUpperBound();
                Expr lowVal = new IntExpr(BigDecimal.valueOf(((IntegerLiteral) lowerBound).getScaledValue()).toBigInteger());
                Expr highVal = new IntExpr(BigDecimal.valueOf(((IntegerLiteral) upperBound).getScaledValue()).toBigInteger());
                Expr lowBound = new BinaryExpr(lowVal, BinaryOp.LESSEQUAL, propInputIdExpr);
                Expr highBound = new BinaryExpr(propInputIdExpr, BinaryOp.LESSEQUAL, highVal);
                bound = LustreExprFactory.makeANDExpr(lowBound, highBound);
            }
        } else if (prop.getReferencedPropertyType() instanceof AadlReal) {
            AadlReal aadlReal = (AadlReal) prop.getReferencedPropertyType();
            type = NamedType.REAL;
            if (aadlReal.getRange() != null) {
                PropertyExpression lowerBound = aadlReal.getRange().getLowerBound();
                PropertyExpression upperBound = aadlReal.getRange().getUpperBound();
                Expr lowVal = new RealExpr(BigDecimal.valueOf(((RealLiteral) lowerBound).getValue()));
                Expr highVal = new RealExpr(BigDecimal.valueOf(((RealLiteral) upperBound).getValue()));
                Expr lowBound = new BinaryExpr(lowVal, BinaryOp.LESSEQUAL, propInputIdExpr);
                Expr highBound = new BinaryExpr(propInputIdExpr, BinaryOp.LESSEQUAL, highVal);
                bound = LustreExprFactory.makeANDExpr(lowBound, highBound);
            }
        } else {
            throw new AgreeException("Could not locate property value '\" + prop.getFullName() + \"' in component '\"\n" + "//						+ compName.getName() + \"'.   Analysis on abstract values not supported for " + "AADL property type " + prop.getReferencedPropertyType() + ".");
        }
        AgreeVar propInputVar = new AgreeVar(propInputName, type, expr, curInst, null);
        Expr constraint = getUnchangingConstraintExpr(propInputIdExpr);
        if (bound != null) {
            constraint = LustreExprFactory.makeANDExpr(constraint, bound);
        }
        inputs.add(propInputVar);
        assumptions.add(new AgreeStatement("", constraint, prop));
    }
}
Also used : AadlReal(org.osate.aadl2.AadlReal) IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealLiteral(org.osate.aadl2.RealLiteral) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) AadlBoolean(org.osate.aadl2.AadlBoolean) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) PropertyExpression(org.osate.aadl2.PropertyExpression) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AadlInteger(org.osate.aadl2.AadlInteger) IntExpr(jkind.lustre.IntExpr) Property(org.osate.aadl2.Property) RealExpr(jkind.lustre.RealExpr) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

IntegerLiteral (org.osate.aadl2.IntegerLiteral)9 AadlBoolean (org.osate.aadl2.AadlBoolean)8 AadlInteger (org.osate.aadl2.AadlInteger)8 AadlReal (org.osate.aadl2.AadlReal)8 AadlString (org.osate.aadl2.AadlString)7 RealLiteral (org.osate.aadl2.RealLiteral)7 BooleanLiteral (org.osate.aadl2.BooleanLiteral)5 StringLiteral (org.osate.aadl2.StringLiteral)5 EPackage (org.eclipse.emf.ecore.EPackage)4 Action (org.eclipse.xtext.Action)4 Parameter (org.eclipse.xtext.Parameter)4 ParserRule (org.eclipse.xtext.ParserRule)4 RangeValue (org.osate.aadl2.RangeValue)3 APropertyReference (org.osate.alisa.common.common.APropertyReference)3 AUnitExpression (org.osate.alisa.common.common.AUnitExpression)3 ClassifierType (org.osate.aadl2.ClassifierType)2 ClassifierValue (org.osate.aadl2.ClassifierValue)2 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)2 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)2 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)2