use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class InstanceModelUtil method getBoundSWComponents.
/**
* get all top level SW components bound to the given processor or VP component
* The list contains only the top component if a component and its children are bound
* to the same processor.
* @param procorVP
* @return
*/
public static EList<ComponentInstance> getBoundSWComponents(final ComponentInstance associatedObject) {
EList<Element> boundComponents = null;
if (boundSWCache.containsKey(associatedObject)) {
return boundSWCache.get(associatedObject);
}
SystemInstance root = associatedObject.getSystemInstance();
if ((associatedObject.getCategory() == ComponentCategory.PROCESSOR) || (associatedObject.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR)) {
boundComponents = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
ComponentInstance ci = (ComponentInstance) obj;
ComponentCategory cat = ci.getCategory();
return ((cat == ComponentCategory.THREAD || cat == ComponentCategory.THREAD_GROUP || cat == ComponentCategory.PROCESS || cat == ComponentCategory.SYSTEM) && InstanceModelUtil.isBoundToProcessor((ComponentInstance) obj, associatedObject));
}
}.processPreOrderComponentInstance(root);
}
if (associatedObject.getCategory() == ComponentCategory.MEMORY) {
boundComponents = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
return DeploymentProperties.getActualMemoryBinding((ComponentInstance) obj).map(boundMemoryList -> boundMemoryList.isEmpty() ? false : boundMemoryList.get(0) == associatedObject).orElse(false);
}
}.processPostOrderComponentInstance(root);
}
EList<ComponentInstance> topobjects = new BasicEList<ComponentInstance>();
for (Object componentInstance : boundComponents) {
addAsRoot(topobjects, (ComponentInstance) componentInstance);
}
boundSWCache.put(associatedObject, topobjects);
return topobjects;
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class InstanceModelUtil method getBoundThreads.
/**
* get all threads bound to the given component
* @param procorVP
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static EList<ComponentInstance> getBoundThreads(final ComponentInstance procorVP) {
SystemInstance root = procorVP.getSystemInstance();
EList boundComponents = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
ComponentInstance ci = (ComponentInstance) obj;
ComponentCategory cat = ci.getCategory();
return ((cat == ComponentCategory.THREAD) && InstanceModelUtil.isBoundToProcessor((ComponentInstance) obj, procorVP));
}
}.processPreOrderComponentInstance(root);
return boundComponents;
}
use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.
the class InstanceModelUtil method getBoundConnections.
/**
* get all connections bound to the given bus or virtual bus
* @param busorVB
* @return
*/
public static EList<ConnectionInstance> getBoundConnections(final ComponentInstance busorVB) {
EList<ConnectionInstance> result;
EList<ConnectionInstance> connections;
SystemInstance root;
if (!boundBusConnections.containsKey(busorVB)) {
result = new BasicEList<ConnectionInstance>();
root = busorVB.getSystemInstance();
connections = root.getAllConnectionInstances();
for (ConnectionInstance connectionInstance : connections) {
if (InstanceModelUtil.isBoundToBus(connectionInstance, busorVB) || // we derived a bus connection from the connection end bindings
(!InstanceModelUtil.hasBusBinding(connectionInstance) && InstanceModelUtil.connectedByBus(connectionInstance, busorVB))) {
result.add(connectionInstance);
}
}
boundBusConnections.put(busorVB, result);
}
return boundBusConnections.get(busorVB);
}
use of org.osate.aadl2.instance.SystemInstance 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.SystemInstance in project osate2 by osate.
the class DefaultSystemInstanceLoadingService method loadSystemInstance.
private SystemInstance loadSystemInstance(final IPath fullInstancePath) {
final URI uri = URI.createPlatformResourceURI(fullInstancePath.toString(), true);
final ResourceSet resourceSet = new ResourceSetImpl();
try {
final Resource resource = resourceSet.getResource(uri, true);
// If the resource was loaded, retrieve and return the SystemInstance
if (resource != null) {
for (final EObject obj : resource.getContents()) {
if (obj instanceof SystemInstance) {
return (SystemInstance) obj;
}
}
}
} catch (final Exception ex) {
// Suppress the exception but log it. The exception is suppressed because it could happen under normal circumstances. For example
// the exception could be thrown if there is a system instance anywhere in the workspace that cannot be loaded.
StatusManager.getManager().handle(new Status(IStatus.ERROR, FrameworkUtil.getBundle(getClass()).getSymbolicName(), "Error loading system instance resource", ex), StatusManager.LOG);
}
return null;
}
Aggregations