Permalink
Browse files

[#89]: Relax input spec grammar by using Xtext options

Mapping grammar tests are failing

Task-Url: http://github.com/roberthilbrich/assist-public/issues/89
  • Loading branch information...
RobertHilbrich committed Oct 10, 2018
1 parent 2162a13 commit e04d2c6df175bf9f5c9b43289b7c85c7df593f79
Showing with 3,020 additions and 1,381 deletions.
  1. +17 −32 ch.hilbri.assist.mapping.tests/src/ch/hilbri/assist/mapping/tests/basics/CustomPropertiesTests.xtend
  2. +2 −2 ...mapping.tests/src/ch/hilbri/assist/mapping/tests/constraints/CoreUtilizationConstraintTests.xtend
  3. +2 −2 ch.hilbri.assist.mapping/src/ch/hilbri/assist/mapping/analysis/metrics/builtin/MaxFreeCapacity.xtend
  4. +4 −4 ch.hilbri.assist.mapping/src/ch/hilbri/assist/mapping/exporter/DeploymentAsARXML.xtend
  5. +1 −1 ch.hilbri.assist.mapping/src/ch/hilbri/assist/mapping/exporter/DeploymentAsSchedulingModel.xtend
  6. +1 −1 ch.hilbri.assist.mapping/src/ch/hilbri/assist/mapping/exporter/ExportToAPP4MCModel.xtend
  7. +1 −1 ...ri.assist.mapping/src/ch/hilbri/assist/mapping/solver/constraints/CoreUtilizationConstraint.xtend
  8. +1 −1 ...lbri.assist.mapping/src/ch/hilbri/assist/mapping/solver/constraints/DissimilarityConstraint.xtend
  9. BIN ch.hilbri.assist.model.edit/icons/full/ctool16/CreateSoftwareElement_properties_CustomProperty.gif
  10. +0 −48 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/ApplicationItemProvider.java
  11. +0 −48 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/CoreItemProvider.java
  12. +9 −9 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/CustomIntPropertyItemProvider.java
  13. +39 −20 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/CustomPropertyItemProvider.java
  14. +8 −8 ...ilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/CustomStringPropertyItemProvider.java
  15. +5 −0 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/HardwareElementItemProvider.java
  16. +24 −0 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/ModelItemProviderAdapterFactory.java
  17. +0 −24 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/ProcessorItemProvider.java
  18. +5 −0 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/SoftwareElementItemProvider.java
  19. +0 −72 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/TaskItemProvider.java
  20. +178 −17 ch.hilbri.assist.model/model/ASSIST-Model.xcore
  21. +32 −59 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/Application.java
  22. +30 −54 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/Core.java
  23. +14 −14 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/CustomIntProperty.java
  24. +50 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/CustomProperty.java
  25. +12 −12 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/CustomStringProperty.java
  26. +32 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/HardwareElement.java
  27. +9 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/ModelFactory.java
  28. +1,009 −257 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/ModelPackage.java
  29. +16 −28 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/Processor.java
  30. +32 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/SoftwareElement.java
  31. +48 −84 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/Task.java
  32. +137 −99 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ApplicationImpl.java
  33. +12 −7 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/CompartmentImpl.java
  34. +156 −113 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/CoreImpl.java
  35. +24 −24 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/CustomIntPropertyImpl.java
  36. +162 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/CustomPropertyImpl.java
  37. +24 −24 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/CustomStringPropertyImpl.java
  38. +118 −7 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/HardwareElementImpl.java
  39. +4 −4 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/MappingResultImpl.java
  40. +12 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ModelFactoryImpl.java
  41. +323 −72 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ModelPackageImpl.java
  42. +79 −68 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ProcessorImpl.java
  43. +110 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/SoftwareElementImpl.java
  44. +234 −163 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/TaskImpl.java
  45. +19 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/util/ModelAdapterFactory.java
  46. +25 −2 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/util/ModelSwitch.java
@@ -26,17 +26,13 @@ class CustomPropertiesTests extends AbstractMappingTest {
Processor P1 {
Core C0 {
Capacity = 100;
Properties {
"MyIntProperty" = 0;
"MyStringProperty" = "C0";
}
Custom Property "MyIntProperty" = 0;
Custom Property "MyStringProperty" = "C0";
}
Core C1 {
Capacity = 100;
Properties {
"MyIntProperty" = 1;
"MyStringProperty" = "C1";
}
Custom Property "MyIntProperty" = 1;
Custom Property "MyStringProperty" = "C1";
}
}
}
@@ -47,10 +43,8 @@ class CustomPropertiesTests extends AbstractMappingTest {
Software {
Application A1 {
Task A1_T1 {
Properties {
"MyIntProperty" = 1;
"MyStringProperty" = "T1";
}
Custom Property "MyIntProperty" = 1;
Custom Property "MyStringProperty" = "T1";
}
}
}''')
@@ -78,29 +72,20 @@ class CustomPropertiesTests extends AbstractMappingTest {
/* Lets check these properties for the task */
val task = assistModel.allTasks.head
for (property : task.customProperties) {
if (property.name.equals("MyIntProperty")) {
Assert.assertEquals(1, property.intValue)
Assert.assertTrue(property.stringValue.equals("1"))
} else if (property.name.equals("MyStringProperty")) {
Assert.assertTrue(property.stringValue.equals("T1"))
Assert.assertNull(property.intValue)
} else
Assert.assertFalse(true) // there should be no other property
}
val propList = task.getCustomPropertiesWithName("MyIntProperty")
Assert.assertEquals(1, propList.size)
Assert.assertEquals(1, task.getCustomIntProperty("MyIntProperty"))
val propList2 = task.getCustomPropertiesWithName("MyStringProperty")
Assert.assertEquals(1, propList2.size)
Assert.assertEquals("T1", task.getCustomStringProperty("MyStringProperty"))
/* Lets check these properties for the cores */
for (core : assistModel.allCores) {
for (property : core.customProperties) {
if (property.name.equals("MyIntProperty")) {
Assert.assertEquals(assistModel.allCores.indexOf(core), property.intValue)
Assert.assertTrue(property.stringValue.equals(assistModel.allCores.indexOf(core).toString))
} else if (property.name.equals("MyStringProperty")) {
Assert.assertTrue(property.stringValue.equals(core.name))
Assert.assertNull(property.intValue)
} else
Assert.assertFalse(true) // there should be no other property
}
Assert.assertEquals(assistModel.allCores.indexOf(core), core.getCustomIntProperty("MyIntProperty"))
Assert.assertEquals(core.name, core.getCustomIntProperty("MyStringProperty"))
}
}
}
@@ -81,8 +81,8 @@ Software {
if (!mappedTasks.isNullOrEmpty) {
val utilizationSum = mappedTasks.map[coreUtilization].reduce[p1, p2|p1 + p2]
val msg = '''Utilization of «core.name» exceeds capacity (cap.: «core.capacity», util.: «utilizationSum»)'''
Assert.assertTrue(msg, utilizationSum <= core.capacity)
val msg = '''Utilization of «core.name» exceeds capacity (cap.: «core.coreCapacity», util.: «utilizationSum»)'''
Assert.assertTrue(msg, utilizationSum <= core.coreCapacity)
}
else
Assert.assertTrue(mappedTasks === null || mappedTasks.length == 0)
@@ -22,8 +22,8 @@ class MaxFreeCapacity extends AbstractMappingMetricImpl {
if (!result.getTask2CoreMap.values.contains(core)) unusedCores++
// some task would like to use this core - see how much free space we got
if ((core.capacity - result.getAbsoluteCoreUtilization(core)) > maxRemainingCoreCapacity)
maxRemainingCoreCapacity = core.capacity - result.getAbsoluteCoreUtilization(core)
if ((core.coreCapacity - result.getAbsoluteCoreUtilization(core)) > maxRemainingCoreCapacity)
maxRemainingCoreCapacity = core.coreCapacity - result.getAbsoluteCoreUtilization(core)
}
@@ -118,7 +118,7 @@ class DeploymentAsARXML {
</ECUC-CONTAINER-VALUE>
«ENDFOR»
«FOR task : result.model.allTasks.filter[customProperties.filter[name.toUpperCase == "TYPE" && stringValue.toUpperCase == "ISR"].isNullOrEmpty]»
«FOR task : result.model.allTasks.filter[getCustomPropertiesWithNameAndValue("TYPE", "ISR").isNullOrEmpty]»
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>«task.name»</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/AUTOSAR/Os/OsTask</DEFINITION-REF>
@@ -157,7 +157,7 @@ class DeploymentAsARXML {
</ECUC-CONTAINER-VALUE>
«ENDFOR»
«FOR task : result.model.allTasks.filter[customProperties.filter[name.toUpperCase == "TYPE" && stringValue.toUpperCase == "ISR"].size > 0]»
«FOR task : result.model.allTasks.filter[getCustomPropertiesWithNameAndValue("TYPE", "ISR").size > 0]»
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>«task.name»</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/AUTOSAR/Os/OsIsr</DEFINITION-REF>
@@ -180,14 +180,14 @@ class DeploymentAsARXML {
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/AUTOSAR/Os/OsApplication</DEFINITION-REF>
<REFERENCE-VALUES>
«FOR task : application.tasks.filter[customProperties.filter[name.toUpperCase == "TYPE" && stringValue.toUpperCase == "ISR"].isNullOrEmpty]»
«FOR task : application.tasks.filter[getCustomPropertiesWithNameAndValue("TYPE", "ISR").isNullOrEmpty]»
<ECUC-REFERENCE-VALUE>
<DEFINITION-REF DEST="ECUC-REFERENCE-DEF">/AUTOSAR/Os/OsApplication/OsAppTaskRef</DEFINITION-REF>
<VALUE-REF DEST="ECUC-CONTAINER-VALUE">/«result.model.systemName»/Os/«task.name»</VALUE-REF>
</ECUC-REFERENCE-VALUE>
«ENDFOR»
«FOR task : application.tasks.filter[customProperties.filter[name.toUpperCase == "TYPE" && stringValue.toUpperCase == "ISR"].size > 0]»
«FOR task : application.tasks.filter[getCustomPropertiesWithNameAndValue("TYPE", "ISR").size > 0]»
<ECUC-REFERENCE-VALUE>
<DEFINITION-REF DEST="ECUC-REFERENCE-DEF">/AUTOSAR/Os/OsApplication/OsAppIsrRef</DEFINITION-REF>
<VALUE-REF DEST="ECUC-CONTAINER-VALUE">/«result.model.systemName»/Os/«task.name»</VALUE-REF>
@@ -42,7 +42,7 @@ class DeploymentAsSchedulingModel {
val core = entry.value
val coreIdx = oldModel.allCores.indexOf(core)
val periodValue = 20
val taskDuration = Math.round(Math.floor(new Double(task.coreUtilization) / new Double(core.capacity) * periodValue)) as int
val taskDuration = Math.round(Math.floor(new Double(task.coreUtilization) / new Double(core.coreCapacity) * periodValue)) as int
// Here we assume that despite the object cloning, the index of the cores and tasks
@@ -330,7 +330,7 @@ class ExportToAPP4MCModel {
private static def ProcessingUnit createProcessingUnit(AmaltheaFactory factory, Core core) {
factory.createProcessingUnit => [
name = core.fullName
if (!core.architecture.nullOrEmpty) CustomPropertyUtil.customPut(it, "Architecture", core.architecture)
if (!core.coreArchitecture.nullOrEmpty) CustomPropertyUtil.customPut(it, "Architecture", core.coreArchitecture)
]
}
}
@@ -20,7 +20,7 @@ class CoreUtilizationConstraint extends AbstractMappingConstraint {
for (core : model.allCores) {
val indVars = solverVariables.getIndVars(core) // is this task mapped to this core?
val taskUtils = model.allTasks.map[coreUtilization] // how much capacity does it require
val capacity = core.capacity
val capacity = core.coreCapacity
val constraint = chocoModel.scalar(indVars, taskUtils, "<=", capacity)
constraint.post
}
@@ -115,7 +115,7 @@ class DissimilarityConstraint extends AbstractMappingConstraint {
case BOARD_ASSURANCELEVEL: { model.allBoards.map[assuranceLevel.literal] }
case PROCESSOR_MANUFACTURER: { model.allProcessors.map[manufacturer] }
case PROCESSOR_PROCESSORTYPE: { model.allProcessors.map[processorType] }
case CORE_ARCHITECTURE: { model.allCores.map[architecture] }
case CORE_ARCHITECTURE: { model.allCores.map[coreArchitecture] }
}
}
}
@@ -48,58 +48,12 @@ public ApplicationItemProvider(AdapterFactory adapterFactory) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addDevelopedByPropertyDescriptor(object);
addCriticalityLevelPropertyDescriptor(object);
addRestrictMappingToHardwareElementsPropertyDescriptor(object);
addFullNamePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Developed By feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addDevelopedByPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Application_developedBy_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Application_developedBy_feature", "_UI_Application_type"),
ModelPackage.Literals.APPLICATION__DEVELOPED_BY,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Criticality Level feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addCriticalityLevelPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Application_criticalityLevel_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Application_criticalityLevel_feature", "_UI_Application_type"),
ModelPackage.Literals.APPLICATION__CRITICALITY_LEVEL,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Restrict Mapping To Hardware Elements feature.
* <!-- begin-user-doc -->
@@ -212,8 +166,6 @@ public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Application.class)) {
case ModelPackage.APPLICATION__DEVELOPED_BY:
case ModelPackage.APPLICATION__CRITICALITY_LEVEL:
case ModelPackage.APPLICATION__FULL_NAME:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
@@ -45,36 +45,12 @@ public CoreItemProvider(AdapterFactory adapterFactory) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addArchitecturePropertyDescriptor(object);
addCapacityPropertyDescriptor(object);
addFullNamePropertyDescriptor(object);
addProcessorPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Architecture feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addArchitecturePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Core_architecture_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Core_architecture_feature", "_UI_Core_type"),
ModelPackage.Literals.CORE__ARCHITECTURE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Full Name feature.
* <!-- begin-user-doc -->
@@ -97,28 +73,6 @@ protected void addFullNamePropertyDescriptor(Object object) {
null));
}
/**
* This adds a property descriptor for the Capacity feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addCapacityPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Core_capacity_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Core_capacity_feature", "_UI_Core_type"),
ModelPackage.Literals.CORE__CAPACITY,
true,
false,
false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Processor feature.
* <!-- begin-user-doc -->
@@ -179,8 +133,6 @@ public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Core.class)) {
case ModelPackage.CORE__ARCHITECTURE:
case ModelPackage.CORE__CAPACITY:
case ModelPackage.CORE__FULL_NAME:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
@@ -21,7 +21,7 @@
* <!-- end-user-doc -->
* @generated
*/
public class CustomIntPropertyItemProvider extends IntPropertyItemProvider {
public class CustomIntPropertyItemProvider extends CustomPropertyItemProvider {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
@@ -43,29 +43,29 @@ public CustomIntPropertyItemProvider(AdapterFactory adapterFactory) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addNamePropertyDescriptor(object);
addValuePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Name feature.
* This adds a property descriptor for the Value feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
protected void addValuePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_CustomIntProperty_name_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_CustomIntProperty_name_feature", "_UI_CustomIntProperty_type"),
ModelPackage.Literals.CUSTOM_INT_PROPERTY__NAME,
getString("_UI_CustomIntProperty_value_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_CustomIntProperty_value_feature", "_UI_CustomIntProperty_type"),
ModelPackage.Literals.CUSTOM_INT_PROPERTY__VALUE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
null,
null));
}
@@ -108,7 +108,7 @@ public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(CustomIntProperty.class)) {
case ModelPackage.CUSTOM_INT_PROPERTY__NAME:
case ModelPackage.CUSTOM_INT_PROPERTY__VALUE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
Oops, something went wrong.

0 comments on commit e04d2c6

Please sign in to comment.