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