Search in sources :

Example 6 with BooleanLiteral

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

the class Sei method getVdidInspect.

public static Optional<Boolean> getVdidInspect(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getVdidInspect_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((BooleanLiteral) resolved).getValue());
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 7 with BooleanLiteral

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

the class AbstractPropertiesSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 8 with BooleanLiteral

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

the class ExecuteResoluteUtil method addParams.

private void addParams(FnCallExpr call, List<PropertyExpression> params) {
    for (PropertyExpression p : params) {
        if (p instanceof RealLiteral) {
            RealExpr realval = ResoluteFactory.eINSTANCE.createRealExpr();
            realval.setVal((RealLiteral) p);
            call.getArgs().add(realval);
        } else if (p instanceof IntegerLiteral) {
            IntExpr intval = ResoluteFactory.eINSTANCE.createIntExpr();
            intval.setVal((IntegerLiteral) p);
            call.getArgs().add(intval);
        } else if (p instanceof StringLiteral) {
            StringExpr stringval = ResoluteFactory.eINSTANCE.createStringExpr();
            stringval.setVal((StringLiteral) p);
            call.getArgs().add(stringval);
        } else if (p instanceof BooleanLiteral) {
            BoolExpr boolval = ResoluteFactory.eINSTANCE.createBoolExpr();
            boolval.setVal((BooleanLiteral) p);
            call.getArgs().add(boolval);
        }
    }
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral) StringExpr(com.rockwellcollins.atc.resolute.resolute.StringExpr) BoolExpr(com.rockwellcollins.atc.resolute.resolute.BoolExpr) StringLiteral(org.osate.aadl2.StringLiteral) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyExpression(org.osate.aadl2.PropertyExpression) IntExpr(com.rockwellcollins.atc.resolute.resolute.IntExpr) RealExpr(com.rockwellcollins.atc.resolute.resolute.RealExpr) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 9 with BooleanLiteral

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

the class ExecuteResoluteUtil method executeResoluteFunctionOnce.

/**
 * invokes Resolute claim function on targetComponent or targetElement if not null.
 * instanceroot is used to initialize the Resolute evaluation context.
 * targetComponent is the evaluation context
 * targetElement is the model element within the component instance or null.
 * parameterObjects is a list of additional parameters of types RealLiteral, IntegerLiteral, StringLiteral, BooleanLiteral
 * parameterObjects can be null or an empty list.
 * The return value is an Issue object with subissues for the list of issues returned in the Resolute ClaimResult.
 * If the proof fails then the top Issue is set to FAIL, if successful it is set to SUCCESS
 */
public Diagnostic executeResoluteFunctionOnce(EObject fundef, final SystemInstance instanceroot, final ComponentInstance targetComponent, final InstanceObject targetElement, List<PropertyExpression> parameterObjects) {
    FunctionDefinition fd = (FunctionDefinition) fundef;
    initializeResoluteContext(instanceroot);
    EvaluationContext context = new EvaluationContext(targetComponent, sets, featToConnsMap);
    // check for claim function
    FnCallExpr fcncall = createWrapperFunctionCall(fd, targetComponent, targetElement, parameterObjects);
    if (fcncall != null) {
        // using com.rockwellcollins.atc.resolute.analysis.results.ClaimResult
        ResoluteProver prover = new ResoluteProver(context) {

            @Override
            protected ResoluteEvaluator createResoluteEvaluator() {
                return new ResoluteEvaluator(context, varStack.peek()) {

                    @Override
                    public ResoluteValue caseThisExpr(ThisExpr object) {
                        NamedElement curr = context.getThisInstance();
                        if (object.getSub() != null) {
                            curr = object.getSub().getBase();
                        }
                        return new NamedElementValue(curr);
                    }
                };
            }
        };
        ResoluteResult res = prover.doSwitch(fcncall);
        return doResoluteResults(res);
    } else {
        return ResultUtil.createErrorDiagnostic("Could not find Resolute Function " + fd.getName(), fd);
    }
}
Also used : ResoluteEvaluator(com.rockwellcollins.atc.resolute.analysis.execution.ResoluteEvaluator) ResoluteResult(com.rockwellcollins.atc.resolute.analysis.results.ResoluteResult) NamedElementValue(com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue) FunctionDefinition(com.rockwellcollins.atc.resolute.resolute.FunctionDefinition) EvaluationContext(com.rockwellcollins.atc.resolute.analysis.execution.EvaluationContext) FnCallExpr(com.rockwellcollins.atc.resolute.resolute.FnCallExpr) NamedElement(org.osate.aadl2.NamedElement) ResoluteProver(com.rockwellcollins.atc.resolute.analysis.execution.ResoluteProver) ThisExpr(com.rockwellcollins.atc.resolute.resolute.ThisExpr)

Example 10 with BooleanLiteral

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

the class CommonSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.AADL_BOOLEAN:
                sequence_TypeRef(context, (AadlBoolean) semanticObject);
                return;
            case Aadl2Package.AADL_INTEGER:
                sequence_TypeRef(context, (AadlInteger) semanticObject);
                return;
            case Aadl2Package.AADL_REAL:
                sequence_TypeRef(context, (AadlReal) semanticObject);
                return;
            case Aadl2Package.AADL_STRING:
                sequence_TypeRef(context, (AadlString) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_ABooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_AIntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_ARealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    else if (epackage == CommonPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case CommonPackage.ABINARY_OPERATION:
                sequence_AAdditiveExpression_AAndExpression_AEqualityExpression_AMultiplicativeExpression_AOrExpression_ARelationalExpression(context, (ABinaryOperation) semanticObject);
                return;
            case CommonPackage.ACONDITIONAL:
                sequence_AIfExpression(context, (AConditional) semanticObject);
                return;
            case CommonPackage.AFUNCTION_CALL:
                sequence_AFunctionCall(context, (AFunctionCall) semanticObject);
                return;
            case CommonPackage.AMODEL_REFERENCE:
                sequence_AModelReference(context, (AModelReference) semanticObject);
                return;
            case CommonPackage.APROPERTY_REFERENCE:
                if (rule == grammarAccess.getAModelOrPropertyReferenceRule() || rule == grammarAccess.getAExpressionRule() || rule == grammarAccess.getAOrExpressionRule() || action == grammarAccess.getAOrExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAndExpressionRule() || action == grammarAccess.getAAndExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAEqualityExpressionRule() || action == grammarAccess.getAEqualityExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getARelationalExpressionRule() || action == grammarAccess.getARelationalExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAdditiveExpressionRule() || action == grammarAccess.getAAdditiveExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAMultiplicativeExpressionRule() || action == grammarAccess.getAMultiplicativeExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAUnaryOperationRule() || rule == grammarAccess.getAUnitExpressionRule() || action == grammarAccess.getAUnitExpressionAccess().getAUnitExpressionExpressionAction_1_0() || rule == grammarAccess.getAPrimaryExpressionRule() || rule == grammarAccess.getAParenthesizedExpressionRule()) {
                    sequence_AModelOrPropertyReference_APropertyReference(context, (APropertyReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAPropertyReferenceRule()) {
                    sequence_APropertyReference(context, (APropertyReference) semanticObject);
                    return;
                } else
                    break;
            case CommonPackage.ARANGE:
                sequence_ARangeExpression(context, (ARange) semanticObject);
                return;
            case CommonPackage.AUNARY_OPERATION:
                sequence_AUnaryOperation(context, (AUnaryOperation) semanticObject);
                return;
            case CommonPackage.AUNIT_EXPRESSION:
                if (rule == grammarAccess.getAExpressionRule() || rule == grammarAccess.getAOrExpressionRule() || action == grammarAccess.getAOrExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAndExpressionRule() || action == grammarAccess.getAAndExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAEqualityExpressionRule() || action == grammarAccess.getAEqualityExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getARelationalExpressionRule() || action == grammarAccess.getARelationalExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAAdditiveExpressionRule() || action == grammarAccess.getAAdditiveExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAMultiplicativeExpressionRule() || action == grammarAccess.getAMultiplicativeExpressionAccess().getABinaryOperationLeftAction_1_0_0_0() || rule == grammarAccess.getAUnaryOperationRule() || rule == grammarAccess.getAUnitExpressionRule() || action == grammarAccess.getAUnitExpressionAccess().getAUnitExpressionExpressionAction_1_0() || rule == grammarAccess.getAPrimaryExpressionRule() || rule == grammarAccess.getAParenthesizedExpressionRule()) {
                    sequence_AUnitExpression(context, (AUnitExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getShowValueRule()) {
                    sequence_ShowValue(context, (AUnitExpression) semanticObject);
                    return;
                } else
                    break;
            case CommonPackage.AVARIABLE_REFERENCE:
                sequence_AVariableReference(context, (AVariableReference) semanticObject);
                return;
            case CommonPackage.COMPUTE_DECLARATION:
                sequence_ComputeDeclaration(context, (ComputeDeclaration) semanticObject);
                return;
            case CommonPackage.DESCRIPTION:
                sequence_Description(context, (Description) semanticObject);
                return;
            case CommonPackage.DESCRIPTION_ELEMENT:
                sequence_DescriptionElement(context, (DescriptionElement) semanticObject);
                return;
            case CommonPackage.IMAGE_REFERENCE:
                sequence_ImageReference(context, (ImageReference) semanticObject);
                return;
            case CommonPackage.MODEL_REF:
                sequence_TypeRef(context, (ModelRef) semanticObject);
                return;
            case CommonPackage.PROPERTY_REF:
                sequence_PropertyRef(context, (PropertyRef) semanticObject);
                return;
            case CommonPackage.RATIONALE:
                sequence_Rationale(context, (Rationale) semanticObject);
                return;
            case CommonPackage.TYPE_REF:
                sequence_TypeRef(context, (TypeRef) semanticObject);
                return;
            case CommonPackage.UNCERTAINTY:
                sequence_Uncertainty(context, (Uncertainty) semanticObject);
                return;
            case CommonPackage.VAL_DECLARATION:
                sequence_ValDeclaration(context, (ValDeclaration) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : AadlReal(org.osate.aadl2.AadlReal) ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) APropertyReference(org.osate.alisa.common.common.APropertyReference) BooleanLiteral(org.osate.aadl2.BooleanLiteral) AUnitExpression(org.osate.alisa.common.common.AUnitExpression) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) AadlBoolean(org.osate.aadl2.AadlBoolean) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) AadlInteger(org.osate.aadl2.AadlInteger) AadlString(org.osate.aadl2.AadlString) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

BooleanLiteral (org.osate.aadl2.BooleanLiteral)29 PropertyExpression (org.osate.aadl2.PropertyExpression)19 StringLiteral (org.osate.aadl2.StringLiteral)18 IntegerLiteral (org.osate.aadl2.IntegerLiteral)17 RealLiteral (org.osate.aadl2.RealLiteral)17 Property (org.osate.aadl2.Property)16 NamedValue (org.osate.aadl2.NamedValue)12 RangeValue (org.osate.aadl2.RangeValue)11 RecordValue (org.osate.aadl2.RecordValue)11 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)11 EPackage (org.eclipse.emf.ecore.EPackage)10 Action (org.eclipse.xtext.Action)10 Parameter (org.eclipse.xtext.Parameter)10 ParserRule (org.eclipse.xtext.ParserRule)10 ClassifierValue (org.osate.aadl2.ClassifierValue)10 ListValue (org.osate.aadl2.ListValue)10 ReferenceValue (org.osate.aadl2.ReferenceValue)10 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)9 PropertyAssociation (org.osate.aadl2.PropertyAssociation)9 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)8