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;
}
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;
}
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));
}
}
Aggregations