Search in sources :

Example 81 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance 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)

Example 82 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.

the class BusLoadAnalysis 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();
            checkBusLoads(root, som);
        }
        monitor.done();
    } else {
        Dialog.showError("Bound Bus Bandwidth 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)

Example 83 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.

the class Binpack method analyzeInstanceModel.

@Override
protected void analyzeInstanceModel(final IProgressMonitor monitor, final AnalysisErrorReporterManager errManager, final SystemInstance root, final SystemOperationMode som) {
    try {
        monitor.beginTask("Binding threads to processors in " + root.getName(), IProgressMonitor.UNKNOWN);
        logInfo("Binpacker Analysis Report\n");
        /*
			 * Verify that all the busses have a transmission time
			 */
        final ForAllElement addBuses = new ForAllElement(errManager) {

            @Override
            public void process(Element obj) {
                checkBuses((ComponentInstance) obj);
            }
        };
        addBuses.processPreOrderComponentInstance(root, ComponentCategory.BUS);
        /*
			 * Find and report all thread and device instances that don't have a
			 * period specified.
			 */
        EList<Element> incompletethreads = new ForAllElement() {

            @Override
            protected boolean suchThat(Element obj) {
                final ComponentCategory cat = ((ComponentInstance) obj).getCategory();
                if (cat == ComponentCategory.THREAD || cat == ComponentCategory.DEVICE) {
                    return org.osate.pluginsupport.properties.PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj, TimeUnits.MS).orElse(0.0) == 0.0;
                } else {
                    return false;
                }
            }
        }.processPreOrderComponentInstance(root);
        for (final Iterator<Element> i = incompletethreads.iterator(); i.hasNext(); ) {
            final ComponentInstance o = (ComponentInstance) i.next();
            logWarning((InstanceModelUtil.isThread(o) ? "Thread " : "Device ") + o.getComponentInstancePath() + " is missing period property. Using default of 1 ns");
        }
        /*
			 * Find and report all thread instances that don't have a
			 * compute execution time specified.
			 */
        incompletethreads = new ForAllElement() {

            @Override
            protected boolean suchThat(Element obj) {
                return GetProperties.getThreadExecutioninMilliSec((ComponentInstance) obj) == 0.0;
            }
        }.processPreOrderComponentInstance(root, ComponentCategory.THREAD);
        for (final Iterator<Element> i = incompletethreads.iterator(); i.hasNext(); ) {
            final ComponentInstance o = (ComponentInstance) i.next();
            logWarning("Thread " + o.getComponentInstancePath() + " is missing compute_execution_time or InstructionsPerDispatch property. Using default of 0 ns");
        }
        /*
			 * Find if all the port connections have data size
			 */
        final ForAllElement addThreadConnections = new ForAllElement(errManager) {

            @Override
            public void process(Element obj) {
                if (obj instanceof ConnectionInstance) {
                    final ConnectionInstance connInst = (ConnectionInstance) obj;
                    if (connInst.getKind() == ConnectionKind.PORT_CONNECTION) {
                        final FeatureInstance src = (FeatureInstance) connInst.getSource();
                        Feature srcAP = src.getFeature();
                        Classifier cl = srcAP.getClassifier();
                        if (cl instanceof DataClassifier) {
                            DataClassifier srcDC = (DataClassifier) cl;
                            if (AadlContribUtils.getDataSize(srcDC, SizeUnits.BYTES) == 0) {
                                logWarning("Data size of connection source port " + src.getComponentInstancePath() + " not specified");
                            }
                        }
                    }
                }
            }
        };
        addThreadConnections.processPreOrderAll(root);
        /* The partitionChoice is set in initializeANalysis() */
        NoExpansionExpansor expansor = new NoExpansionExpansor();
        LowLevelBinPacker packer = null;
        if (partitionChoice == IMMEDIATE_PARTITION) {
            packer = new BFCPBinPacker(expansor);
        } else if (partitionChoice == DEFER_EXEC_TIME) {
            packer = new DFCPBinPacker(expansor);
        } else if (partitionChoice == DEFER_BANDWIDTH) {
            packer = new DFBPBinPacker(expansor);
        }
        AssignmentResult result = binPackSystem(root, expansor, packer, errManager, som);
        reportResults(som, result);
        if (result.isSuccess()) {
            showResults(som, root, result);
        } else {
            showNoResults(som);
        }
    } catch (InvalidModelException e) {
        error(e.getElement(), e.getMessage());
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) NoExpansionExpansor(EAnalysis.BinPacking.NoExpansionExpansor) BFCPBinPacker(EAnalysis.BinPacking.BFCPBinPacker) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) NamedElement(org.osate.aadl2.NamedElement) AssignmentResult(EAnalysis.BinPacking.AssignmentResult) Classifier(org.osate.aadl2.Classifier) SystemClassifier(org.osate.aadl2.SystemClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ComponentCategory(org.osate.aadl2.ComponentCategory) Feature(org.osate.aadl2.Feature) InvalidModelException(org.osate.aadl2.properties.InvalidModelException) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) LowLevelBinPacker(EAnalysis.BinPacking.LowLevelBinPacker) DFCPBinPacker(EAnalysis.BinPacking.DFCPBinPacker) DFBPBinPacker(EAnalysis.BinPacking.DFBPBinPacker)

Example 84 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.

the class ProcessCheck method perform.

public void perform(SystemInstance si) {
    /**
     * Get processes that do not have thread
     */
    final List<ComponentInstance> processWithoutThread = si.getAllComponentInstances().stream().filter(c -> c.getCategory() == ComponentCategory.PROCESS).filter(pr -> pr.getComponentInstances().stream().filter(subco -> subco.getCategory() == ComponentCategory.THREAD).collect(Collectors.toList()).size() == 0).collect(Collectors.toList());
    for (ComponentInstance process : processWithoutThread) {
        addError(new ErrorReport(process, "Every Process needs to have at least one thread subcomponent"));
    }
    /**
     * Get Processes that are not bound to a virtual processor/runtime
     */
    final List<ComponentInstance> processWithoutRuntime = si.getAllComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESS && !(GetProperties.getBoundProcessor(comp) instanceof VirtualProcessor)).collect(Collectors.toList());
    for (ComponentInstance process : processWithoutRuntime) {
        addError(new ErrorReport(process, "Process must be bound to a Virtual Processor through the property Deployment_Properties::Actual_Processor_Binding"));
    }
    /**
     * Get processes that are not bound to a memory
     */
    final List<ComponentInstance> processWithoutMemory = si.getAllComponentInstances().stream().filter(comp -> (comp.getCategory() == ComponentCategory.PROCESS) && (GetProperties.getActualMemoryBinding(comp) == null)).collect(Collectors.toList());
    for (ComponentInstance process : processWithoutMemory) {
        addError(new ErrorReport(process, "Process must define the property Deployment_Properties::Actual_Memory_Binding"));
    }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) List(java.util.List) ComponentCategory(org.osate.aadl2.ComponentCategory) VirtualProcessor(org.osate.aadl2.VirtualProcessor) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) Collectors(java.util.stream.Collectors) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ErrorReport(org.osate.codegen.checker.report.ErrorReport) VirtualProcessor(org.osate.aadl2.VirtualProcessor) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 85 with SystemInstance

use of org.osate.aadl2.instance.SystemInstance in project osate2 by osate.

the class CheckerHandler method execute.

/**
 * the command has been executed, so extract extract the needed information
 * from the application context.
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow window;
    int checkerkind;
    String checkKind;
    EObject selectedObject;
    SystemInstance selectedSystemInstance;
    List<ErrorReport> errors;
    checkerkind = AbstractCheck.CHECKER_KIND_UNKNOWN;
    checkKind = event.getParameter("org.osate.codegen.checker.kind");
    /**
     * Get the type of check we will do. And then, pass it to the checker
     * object.
     */
    if (checkKind.equalsIgnoreCase("pok")) {
        checkerkind = AbstractCheck.CHECKER_KIND_POK;
    }
    if (checkKind.equalsIgnoreCase("vxworks")) {
        checkerkind = AbstractCheck.CHECKER_KIND_VXWORKS;
    }
    if (checkKind.equalsIgnoreCase("deos")) {
        checkerkind = AbstractCheck.CHECKER_KIND_DEOS;
    }
    window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    errors = new ArrayList<ErrorReport>();
    selectedSystemInstance = null;
    selectedObject = SelectionHelper.getSelectedObjectinOutline();
    if (selectedObject instanceof SystemInstance) {
        selectedSystemInstance = (SystemInstance) selectedObject;
    }
    if (selectedObject instanceof SystemImplementation) {
        try {
            selectedSystemInstance = InstantiateModel.buildInstanceModelFile((SystemImplementation) selectedObject);
        } catch (Exception e) {
            MessageDialog.openError(window.getShell(), e.getMessage(), e.getStackTrace().toString());
            IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
            StatusManager manager = StatusManager.getManager();
            manager.handle(status, StatusManager.LOG);
            selectedSystemInstance = null;
        }
    }
    if (selectedSystemInstance == null) {
        MessageDialog.openError(window.getShell(), "Code Generation Checker", "Please select a system implementation in the outline view");
        return null;
    }
    errors.addAll(executeCheck(selectedSystemInstance, MemoryCheck.class, checkerkind));
    errors.addAll(executeCheck(selectedSystemInstance, ProcessorCheck.class, checkerkind));
    errors.addAll(executeCheck(selectedSystemInstance, ProcessCheck.class, checkerkind));
    errors.addAll(executeCheck(selectedSystemInstance, ThreadCheck.class, checkerkind));
    errors.addAll(executeCheck(selectedSystemInstance, DataCheck.class, checkerkind));
    /**
     * For now, we print the errors.
     */
    String msg = new String();
    for (ErrorReport e : errors) {
        try {
            IMarker marker = getIResource(e.getComponent().eResource()).createMarker(MARKER_TYPE);
            marker.setAttribute(IMarker.MESSAGE, e.getComponent().getName() + " - " + e.getMessage());
            marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
        // marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
        } catch (CoreException exception) {
            msg += exception.getMessage() + System.lineSeparator();
            IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, exception.getMessage(), exception);
            StatusManager manager = StatusManager.getManager();
            manager.handle(status, StatusManager.LOG);
        }
    }
    if (!msg.isEmpty()) {
        MessageDialog.openError(window.getShell(), msg, "1");
    } else if (errors.isEmpty()) {
        MessageDialog.openInformation(window.getShell(), "Code Generation Checker", "No problems found");
    } else {
        MessageDialog.openError(window.getShell(), "Code Generation Checker", errors.size() + " problem(s) found");
    }
    return null;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IStatus(org.eclipse.core.runtime.IStatus) StatusManager(org.eclipse.ui.statushandlers.StatusManager) DataCheck(org.osate.codegen.checker.checks.DataCheck) ThreadCheck(org.osate.codegen.checker.checks.ThreadCheck) MemoryCheck(org.osate.codegen.checker.checks.MemoryCheck) ProcessorCheck(org.osate.codegen.checker.checks.ProcessorCheck) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ProcessCheck(org.osate.codegen.checker.checks.ProcessCheck) CoreException(org.eclipse.core.runtime.CoreException) SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemImplementation(org.osate.aadl2.SystemImplementation) EObject(org.eclipse.emf.ecore.EObject) IMarker(org.eclipse.core.resources.IMarker)

Aggregations

SystemInstance (org.osate.aadl2.instance.SystemInstance)100 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)52 InstanceObject (org.osate.aadl2.instance.InstanceObject)26 ComponentImplementation (org.osate.aadl2.ComponentImplementation)25 Element (org.osate.aadl2.Element)25 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)22 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)21 Classifier (org.osate.aadl2.Classifier)18 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)18 ComponentCategory (org.osate.aadl2.ComponentCategory)17 NamedElement (org.osate.aadl2.NamedElement)16 List (java.util.List)14 Resource (org.eclipse.emf.ecore.resource.Resource)14 AadlPackage (org.osate.aadl2.AadlPackage)14 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)14 ArrayList (java.util.ArrayList)13 EList (org.eclipse.emf.common.util.EList)13 IOException (java.io.IOException)12 IStatus (org.eclipse.core.runtime.IStatus)12 Optional (java.util.Optional)10