Search in sources :

Example 21 with SystemInstance

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;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) BasicEList(org.eclipse.emf.common.util.BasicEList) Element(org.osate.aadl2.Element) ThreadProperties(org.osate.aadl2.contrib.thread.ThreadProperties) HashMap(java.util.HashMap) BusAccess(org.osate.aadl2.BusAccess) Function(java.util.function.Function) BusSubcomponent(org.osate.aadl2.BusSubcomponent) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) DeviceSubcomponent(org.osate.aadl2.DeviceSubcomponent) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) DeploymentProperties(org.osate.aadl2.contrib.deployment.DeploymentProperties) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) CommunicationProperties(org.osate.aadl2.contrib.communication.CommunicationProperties) MemorySubcomponent(org.osate.aadl2.MemorySubcomponent) ProcessSubcomponent(org.osate.aadl2.ProcessSubcomponent) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) SystemInstance(org.osate.aadl2.instance.SystemInstance) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) Iterator(java.util.Iterator) VirtualProcessorSubcomponent(org.osate.aadl2.VirtualProcessorSubcomponent) Collection(java.util.Collection) ConnectionKind(org.osate.aadl2.instance.ConnectionKind) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) OsateDebug(org.osate.aadl2.util.OsateDebug) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentCategory(org.osate.aadl2.ComponentCategory) Optional(java.util.Optional) NamedElement(org.osate.aadl2.NamedElement) VirtualBusSubcomponent(org.osate.aadl2.VirtualBusSubcomponent) SupportedDispatchProtocols(org.osate.aadl2.contrib.aadlproject.SupportedDispatchProtocols) Collections(java.util.Collections) Timing(org.osate.aadl2.contrib.communication.Timing) InstanceObject(org.osate.aadl2.instance.InstanceObject) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) SystemInstance(org.osate.aadl2.instance.SystemInstance) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) NamedElement(org.osate.aadl2.NamedElement) BasicEList(org.eclipse.emf.common.util.BasicEList) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 22 with SystemInstance

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;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) SystemInstance(org.osate.aadl2.instance.SystemInstance) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) NamedElement(org.osate.aadl2.NamedElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 23 with SystemInstance

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);
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance)

Example 24 with SystemInstance

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);
    }
}
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 25 with SystemInstance

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) SystemInstance(org.osate.aadl2.instance.SystemInstance) EObject(org.eclipse.emf.ecore.EObject) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) CoreException(org.eclipse.core.runtime.CoreException) GraphicalEditorException(org.osate.ge.internal.GraphicalEditorException)

Aggregations

SystemInstance (org.osate.aadl2.instance.SystemInstance)100 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)52 InstanceObject (org.osate.aadl2.instance.InstanceObject)26 ComponentImplementation (org.osate.aadl2.ComponentImplementation)25 Element (org.osate.aadl2.Element)25 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)22 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)21 Classifier (org.osate.aadl2.Classifier)18 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)18 ComponentCategory (org.osate.aadl2.ComponentCategory)17 NamedElement (org.osate.aadl2.NamedElement)16 List (java.util.List)14 Resource (org.eclipse.emf.ecore.resource.Resource)14 AadlPackage (org.osate.aadl2.AadlPackage)14 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)14 ArrayList (java.util.ArrayList)13 EList (org.eclipse.emf.common.util.EList)13 IOException (java.io.IOException)12 IStatus (org.eclipse.core.runtime.IStatus)12 Optional (java.util.Optional)10