Search in sources :

Example 61 with InstanceObject

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;
        });
    });
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) Element(org.osate.aadl2.Element) URI(org.eclipse.emf.common.util.URI) Node(org.sireum.awas.ast.Node) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgeGefRuntimeException(org.osate.ge.gef.AgeGefRuntimeException) ResultType(org.sireum.awas.collector.ResultType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AgeEditor(org.osate.ge.gef.ui.editor.AgeEditor) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) Collector(org.sireum.awas.awasfacade.Collector) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) InstanceUtil(org.osate.aadl2.instance.util.InstanceUtil) SystemInstance(org.osate.aadl2.instance.SystemInstance) NodeType(org.sireum.awas.flow.NodeType) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) DiagramService(org.osate.ge.internal.services.DiagramService) SymbolTable(org.sireum.awas.symbol.SymbolTable) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Option(scala.Option) Collectors(java.util.stream.Collectors) StyleBuilder(org.osate.ge.graphics.StyleBuilder) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) DiagramReference(org.osate.ge.internal.services.DiagramService.DiagramReference) EditorUtil(org.osate.ge.internal.ui.util.EditorUtil) List(java.util.List) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GraphicalEditor(org.osate.ge.GraphicalEditor) ExecutionMode(org.osate.ge.internal.services.ActionExecutor.ExecutionMode) Resource(org.eclipse.emf.ecore.resource.Resource) SymbolTableHelper(org.sireum.awas.symbol.SymbolTableHelper) InstanceObject(org.osate.aadl2.instance.InstanceObject) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) Element(org.osate.aadl2.Element) URI(org.eclipse.emf.common.util.URI) InstanceObject(org.osate.aadl2.instance.InstanceObject) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) EObject(org.eclipse.emf.ecore.EObject) HashSet(java.util.HashSet)

Example 62 with InstanceObject

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

Example 63 with InstanceObject

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;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) IPath(org.eclipse.core.runtime.IPath) Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI)

Example 64 with InstanceObject

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;
}
Also used : 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) 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 65 with InstanceObject

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");
    }
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Aggregations

InstanceObject (org.osate.aadl2.instance.InstanceObject)77 PropertyExpression (org.osate.aadl2.PropertyExpression)38 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)36 Property (org.osate.aadl2.Property)35 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 SystemInstance (org.osate.aadl2.instance.SystemInstance)27 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)24 ArrayList (java.util.ArrayList)19 ListValue (org.osate.aadl2.ListValue)17 NamedElement (org.osate.aadl2.NamedElement)17 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)15 Element (org.osate.aadl2.Element)14 Classifier (org.osate.aadl2.Classifier)13 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 List (java.util.List)11 EObject (org.eclipse.emf.ecore.EObject)11 Resource (org.eclipse.emf.ecore.resource.Resource)10 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)10 URI (org.eclipse.emf.common.util.URI)9