Commit 2fe6b946 authored by Simon Barner's avatar Simon Barner
Browse files

Ensure deterministic generation order

* Sort list of partitions and components
* Use TreeMaps with a lexicographical comparator instead of HashMaps
* Eases debugging

Issue-Ref: 3337
Issue-Url: https://af3-developer.fortiss.org/issues/3337

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 1719a7c5
BareMetalExecutable.java a8ab4e19802e7123b135a1f8897f351141282098 YELLOW
BareMetalExecutable.java b2fef6e6791e7ebf9cdd5afbe8113cf4d0e7a55b YELLOW
BareMetalExecutableTransformationContext.java a2617f33fcc542c73a183908e1221b273bfdcdac YELLOW
BareMetalTransformation.java 9172fb031f8f53e8951cb9478181357ea3e5986f YELLOW
BareMetalTransformationContext.java f0bf7fbecf41b086e2e69fa5d8f56abc34535bf8 YELLOW
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.baremetal.generator;
import static java.util.Collections.sort;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createRootConfigureFile;
import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createSourcePackage;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAtomicExecutionUnitTransceivers;
......@@ -28,8 +29,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.conqat.lib.commons.collections.Pair;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.Port;
......@@ -48,6 +51,7 @@ import org.fortiss.af3.platform.model.Transmitter;
import org.fortiss.af3.platform.model.allocation.ComponentToExecutionUnitAllocationTable;
import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
import org.fortiss.tooling.kernel.extension.exception.ChainTransformationFailedException;
import org.fortiss.tooling.kernel.utils.HierarchicalNameComparator;
/**
* Executable generated by the {@link BareMetalTransformation}.
......@@ -116,14 +120,18 @@ public class BareMetalExecutable {
BareMetalExecutableTransformationContext ctx =
new BareMetalExecutableTransformationContext(this, context);
for(ExecutionUnit eu : ca2hw.getExecutionUnits()) {
EList<ExecutionUnit> executionUnits = new BasicEList<>(ca2hw.getExecutionUnits());
HierarchicalNameComparator cmp = new HierarchicalNameComparator();
sort(executionUnits, cmp);
for(ExecutionUnit eu : executionUnits) {
ExecutionUnitExecutableBase<?, ?> exec = platformExecutable.getExecutable(eu);
List<Pair<ExecutionUnit, Component>> deployedComponents =
new ArrayList<Pair<ExecutionUnit, Component>>();
for(Component c : ca2hw.getComponents(eu)) {
ca2hw.getComponents(eu).stream().sorted(cmp).forEachOrdered(c -> {
deployedComponents.add(new Pair<ExecutionUnit, Component>(eu, c));
}
});
List<Pair<PlatformConnectorUnit, Port>> deployedPorts =
new ArrayList<Pair<PlatformConnectorUnit, Port>>();
......@@ -139,14 +147,15 @@ public class BareMetalExecutable {
}
for(TransmissionUnit tu : unitCatalog.keySet()) {
Map<ExecutionUnit, List<Port>> euPortsPair = new HashMap<ExecutionUnit, List<Port>>();
Map<ExecutionUnit, List<Port>> euPortsPair =
new TreeMap<ExecutionUnit, List<Port>>(cmp);
Map<ExecutionUnit, List<Component>> euComponentList =
new HashMap<ExecutionUnit, List<Component>>();
new TreeMap<ExecutionUnit, List<Component>>(cmp);
SourcePackage pack = deploymentPackage;
TransmissionUnitExecutableBase<?> texec = platformExecutable.getExecutable(tu);
for(ExecutionUnit eu : ca2hw.getExecutionUnits()) {
for(ExecutionUnit eu : executionUnits) {
List<Port> deployedPorts = new ArrayList<Port>();
List<Component> deployedComponents = new ArrayList<Component>();
for(PlatformConnectorUnit unit : eu.getPlatformConnectorUnits()) {
......@@ -157,9 +166,9 @@ public class BareMetalExecutable {
// list of ports per ecu since port variables are needed to be created
euPortsPair.put(eu, deployedPorts);
for(Component c : ca2hw.getComponents(eu)) {
ca2hw.getComponents(eu).stream().sorted(cmp).forEachOrdered(c -> {
deployedComponents.add(c);
}
});
// list of components deployed per ecu
euComponentList.put(eu, deployedComponents);
}
......@@ -169,9 +178,9 @@ public class BareMetalExecutable {
// used to find the correct deployment from multiple manual deployments
int ca2hwId = ca2hw.getId();
if(texec != null)
texec.createAllFiles(pack, euPortsPair, euComponentList, topComponent,
ca2hwId);
if(texec != null) {
texec.createAllFiles(pack, euPortsPair, euComponentList, topComponent, ca2hwId);
}
}
deploymentPackage.getUnits().add(createRootConfigureFile());
......
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