Search in sources :

Example 1 with ErrorReport

use of org.osate.codegen.checker.report.ErrorReport in project osate2 by osate.

the class ProcessorCheck method perform.

@Override
public void perform(SystemInstance si) {
    /**
     * processor needs to define their schedule
     */
    if (vxworks() || deos()) {
        final List<ComponentInstance> badProcessors = si.getAllComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESSOR).filter(cpu -> GetProperties.getModuleSchedule(cpu).size() == 0).collect(Collectors.toList());
        for (ComponentInstance cpu : badProcessors) {
            addError(new ErrorReport(cpu, "Processor must define the property ARINC653::Module_Schedule"));
        }
    }
    /**
     * For vxworks, we need to check that the Source_Name property is
     * defined on each virtual processor.
     */
    if (vxworks()) {
        final List<ComponentInstance> virtualProcessorsWithoutSourceName = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (GetProperties.getSourceName(comp) == null))).collect(Collectors.toList());
        for (ComponentInstance vp : virtualProcessorsWithoutSourceName) {
            addError(new ErrorReport(vp, "Virtual Processor must define the property Programming_Properties::Source_Name"));
        }
    }
    /**
     * For vxworks, we need to check that the Source_Name property is
     * defined on each virtual processor.
     */
    if (deos()) {
        final List<ComponentInstance> virtualProcessorsWithoutExecutionTime = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (GetProperties.getExecutionTimeInMS(comp) == 0))).collect(Collectors.toList());
        for (ComponentInstance vp : virtualProcessorsWithoutExecutionTime) {
            addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Execution_Time"));
        }
        final List<ComponentInstance> virtualProcessorsWithoutPeriod = si.getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS).orElse(0.0) == 0))).collect(Collectors.toList());
        for (ComponentInstance vp : virtualProcessorsWithoutPeriod) {
            addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Period"));
        }
    }
    if (pok()) {
        OsateDebug.osateDebug("pok case");
        /**
         * For each CPU, we check that every virtual processor contained in
         * the cpu is correctly referenced in the schedule slots
         */
        for (ComponentInstance cpu : si.getComponentInstances().stream().filter(comp -> comp.getCategory() == ComponentCategory.PROCESSOR).collect(Collectors.toList())) {
            final List<ComponentInstance> unreferencedVirtualProcessors = cpu.getComponentInstances().stream().filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) && (PokProperties.getSlotsAllocation(cpu).contains(comp) == false))).collect(Collectors.toList());
            for (ComponentInstance vp : unreferencedVirtualProcessors) {
                addError(new ErrorReport(vp, "Virtual processor must be declared in the containing processor's POK::Slots_Allocation property"));
            }
            int slotsAllocationSize = PokProperties.getSlotsAllocation(cpu).size();
            int slotsSize = PokProperties.getTimeSlotInMs(cpu).size();
            if (slotsAllocationSize != slotsSize) {
                addError(new ErrorReport(cpu, "Property POK::Slots_Allocation has " + slotsAllocationSize + " elements, but property POK::Slots has " + slotsSize + "elements"));
            }
        }
    // List<ComponentInstance> badProcessors = (List<ComponentInstance>)
    // si.getAllComponentInstances().stream()
    // .filter( comp -> comp.getCategory() ==
    // ComponentCategory.PROCESSOR).filter( cpu ->
    // GetProperties.getModuleSchedule(cpu).size() ==
    // 0).collect(Collectors.toList());
    // 
    // for (ComponentInstance cpu : badProcessors)
    // {
    // addError (new ErrorReport (cpu, "Need to define the processor
    // schedule"));
    // }
    }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) List(java.util.List) TimingProperties(org.osate.aadl2.contrib.timing.TimingProperties) ComponentCategory(org.osate.aadl2.ComponentCategory) PropertyUtils(org.osate.pluginsupport.properties.PropertyUtils) TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) OsateDebug(org.osate.aadl2.util.OsateDebug) Collectors(java.util.stream.Collectors) ErrorReport(org.osate.codegen.checker.report.ErrorReport) PokProperties(org.osate.codegen.checker.utils.PokProperties) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 2 with ErrorReport

use of org.osate.codegen.checker.report.ErrorReport in project osate2 by osate.

the class ThreadCheck method perform.

@Override
public void perform(SystemInstance si) {
    final List<ComponentInstance> allThreads = si.getAllComponentInstances().stream().filter(comp -> (comp.getCategory() == ComponentCategory.THREAD)).collect(Collectors.toList());
    /**
     * Each thread needs to specify the dispatch protocol "periodic" or
     * "sporadic"
     */
    allThreads.stream().filter(comp -> {
        EnumerationLiteral protocol = GetProperties.getDispatchProtocol(comp);
        return protocol == null || !(protocol.toString().equalsIgnoreCase(AadlProject.PERIODIC_LITERAL) || protocol.toString().equalsIgnoreCase(AadlProject.SPORADIC_LITERAL));
    }).forEach(thr -> addError(new ErrorReport(thr, "Thread needs a Thread_Properties::Dispatch_Protocol property of 'Periodic' or 'Sporadic'")));
    /**
     * Each thread needs to specify period
     */
    final List<ComponentInstance> threadMissingPeriod = allThreads.stream().filter(comp -> (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS).orElse(0.0) == 0.0)).collect(Collectors.toList());
    for (ComponentInstance thr : threadMissingPeriod) {
        addError(new ErrorReport(thr, "Thread must define the property Timing_Properties::Period"));
    }
    final List<ComponentInstance> threadMissingDeadline = allThreads.stream().filter(comp -> (PropertyUtils.getScaled(TimingProperties::getDeadline, comp, TimeUnits.MS).orElse(0.0) == 0.0)).collect(Collectors.toList());
    for (ComponentInstance thr : threadMissingDeadline) {
        addError(new ErrorReport(thr, "Thread must define the property Timing_Properties::Deadline"));
    }
    for (ComponentInstance ci : allThreads) {
        ComponentClassifier cc = ci.getComponentClassifier();
        if (cc instanceof ThreadImplementation) {
            ThreadImplementation ti = (ThreadImplementation) cc;
            for (SubprogramCall sc : ti.getSubprogramCalls()) {
                NamedElement cs = (NamedElement) sc.getCalledSubprogram();
                if (GetProperties.getSourceName(cs) == null) {
                    addError(new ErrorReport(cs, "Subprogram must define the property Programming_Properties::Source_Name"));
                }
                if (GetProperties.getSourceText(cs).size() == 0) {
                    addError(new ErrorReport(cs, "Subprogram must define the property Programming_Properties::Source_Text"));
                }
                if (GetProperties.getSourceLanguage(cs).size() == 0) {
                    addError(new ErrorReport(cs, "Subprogram must define the property Programming_Properties::Source_Language"));
                }
            }
        }
    }
/**
 * FIXME JD Each thread needs to specify execution time
 */
// List<ComponentInstance> threadMissingExecutionTime =
// (List<ComponentInstance>) si.getAllComponentInstances().stream().
// filter( comp -> (comp.getCategory() == ComponentCategory.THREAD) &&
// (GetProperties.get > 0.0));
// for (ComponentInstance thr : threadMissingPeriod)
// {
// addError (new ErrorReport (thr, "Thread needs to define a period"));
// }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) ThreadImplementation(org.osate.aadl2.ThreadImplementation) PropertyUtils(org.osate.pluginsupport.properties.PropertyUtils) AadlProject(org.osate.xtext.aadl2.properties.util.AadlProject) Collectors(java.util.stream.Collectors) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ComponentClassifier(org.osate.aadl2.ComponentClassifier) List(java.util.List) TimingProperties(org.osate.aadl2.contrib.timing.TimingProperties) ComponentCategory(org.osate.aadl2.ComponentCategory) TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) NamedElement(org.osate.aadl2.NamedElement) SubprogramCall(org.osate.aadl2.SubprogramCall) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ThreadImplementation(org.osate.aadl2.ThreadImplementation) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) SubprogramCall(org.osate.aadl2.SubprogramCall) NamedElement(org.osate.aadl2.NamedElement)

Example 3 with ErrorReport

use of org.osate.codegen.checker.report.ErrorReport 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 4 with ErrorReport

use of org.osate.codegen.checker.report.ErrorReport 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)4 ErrorReport (org.osate.codegen.checker.report.ErrorReport)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ComponentCategory (org.osate.aadl2.ComponentCategory)3 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)3 GetProperties (org.osate.xtext.aadl2.properties.util.GetProperties)3 TimeUnits (org.osate.aadl2.contrib.aadlproject.TimeUnits)2 TimingProperties (org.osate.aadl2.contrib.timing.TimingProperties)2 PropertyUtils (org.osate.pluginsupport.properties.PropertyUtils)2 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IMarker (org.eclipse.core.resources.IMarker)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 EObject (org.eclipse.emf.ecore.EObject)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 StatusManager (org.eclipse.ui.statushandlers.StatusManager)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)1