Search in sources :

Example 6 with PROCESSOR

use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.

the class AnalysisModel method populateBindingPaths.

/**
 * populate direct bindings from the specified component to its resources
 *
 * @param ci
 */
protected void populateBindingPaths(InstanceObject obj) {
    if (obj instanceof ComponentInstance) {
        ComponentInstance ci = (ComponentInstance) obj;
        List<ComponentInstance> cpus = InstanceModelUtil.getProcessorBinding(ci);
        for (ComponentInstance cpu : cpus) {
            populateBindingPropagationPaths(ci, cpu, "processor");
        }
        if (!(ci instanceof VirtualProcessor)) {
            // do memory bindings
            List<ComponentInstance> mems = InstanceModelUtil.getMemoryBinding(ci);
            for (ComponentInstance mem : mems) {
                populateBindingPropagationPaths(ci, mem, "memory");
            }
        }
        if (ci instanceof VirtualBus) {
            // do connection bindings
            List<InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(ci);
            for (InstanceObject bres : boundresources) {
                populateBindingPropagationPaths(ci, (ComponentInstance) bres, "connection");
            }
        }
        List<ComponentInstance> systems = InstanceModelUtil.getFunctionBinding(ci);
        for (ComponentInstance system : systems) {
            populateBindingPropagationPaths(ci, system, "binding");
        }
    } else if (obj instanceof ConnectionInstance) {
        // do connection bindings
        List<? extends InstanceObject> boundresources = InstanceModelUtil.getConnectionBindings(obj);
        if (boundresources.isEmpty()) {
            boundresources = InstanceModelUtil.deriveBoundBuses((ConnectionInstance) obj);
        }
        for (InstanceObject bres : boundresources) {
            populateBindingPropagationPaths((ConnectionInstance) obj, (ComponentInstance) bres, "connection");
        }
    }
}
Also used : VirtualProcessor(org.osate.aadl2.VirtualProcessor) InstanceObject(org.osate.aadl2.instance.InstanceObject) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) VirtualBus(org.osate.aadl2.VirtualBus) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) BasicEList(org.eclipse.emf.common.util.BasicEList) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 7 with PROCESSOR

use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.

the class InstanceModelUtil method connectedByBus.

/**
 * true if the processor of the port connection source is connected to the
 * specified bus
 *
 * @param pci
 * @param curBus
 * @return
 */
public static boolean connectedByBus(ConnectionInstance pci, ComponentInstance curBus) {
    ComponentInstance srcHW = getHardwareComponent(pci.getSource());
    ComponentInstance dstHW = getHardwareComponent(pci.getDestination());
    if (srcHW == null || dstHW == null || srcHW == dstHW) {
        return false;
    }
    return connectedToBus(srcHW, curBus) && connectedToBus(dstHW, curBus);
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 8 with PROCESSOR

use of org.osate.aadl2.ComponentCategory.PROCESSOR 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 9 with PROCESSOR

use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.

the class InstanceModelUtil method getHardwareComponent.

/**
 * return the hardware component of the connection instance end.
 * If it is a hardware component or device return it.
 * If it is a software component, return the processor it is bound to.
 * If it is a component instance (BUS), return the bus
 * If it is a DATA, SUBPROGRAM, or SUBPROGRAM GROUP component instance, then return the memory it is bound to.
 * @param cie
 * @return hw component instance
 */
public static ComponentInstance getHardwareComponent(ConnectionInstanceEnd cie) {
    ComponentInstance swci = null;
    if (cie instanceof FeatureInstance) {
        FeatureInstance fi = (FeatureInstance) cie;
        swci = fi.getContainingComponentInstance();
    } else if (cie instanceof ComponentInstance) {
        swci = (ComponentInstance) cie;
    }
    if (isDevice(swci) || isProcessor(swci) || isBus(swci) || isMemory(swci)) {
        return swci;
    }
    return getBoundPhysicalProcessor(swci);
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 10 with PROCESSOR

use of org.osate.aadl2.ComponentCategory.PROCESSOR in project osate2 by osate.

the class GetProperties method getBoundProcessor.

/**
 * Get the bound processor. It will take the first if the binding identifies
 * more than one.
 */
public static ComponentInstance getBoundProcessor(final ComponentInstance processorthread) {
    List<ComponentInstance> pciList = getActualProcessorBinding(processorthread);
    ComponentInstance pci = pciList.isEmpty() ? null : pciList.get(0);
    if (pci != null) {
        return pci;
    }
    return null;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Aggregations

ComponentInstance (org.osate.aadl2.instance.ComponentInstance)37 ComponentCategory (org.osate.aadl2.ComponentCategory)12 Property (org.osate.aadl2.Property)12 Element (org.osate.aadl2.Element)11 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)10 Iterator (java.util.Iterator)9 List (java.util.List)9 BasicProperty (org.osate.aadl2.BasicProperty)9 UnitLiteral (org.osate.aadl2.UnitLiteral)9 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)9 NamedElement (org.osate.aadl2.NamedElement)8 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)8 InstanceObject (org.osate.aadl2.instance.InstanceObject)8 EList (org.eclipse.emf.common.util.EList)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 EObject (org.eclipse.emf.ecore.EObject)6 SystemInstance (org.osate.aadl2.instance.SystemInstance)6 BasicEList (org.eclipse.emf.common.util.BasicEList)5 ComponentImplementation (org.osate.aadl2.ComponentImplementation)5