Commit bfd033c9 authored by Simon Barner's avatar Simon Barner
Browse files

- AllocationToSchedule: Link input AllocationTableCollection in generated SystemSchedule

- ScheduleRun: Generate constraints required for weak causality only for Tasks where only weakly causal Components are mapped
refs 3343
parent b6ce16f4
......@@ -39,6 +39,7 @@ import java.util.stream.Collectors;
import javax.activation.UnsupportedDataTypeException;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.efficientdeployment.model.ExplorationSpecificationSubSet;
import org.fortiss.af3.exploration.dsl_v2.model.arithmetic.ArithmeticLiteral;
import org.fortiss.af3.exploration.dsl_v2.model.arithmetic.IArithmeticExpression;
......@@ -77,6 +78,7 @@ import org.fortiss.af3.schedule.model.SystemSchedule;
import org.fortiss.af3.schedule.utils.ScheduleUtils;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskOutputPort;
import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationTable;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
......@@ -408,6 +410,22 @@ public class ScheduleRun extends SolverRun {
return assertions;
}
/**
* Predicate if the given {@link Task} is strongly causal, i.e. if at least of the logical
* {@link Component}s allocated to it is strongly causal.
*/
private static boolean isStronglyCausal(Task task, ComponentToTaskAllocationTable ca2ta) {
if(ca2ta == null) {
return false;
}
for(Component component : ca2ta.getComponents(task)) {
if(component.isStronglyCausal()) {
return true;
}
}
return true;
}
/** Creates the (FOCUS) causality constraints of the given schedule (strong vs. weak causal). */
public static List<IBooleanExpression> createCausalityConstraints(SystemSchedule schedule) {
List<IBooleanExpression> assertions = new ArrayList<>();
......@@ -418,6 +436,10 @@ public class ScheduleRun extends SolverRun {
.filter(s -> (s instanceof ResourceSchedule && ((ResourceSchedule)s)
.getResource() instanceof TransmissionUnit))
.collect(Collectors.toList());
ComponentToTaskAllocationTable ca2ta =
schedule.getAllocationTableCollection().getAllocationTable(
ComponentToTaskAllocationTable.class);
for(Schedule s : collect) {
for(ResourceAllocation signal : s.getResourceAllocationList()) {
TaskOutputPort modelElement =
......@@ -425,8 +447,7 @@ public class ScheduleRun extends SolverRun {
Task sourceTask = (Task)modelElement.getOwner();// tComponent();
ResourceAllocation resourceAllocationSource =
ScheduleUtils.getResourceAllocation(schedule, sourceTask);
// if(!sourceTask.isStronglyCausal()) {
// considering everything weakly causal for the moment!
if(!isStronglyCausal(sourceTask, ca2ta)) {
for(IConnection oc : modelElement.getOutgoing()) {
Task targetTask = (Task)oc.getTarget().getOwner();
ResourceAllocation resourceAllocationTarget =
......@@ -438,7 +459,8 @@ public class ScheduleRun extends SolverRun {
ForAll forAll1 = createForAll();
Set<IModelElement> set1 =
DSMLModelElementFactory.createSet("sourceTask", IModelElement.class);
DSMLModelElementFactory
.createSet("sourceTask", IModelElement.class);
set1.getEntries().add(resourceAllocationSource);
forAll1.setSet(set1);
ForAll forAll2 = createForAll();
......@@ -482,7 +504,7 @@ public class ScheduleRun extends SolverRun {
assertions.add(forAll1);
}
}
// }
}
}
return assertions;
......
......@@ -87,6 +87,8 @@ public class AllocationToSchedule {
}
}
generateAllIDs(systemSchedule);
systemSchedule.setAllocationTableCollection(ta2hw.getAllocationTableCollection());
return systemSchedule;
}
......@@ -180,8 +182,7 @@ public class AllocationToSchedule {
}
List<TransmissionUnit> transmissionUnits =
PlatformArchitectureUtils
.findAtomicTransmissionUnits((PlatformArchitecture)ta2hw
PlatformArchitectureUtils.findAtomicTransmissionUnits((PlatformArchitecture)ta2hw
.getTargetView());
for(TransmissionUnit ts : transmissionUnits) {
List<IHierarchicElement> connectedElements =
......
Supports Markdown
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