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