Commit d22708d8 authored by Alexander Diewald's avatar Alexander Diewald

DSE-TCgen: Add a timing definition

The values for the periodic constraints are added as part of the
annotation value definition as their calculation is based on
potentially present WCET values of tasks.

Issue-Ref: 4008
Issue-Url: https://af3-developer.fortiss.org/issues/4008Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 04c82761
AnnotationGenerationUtils.java 7fdab0a64ce72636bc59262b889b62eed54980ee YELLOW
AnnotationGenerationUtils.java 599f568c7e7da8555399ae7ee4eb922cb490effd YELLOW
CompArchGeneratonUtil.java e771498a4bd7fe56219a3af74c40c190d02959ae YELLOW
DseUtils.java d81af0b7f649d2453aada362fc50572fce31ebc8 YELLOW
FileWriterUtil.java 4a95559f571d41fa44e6236fc055ab5baac7c384 YELLOW
GraphGenerationUtilities.java 40213f344dec1f62a0bb965739cb967f367803d4 YELLOW
GraphMetricUtils.java 99a398d4ff9b15b3eeb35748e32aa34a9b197f07 YELLOW
GraphUtils.java 08b285a67bf86c2b92bb0eab3d50551ba23dc410 YELLOW
ProjectUtils.java fe0009a32f6aaa58fb3330e2b9e383e217afc0dd YELLOW
ProjectUtils.java 5d4b2cbae16526bd99fedf38a10866d3b2eadde5 YELLOW
......@@ -16,6 +16,7 @@
package org.fortiss.af3.exploration.testgenerator.util;
import static java.lang.Math.floor;
import static java.math.BigDecimal.valueOf;
import static org.fortiss.af3.safety.model.SafetyStandard.IEC61508;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import static org.fortiss.tooling.base.utils.AnnotationUtils.setAnnotationValue;
......@@ -23,6 +24,7 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -38,6 +40,9 @@ import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.af3.task.model.annotation.FlashRequirement;
import org.fortiss.af3.task.model.timing.TaskStartEvent;
import org.fortiss.af3.timing.model.PeriodicConstraint;
import org.fortiss.af3.timing.model.TimingSpecification;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
......@@ -157,6 +162,7 @@ public class AnnotationGenerationUtils {
TaskArchitecture taskArch =
pickFirstInstanceOf(TaskArchitecture.class, expandedFP.getRootElements());
defineTaskMemoryRequirements(taskArch, 550, memoryUsage);
defineWCETs(expandedFP, taskArch);
expandedFileProjects.add(expandedFP);
}
}
......@@ -210,4 +216,25 @@ public class AnnotationGenerationUtils {
return memoryRequirements;
}
/** Defines the WCETs of tasks. */
private static void defineWCETs(FileProject fp, TaskArchitecture taskArch) {
TimingSpecification timingSpec =
pickFirstInstanceOf(TimingSpecification.class, fp.getRootElements());
// We use the sum of task WCETs to get an upper bound for single-core execution. Not
// considering allocation constraints, no multicore-based schedule should be worse
BigDecimal wcetSum = BigDecimal.ZERO;
for(Task task : taskArch.getTasks()) {
BigDecimal wcet = task.getWcet() != null ? task.getWcet() : BigDecimal.ZERO;
wcetSum.add(wcet);
}
wcetSum = wcetSum.multiply(valueOf(1.1)); // Just for safety
for(Task task : taskArch.getTasks()) {
PeriodicConstraint pConstr =
timingSpec.getConstraint(task, PeriodicConstraint.class, TaskStartEvent.class);
pConstr.setPeriod(wcetSum);
}
}
}
......@@ -24,10 +24,14 @@ import static org.fortiss.af3.project.utils.ProjectModelElementFactory.createFil
import static org.fortiss.af3.project.utils.ProjectModelElementFactory.createProjectConfiguration;
import static org.fortiss.af3.project.utils.ProjectUtils.ensureEclipseContainerProjectExists;
import static org.fortiss.af3.project.utils.ProjectUtils.saveProject;
import static org.fortiss.af3.timing.utils.TimingModelElementFactory.createEntityEvent;
import static org.fortiss.af3.timing.utils.TimingModelElementFactory.createPeriodicConstraint;
import static org.fortiss.af3.timing.utils.TimingModelElementFactory.createTimingSpecification;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateAllIDs;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -37,8 +41,12 @@ import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.af3.task.model.timing.TaskStartEvent;
import org.fortiss.af3.task.util.ComponentToTaskArchitectureTransformation;
import org.fortiss.af3.timing.model.PeriodicConstraint;
import org.fortiss.af3.timing.model.TimingSpecification;
/**
* Utility class for interacting with persistent AF3 projects.
......@@ -70,9 +78,10 @@ public class ProjectUtils {
AllocationTableCollection allocTableColl =
createAllocationTableCollection("AllocationTable");
TaskArchitecture taskArch = generateTaskArchitecture(fpCompArch, allocTableColl);
TimingSpecification timingSpec = generateTimingSpecification(taskArch);
FileProject fp =
createAF3Project(fpCompArch, taskArch, allocTableColl, fpPlatArch, name);
FileProject fp = createAF3Project(fpCompArch, taskArch, timingSpec, allocTableColl,
fpPlatArch, name);
fileProjects.add(fp);
}
}
......@@ -99,15 +108,38 @@ public class ProjectUtils {
return taskArchitecture;
}
/** Generates a timing specification for the given {@link TaskArchitecture}. */
private static TimingSpecification generateTimingSpecification(TaskArchitecture taskArch) {
TimingSpecification timingSpec =
createTimingSpecification("Timing Specification", taskArch);
for(Task task : taskArch.getTasks()) {
PeriodicConstraint pConstraint = createPeriodicConstraint();
pConstraint.setPeriod(BigDecimal.ONE);
pConstraint.setJitter(BigDecimal.ZERO);
TaskStartEvent startEvent =
(TaskStartEvent)createEntityEvent(TaskStartEvent.class, task);
timingSpec.addEvent(startEvent);
pConstraint.setEvent(startEvent);
timingSpec.getConstraints().add(pConstraint);
}
return timingSpec;
}
/** Creates an AF3 project with the given root elements. */
private static FileProject createAF3Project(ComponentArchitecture componentArchitecture,
TaskArchitecture taskArch, AllocationTableCollection allocationTableCollection,
TaskArchitecture taskArch, TimingSpecification timingSpec,
AllocationTableCollection allocationTableCollection,
PlatformArchitecture platformArchitecture, String name) throws IllegalStateException {
FileProject fileProject = createFileProject(name, createProjectConfiguration());
fileProject.getRootElements().add(componentArchitecture);
fileProject.getRootElements().add(allocationTableCollection);
fileProject.getRootElements().add(taskArch);
fileProject.getRootElements().add(timingSpec);
fileProject.getRootElements().add(platformArchitecture);
return fileProject;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment