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"));
// }
}
}
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"));
// }
}
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"));
}
}
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;
}
Aggregations