use of org.osate.aadl2.instance.InstanceObject in project osate-plugin by sireum.
the class AwasUtil method highlightDiagrams.
@SuppressWarnings("restriction")
public static void highlightDiagrams(Set<AgeEditor> ads, Collector qres, Boolean isImpleDiagram, SymbolTable st, Resource resource) {
// AtomicBoolean isNode = new AtomicBoolean(true);
Set<String> uris = new HashSet<String>();
if (qres.getResultType().isPresent()) {
if (qres.getResultType().get() == ResultType.Node()) {
uris.addAll(qres.getNodes().stream().map(it -> it.getUri()).collect(Collectors.toSet()));
} else {
uris.addAll(qres.getPorts());
uris.addAll(qres.getFlows());
uris.addAll(qres.getNodes().stream().filter(it -> it.getResourceType() == NodeType.CONNECTION()).map(it -> it.getUri()).collect(Collectors.toSet()));
// isNode.getAndSet(false);
}
} else if (!qres.getNodes().isEmpty()) {
uris.addAll(qres.getNodes().stream().map(it -> it.getUri()).collect(Collectors.toSet()));
}
Set<InstanceObject> ios = awasUri2AadlInstObj(uris, st, resource);
Set<URI> aadlUris = new HashSet<URI>();
if (isImpleDiagram) {
Set<Element> elems = instObjs2Elements(ios);
aadlUris.addAll(elems.stream().map(it -> new EObjectURIWrapper(it).getUri()).collect(Collectors.toSet()));
} else {
aadlUris.addAll(ios.stream().map(it -> new EObjectURIWrapper(it).getUri()).collect(Collectors.toSet()));
}
Set<DiagramElement> des = new HashSet<DiagramElement>();
ads.forEach(ad -> {
// getDiagram()));
des.addAll(getAllDiagramElements(ad.getDiagram()));
});
des.forEach(de -> {
if (de.getBusinessObject() instanceof EObject && aadlUris.contains(new EObjectURIWrapper((EObject) de.getBusinessObject()).getUri())) {
de.setStyle(StyleBuilder.create(de.getStyle()).backgroundColor(org.osate.ge.graphics.Color.ORANGE).outlineColor(org.osate.ge.graphics.Color.MAGENTA).build());
}
});
ads.forEach(ad -> {
ad.getActionExecutor().execute("highlight diagram", ExecutionMode.NORMAL, () -> {
ad.updateNowIfModelHasChanged();
ad.updateDiagram();
ad.getGefDiagram().refreshDiagramStyles();
ad.doSave(new NullProgressMonitor());
return null;
});
});
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method processActualConnectionBindingsSampling.
/*
* connOrVB - Can be a ConnectionInstance (initial call), ComponentInstance (bus or virtual bus bound to a connection or virtual bus), or a
* ComponentClassifier (required by a connection or virtual bus).
*
* onBehalfOfConnection - The connection instance that is bound to this mess. When connOrVB is a connection instance then
* it must be that connOrVB == onBehalfOfConnection
*/
private void processActualConnectionBindingsSampling(final NamedElement connOrVB, final LatencyContributor latencyContributor, final ConnectionInstance onBehalfOfConnection) {
boolean willDoVirtualBuses = false;
boolean willDoBuses = false;
if (connOrVB instanceof InstanceObject) {
// look for actual binding if we have a connection instance or virtual bus instance
List<InstanceObject> bindings = DeploymentProperties.getActualConnectionBinding(connOrVB).orElse(Collections.emptyList());
for (InstanceObject componentInstance : bindings) {
if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) {
willDoVirtualBuses = true;
} else {
willDoBuses = true;
}
}
/**
* required virtual bus class indicates protocols the connection intends to use.
* We also can have an actual connection binding to a virtual bus
* If we have that we want to use that virtual bus overhead
*/
if (!willDoVirtualBuses) {
List<Classifier> protocols = DeploymentProperties.getRequiredVirtualBusClass(connOrVB).orElse(Collections.emptyList());
// XXX: [Code Coverage] protocols cannot be null.
if ((protocols != null) && (protocols.size() > 0)) {
if (willDoBuses) {
latencyContributor.reportInfo("Adding required virtual bus contributions to bound bus");
}
for (Classifier cc : protocols) {
processSamplingAndQueuingTimes(cc, null, latencyContributor);
processActualConnectionBindingsSampling(cc, latencyContributor, onBehalfOfConnection);
}
}
}
for (InstanceObject componentInstance : bindings) {
processSamplingAndQueuingTimes(componentInstance, onBehalfOfConnection, latencyContributor);
if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) {
processActualConnectionBindingsSampling(componentInstance, latencyContributor, onBehalfOfConnection);
}
}
}
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class ReportUtils method getReportPath.
/**
* @param root - the root object related to the report
* @param subDirectory - the directory where we store the report, relative to the root object
* @param reportType - the type of the report (latency, etc.)
* @param fileSuffix - any suffix for the file
* @param fileExtension - the file extension (.csv, .xls, etc.)
* @return the path for the file.
*/
public static IPath getReportPath(EObject root, String subDirectory, String reportPostfix, String fileExtension) {
String filename = null;
subDirectory = subDirectory.replaceAll(" ", "");
Resource res = root.eResource();
URI uri = res.getURI();
IPath path = OsateResourceUtil.toIFile(uri).getFullPath();
if (root instanceof InstanceObject) {
path = path.removeFileExtension();
filename = path.lastSegment() + "__" + reportPostfix;
path = path.removeLastSegments(1).append("/reports/" + subDirectory + "/" + filename);
} else {
filename = path.lastSegment() + reportPostfix;
path = path.removeLastSegments(1).append("/reports/" + subDirectory + "/" + filename);
}
path = path.addFileExtension(fileExtension);
return path;
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class BoundResourceAnalysis method getMemoryBindings.
/*
* Issue 2169: This is copied from InstanceModelUtil.getBoundSWComponents, but we had
* to specialize it because now processor/virtual processors are treated as things
* that have memory and the original method gets the wrong things from the processors.
*
* associatedObject is of category memory, system, processor, virtual processor, abstract
*/
private static EList<ComponentInstance> getMemoryBindings(final ComponentInstance associatedObject) {
EList<Element> boundComponents = null;
final SystemInstance root = associatedObject.getSystemInstance();
final ComponentCategory cc = associatedObject.getCategory();
if (cc == ComponentCategory.MEMORY || cc == ComponentCategory.SYSTEM || cc == ComponentCategory.PROCESSOR || cc == ComponentCategory.VIRTUAL_PROCESSOR || cc == ComponentCategory.ABSTRACT) {
boundComponents = new ForAllElement() {
@Override
protected boolean suchThat(Element obj) {
final List<InstanceObject> boundMemoryList = DeploymentProperties.getActualMemoryBinding((ComponentInstance) obj).orElse(Collections.emptyList());
if (boundMemoryList.isEmpty()) {
return false;
}
return boundMemoryList.contains(associatedObject);
}
}.processPostOrderComponentInstance(root);
} else {
return new BasicEList<ComponentInstance>();
}
EList<ComponentInstance> topobjects = new BasicEList<ComponentInstance>();
for (Object componentInstance : boundComponents) {
InstanceModelUtil.addAsRoot(topobjects, (ComponentInstance) componentInstance);
}
return topobjects;
}
use of org.osate.aadl2.instance.InstanceObject in project osate2 by osate.
the class BoundResourceAnalysis method analysisBody.
public void analysisBody(final IProgressMonitor monitor, final Element obj) {
if (obj instanceof InstanceObject) {
SystemInstance root = ((InstanceObject) obj).getSystemInstance();
monitor.beginTask(actionName, IProgressMonitor.UNKNOWN);
final SOMIterator soms = new SOMIterator(root);
while (soms.hasNext()) {
final SystemOperationMode som = soms.nextSOM();
checkProcessorLoads(root, som);
checkVirtualProcessorLoads(root, som);
checkMemoryLoads(root, som);
}
monitor.done();
} else {
Dialog.showError("Bound Resource Analysis Error", "Can only check system instances");
}
}
Aggregations