Search in sources :

Example 26 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class Util method populateUserDeclaredPropagationPaths.

protected static void populateUserDeclaredPropagationPaths(PropagationGraph pg, InstanceObject obj) {
    if (obj instanceof ComponentInstance) {
        ComponentInstance ci = (ComponentInstance) obj;
        Collection<PropagationPath> pplist = EMV2Util.getAllPropagationPaths(ci.getComponentClassifier());
        for (PropagationPath propagationPath : pplist) {
            addUserDeclaredPropagationPath(pg, ci, propagationPath);
        }
    }
}
Also used : PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 27 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject 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 28 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class Util method executeCondition.

public static boolean executeCondition(IfCondition ifCondition, InstanceObject target, EObject emv2target) {
    ComponentInstance targetComponent = null;
    InstanceObject targetElement = null;
    if (target instanceof ComponentInstance) {
        targetComponent = (ComponentInstance) target;
    } else {
        targetComponent = target.getContainingComponentInstance();
        targetElement = target;
    }
    if (ifCondition.getJavaMethod() != null) {
        // Java class reference
        Object res = ExecuteJavaUtil.invokeJavaMethod(ifCondition.getJavaMethod(), targetElement);
        if (res instanceof Boolean) {
            return (Boolean) res;
        } else {
            return true;
        }
    } else if (!Aadl2Util.isNull(ifCondition.getResoluteFunction())) {
        if (RESOLUTE_INSTALLED) {
            Diagnostic res = ExecuteResoluteUtil.eInstance.executeResoluteFunctionOnce(ifCondition.getResoluteFunction(), target.getSystemInstance(), targetComponent, targetElement, null);
            return res != null && res.getDiagnosticType() != DiagnosticType.ERROR;
        } else {
            return true;
        }
    } else {
        return true;
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Diagnostic(org.osate.result.Diagnostic) EObject(org.eclipse.emf.ecore.EObject) InstanceObject(org.osate.aadl2.instance.InstanceObject)

Example 29 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class InstanceUtil method resolveComponentPrototype.

/**
 * Find the binding for a given component prototype.
 *
 * @param proto the prototype to resolve
 * @param context the context in which the prototype is used, e.g., a
 *            subcomponent instance
 * @param classifierCache an optional cache of known instantiated
 *            classifiers, may be null
 * @return The component prototype actual that the prototype resolves to.
 */
public static ComponentPrototypeActual resolveComponentPrototype(Prototype proto, InstanceObject context, HashMap<InstanceObject, InstantiatedClassifier> classifierCache) {
    ComponentPrototypeActual cpa = null;
    ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) resolvePrototype(proto, context, classifierCache);
    if (cpb == null) {
        // cannot resolve
        return null;
    }
    EList<ComponentPrototypeActual> actuals = cpb.getActuals();
    if (actuals != null && actuals.size() > 0) {
        ComponentPrototypeActual actual = actuals.get(0);
        if (actual.getSubcomponentType() instanceof ComponentClassifier) {
            cpa = actual;
        } else {
            // resolve recursively
            cpa = resolveComponentPrototype((ComponentPrototype) actual.getSubcomponentType(), context.getContainingComponentInstance(), classifierCache);
        }
    }
    return cpa;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 30 with InstanceObject

use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.

the class InstanceUtil method resolveFeatureGroupPrototype.

/**
 * Find the binding for a given feature group prototype.
 *
 * @param proto the prototype to resolve
 * @param context the context in which the prototype is used, e.g., a
 *            subcomponent instance
 * @param classifierCache an optional cache of known instantiated
 *            classifiers, may be null
 * @return The feature group prototype actual the prototype is bound to.
 */
public static FeatureGroupPrototypeActual resolveFeatureGroupPrototype(Prototype proto, InstanceObject context, HashMap<InstanceObject, InstantiatedClassifier> classifierCache) {
    FeatureGroupPrototypeActual result = null;
    FeatureGroupPrototypeBinding fgpb = (FeatureGroupPrototypeBinding) resolvePrototype(proto, context, classifierCache);
    if (fgpb == null) {
        // cannot resolve
        return null;
    }
    FeatureGroupPrototypeActual actual = fgpb.getActual();
    if (actual.getFeatureType() instanceof FeatureGroupType) {
        result = actual;
    } else {
        // resolve recursively
        result = resolveFeatureGroupPrototype((FeatureGroupPrototype) actual.getFeatureType(), context.getContainingComponentInstance(), classifierCache);
    }
    return result;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeatureGroupType(org.osate.aadl2.FeatureGroupType) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual)

Aggregations

InstanceObject (org.osate.aadl2.instance.InstanceObject)71 PropertyExpression (org.osate.aadl2.PropertyExpression)38 Property (org.osate.aadl2.Property)35 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)35 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)24 SystemInstance (org.osate.aadl2.instance.SystemInstance)22 ListValue (org.osate.aadl2.ListValue)17 NamedElement (org.osate.aadl2.NamedElement)17 ArrayList (java.util.ArrayList)16 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)15 Classifier (org.osate.aadl2.Classifier)13 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 Element (org.osate.aadl2.Element)11 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)10 BasicProperty (org.osate.aadl2.BasicProperty)9 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)9 List (java.util.List)8 Subcomponent (org.osate.aadl2.Subcomponent)8