use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class CheckBindingConstraints method runAnalysis.
public static List<Issue> runAnalysis(IProgressMonitor monitor, SystemInstance si) {
List<Issue> issuesList = new ArrayList<>();
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
System.out.println(si.getSystemOperationModes().size());
SubMonitor loopMonitor = subMonitor.split(100).setWorkRemaining(si.getSystemOperationModes().size());
for (SOMIterator somIter = new SOMIterator(si); somIter.hasNext(); ) {
SystemOperationMode som = somIter.next();
SubMonitor iterationMonitor = loopMonitor.split(1);
iterationMonitor.setWorkRemaining(8);
// Processor binding
SubMonitor processorChild = iterationMonitor.split(2);
subMonitor.setTaskName("Getting Processor Binding Components");
processorChild.split(1);
List<ComponentInstance> processorBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.VIRTUAL_PROCESSOR, ComponentCategory.DEVICE).collect(Collectors.toList());
processorChild.setTaskName("Checking Processor Bindings");
processorChild.split(1);
issuesList.addAll(checkBindingConstraints(processorBindingComponents.stream(), "processor", GetProperties::getActualProcessorBinding, GetProperties::getAllowedProcessorBinding, GetProperties::getAllowedProcessorBindingClass, som));
// Dispatch Protocol
subMonitor.setTaskName("Checking Dispacth Protocols");
SubMonitor dispatchChild = iterationMonitor.split(1);
issuesList.addAll(checkDispatchProtocol(processorBindingComponents.stream(), som));
// Memory binding
subMonitor.setTaskName("Getting Memory Components");
SubMonitor memrChild = iterationMonitor.split(2);
memrChild.split(1);
Stream<ComponentInstance> memoryBindingComponents = getComponents(monitor, si, ComponentCategory.THREAD, ComponentCategory.DEVICE, ComponentCategory.DATA, ComponentCategory.SUBPROGRAM, ComponentCategory.PROCESSOR, ComponentCategory.VIRTUAL_PROCESSOR);
subMonitor.setTaskName("Checking Memory Bindings");
memrChild.split(1);
Stream<FeatureInstance> memoryBindingFeatures = getFeatures(monitor, si, FeatureCategory.DATA_PORT, FeatureCategory.EVENT_DATA_PORT);
Stream<InstanceObject> memoryBindingElements = Stream.concat(memoryBindingComponents, memoryBindingFeatures);
issuesList.addAll(checkBindingConstraints(memoryBindingElements, "memory", GetProperties::getActualMemoryBinding, GetProperties::getAllowedMemoryBinding, GetProperties::getAllowedMemoryBindingClass, som));
// Connection binding (only handles connection and virtual bus)
subMonitor.setTaskName("Checking Connection Bindings");
SubMonitor conenctionChild = iterationMonitor.split(1);
Stream<ComponentInstance> connectionBindingComponents = getComponents(monitor, si, ComponentCategory.VIRTUAL_BUS);
Stream<ConnectionInstance> connectionBindingConnections = getConnections(monitor, si);
List<InstanceObject> connectionBindingElements = Stream.concat(connectionBindingComponents, connectionBindingConnections).collect(Collectors.toList());
issuesList.addAll(checkBindingConstraints(connectionBindingElements.stream(), "connection", GetProperties::getActualConnectionBinding, GetProperties::getAllowedConnectionBinding, GetProperties::getAllowedConnectionBindingClass, som));
// Connection Quality of Service
subMonitor.setTaskName("Checking Connection Quality of Services");
SubMonitor qualityChild = iterationMonitor.split(1);
issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredConnectionQualityOfService, "Required_Connection_Quality_Of_Service", GetProperties::getProvidedConnectionQualityOfService, qos -> qos.getName(), som));
// Virtual Bus Class
subMonitor.setTaskName("Checking Virtual Bus Bindings");
SubMonitor busChild = iterationMonitor.split(1);
Function<ComponentInstance, Collection<ComponentClassifier>> getProvidedVBClass = boundElement -> {
Stream<ComponentClassifier> providedProperty = GetProperties.getProvidedVirtualBusClass(boundElement).stream();
Stream<ComponentClassifier> providedBySubcomponent = boundElement.getComponentInstances().stream().map(subcomponent -> subcomponent.getClassifier());
return Stream.concat(providedProperty, providedBySubcomponent).collect(Collectors.toSet());
};
issuesList.addAll(checkRequiredAndProvided(connectionBindingElements.stream(), GetProperties::getRequiredVirtualBusClass, "Required_Virtual_Bus_Class", getProvidedVBClass, vbClass -> vbClass.getName(), som));
busChild.setWorkRemaining(0);
}
subMonitor.setWorkRemaining(0);
return issuesList;
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class AadlContribUtils method getDataSize.
private static double getDataSize(final NamedElement ne, final SizeUnits unit, final int nesting) {
final double elementSize = PropertyUtils.getScaled(MemoryProperties::getDataSize, ne, unit).orElseGet(() -> {
final ComponentCategory cc = ne instanceof ComponentClassifier ? ((ComponentClassifier) ne).getCategory() : (ne instanceof ComponentInstance ? ((ComponentInstance) ne).getCategory() : null);
if (cc != ComponentCategory.BUS && cc != ComponentCategory.VIRTUAL_BUS) {
return PropertyUtils.getScaled(MemoryProperties::getSourceDataSize, ne, unit).orElse(0.0);
} else {
return 0.0;
}
});
final long multiplier = ne instanceof DataSubcomponent ? AadlUtil.getMultiplicity(ne) : 1;
if (elementSize != 0.0) {
return elementSize * multiplier;
} else {
if ((nesting <= 10) && (ne instanceof DataSubcomponent || ne instanceof DataImplementation)) {
// mult is one or the array size of the data subcomponent.
return sumElementsDataSize(ne, unit, nesting + 1) * multiplier;
} else {
return 0.0;
}
}
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class AadlUtil method getElement.
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified list
// of component classifiers or port group classifiers
// * @param aobjlist
// * @return list of packages
// */
// public static EList<AadlPackage> getUsedPackages(List<? extends Element>
// aobjlist){
// return doGetUsedPackages(aobjlist, false);
// }
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified list
// of component classifiers or port group classifiers
// * recursively consider the features in port groups
// * @param aobjlist
// * @return list of packages
// */
// public static EList<AadlPackage> getAllUsedPackages(List<? extends
// Element> aobjlist){
// return doGetUsedPackages(aobjlist, true);
// }
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified list
// of component classifiers or port group classifiers
// * recursively consider the features in port groups if so indicated
// * @param aobjlist
// * @param recurse
// * @return list of packages
// */
// private static EList<AadlPackage> doGetUsedPackages(List<? extends
// Element> aobjlist, boolean recurse){
// EList<AadlPackage> packagerefFound = new UniqueEList<AadlPackage>();
// for (Element ao : aobjlist){
// if (ao instanceof ComponentType){
// usedPackages(packagerefFound, (ComponentType)ao, recurse);
// } else if (ao instanceof ComponentImplementation){
// usedPackages(packagerefFound, (ComponentImplementation)ao);
// } else if (ao instanceof FeatureGroupType){
// usedPackages(packagerefFound, (FeatureGroupType)ao, recurse);
// }
// }
// return packagerefFound;
// }
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified
// component type
// * @param ct ComponentType
// * @return list of packages
// */
// public static List<AadlPackage> getUsedPackages(ComponentType ct){
// EList<AadlPackage> packagerefFound = new UniqueEList<AadlPackage>();
// return usedPackages(packagerefFound,ct,false);
// }
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified
// component type
// * recurseively consider the features in port groups
// * @param ct ComponentType
// * @return list of packages
// */
// public static List<AadlPackage> getAllUsedPackages(ComponentType ct){
// EList<AadlPackage> packagerefFound = new UniqueEList<AadlPackage>();
// return usedPackages(packagerefFound,ct,true);
// }
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified
// component type
// * @param ci ComponentImpl
// * @return list of packages
// */
// public static List<AadlPackage> getUsedPackages(ComponentImplementation
// ci){
// EList<AadlPackage> packagerefFound = new UniqueEList<AadlPackage>();
// return usedPackages(packagerefFound,ci);
// }
// TODO: [ASKLUTZ] Uncomment after Joe asks Lutz about
// Classifier.allFeatures().
// /**
// * get list of packages referenced by the features of the specified port
// group type
// * @param pgt PortGroupType
// * @return list of packages
// */
// public static List<AadlPackage> getUsedPackages(FeatureGroupType pgt){
// EList<AadlPackage> packagerefFound = new UniqueEList<AadlPackage>();
// return usedPackages(packagerefFound,pgt, false);
// }
// TODO: [ASKLUTZ] Rewrite after Joe asks Lutz about
// ComponentType.allFeatures().
// /**
// * add packages referenced by the component type's features to the list of
// package references
// * @param packrefFound
// * @param obj
// */
// private static List<AadlPackage> usedPackages(List<AadlPackage>
// packrefFound, ComponentType obj, boolean recurse){
// EList featurelist = obj.getXAllFeature();
// for (Iterator it = featurelist.iterator(); it.hasNext();){
// Feature f = (Feature) it.next();
// Classifier dc = f.getXAllClassifier();
// if (dc != null){
// Element root = dc.getElementRoot();
// if (root instanceof AadlPackage){
// packrefFound.add((AadlPackage)root);
// }
// if (recurse && dc instanceof PortGroup){
// PortGroupType pgt = ((PortGroup)dc).getPortGroupType();
// if (pgt != null){
// usedPackages(packrefFound,pgt, recurse);
// }
// }
// }
// }
// return packrefFound;
// }
// TODO: [ASKLUTZ] Rewrite after Joe asks Lutz about
// FeatureGroupType.allFeatures().
// /**
// * add packages referenced by the component type's features to the list of
// package references
// * @param packrefFound
// * @param obj
// */
// private static List<AadlPackage> usedPackages(List<AadlPackage>
// packrefFound, FeatureGroupType obj, boolean recurse){
// EList featurelist = obj.getXAllFeature();
// for (Iterator it = featurelist.iterator(); it.hasNext();){
// Feature f = (Feature) it.next();
// Classifier dc = f.getXAllClassifier();
// if (dc != null){
// Element root = dc.getElementRoot();
// if (root instanceof AadlPackage){
// packrefFound.add((AadlPackage)root);
// }
// if (recurse && dc instanceof PortGroup){
// PortGroupType pgt = ((PortGroup)dc).getPortGroupType();
// if (pgt != null){
// usedPackages(packrefFound,pgt, recurse);
// }
// }
// }
// }
// return packrefFound;
// }
// TODO: [SUBCOMPONENTS] Rewrite after
// ComponentImplementation.getSubcomponents() is created.
// /**
// * add packages referenced by the component type's features to the list of
// package references
// * @param packrefFound
// * @param obj
// */
// private static List<AadlPackage> usedPackages(List<AadlPackage>
// packrefFound, ComponentImplementation obj){
// EList subcomplist = obj.getXAllSubcomponent();
// for (Iterator it = subcomplist.iterator(); it.hasNext();){
// Subcomponent f = (Subcomponent) it.next();
// Classifier cc = f.getXAllClassifier();
// if (cc != null){
// Element root = cc.getElementRoot();
// if (root instanceof AadlPackage){
// packrefFound.add((AadlPackage)root);
// }
// }
// }
// EList calls = obj.getXAllCallSequence();
// for (Iterator iit = calls.iterator(); iit.hasNext();) {
// EList calllist = ((CallSequence) iit.next()).getCall();
// for (Iterator it = calllist.iterator(); it.hasNext();) {
// Subcomponent sc = (Subcomponent) it.next();
// ComponentClassifier cc = sc.getXAllClassifier();
// if (cc != null){
// Element root = cc.getElementRoot();
// if (root instanceof AadlPackage){
// packrefFound.add((AadlPackage)root);
// }
// }
// }
// }
// return packrefFound;
// }
/**
* Try to retrieve an {@link org.osate.aadl2.Element} from an object.
* This method is intended to be used with objects that obtained from a
* selection event, i.e., from the
* {@link org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)}
* method.
* <p>
* If the object is an Element, it is returned. Otherwise, the method tries
* to adapt the object to an Element. The Object could be an Element, IAdaptable, an instance model resource,
* or a TreeSelection of a IFile in the Navigator
*
* @param object The object to get an Element from.
* @return The Element, or <code>null</code> if no Element can be obtained
* from the given object.
*/
public static Element getElement(final Object object) {
Element theElement = null;
// Is it an Element?
if (object instanceof Element) {
theElement = (Element) object;
if (theElement != null) {
return theElement;
}
}
if (object instanceof IAdaptable) {
theElement = ((IAdaptable) object).getAdapter(Element.class);
if (theElement != null) {
return theElement;
}
}
if (object instanceof IFile && FileNameConstants.INSTANCE_FILE_EXT.equalsIgnoreCase(((IFile) object).getFileExtension())) {
Resource res = new ResourceSetImpl().getResource(OsateResourceUtil.toResourceURI((IResource) object), true);
EList<EObject> rl = res.getContents();
if (!rl.isEmpty() && rl.get(0) instanceof Element) {
return (Element) rl.get(0);
}
}
if (object instanceof IFile && FileNameConstants.SOURCE_FILE_EXT.equalsIgnoreCase(((IFile) object).getFileExtension())) {
Resource res = new ResourceSetImpl().getResource(OsateResourceUtil.toResourceURI((IResource) object), true);
EList<EObject> rl = res.getContents();
if (!rl.isEmpty() && rl.get(0) instanceof LazyLinkingResource) {
if ((((LazyLinkingResource) rl.get(0)).getContents().size() > 0) && (((LazyLinkingResource) rl.get(0)).getContents().get(0) instanceof Element)) {
theElement = (Element) ((LazyLinkingResource) rl.get(0)).getContents().get(0);
return theElement;
}
}
if (!rl.isEmpty() && rl.get(0) instanceof Element) {
theElement = (Element) rl.get(0);
return theElement;
}
}
if (object instanceof TreeSelection) {
for (Iterator<?> iterator = ((TreeSelection) object).iterator(); iterator.hasNext(); ) {
Object f = iterator.next();
if (f instanceof IResource) {
URI uri = OsateResourceUtil.toResourceURI((IResource) f);
Resource res = new ResourceSetImpl().getResource(uri, true);
EList<EObject> rl = res.getContents();
if (!rl.isEmpty() && rl.get(0) instanceof Element) {
return (Element) rl.get(0);
}
}
}
return null;
}
if (object instanceof EObjectURIWrapper) {
EObjectURIWrapper wrapper = (EObjectURIWrapper) object;
EObject eObject = new ResourceSetImpl().getEObject(wrapper.getUri(), true);
if (eObject instanceof Element) {
return (Element) eObject;
}
}
return null;
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class AbstractTopDownComponentTraversal method hasUsageReferences.
private boolean hasUsageReferences(final ComponentClassifier aobj, final EList<ComponentImplementation> allci) {
for (Iterator<ComponentImplementation> all = allci.iterator(); processingMethod.notCancelled() && all.hasNext(); ) {
ComponentImplementation ci = all.next();
EList<Subcomponent> sublist = ci.getAllSubcomponents();
for (Iterator<Subcomponent> it = sublist.iterator(); it.hasNext(); ) {
Subcomponent sc = it.next();
ComponentClassifier cc = sc.getAllClassifier();
if (cc == aobj) {
return true;
}
}
}
return false;
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class SubcomponentImpl method getPropertyValue.
public void getPropertyValue(Property prop, PropertyAcc pas, Classifier cl, final boolean all) {
final ComponentImplementation owner = (ComponentImplementation) getContainingClassifier();
if (pas.addLocalContained(this, owner)) {
return;
}
// get local value
if (pas.addLocal(this)) {
return;
}
// collect values from refined subcomponents
Subcomponent refined = getRefined();
while (refined != null) {
if (pas.addLocal(refined)) {
return;
}
refined = refined.getRefined();
}
// get values from classifier
if (cl != null) {
cl.getPropertyValueInternal(prop, pas, true, all);
} else {
final ComponentClassifier cc = getClassifier();
if (cc != null) {
cc.getPropertyValueInternal(prop, pas, true, all);
}
}
}
Aggregations