Commit 8a126253 authored by Marco Volpe's avatar Marco Volpe
Browse files

Part of the review comments addressed.

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

Signed-off-by: Marco Volpe's avatarMarco Volpe <volpe@fortiss.org>
parent 8f9f5a89
AnnotationContentProvider.java 27cf0ad51cc44e0549321c384793f5f0543c91d0 RED
AnnotationContentProvider.java bb971895f90ee93f0f8ebac9a50b33dff2a3aa72 YELLOW
ConstraintObjectiveFXController.java e85e42b88a94cc2282af0048830c0d20a8bf650f RED
DSEPerspectiveViewBase.java c1dcee18f44a9f3ae31b91f6e41ba0b27ec7505a GREEN
DseSaveableView.java 8320c2b0949df2d4cc4e37fc7267f81afc1d3ff0 GREEN
......
......@@ -16,6 +16,7 @@
package org.fortiss.af3.exploration.ui.perspective.generic;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
......@@ -41,7 +42,6 @@ public class AnnotationContentProvider extends DynamicTreeContentProviderBase<EO
.getAnnotationEntry((IModelElement)parent).getSpecificationsList();
return list;
}
// TODO(AD): Here, it is better to return an empty Collection (Collections.emptyList()) since we structurally can avoid NPE by that.
return null;
return Collections.emptyList();
}
}
AllocationPatternFXController.java 1a5646895fec7611353c757b3c656025b16af902 RED
CouplingPatternFXController.java 642814a8b113784daed82c8ba922b0c95b46d437 RED
MemoryPatternFXController.java ca503dd356a44c1025f870fad9659dd7b403fab8 RED
SafetyPatternFXController.java a186d0b9d0858f133dc370562e01d820f53e222b RED
AllocationPatternFXController.java 16b8fb8250581fc07ab800c8e0daf57c86624b4c YELLOW
CouplingPatternFXController.java 7b5bb5699d270aed06e3941aafdfc389bbef489a YELLOW
MemoryPatternFXController.java d5bc8d309f23c1a321aba18145ea5eed6582357b YELLOW
SafetyPatternFXController.java bdf1338096a6cdcfe393d13ccdd07e051f145bce YELLOW
......@@ -101,13 +101,9 @@ public class AllocationPatternFXController extends PatternFXControllerBase {
if(!tasks.isEmpty()) {
name = calcPatternName(tasks, "; ");
}
// TODO(AD): Use ternary operators.
if(allocationButton.isSelected()) {
name += " -> ";
} else {
name += " -/> ";
}
name += allocationButton.isSelected() ? " -> " : " -/> ";
if(!ecus.isEmpty()) {
name += calcPatternName(ecus, " | ");
}
......
......@@ -95,13 +95,7 @@ public class CouplingPatternFXController extends PatternFXControllerBase {
@Override
public String getExplorationTargetName() {
List<Task> tasks = getSelectedTasks();
String name;
// TODO(AD): Use ternary operators.
if(couplingButton.isSelected()) {
name = "Coupling ";
} else {
name = "Decoupling ";
}
String name = couplingButton.isSelected() ? "Coupling " : "Decoupling ";
if(tasks.size() == 1) {
name = name + "{";
}
......
......@@ -16,7 +16,6 @@
package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern;
import static java.lang.Integer.valueOf;
import static java.lang.String.valueOf;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
......@@ -24,7 +23,6 @@ import static org.fortiss.af3.exploration.smt.util.Z3ModelElementFactory.createS
import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createAnd;
import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createBooleanLiteral;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createUtilizationPatternExpression;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import java.util.Collection;
import java.util.HashMap;
......@@ -42,6 +40,7 @@ import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.annotation.FlashSize;
import org.fortiss.af3.platform.model.annotation.RamSize;
import org.fortiss.af3.task.model.annotation.RamRequirement;
import org.fortiss.tooling.base.utils.AnnotationUtils;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
......@@ -158,9 +157,8 @@ public class MemoryPatternFXController extends PatternFXControllerBase {
case 0:
return ((INamedElement)element).getName();
case 1:
// TODO(AD): Use AnnotationUtils.getAnnotationValue().
return valueOf(getAnnotation(((ExecutionUnit)element), FlashSize.class)
.getBytes());
return AnnotationUtils.getAnnotationValue((ExecutionUnit)element,
FlashSize.class, String.class);
case 2:
return memoryUtilization.get(element).toString();
default:
......
......@@ -22,7 +22,6 @@ import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createAnd
import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createBooleanLiteral;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.calcPatternName;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createSafetyPatternExpression;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import java.util.Collection;
import java.util.List;
......@@ -36,7 +35,9 @@ import org.fortiss.af3.exploration.ui.perspective.generic.PatternFXControllerBas
import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.safety.model.ASIL;
import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
import org.fortiss.tooling.base.utils.AnnotationUtils;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
......@@ -148,11 +149,8 @@ public class SafetyPatternFXController extends PatternFXControllerBase {
case 0:
return ((INamedElement)element).getName();
case 1:
// TODO(AD): Use AnnotationUtils.getAnnotationValue()! Only by using
// that methodm one does not limit the scope to the level names to one
// of the safety standards.
return getAnnotation(((ExecutionUnit)element),
SafetyIntegrityLevel.class).getAsilValue().toString();
return AnnotationUtils.getAnnotationValue((ExecutionUnit)element,
SafetyIntegrityLevel.class, ASIL.class).toString();
default:
return "";
}
......
BusBandwidthOptimizationPatternFXController.java 1c88bce9f57671f018194411877289203d82ce74 RED
HardwareOptimizationPatternFXController.java 33e9ebcc80294588f0662af9a6f0c0b3d949e471 RED
BusBandwidthOptimizationPatternFXController.java 2765573c1227f0e51b86788ff03841db785c64e9 YELLOW
HardwareOptimizationPatternFXController.java 6bfc50de161fb634420583a40278e01f8a5c71eb YELLOW
......@@ -88,9 +88,9 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
public ExplorationTarget<?> getExplorationTarget() {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
TransmissionUnit selectedBus = getSelectedTransmissionUnit();
// TODO(AD): Always use braces.
if(selectedBus == null)
if(selectedBus == null) {
return null;
}
Collection<SMTConstraint> constraints = new HashSet<SMTConstraint>();
IExpression routeWeightExpression = createRouteWeightConstraintPatternExpression(dse);
constraints.add(createSMTConstraint("BandwidthWeight", routeWeightExpression, true));
......@@ -130,19 +130,8 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
@Override
public String getExplorationTargetName() {
TransmissionUnit transmissionUnit = getSelectedTransmissionUnit();
String name;
// TODO(AD): Please use the ternary operator.
if(minButton.isSelected()) {
name = "Min Bandwidth";
} else {
name = "Max Bandwidth";
}
String busName;
// TODO(AD): Always use braces. But better use the ternary operator anyways.
if(transmissionUnit != null)
busName = transmissionUnit.getName();
else
busName = "";
String name = minButton.isSelected() ? "Min Bandwidth" : "Max Bandwidth";
String busName = (transmissionUnit != null) ? transmissionUnit.getName() : "";
name = name + " (" + busName + ")";
return name;
}
......
......@@ -103,11 +103,12 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
/** {@inheritDoc} */
@Override
public boolean isFullySpecified() {
// TODO(AD): Always use braces.
if(getSelectedExecutionUnits().isEmpty() || getSelectedTasks().isEmpty())
if(getSelectedExecutionUnits().isEmpty() || getSelectedTasks().isEmpty()) {
return false;
if(getSelectedProperty() == null && sumButton.isSelected())
}
if(getSelectedProperty() == null && sumButton.isSelected()) {
return false;
}
return true;
}
......@@ -116,13 +117,7 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
public ExplorationTarget<?> getExplorationTarget() {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SMTObjective objective = createSMTObjective();
int operation;
// TODO(AD): Use the ternary operator
if(sumButton.isSelected()) {
operation = 0;
} else {
operation = 1;
}
int operation = sumButton.isSelected() ? 0 : 1;
Class<? extends IAnnotatedSpecification> property = null;
if(getSelectedProperty() != null) {
property = getSelectedProperty().getClass();
......@@ -148,11 +143,11 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
* Returns the property currently selected in the viewer.
*/
private IAnnotatedSpecification getSelectedProperty() {
// TODO(AD): Use AnnotationUtils.getAnnotationValue.
List<IAnnotatedSpecification> list = propertyView.getSelectionModel().getSelectedItems()
.stream().map(item -> (IAnnotatedSpecification)item.getValue()).collect(toList());
if(list.isEmpty())
if(list.isEmpty()) {
return null;
}
// in case the list is not empty, we know that at most one element is selected
return list.get(0);
}
......@@ -168,46 +163,19 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
/** {@inheritDoc} */
@Override
public String getExplorationTargetName() {
String name;
IAnnotatedSpecification property = getSelectedProperty();
// TODO(AD): Use the ternary operator
if(minButton.isSelected()) {
name = "Min ";
} else {
name = "Max ";
}
// TODO(AD): Use the ternary operator
if(sumButton.isSelected()) {
name = name + "Sum (";
} else {
name = name + "Count (";
}
String name = minButton.isSelected() ? "Min " : "Max ";
name = sumButton.isSelected() ? name + "Sum (" : name + "Count (";
SuperSet<ExecutionUnit> ecus = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE()
.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
// TODO(AD): Use the ternary operator
if(getSelectedExecutionUnits().size() == ecus.getEntries().size()) {
name = name + "All ECUs, ";
} else {
name = name + calcPatternName(getSelectedExecutionUnits(), ", ") + ", ";
}
// TODO(AD): Use the ternary operator
if(!(property == null)) {
name = name + getPropertyName(property) + ", ";
} else {
name = name + " - , ";
}
name = (getSelectedExecutionUnits().size() == ecus.getEntries().size())
? name + "All ECUs, "
: name + calcPatternName(getSelectedExecutionUnits(), ", ") + ", ";
name = !(property == null) ? name + getPropertyName(property) + ", " : name + " - , ";
SuperSet<Task> tasks = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE()
.getCurrentStep().getSuperSetMap().get(Task.class);
// TODO(AD): Use the ternary operator
if(getSelectedTasks().size() == tasks.getEntries().size()) {
name = name + "All Tasks)";
} else {
name = name + calcPatternName(getSelectedTasks(), ", ") + ")";
}
name = (getSelectedTasks().size() == tasks.getEntries().size()) ? name + "All Tasks)"
: name + calcPatternName(getSelectedTasks(), ", ") + ")";
return name;
}
......
......@@ -6,4 +6,4 @@ ExplorationModelElementFactory.java bb48b2d09b92efcb1b2d3e382555089bb7ed5db5 GRE
ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN
ExplorationUtils.java 79f8960b63762045008d27def3752d735dad43f0 GREEN
ModelSnapshotExtractUtils.java 940c5f0e2859519522ae8edfda63e05112870776 GREEN
PatternFactoryUtils.java 9733610d3e19e122d12ebcc0f64bd61592a3f057 RED
PatternFactoryUtils.java 69ad824c479dc345a061019b3d3dfb723053f5e6 YELLOW
......@@ -90,14 +90,13 @@ public class PatternFactoryUtils {
static int MAX_ALLOC_SIZE_PER_SIDE = 50;
/**
* Creates an {@link IBooleanExpression} according to the {@link Route} weight constraint
* Creates an {@link IExpression} according to the {@link Route} weight constraint
* pattern.
*
* @param dse
* Current {@link DSE}
* @return {@link IBooleanExpression} defining the weight of a {@link Route}
* @return {@link IExpression} defining the weight of a {@link Route}
*/
// TODO(AD): Discrepancy with the docs: BooleanExpression as return type?
public static IExpression createRouteWeightConstraintPatternExpression(DSE dse) {
SuperSetMap superSetMap = dse.getCurrentStep().getSuperSetMap();
......@@ -166,9 +165,11 @@ public class PatternFactoryUtils {
* Current {@link DSE}
* @param bus
* {@link TransmissionUnit} for which to optimize
* @param minimize
* Condition being true in case the expression needs to be minimized, false
* otherwise
* @return {@link IExpression} minimizing the weight of the given {@link TransmissionUnit}
*/
// TODO(AD): Warning, please document all parameters in util classes.
public static IExpression createBusWeightOptimizationPatternExpression(DSE dse,
TransmissionUnit bus, boolean minimize) {
SuperSetMap superSetMap = dse.getCurrentStep().getSuperSetMap();
......@@ -198,11 +199,10 @@ public class PatternFactoryUtils {
Sum sum = createSum(setRoute.getCastedSet(IModelElement.class), and, routeWeight);
// TODO(AD): ALWAYS use braces. Also, there is a warning that the second else is not needed.
if(minimize)
if(minimize) {
return createMinimize(sum);
else
return createMaximize(sum);
}
return createMaximize(sum);
}
/**
......
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