Browse Source

Merge branch 'master' into au/window

# Conflicts:
#	DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/modelDescription.xml
#	DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest.xtend
#	ModelicaModels/Window.mo
Casper Thule 4 years ago
parent
commit
70c1771c0f
100 changed files with 1087 additions and 8307 deletions
  1. 11 1
      .gitignore
  2. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/Window.fmu
  3. 30 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/modelDescription.xml
  4. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/window_sa_canonical.BASE.sa
  5. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppAutoTest.xtend
  6. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest2.xtend
  7. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppModuleTest.xtend
  8. 0 63
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/controller_sa.sa
  9. 1 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_inline.sa
  10. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_model_only.sa
  11. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_multi_rate.sa
  12. 0 25
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/plant.sa
  13. 71 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller.sa
  14. 128 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller_sa_allInOne.sa
  15. 80 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller_sa_commented.sa
  16. 69 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/lazy.sa
  17. 108 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/lazy_sa_commented.sa
  18. 45 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/loop.sa
  19. 74 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/loop_canonical.sa
  20. 12 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/power.BASE.sa
  21. 36 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/rate.sa
  22. 2 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_obstacle_sa_flat.BASE.sa
  23. 6 68
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa.BASE.sa
  24. 20 31
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical.BASE.sa
  25. 67 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical_commented.BASE.sa
  26. 79 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_commented.BASE.sa
  27. 0 34
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow.sa
  28. 0 24
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_delay_BASE.sa
  29. 0 19
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration.sa
  30. 0 111
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration_BASE.sa
  31. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa
  32. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_controller_delay.sa
  33. 0 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_model_only.sa
  34. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window2/window_sa_canonical.BASE.sa
  35. 0 31
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/test1.sa
  36. 0 24
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE.sa
  37. 0 28
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE_new.sa
  38. 0 18
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE.sa
  39. 0 28
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE_new.sa
  40. 0 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/ParserFolderTest.xtend
  41. 32 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/PowerWindowCaseStudyFolderTest.xtend
  42. 6 85
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SemanticAdaptationParsingTest.xtend
  43. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SingleFolderTest.xtend
  44. 0 13
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa
  45. 0 23
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_controller_delay.sa
  46. 2 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/DEPRECATED.txt
  47. 6 6
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/algorithm.c
  48. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/sketch.BASE.sa
  49. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/window_obstacle_sa.BASE.sa
  50. 7 7
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/SemanticAdaptation.xtext
  51. 2 2
      ModelicaModels/NoObstacle_Test.mo
  52. 3 3
      ModelicaModels/Obstacle.mo
  53. 4 16
      ModelicaModels/PowerSystemStandAlone.mo
  54. 4 4
      ModelicaModels/UncontrolledScenario.mo
  55. 113 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/.cproject
  56. 1 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/.gitignore
  57. 26 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/.project
  58. 3 12
      SemanticAdaptationForFMI/Experiments/power_window_case_study/README.txt
  59. 0 57
      SemanticAdaptationForFMI/Experiments/power_window_case_study/bin/License.txt
  60. 29 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/build.ps1
  61. 0 10
      SemanticAdaptationForFMI/Experiments/power_window_case_study/build_all.bat
  62. 0 26
      SemanticAdaptationForFMI/Experiments/power_window_case_study/build_run_all.bat
  63. 0 1735
      SemanticAdaptationForFMI/Experiments/power_window_case_study/crashedlog1.txt
  64. 0 1735
      SemanticAdaptationForFMI/Experiments/power_window_case_study/crashedlog2.txt
  65. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2.h
  66. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2FunctionTypes.h
  67. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2Functions.h
  68. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2TypesPlatform.h
  69. 0 7
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/.gitignore
  70. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/Debug/libFMI_SEL.dll
  71. 0 542
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/FMI_SEL.c
  72. 0 51
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/FMI_SEL.h
  73. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_TD/Debug/libFMI_TD.dll
  74. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_Window_sa/Debug/libFMI_Window_sa.dll
  75. 0 490
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_Window_sa/FMI_Window_sa.c
  76. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_control_master/Debug/libFMI_control_master.dll
  77. 0 535
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_control_master/FMI_CM.c
  78. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_generic_master/Debug/libFMI_generic_master.dll
  79. 0 602
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_generic_master/FMI_GM.c
  80. 0 27
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/ACKNOWLEDGEMENTS-FMUChecker.txt
  81. 0 64
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/BUILD-FMUChecker.txt
  82. 0 27
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/LICENCE-FMUChecker.txt
  83. 0 101
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/README-FMUChecker.txt
  84. 0 83
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/RELEASE-NOTES-FMUChecker.txt
  85. 0 5
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/.svn/all-wcprops
  86. 0 34
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/.svn/entries
  87. 0 35
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/all-wcprops
  88. 0 198
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/entries
  89. 0 9
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/text-base/FMILIB_FMI1_Readme.txt.svn-base
  90. 0 231
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/text-base/fmiFunctions.h.svn-base
  91. 0 210
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/text-base/fmiModelFunctions.h.svn-base
  92. 0 91
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/text-base/fmiModelTypes.h.svn-base
  93. 0 73
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/.svn/text-base/fmiPlatformTypes.h.svn-base
  94. 0 9
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/FMILIB_FMI1_Readme.txt
  95. 0 231
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/fmiFunctions.h
  96. 0 210
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/fmiModelFunctions.h
  97. 0 91
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/fmiModelTypes.h
  98. 0 73
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI1/fmiPlatformTypes.h
  99. 0 23
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI2/.svn/all-wcprops
  100. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMUChecker-2.0b3-win32/include/FMI2/.svn/entries

+ 11 - 1
.gitignore

@@ -21,7 +21,6 @@ Thumbs.db
 *.jar
 
 .classpath
-.project
 .metadata
 .settings
 
@@ -37,3 +36,14 @@ xtend-gen/
 .DS_Store
 /DSL_SemanticAdaptation/copy.bat
 /DSL_SemanticAdaptation/copyfiles.bat
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/case/result_Control_sa.html
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/case/result_ENV.html
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/case/result_power_sa.html
+*.o
+*.o
+*.o
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/lib/*.libs
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/fmus/FMI_Window_sa/log.txt
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/fmus/FMI_power_sa/log.txt
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/fmus/FMI_loop_sa/log.txt
+/SemanticAdaptationForFMI/Experiments/power_window_case_study/fmus/FMI_controller/log.txt

DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/Window.fmu → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/Window.fmu


+ 30 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/input/single_folder_spec/window/modelDescription.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<fmiModelDescription fmiVersion="2.0" modelName="SingleWatertank" guid="{cfc65592-9ece-4563-9705-1581b6e7071c}" generationTool="20-sim" numberOfEventIndicators="0" copyright="Controllab Products B.V." license="-">
+<CoSimulation modelIdentifier="SingleWatertank" needsExecutionTool="false" canHandleVariableCommunicationStepSize="true" canInterpolateInputs="false" maxOutputDerivativeOrder="0" canRunAsynchronuously="false" canBeInstantiatedOnlyOncePerProcess="true" canNotUseMemoryManagementFunctions="true" canGetAndSetFMUstate="false" canSerializeFMUstate="false" providesDirectionalDerivative="false" />
+
+<ModelVariables>
+<ScalarVariable name="reaction_force" valueReference="1" variability="continuous" causality="input">
+<Real start="0.0" />
+</ScalarVariable>
+<ScalarVariable name="displacement" valueReference="2" variability="continuous" causality="input">
+<Real start="0.0" />
+</ScalarVariable>
+<ScalarVariable name="speed" valueReference="3" variability="continuous" causality="input">
+<Real start="0.0" />
+</ScalarVariable>
+
+<ScalarVariable name="disp" valueReference="4" variability="continuous" causality="output">
+<Real />
+</ScalarVariable>
+<ScalarVariable name="tau" valueReference="5" variability="continuous" causality="output">
+<Real />
+</ScalarVariable>
+
+</ModelVariables>
+<ModelStructure>
+<Outputs>
+<Unknown index="4" />
+<Unknown index="5" />
+</Outputs>
+</ModelStructure>
+</fmiModelDescription>

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/window_sa_canonical.BASE.sa

@@ -4,7 +4,7 @@ semantic adaptation reactive mealy WindowSA windowSA
 at "./path/to/WindowSA.fmu"
 
 	for inner fmu Window window
-		at "test_input/single_folder_spec/window/Window.fmu"
+		at "input/single_folder_spec/window/Window.fmu"
 		with input ports displacement (rad), speed (rad/s), reaction_force (N)
 		with output ports height (m), reaction_torque (N.m)
 
@@ -21,7 +21,7 @@ input ports 	reaction_force,
 					tau
 
 
-control {
+control rules {
 	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
 	return H;
 }

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppAutoTest.xtend

@@ -44,7 +44,7 @@ class CgCppAutoTest extends AbstractSemanticAdaptationTest {
 	@Parameters(name = "{index}")
 	def static Collection<Object[]> data() {
 		val files = new ArrayList<List<File>>();
-		listf("test_input/single_folder_spec", files);
+		listf("input/single_folder_spec", files);
 		val test = new ArrayList();
 		test.add(files.get(0));
 		//val test2 = new ArrayList();

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest2.xtend

@@ -30,7 +30,7 @@ class CgCppBasicTest2 extends AbstractSemanticAdaptationTest {
 	@Inject extension  ValidationTestHelper
 
 	@Ignore
-	@Test def powerwindow_model_only() { __parseNoErrors('test_input/window/window_sa_canonical.BASE.sa') }
+	@Test def powerwindow_model_only() { __parseNoErrors('input/window/window_sa_canonical.BASE.sa') }
 
 	def __parseNoErrors(String filename) {
 		val model = __parse(filename)

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppModuleTest.xtend

@@ -33,14 +33,14 @@ class CgCppModuleTest extends AbstractSemanticAdaptationTest {
 	@Inject extension  ValidationTestHelper
 
 	@Ignore
-	@Test def powerwindow_model_only() { __parseNoErrors('test_input/single_folder_spec/window/window_sa_canonical.BASE.sa') }
+	@Test def powerwindow_model_only() { __parseNoErrors('input/single_folder_spec/window/window_sa_canonical.BASE.sa') }
 
 	def __parseNoErrors(String filename) {
 
 		val file = new File(filename)
 
 		assertTrue("File not found: " + filename, file.exists);
-
+		
 		var SemanticAdaptation model = null;
 		if (file.isDirectory) {
 			for (f : file.listFiles) {

+ 0 - 63
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/controller_sa.sa

@@ -1,63 +0,0 @@
-// outdated
-
-import PowerWindowModel
-
-module Controller_SA
-
-semantic adaptation controller_sa
-for fmu controller
-input ports armature_current -> obj_detected, passenger_up, passenger_down, driver_up, driver_down
-output ports up, down
-param REL_TOL = 0.0001;
-param ABS_TOL = 1e-8;
-param CROSSING = 5;
-param init_armature_current = CROSSING;
-param init_up = 0;
-param init_down = 0;
-control var internal_transition;
-control rules { // overwriting master! What to do in case of roll back? How to reuse generic algorithm
-	if (not is_set(internal_transition)) { // only at start of simulation
-		var state := get_state(controller);
-		internal_transition := do_step(controller, MAX) + t; // may return internal transition time or MAX
-		set_state(controller, state);
-	}
-	var step_size; // may be used to determine roll-back
-	if (signal == true or t >= internal_transition) {
-		step_size := do_step(controller, H); // do a step, then decide next internal transition
-		var state := get_state(controller);
-		internal_transition := do_step(controller, MAX) + t;
-		set_state(controller, state);
-	}
-	return step_size;
-}
-in var stored_armature_current := init_armature_current;
-in rules {
-	true -> {
-		obj_detected := false;
-		if (not (not is_close(stored_armature_current, CROSSING, REL_TOL, ABS_TOL) and stored_armature_current > CROSSING)
-					and (not is_close(armature_current, CROSSING, REL_TOL, ABS_TOL) and armature_current > CROSSING)) { // crossing, but not within tolerance
-			var negative_value := stored_armature_current - CROSSING;
-			var positive_value := armature_current - CROSSING;
-			var new_step_size := (H * (- negative_value)) / (positive_value - negative_value);
-			discard(new_step_size);
-		} else {
-			if (not (not is_close(stored_armature_current, CROSSING, REL_TOL, ABS_TOL) and stored_armature_current > CROSSING)
-						and is_close(armature_current, CROSSING, REL_TOL, ABS_TOL)) { // crossing within tolerance found
-				obj_detected := true;
-			}
-		}
-		stored_armature_current := armature_current;
-	} --> { };
-}
-out var stored_up := init_up;
-out var stored_down := init_down;
-out rules {
-	up == true -> { up := 1; } --> { };
-	otherwise up -> { } --> { };
-	down == true -> { down := 1; } --> { };
-	otherwise down -> { } --> { };
-	stop == true -> { up := 0; down := 0; } --> { };
-	otherwise stop -> { } --> { };
-	true -> { up := stored_up; stored_up := up; } --> { };
-	true -> { down := stored_down; stored_down := down; } --> { }; 
-}

+ 1 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_inline.sa

@@ -10,7 +10,7 @@ for inner fmu Controller controller
 	at "./path/to/Controller.fmu"
 	with input ports obj_detected, passenger_up, passenger_down, driver_up, driver_down
 	with output ports up, down, stop
-input ports armature_current -> obj_detected, passenger_up, passenger_down, driver_up, driver_down
+input ports obj_detected -> obj_detected, passenger_up, passenger_down, driver_up, driver_down
 triggered by signal == true
 in rules with crossing absolute tolerance = 1e-8 and relative tolerance = 0.0001, no hold {
 	armature_current >! 5 -> obj_detected := true;
@@ -20,7 +20,6 @@ out rules with zero order hold {
 	"up" -> up := 1;
 	"stop" -> { up := 0; down := 0; };
 	"down" -> down := 1;
-	delay at up and down;
 }
 
 semantic adaptation WindowSA window_sa

DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_model_only.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_model_only.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_multi_rate.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/inter_module_powerwindow/powerwindow_multi_rate.sa


+ 0 - 25
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/plant.sa

@@ -1,25 +0,0 @@
-// outdated
-
-semantic adaptation power_sa
-for continuous time
-input ports up, down, reaction_torque
-output ports armature_current, motor_speed
-in rules {} // needs to be detected exactly when reaction_torque starts to change rapidly -> zero crossing on derivative abs(reaction_torque') >! 100
-out rules {}
-control rules {}
-
-semantic adaptation window_sa
-for continuous time
-input ports motor_speed
-output ports height, window_reaction_torque
-in rules {}
-out rules {}
-control rules {}
-
-semantic adaptation obstacle_sa
-for continuous time
-input ports height
-output ports obstacle_reaction_torque
-in rules {}
-out rules {}
-control rules {}

+ 71 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller.sa

@@ -0,0 +1,71 @@
+semantic adaptation reactive moore ControllerSA controller_sa
+at "./path/to/ControllerSA.fmu"
+
+	for inner fmu LazySA lazy
+	at "./path/to/LazySA.fmu"
+	with input ports obj_detected, passenger_up, passenger_down, passenger_stop, driver_up, driver_down, driver_stop
+	with output ports up, down, stop
+
+input ports armature_current -> lazy.obj_detected, 
+			passenger_up -> lazy.passenger_up, 
+			passenger_down -> lazy.passenger_down,
+			passenger_stop -> lazy.passenger_stop,
+			driver_up -> lazy.driver_up, 
+			driver_down -> lazy.driver_down,
+			driver_stop -> lazy.driver_stop
+
+output ports	u,
+				d
+
+param	RTOL := 0.0001,
+		ATOL := 1e-8,
+		T := 5.0,
+		INIT_V := 0.0;
+
+control var	c := false,
+			p_v := INIT_V;
+control rules {
+	var step_size := H;
+	var aux_obj_detected := false;
+	var crossedTooFar := false;
+	if ((not is_close(p_v, T, RTOL, ATOL) and p_v < T)
+				and (not is_close(f_v, T, RTOL, ATOL) and f_v > T)) {
+		crossedTooFar := true;
+		var negative_value := p_v - T;
+		var positive_value := f_v - T;
+		step_size := (H * (- negative_value)) / (positive_value - negative_value);
+	} else {
+		if ((not is_close(p_v, T, RTOL, ATOL) and p_v < T)
+					and is_close(f_v, T, RTOL, ATOL )) { 
+			c := true;
+		}
+	}
+	
+	if (not crossedTooFar){
+		step_size := do_step(lazy, t, H);
+	}
+	
+	if (is_close(step_size, H, RTOL, ATOL)) {
+		p_v := f_v;
+	}
+	return step_size;
+}
+
+in var	f_v := INIT_V;
+in rules {
+	true -> {
+		f_v := controller_sa.armature_current;
+	} --> {
+		lazy.obj_detected := c;
+	};
+}
+
+out rules {
+	lazy.up -> { } --> {controller_sa.u := 1.0; };
+	not lazy.up -> { } --> {controller_sa.u := 0.0; };
+	
+	lazy.down -> { } --> {controller_sa.d := 1.0; };
+	not lazy.down -> { } --> {controller_sa.d := 0.0; };
+	
+	lazy.stop -> { } --> {controller_sa.u := 0.0 ; controller_sa.d := 0.0; };
+}

+ 128 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller_sa_allInOne.sa

@@ -0,0 +1,128 @@
+module Controller_SA
+
+/*
+ * This file is not used in the case study.
+ * The adaptations it does have been split.
+ */
+
+semantic adaptation reactive moore ControllerSA controller_sa
+at "./path/to/ControllerSA.fmu"
+
+	for inner fmu Controller controller
+	at "./path/to/Controller.fmu"
+	with input ports obj_detected, passenger_up, passenger_down, passenger_stop, driver_up, driver_down, driver_stop
+	with output ports up, down, stop
+
+/*
+At some point in the future, we support for simple wildcars in the input ports.
+According to Casper and Kenneth, some FMUs have thousands of ports...
+*/
+input ports armature_current -> controller.obj_detected, 
+			passenger_up -> controller.passenger_up, // You could write passenger_* here.
+			passenger_down -> controller.passenger_down,
+			passenger_stop -> controller.passenger_stop,
+			driver_up -> controller.driver_up, // You could write driver_* here.
+			driver_down -> controller.driver_down,
+			driver_stop -> controller.driver_stop
+
+output ports	u,
+				d
+
+param	REL_TOL := 0.0001,
+		ABS_TOL := 1e-8,
+		CROSSING := 5.0,
+		INIT_ARMATURE_CURRENT := 0.0,
+		INIT_U := 0.0,
+		INIT_D := 0.0;
+
+control var	aux_obj_detected := 0,
+			get_next_step := true,
+			previous_arm_current := INIT_ARMATURE_CURRENT;
+control rules {
+	var step_size := H;
+	aux_obj_detected := false;
+	if ((not is_close(previous_arm_current, CROSSING, REL_TOL, ABS_TOL) and previous_arm_current < CROSSING)
+				and (not is_close(future_arm_current, CROSSING, REL_TOL, ABS_TOL) and future_arm_current > CROSSING)) { // crossing, but not within tolerance
+		var negative_value := previous_arm_current - CROSSING;
+		var positive_value := future_arm_current - CROSSING;
+		step_size := (H * (- negative_value)) / (positive_value - negative_value);
+	} else {
+		if ((not is_close(previous_arm_current, CROSSING, REL_TOL, ABS_TOL) and previous_arm_current < CROSSING)
+					and is_close(future_arm_current, CROSSING, REL_TOL, ABS_TOL )) { // crossing within tolerance found
+			aux_obj_detected := true;
+		}
+	}
+	
+	if (aux_obj_detected == true or t >= next_time_step) {
+		var aux_h := do_step(controller, t-e, e); // do a step, then decide next internal transition
+		//assert aux_h == e; this must always be the case, otherwise it is better not to use the timed transition adaptation.
+		get_next_step := true; // next time the setValues is called, the internal transition will be set again.
+	} else {
+		get_next_step := false;
+	}
+	if (is_close(step_size, H, REL_TOL, ABS_TOL)) {
+		// Step accepted, so store the known input.
+		// We cannot store the armature current at the in rules because we may not accept the step and because they may be called multiple times. 
+		// If that happens, we want to still have the old value of armature current, to compare it with the new one.
+		previous_arm_current := future_arm_current;
+	}
+	return step_size;
+}
+
+in var	next_time_step := -1.0,
+		future_arm_current := INIT_ARMATURE_CURRENT;
+in rules {
+	get_next_step -> {
+		next_time_step := get_next_time_step(controller) + last_execution_time(controller); 
+		/*
+		The get_next_time_step(controller) function is equivalent to the following snippet:
+		save_state(controller);
+		internal_transition := do_step(controller, last_execution_time(controller), MAX);
+		next_time_step := last_execution_time(controller) + internal_transition;
+		rollback(controller);
+		*/
+	} --> { };
+	
+	true -> {
+		future_arm_current := armature_current;
+	} --> {
+		obj_detected := aux_obj_detected; // Sets this input to the FMU 
+	};
+}
+
+out var stored_up := INIT_U,
+		stored_down := INIT_D;
+out rules {
+	true -> {
+		/*
+		Previously, there was this intruction here:
+		internal_transition := get_next_time_step(controller) + t
+		
+		However, it cannot be here, since there is no guarantee in the control rules block, that the doStep of the controller will be called.
+		*/
+	} --> {};
+	
+	/*
+	What does "otherwise var" mean?
+	Suppose I have the following rules:
+		var1 == true and var2 == false -> ...
+		otherwise var1 -> ...
+	
+	controller.up == true -> { stored_up := 1; } --> { };
+	otherwise up -> { } --> { }; 
+	down == true -> { down := 1; } --> { };
+	otherwise down -> { } --> { };
+	stop == true -> { up := 0; down := 0; } --> { };
+	otherwise stop -> { } --> { };
+	true -> { up := stored_up; stored_up := up; } --> { };
+	true -> { down := stored_down; stored_down := down; } --> { }; 
+	*/
+	controller.up -> {stored_up := 1; } --> {u := stored_up; };
+	not controller.up -> {stored_up := 0; } --> {u := stored_up; };
+	
+	controller.down -> {stored_down := 1; } --> {d := stored_down; };
+	not controller.down -> {stored_down := 0; } --> {d := stored_down; };
+	
+	controller.stop -> {stored_down := 0; stored_up :=0; } --> {u := stored_up ; d := stored_down; };
+	
+}

+ 80 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/controller_sa_commented.sa

@@ -0,0 +1,80 @@
+module Controller_SA
+
+semantic adaptation reactive moore ControllerSA controller_sa
+at "./path/to/ControllerSA.fmu"
+
+	for inner fmu LazySA lazy
+	at "./path/to/LazySA.fmu"
+	with input ports obj_detected, passenger_up, passenger_down, passenger_stop, driver_up, driver_down, driver_stop
+	with output ports up, down, stop
+
+/*
+At some point in the future, we support for simple wildcars in the input ports.
+According to Casper and Kenneth, some FMUs have thousands of ports...
+*/
+input ports armature_current -> lazy.obj_detected, 
+			passenger_up -> lazy.passenger_up, // You could write passenger_* here.
+			passenger_down -> lazy.passenger_down,
+			passenger_stop -> lazy.passenger_stop,
+			driver_up -> lazy.driver_up, // You could write driver_* here.
+			driver_down -> lazy.driver_down,
+			driver_stop -> lazy.driver_stop
+
+output ports	u,
+				d
+
+param	REL_TOL := 0.0001,
+		ABS_TOL := 1e-8,
+		CROSSING := 5.0,
+		INIT_ARMATURE_CURRENT := 0.0;
+
+control var	aux_obj_detected := 0,
+			previous_arm_current := INIT_ARMATURE_CURRENT;
+control rules {
+	var step_size := H;
+	var aux_obj_detected := false;
+	var crossedTooFar := false;
+	if ((not is_close(previous_arm_current, CROSSING, REL_TOL, ABS_TOL) and previous_arm_current < CROSSING)
+				and (not is_close(future_arm_current, CROSSING, REL_TOL, ABS_TOL) and future_arm_current > CROSSING)) { // crossing, but not within tolerance
+		crossedTooFar := true;
+		var negative_value := previous_arm_current - CROSSING;
+		var positive_value := future_arm_current - CROSSING;
+		step_size := (H * (- negative_value)) / (positive_value - negative_value);
+	} else {
+		if ((not is_close(previous_arm_current, CROSSING, REL_TOL, ABS_TOL) and previous_arm_current < CROSSING)
+					and is_close(future_arm_current, CROSSING, REL_TOL, ABS_TOL )) { // crossing within tolerance found
+			aux_obj_detected := true;
+		}
+	}
+	
+	if (not crossedTooFar){
+		step_size := do_step(lazy, t, H);
+	}
+	
+	if (is_close(step_size, H, REL_TOL, ABS_TOL)) {
+		// Step accepted, so store the known input.
+		// We cannot store the armature current at the in rules because we may not accept the step and because they may be called multiple times. 
+		// If that happens, we want to still have the old value of armature current, to compare it with the new one.
+		previous_arm_current := future_arm_current;
+	}
+	return step_size;
+}
+
+in var	future_arm_current := INIT_ARMATURE_CURRENT;
+in rules {
+	true -> {
+		future_arm_current := armature_current;
+	} --> {
+		obj_detected := aux_obj_detected; // Sets this input to the FMU 
+	};
+}
+
+out rules {
+	lazy.up -> { } --> {u := 1.0; };
+	not lazy.up -> { } --> {u := 0.0; };
+	
+	lazy.down -> { } --> {d := 1.0; };
+	not lazy.down -> { } --> {d := 0.0; };
+	
+	lazy.stop -> { } --> {u := 0.0 ; d := 0.0; };
+}

+ 69 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/lazy.sa

@@ -0,0 +1,69 @@
+semantic adaptation reactive moore LazySA lazy_sa
+at "./path/to/LazySA.fmu"
+
+	for inner fmu Controller controller
+	at "./path/to/Controller.fmu"
+	with input ports obj_detected, passenger_up, passenger_down, passenger_stop, driver_up, driver_down, driver_stop
+	with output ports up, down, stop
+
+input ports obj_detected -> controller.obj_detected,
+			passenger_up -> controller.passenger_up,
+			passenger_down -> controller.passenger_down,
+			passenger_stop -> controller.passenger_stop,
+			driver_up -> controller.driver_up,
+			driver_down -> controller.driver_down,
+			driver_stop -> controller.driver_stop
+
+output ports up, down, stop
+
+param 	INIT_OBJ_DETECTED := false,
+		INIT_PASSENGER_UP := false,
+		INIT_PASSENGER_DOWN := false,
+		INIT_PASSENGER_STOP := false,
+		INIT_DRIVER_UP := false,
+		INIT_DRIVER_DOWN := false,
+		INIT_DRIVER_STOP := false;
+
+control var	tn := -1.0,
+			tl := -1.0,
+			prev_obj_detected := INIT_OBJ_DETECTED,
+			prev_passenger_up := INIT_PASSENGER_UP,
+			prev_passenger_down := INIT_PASSENGER_DOWN,
+			prev_passenger_stop := INIT_PASSENGER_STOP,
+			prev_driver_up := INIT_DRIVER_UP,
+			prev_driver_down := INIT_DRIVER_DOWN,
+			prev_driver_stop := INIT_DRIVER_STOP;
+
+control rules {
+	if (tl < 0.0){
+		tl := t;
+	}
+	
+	var step_size := min(H, tn - t); 
+	if (lazy_sa.obj_detected != prev_obj_detected or
+		lazy_sa.passenger_up != prev_passenger_up or
+		lazy_sa.passenger_down != prev_passenger_down or
+		lazy_sa.passenger_stop != prev_passenger_stop or
+		lazy_sa.driver_up != prev_driver_up or
+		lazy_sa.driver_down != prev_driver_down or
+		lazy_sa.driver_stop != prev_driver_stop or
+		(t+H) >= tn
+	){
+		var step_to_be_done := (t+H-tl);
+		var step_done := do_step(controller, t, step_to_be_done); 
+		tn := tl + step_done + get_next_time_step(controller); 
+		step_size := tl + step_done - t; 
+		tl := tl + step_done; 
+	}
+	
+	prev_obj_detected := lazy_sa.obj_detected;
+	prev_passenger_up := lazy_sa.passenger_up;
+	prev_passenger_down := lazy_sa.passenger_down;
+	prev_passenger_stop := lazy_sa.passenger_stop;
+	prev_driver_up := lazy_sa.driver_up;
+	prev_driver_down := lazy_sa.driver_down;
+	prev_driver_stop := lazy_sa.driver_stop;
+	
+	return step_size;
+}
+

+ 108 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/lazy_sa_commented.sa

@@ -0,0 +1,108 @@
+module Lazy_SA
+
+/*
+ * The purpose of this adaptation is to only run the internal FMU 
+ * 	when any of its inputs changes, or when it requests to be explicitly run.
+ */
+
+semantic adaptation reactive moore LazySA lazy_sa
+at "./path/to/LazySA.fmu"
+
+	for inner fmu Controller controller
+	at "./path/to/Controller.fmu"
+	with input ports obj_detected, passenger_up, passenger_down, passenger_stop, driver_up, driver_down, driver_stop
+	with output ports up, down, stop
+
+/*
+ * In addition, we do not need to do anything about the outputs of the inner FMU, because they are zero order holded by default.
+ */
+input ports obj_detected -> controller.obj_detected,
+			passenger_up -> controller.passenger_up,
+			passenger_down -> controller.passenger_down,
+			passenger_stop -> controller.passenger_stop,
+			driver_up -> controller.driver_up,
+			driver_down -> controller.driver_down,
+			driver_stop -> controller.driver_stop
+
+output ports up, down, stop
+
+param 	INIT_OBJ_DETECTED := false,
+		INIT_PASSENGER_UP := false,
+		INIT_PASSENGER_DOWN := false,
+		INIT_PASSENGER_STOP := false,
+		INIT_DRIVER_UP := false,
+		INIT_DRIVER_DOWN := false,
+		INIT_DRIVER_STOP := false;
+
+control var	tn := -1.0,
+			tl := -1.0,
+			prev_obj_detected := INIT_OBJ_DETECTED,
+			prev_passenger_up := INIT_PASSENGER_UP,
+			prev_passenger_down := INIT_PASSENGER_DOWN,
+			prev_passenger_stop := INIT_PASSENGER_STOP,
+			prev_driver_up := INIT_DRIVER_UP,
+			prev_driver_down := INIT_DRIVER_DOWN,
+			prev_driver_stop := INIT_DRIVER_STOP;
+
+control rules {
+	// This initialisation covers simulations that start at a non-zero time.
+	if (tl < 0.0){
+		tl := t;
+	}
+	
+	var step_size := min(H, tn - t); // In case tn < t, this ensures that the controller will be run at the right time.
+	// Note that the expression lazy_sa.obj_detected gets replaced by the corresponding storage var in the canonical version.
+	if (lazy_sa.obj_detected != prev_obj_detected or
+		lazy_sa.passenger_up != prev_passenger_up or
+		lazy_sa.passenger_down != prev_passenger_down or
+		lazy_sa.passenger_stop != prev_passenger_stop or
+		lazy_sa.driver_up != prev_driver_up or
+		lazy_sa.driver_down != prev_driver_down or
+		lazy_sa.driver_stop != prev_driver_stop or
+		(t+H) >= tn
+	){
+		var step_to_be_done := (t+H-tl);
+		var step_done := do_step(controller, t, step_to_be_done); // calls the mapIn function that will take care of forwarding the values of the input ports to the internal FMU.
+		// We calculate these as if step_done == step_to_be_done. If that is not the case, a rollback will be done anyway.
+		tn := tl + step_done + get_next_time_step(controller); // calculates the next time step that is tolerated by the controller.
+		/*
+			The get_next_time_step(controller) function is equivalent to the following snippet:
+			save_state(controller);
+			internal_transition := do_step(controller, last_execution_time(controller), MAX);
+			next_time_step := last_execution_time(controller) + internal_transition;
+			rollback(controller);
+		 */
+		// This is the actual step size taken, from the outside world:
+		step_size := tl + step_done - t; // assert step_size <= H
+		tl := tl + step_done; // assert tl == t+H
+	}
+	
+	// Store the previous values of the inputs
+	prev_obj_detected := lazy_sa.obj_detected;
+	prev_passenger_up := lazy_sa.passenger_up;
+	prev_passenger_down := lazy_sa.passenger_down;
+	prev_passenger_stop := lazy_sa.passenger_stop;
+	prev_driver_up := lazy_sa.driver_up;
+	prev_driver_down := lazy_sa.driver_down;
+	prev_driver_stop := lazy_sa.driver_stop;
+	
+	return step_size;
+}
+
+/*
+The following code is not needed because the outputs are zero order hold'ed by default:
+out var	stored_up := INIT_UP,
+		stored_down := INIT_DOWN,
+		stored_stop := INIT_STOP;
+out rules{
+	 true -> {
+		stored_up := controller.up;
+		stored_down := controller.down;
+		stored_stop := controller.stop;
+	} --> {
+		lazy_sa.up := stored_up;
+		lazy_sa.down := stored_down;
+		lazy_sa.stop := stored_stop;
+	};
+}
+ */

+ 45 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/loop.sa

@@ -0,0 +1,45 @@
+semantic adaptation reactive moore LoopSA loop_sa
+at "./path/to/LoopSA.fmu"
+
+	for inner fmu WindowSA window_sa
+		at "./path/to/WindowSA.fmu"
+		with input ports displacement (rad), speed (rad/s), reaction_force (N)
+		with output ports disp (m), tau (N.m)
+	
+	for inner fmu Obstacle obstacle
+		at "./path/to/Obstacle.fmu"
+		with input ports disp (m)
+		with output ports reaction_force (m)
+	
+	with window_sa.disp -> obstacle.disp
+	with obstacle.reaction_force -> window_sa.reaction_force
+
+output ports tau <- window_sa.tau
+
+param 	MAXITER := 10, 
+		REL_TOL := 1e-05, 
+		ABS_TOL := 1e-05;
+
+control var prev_disp := 0.0;
+control rules {
+	var repeat := false;
+	for (var iter in 0 .. MAXITER) {
+		save_state(obstacle);
+		save_state(window_sa);
+		obstacle.disp := prev_disp;
+		do_step(obstacle,t,H);
+		do_step(window_sa,t,H);
+		
+		repeat := is_close(prev_disp, window_sa.disp, REL_TOL, ABS_TOL);
+		prev_disp := window_sa.disp;
+		if (repeat) {
+			break;
+		} else {
+			rollback(obstacle);
+			rollback(window_sa);
+		}
+	}
+	return H;
+}
+
+

+ 74 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/loop_canonical.sa

@@ -0,0 +1,74 @@
+semantic adaptation reactive moore LoopSA loop_sa
+at "./path/to/LoopSA.fmu"
+	
+	for inner fmu WindowSA window_sa
+		at "./path/to/WindowSA.fmu"
+		with input ports displacement (rad), speed (rad/s), reaction_force (N)
+		with output ports disp (m), tau (N.m)
+	
+	for inner fmu Obstacle obstacle
+		at "./path/to/Obstacle.fmu"
+		with input ports disp (m)
+		with output ports reaction_force (m)
+	
+	with window_sa.disp -> obstacle.disp
+	with obstacle.reaction_force -> window_sa.reaction_force
+
+input ports displacement, speed
+
+output ports tau
+
+param 	MAXITER := 10, REL_TOL := 1e-05, ABS_TOL := 1e-05,
+		INIT_LOOP_SA_DISPLACEMENT := 0.0,
+		INIT_LOOP_SA_SPEED := 0.0,
+		INIT_WINDOW_SA_DISP := 0.0,
+		INIT_WINDOW_SA_TAU := 0.0,
+		INIT_OBSTACLE_REACTION_FORCE := 0.0;
+
+control var prev_disp := 0.0;
+control rules {
+	var repeat := false;
+	for (var iter in 0 .. MAXITER) {
+		save_state(obstacle);
+		save_state(window_sa);
+		obstacle.disp := prev_disp;
+		do_step(obstacle,t,H);
+		window_sa.reaction_force := stored_obstacle_reaction_force;
+		do_step(window_sa,t,H);
+		
+		repeat := is_close(prev_disp, stored_window_sa_disp, REL_TOL, ABS_TOL);
+		prev_disp := stored_window_sa_disp;
+		if (repeat) {
+			break;
+		} else {
+			rollback(obstacle);
+			rollback(window_sa);
+		}
+	}
+	return H;
+}
+
+in var 	stored_loop_sa_displacement := INIT_LOOP_SA_DISPLACEMENT,
+		stored_loop_sa_speed := INIT_LOOP_SA_SPEED;
+in rules {
+	true -> {
+		stored_loop_sa_displacement := loop_sa.displacement;
+		stored_loop_sa_speed := loop_sa.speed;
+	} --> {
+		window_sa.displacement := stored_loop_sa_displacement;
+		window_sa.speed := stored_loop_sa_speed;
+	};
+}
+
+out var	stored_window_sa_disp := INIT_WINDOW_SA_DISP,
+		stored_window_sa_tau := INIT_WINDOW_SA_TAU,
+		stored_obstacle_reaction_force := INIT_OBSTACLE_REACTION_FORCE;
+out rules{
+	true -> {
+		stored_window_sa_disp := window_sa.disp;
+		stored_window_sa_tau := window_sa.tau;
+		stored_obstacle_reaction_force := obstacle.tau;
+	} --> {
+		loop_sa.tau := stored_window_sa_tau;
+	};
+}

+ 12 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/power.BASE.sa

@@ -0,0 +1,12 @@
+semantic adaptation delayed moore PowerSA power_sa
+at "./path/to/PowerSA.fmu"
+
+	for inner fmu Power power
+	at "./path/to/Power.fmu"
+	with input ports u, d, tau (N.m)
+	with output ports armature_current (A), speed (rad/s), displacement (rad)
+
+output ports armature_current <- power.armature_current, 
+			speed <- power.speed,
+			displacement <- power.displacement
+

+ 36 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/rate.sa

@@ -0,0 +1,36 @@
+semantic adaptation reactive moore RateSA rate_sa
+at "./path/to/RateSA.fmu"
+
+	for inner fmu LoopSA loop_sa
+		at "./path/to/LoopSA.fmu"
+		with input ports displacement (rad), speed (rad/s)
+		with output ports tau (N.m)
+	
+input ports speed
+output ports tau <- loop_sa.tau
+
+param 	RATE := 10;
+
+control var previous_speed := 0;
+control rules {
+	var micro_step := H/RATE;
+	var inner_time := t;
+	
+	for (var iter in 0 .. RATE) { 
+		do_step(loop_sa,inner_time,micro_step);
+		inner_time := inner_time + micro_step;	
+	}
+	
+	previous_speed := current_speed;
+	return H;
+}
+
+in var current_speed := 0;
+in rules {
+	true -> {
+		current_speed := speed;
+	} --> {
+		loop_sa.speed := previous_speed + (current_speed - previous_speed)*(dt + h);
+	};
+}
+

+ 2 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_obstacle_sa_flat.BASE.sa

@@ -31,8 +31,8 @@ param 	RATE := 10,
 		REL_TOL := 1e-05, 
 		ABS_TOL := 1e-05;
 
-ctrl var previous_speed := 0, future_speed := 0;
-control {
+control var previous_speed := 0, future_speed := 0;
+control rules {
 	var inner_dt := H/RATE;
 	/*
 	The two instructions below need to be made, because previously they were made in the sa_in block, but multiple calls to the sa_in block would make them fail.

+ 6 - 68
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa.BASE.sa

@@ -1,79 +1,17 @@
-module Window_SA
-
 semantic adaptation reactive mealy WindowSA windowSA
 at "./path/to/WindowSA.fmu"
 
-/*
-Reactive means that the unit expects the following treatment:
-Supose the external master is at time t, and that there is an FMU f providing inputs to windowsa.
-Then,
-f.doStep(t, H) // f goes from t->t+H 
-u := f.getValues(...)
-windowsa.setValues(u) // Input provided from the future (t+H)
-windowsa.doStep(t, H) // windowsa goes from t->t+H
-v := windowsa.getValues(...)
-
-Delayed unit means that the unit expects the following treatment:
-Supose the external master is at time t, and that there is an FMU f providing inputs to windowsa.
-Then,
-pu := f.getValues(...)
-f.doStep(t, H) // f goes from t->t+H 
-windowsa.setValues(pu) // Input provided at the time t
-windowsa.doStep(t, H) // windowsa goes from t->t+H and does not need input at time (t+H)
-v := windowsa.getValues(...)
-
-
-Mealy unit means the following:
-windowsa.setValues(v1)  // values set at time t
-o1 = windowsa.getValues() // values set at time t
-assert v2 <> v1 // Assumption
-windowsa.setValues(v2)  // values set at time t
-o2 = windowsa.getValues() // values set at time t
-It is probably the case that o1 <> o2
-
-Moore unit means the following:
-windowsa.setValues(v1)  // values set at time t
-o1 = windowsa.getValues() // values set at time t
-assert v2 <> v1 // Assumption
-windowsa.setValues(v2)  // values set at time t
-o2 = windowsa.getValues() // values set at time t
-It must be the case that o1 == o2
-In other words, the output at time t, only depends on the state at time t.
-*/
-
-	
-	/*
-	The definition for the wrapped FMU is now done here.
-	This is because, for adaptations that wrap multiple FMUs as well as other adaptations, the connection information cannot be fully completed in the senario description (see the window_obstacle.sa example).
-	*/
 	for inner fmu Window window
-		at "./path/to/WindowSA.fmu"
+		at "./path/to/Window.fmu"
 		with input ports displacement (rad), speed (rad/s), reaction_force (N)
 		with output ports height (cm), reaction_torque (N.m)
 
-/*
-No need to have input ports declared for this model.
-Every input port of the original FMU will be automatically assumed to be an input port of the adapted FMU.
-
-If there is an input port window.p which is dangling, but is not declared here, then an input port windowsa.p will be created in the adapted FMU, and we will have that window.p -> windowsa.p.
-*/
-
-/*
-Declares two output ports, and specified how height is mapped to disp.
-Here, the units need to be specified, so that the conversion can take place.
-The units of disp can be either obtained from the scenario, or specified explicitly here.
-*/
-output ports disp (m)  <- height, tau
-/*
-There are alternative ways that this can be interpreted:
-disp  := arbitrary_function(height) * 100 or arbitrary_function(height * 100) (they are not necessarily equal)
-We pick the first one, so what we have is this:
-aux_var := arbitrary_function(height);
-disp := aux_var*100; // This part never has to be coded.
-*/
+output ports disp (m)  <- window.height, tau
 
 out rules {
 	true -> {} --> {
-		tau := -reaction_force;
+		windowSA.tau := -window.reaction_force;
 	};
-}
+}
+
+

+ 20 - 31
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical.BASE.sa

@@ -1,5 +1,3 @@
-module Window_SA
-
 semantic adaptation reactive mealy WindowSA windowSA
 at "./path/to/WindowSA.fmu"
 
@@ -8,11 +6,6 @@ at "./path/to/WindowSA.fmu"
 		with input ports displacement (rad), speed (rad/s), reaction_force (N)
 		with output ports height (m), reaction_torque (N.m)
 
-/*
-In the original version, no input ports where declared, so all dangling inputs of the original fmus are bound to the input ports of the adapted FMU.
-In the canonical version, the input and output ports are all declared explicitly, and their bindings are implemented in the in/out rules.
-*/
-
 input ports 	reaction_force,
 				displacement,
 				speed
@@ -20,31 +13,26 @@ input ports 	reaction_force,
 output ports	disp,
 				tau
 
+param 	INIT_WINDOWSA_REACTION_FORCE := 0.0,
+		INIT_WINDOWSA_DISPLACEMENT := 0.0,
+		INIT_WINDOWSA_SPEED := 0.0,
+		INIT_WINDOW_REACTION_TORQUE := 0.0,
+		INIT_WINDOW_REACTION_HEIGHT := 0.0;
 
-control {
-	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
-	return H;
+control rules {
+	var H_window := do_step(window, t, H);
+	return H_window;
 }
 
-in var 	stored_windowsa_reaction_force := 0.0, 
-		stored_windowsa_displacement := 0.0, 
-		stored_windowsa_speed := 0.0;
+in var 	stored_windowsa_reaction_force := INIT_WINDOWSA_REACTION_FORCE, 
+		stored_windowsa_displacement := INIT_WINDOWSA_DISPLACEMENT, 
+		stored_windowsa_speed := INIT_WINDOWSA_SPEED;
 
 in rules {
 	true -> {
-		/*
-		is_set checks whether the input value is given in the setValues call of the adapted FMU.
-		Notice that in the canonical version, all ports are prefixed.
-		*/
-		if (is_set(windowSA.reaction_force)){
-			stored_windowsa_reaction_force := windowSA.reaction_force;
-		}
-		if (is_set(windowSA.displacement)){
-			stored_windowsa_displacement := windowSA.displacement;			
-		}
-		if (is_set(windowSA.speed)){
-			stored_windowsa_speed := windowSA.speed;
-		}
+		stored_windowsa_reaction_force := windowSA.reaction_force;
+		stored_windowsa_displacement := windowSA.displacement;			
+		stored_windowsa_speed := windowSA.speed;
 	} --> {
 		window.reaction_force := stored_windowsa_reaction_force;
 		window.displacement := stored_windowsa_displacement; 
@@ -52,16 +40,17 @@ in rules {
 	};
 }
 
-out var stored_window_reaction_torque := 0,
-		stored_window_height := 0;
-		
+out var stored_window_reaction_torque := INIT_WINDOW_REACTION_TORQUE,
+		stored_window_height := INIT_WINDOW_REACTION_HEIGHT;
+
 out rules {
 	true -> {
 		stored_window_reaction_torque := window.reaction_torque;
 		stored_window_height := window.height;
 	} --> {
-		windowSA.tau := - stored_window_reaction_torque;
 		windowSA.disp := stored_window_height / 100;
 	};
+	true -> { } --> {
+		windowSA.tau := -stored_window_reaction_torque;
+	};
 }
-

+ 67 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_canonical_commented.BASE.sa

@@ -0,0 +1,67 @@
+module Window_SA
+
+semantic adaptation reactive mealy WindowSA windowSA
+at "./path/to/WindowSA.fmu"
+
+	for inner fmu Window window
+		at "./path/to/Window.fmu"
+		with input ports displacement (rad), speed (rad/s), reaction_force (N)
+		with output ports height (m), reaction_torque (N.m)
+
+/*
+In the original version, no input ports where declared, so all dangling inputs of the original fmus are bound to the input ports of the adapted FMU.
+In the canonical version, the input and output ports are all declared explicitly, and their bindings are implemented in the in/out rules.
+*/
+
+input ports 	reaction_force,
+				displacement,
+				speed
+
+output ports	disp,
+				tau
+
+
+control rules {
+	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
+	return H;
+}
+
+in var 	stored_windowsa_reaction_force := 0.0, 
+		stored_windowsa_displacement := 0.0, 
+		stored_windowsa_speed := 0.0;
+
+in rules {
+	true -> {
+		/*
+		is_set checks whether the input value is given in the setValues call of the adapted FMU.
+		Notice that in the canonical version, all ports are prefixed.
+		*/
+		if (is_set(windowSA.reaction_force)){
+			stored_windowsa_reaction_force := windowSA.reaction_force;
+		}
+		if (is_set(windowSA.displacement)){
+			stored_windowsa_displacement := windowSA.displacement;			
+		}
+		if (is_set(windowSA.speed)){
+			stored_windowsa_speed := windowSA.speed;
+		}
+	} --> {
+		window.reaction_force := stored_windowsa_reaction_force;
+		window.displacement := stored_windowsa_displacement; 
+		window.speed := stored_windowsa_speed;
+	};
+}
+
+out var stored_window_reaction_torque := 0,
+		stored_window_height := 0;
+		
+out rules {
+	true -> {
+		stored_window_reaction_torque := window.reaction_torque;
+		stored_window_height := window.height;
+	} --> {
+		windowSA.tau := - stored_window_reaction_torque;
+		windowSA.disp := stored_window_height / 100;
+	};
+}
+

+ 79 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/power_window_case_study/window_sa_commented.BASE.sa

@@ -0,0 +1,79 @@
+module Window_SA
+
+semantic adaptation reactive mealy WindowSA windowSA
+at "./path/to/WindowSA.fmu"
+
+/*
+Reactive means that the unit expects the following treatment:
+Supose the external master is at time t, and that there is an FMU f providing inputs to windowsa.
+Then,
+f.doStep(t, H) // f goes from t->t+H 
+u := f.getValues(...)
+windowsa.setValues(u) // Input provided from the future (t+H)
+windowsa.doStep(t, H) // windowsa goes from t->t+H
+v := windowsa.getValues(...)
+
+Delayed unit means that the unit expects the following treatment:
+Supose the external master is at time t, and that there is an FMU f providing inputs to windowsa.
+Then,
+pu := f.getValues(...)
+f.doStep(t, H) // f goes from t->t+H 
+windowsa.setValues(pu) // Input provided at the time t
+windowsa.doStep(t, H) // windowsa goes from t->t+H and does not need input at time (t+H)
+v := windowsa.getValues(...)
+
+
+Mealy unit means the following:
+windowsa.setValues(v1)  // values set at time t
+o1 = windowsa.getValues() // values set at time t
+assert v2 <> v1 // Assumption
+windowsa.setValues(v2)  // values set at time t
+o2 = windowsa.getValues() // values set at time t
+It is probably the case that o1 <> o2
+
+Moore unit means the following:
+windowsa.setValues(v1)  // values set at time t
+o1 = windowsa.getValues() // values set at time t
+assert v2 <> v1 // Assumption
+windowsa.setValues(v2)  // values set at time t
+o2 = windowsa.getValues() // values set at time t
+It must be the case that o1 == o2
+In other words, the output at time t, only depends on the state at time t.
+*/
+
+	
+	/*
+	The definition for the wrapped FMU is now done here.
+	This is because, for adaptations that wrap multiple FMUs as well as other adaptations, the connection information cannot be fully completed in the senario description (see the window_obstacle.sa example).
+	*/
+	for inner fmu Window window
+		at "./path/to/WindowSA.fmu"
+		with input ports displacement (rad), speed (rad/s), reaction_force (N)
+		with output ports height (cm), reaction_torque (N.m)
+
+/*
+No need to have input ports declared for this model.
+Every input port of the original FMU will be automatically assumed to be an input port of the adapted FMU.
+
+If there is an input port window.p which is dangling, but is not declared here, then an input port windowsa.p will be created in the adapted FMU, and we will have that window.p -> windowsa.p.
+*/
+
+/*
+Declares two output ports, and specified how height is mapped to disp.
+Here, the units need to be specified, so that the conversion can take place.
+The units of disp can be either obtained from the scenario, or specified explicitly here.
+*/
+output ports disp (m)  <- height, tau
+/*
+There are alternative ways that this can be interpreted:
+disp  := arbitrary_function(height) * 100 or arbitrary_function(height * 100) (they are not necessarily equal)
+We pick the first one, so what we have is this:
+aux_var := arbitrary_function(height);
+disp := aux_var*100; // This part never has to be coded.
+*/
+
+out rules {
+	true -> {} --> {
+		tau := -reaction_force;
+	};
+}

+ 0 - 34
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow.sa

@@ -1,34 +0,0 @@
-import PowerWindowModel
-
-semantic adaptation ArmatureCurrentSA armature_current_sa
-at "./path/to/ArmatureCurrentSA.fmu"
-for fmu controller
-triggered by signal == true
-in rules with crossing absolute tolerance = 1e-8 and relative tolerance = 0.0001, no hold {
-	armature_current >! 5 -> obj_detected := true;
-	otherwise -> obj_detected := false;
-}
-out rules with zero order hold {
-	"up" -> up := 1;
-	"stop" -> { up := 0; down := 0; };
-	"down" -> down := 1;
-	delay at up and down;
-}
-
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	reaction_torque := -reaction_torque;
-}
-
-semantic adaptation WindowObstacleSA window_obstacle_sa
-at "./path/to/WindowObstacleSA.fmu"
-for fmu window_sa, obstacle
-multiply rate 10 times with first order interpolation
-successive substitution starts at height with absolute tolerance = 1e-8 and relative tolerance = 0.0001
-
-semantic adaptation PlantSA plant_sa
-at "./path/to/PlantSA.fmu"
-for fmu power, window_obstacle_sa
-successive substitution starts at reaction_torque with absolute tolerance = 1e-6 and relative tolerance = 1e-6

+ 0 - 24
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_delay_BASE.sa

@@ -1,24 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	true -> { } --> { reaction_torque := -reaction_torque; };
-}
-
-// algebraic loop, simply use delay... written in baseDSL
-semantic adaptation WindowSADelay window_sa_delay //with master
-at "./path/to/WindowSADelay.fmu"
-for fmu window_sa // inner SA, makes it possible to enforce order among adaptations this way
-param init_height := 0;
-param init_reaction_torque := 0;
-out var stored_height := init_height;
-out var stored_reaction_torque := init_reaction_torque;
-out rules {
-	true -> { var temp_height := height; height := stored_height; stored_height := temp_height; } --> { };
-	true -> { var temp_reaction_torque := reaction_torque; reaction_torque := stored_reaction_torque; stored_reaction_torque := temp_reaction_torque; } --> { }; 
-}
-

+ 0 - 19
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration.sa

@@ -1,19 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	reaction_torque := -reaction_torque;
-}
-
-// algebraic loop
-semantic adaptation PowerWindowObstacleSA power_window_obstacle_sa
-at "./path/to/PowerWindowObstacleSA.fmu"
-for fmu power, window_sa, obstacle
-input ports up, down // optional, can be figured out from model
-output ports armature_current // optional, can be figured out from model
-successive substitution starts at reaction_torque and height with absolute tolerance = 1e-8 and relative tolerance = 0.0001
-

+ 0 - 111
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_iteration_BASE.sa

@@ -1,111 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu Window window
-out rules {
-	true -> { } --> { reaction_torque := -reaction_torque; };
-}
-
-// algebraic loop
-semantic adaptation PowerWindowObstacleSA power_window_obstacle_sa // without master -> not necessary: custom control rules override master
-at "./path/to/PowerWindowObstacleSA.fmu"
-for fmu power, window_sa, obstacle
-input ports up, down
-output ports armature_current
-//algebraic loop fix point iteration at reaction_torque and height with absolute tolerance = 1e-8 and relative tolerance = 0.0001
-param MAXITER := 100;
-param REL_TOL := 1e-8;
-param ABS_TOL := 1e-8;
-control {
-	// do_step will always use the last values, do_step does not advance time so will replace the last signal values! 
-	// therefore, we must set the signal at time t+h of reaction_torque and height
-	// this is done by a very weird statement:
-	reaction_torque := reaction_torque;
-	height := height;
-	// and just initialise other values at time t+h
-	armature_current := 0;
-	motor_speed := 0;
-	reaction_force := 0;
-	// now, all inputs are set at time t+h and we can start substituting them
-	var converged := false;
-	var temp_height; // to compare new value with previous value
-	var temp_reaction_torque; // to compare new value with previous value
-	// from here on: taken from Claudio's example
-	var prev_height := window_sa.height;
-	var inner_time := t;
-	for (var iter in 0 .. MAXITER) {
-		save_state(obstacle); // Inspired by transactions in databases.
-		save_state(window_sa);
-		do_step(obstacle, inner_time,h);
-		do_step(window_sa,inner_time,h);
-		
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		} else {
-			prev_height := height;
-			rollback(obstacle);
-			rollback(window_sa);
-		}
-	}
-	return H;
-}
-
-/*// this is the one for the paper
-semantic adaptation WindowObstacleSALoop window_obstacle_sa_loop// overrides master -> not necessary: custom control rules override master
-at "./path/to/WindowObstacleSALoop.fmu"
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER := 100;
-param REL_TOL := 1e-8;
-param ABS_TOL := 1e-8;
-control {
-	var prev_height; // to compare new value with previous value
-	var window_state;
-	var obstacle_state;
-	height := height; // do_step will always use the last values, local_step does not advance time so will replace the last signal values! therefore, we must set the signal at time t+h of reaction_torque and height. this is done by a very weird statement:
-	reaction_force := 0; // and just initialise other values at time t+h
-	for (var iter in 0 .. MAXITER) {
-		prev_height := height;
-		local_step(obstacle); // with delayed input for height. overwrite current time step: basically a set_state (state at previous time step), do_step (with time step H)
-		local_step(window_sa);
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		}
-	}
-	return H;
-}
-
-// other version without local_step
-semantic adaptation WindowObstacleSALoop2 window_obstacle_sa_loop2// overrides master -> not necessary: custom control rules override master
-at "./path/to/WindowObstacleSALoop2.fmu"
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER := 100;
-param REL_TOL := 1e-8;
-param ABS_TOL := 1e-8;
-control {
-	var prev_height; // to compare new value with previous value
-	var window_state;
-	var obstacle_state;
-	for (var iter in 0 .. MAXITER) {
-		window_state := get_state(window_sa);
-		obstacle_state := get_state(obstacle);
-		prev_height := height;
-		do_step(obstacle, H); // with delayed input for height
-		do_step(window_sa, H);
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		} else {
-			set_state(window_sa, window_state);
-			set_state(obstacle, obstacle_state);
-		}
-	}
-	return H;
-}
-*/
-

DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_algebraic_loop_delay.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/powerwindow_controller_delay.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_controller_delay.sa


DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_model_only.sa → DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/single_folder_spec/window/powerwindow_model_only.sa


+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window2/window_sa_canonical.BASE.sa

@@ -21,7 +21,7 @@ output ports	disp,
 				tau
 
 
-control {
+control rules {
 	do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
 	return H;
 }

+ 0 - 31
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/test1.sa

@@ -1,31 +0,0 @@
-// horribly outdated, never look at this again!
-
-semantic adaptation TEST
-for discrete event
-input ports x[1 .. 2] (kg.m/s 2), y, z
-output ports a, b, c
-extract directionalderivative 
-{= (signal-signal[prev]) / h }
-{
-	def firstorder(s) {
-		var temp;
-		temp = s-s[prev];
-		return temp / h;
-	}
-	return firstorder(x);
-}
-
-in rules with zero crossing tolerance = 0.001, no hold { // for CT to inner DE
-	not x[prev]+3 > 2+2*floor(y[now]+round(8.2)) and y < 4 -> todo --> todo;
-	x >! 2 with tolerance = 0.0001 -> "high" --> no hold; // means condition -> IN action -> UPDATE IN action
-	x >! 1 or x <! 2 -> "low" --> no hold;
-	x <! 1 -> "off"; // i.e., no hold is the default
-	otherwise(x) -> null --> zero order hold;
-	quantize(y, "off", 1, "low", 2, "high") --> no hold;
-	quantize(z, ="event"+floor(z + 0.5)) --> no hold;
-	quantize(z, ="event"+round(z)) --> no hold;
-	quantize z every 2 offset 1 --> no hold;
-}
-//out rules with buffer[10] {}
-out rules {}
-control rules {}

+ 0 - 24
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE.sa

@@ -1,24 +0,0 @@
-// outdated
-
-semantic adaptation window_obstacle_sa_loop overrides master
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER = 100;
-param REL_TOL = 1e-8;
-param ABS_TOL = 1e-8;
-in rules {
-	true -> {
-		height := height; // do_step will always use the last values, local_step does not advance time so will replace the last signal values! therefore, we must set the signal at time t+h of reaction_torque and height. this is done by a very weird statement:
-		reaction_force := 0; // and just initialise other values at time t+h
-		var prev_height; // to compare new value with previous value
-		for (var iter in 0 .. MAXITER) {
-			prev_height := height;
-			local_step(obstacle); // with delayed input for height
-			local_step(window_sa);
-			if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-				break;
-			}
-		}
-	} --> { };
-}

+ 0 - 28
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_loop_BASE_new.sa

@@ -1,28 +0,0 @@
-//outdated
-
-semantic adaptation window_obstacle_sa_loop
-for fmu window_sa, obstacle
-input ports motor_speed
-output ports reaction_torque
-param MAXITER = 100;
-param REL_TOL = 1e-8;
-param ABS_TOL = 1e-8;
-control rules {
-	var prev_height;
-	var window_state;
-	var obstacle_state;
-	for (var iter in 0 .. MAXITER) {
-		window_state := get_state(window_sa);
-		obstacle_state := get_state(obstacle);
-		prev_height := height;
-		do_step(obstacle, H); // with delayed input for height
-		do_step(window_sa, H);
-		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
-			break;
-		} else {
-			set_state(window_sa, window_state);
-			set_state(obstacle, obstacle_state);
-		}
-	}
-	return H;
-}

+ 0 - 18
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE.sa

@@ -1,18 +0,0 @@
-// outdated
-
-semantic adaptation window_obstacle_sa_multirate
-for fmu window_obstacle_sa_loop
-input ports motor_speed
-output ports reaction_torque
-param init_motor_speed = 0;
-control rules { multiplied 10 times }
-in var stored_motor_speed := init_motor_speed;
-in var linear_increment;
-in rules {
-	true -> {
-		linear_increment := (motor_speed - stored_motor_speed) / 10;
-		stored_motor_speed := motor_speed;
-	} --> {
-		motor_speed := motor_speed + linear_increment;
-	};
-}

+ 0 - 28
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/input/window_obstacle_sa_multirate_BASE_new.sa

@@ -1,28 +0,0 @@
-// outdated
-
-semantic adaptation window_obstacle_sa_multirate
-for fmu window_obstacle_sa_loop
-input ports motor_speed
-output ports reaction_torque
-param init_motor_speed = 0;
-control rules {
-	var h := H/10;
-	var proposed_h := H;
-	for (var iter in 0 .. 10) {
-		var returned_h := do_step(window_obstacle_sa_loop, h);
-		if (returned_h != h) { // for backtracking
-			 proposed_h := iter*h + returned_h;
-		}
-	}
-	return proposed_h;
-}
-in var stored_motor_speed := init_motor_speed;
-in var linear_increment;
-in rules {
-	true -> {
-		linear_increment := (motor_speed - stored_motor_speed) / 10;
-		stored_motor_speed := motor_speed;
-	} --> {
-		motor_speed := motor_speed + linear_increment;
-	};
-}

+ 0 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/ParserFolderTest.xtend

@@ -8,8 +8,6 @@ import org.junit.Assert
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.Parameterized
-import java.io.BufferedReader
-import java.io.FileReader
 import java.util.List
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
 import java.util.HashMap

+ 32 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/PowerWindowCaseStudyFolderTest.xtend

@@ -0,0 +1,32 @@
+package be.uantwerpen.ansymo.semanticadaptation.tests
+
+import java.io.File
+import java.util.Collection
+import java.util.List
+import java.util.Vector
+import org.junit.runners.Parameterized.Parameters
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+import org.eclipse.xtext.testing.InjectWith
+import be.uantwerpen.ansymo.semanticadaptation.testframework.XtextParametersRunnerFactory
+
+@RunWith(typeof(Parameterized))
+@InjectWith(SemanticAdaptationInjectorProvider)
+@Parameterized.UseParametersRunnerFactory(XtextParametersRunnerFactory)
+class PowerWindowCaseStudyFolderTest extends ParserFolderTest {
+	
+	@Parameters(name = "{index} - {0}")
+	def static Collection<Object[]> data() {
+		
+		val List<Object[]> tests = new Vector
+		
+		tests.add(#[new File("input/power_window_case_study".replace('/',File.separatorChar))]);
+		
+		return tests;
+	}
+	
+	new(File directory) {
+		super(directory)
+	}
+	
+}

+ 6 - 85
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SemanticAdaptationParsingTest.xtend

@@ -1,99 +1,20 @@
 /*
- * generated by Xtext 2.10.0
+ * generated by Xtext 2.11.0
  */
 package be.uantwerpen.ansymo.semanticadaptation.tests
 
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
-import com.google.inject.Inject
-import java.util.regex.Pattern
-import org.eclipse.emf.ecore.EObject
 import org.eclipse.xtext.testing.InjectWith
 import org.eclipse.xtext.testing.XtextRunner
-import org.eclipse.xtext.testing.util.ParseHelper
-import org.eclipse.xtext.testing.validation.ValidationTestHelper
+import org.junit.Assert
 import org.junit.Test
 import org.junit.runner.RunWith
-import org.junit.Ignore
 
 @RunWith(XtextRunner)
 @InjectWith(SemanticAdaptationInjectorProvider)
-class SemanticAdaptationParsingTest extends AbstractSemanticAdaptationTest{
+class SemanticAdaptationParsingTest {
 	
-	@Inject extension ParseHelper<SemanticAdaptation>
-	@Inject extension ValidationTestHelper
-
-//	@Test 
-//	def void loadModule() {
-//		//val root = this.parseInputFile('test1.sa')
-//		val root = readFile('input/test1.sa').parse
-//		root.assertNoErrors
-//		Assert.assertNotNull(root.adaptations.get(0))
-//		Assert.assertNotNull(root.adaptations.get(0).extractsensitivity)
-//		Assert.assertTrue(root.adaptations.get(0).extractsensitivity.length > 0)
-//		Assert.assertTrue(root.adaptations.get(0).inports.length > 0)
-//		Assert.assertEquals(root.adaptations.get(0).inports.get(0).name, 'x')
-//		print_ast(root)
-//	}
-
-	@Test def power_window__window_obstacle_sa_flat() { __parseNoErrors('input/power_window_case_study/window_obstacle_sa_flat.BASE.sa') }
-	@Test def power_window__window_sa() { __parseNoErrors('input/power_window_case_study/window_sa.BASE.sa') }
-	@Test def power_window__window_sa_canonical() { __parseNoErrors('input/power_window_case_study/window_sa_canonical.BASE.sa') }
-	@Ignore @Test def powerwindow_model_only() { __parseNoErrors('input/powerwindow_model_only.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_delay_BASE() { __parseNoErrors('input/powerwindow_algebraic_loop_delay_BASE.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_delay() { __parseNoErrors('input/powerwindow_algebraic_loop_delay.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_iteration_BASE() { __parseNoErrors('input/powerwindow_algebraic_loop_iteration_BASE.sa') }
-	@Ignore @Test def powerwindow_algebraic_loop_iteration() { __parseNoErrors('input/powerwindow_algebraic_loop_iteration.sa') }
-	@Ignore @Test def powerwindow_controller_delay() { __parseNoErrors('input/powerwindow_controller_delay.sa') }
-	@Ignore @Test def powerwindow_multi_rate() { __parseNoErrors('input/powerwindow_multi_rate.sa') }
-	@Ignore @Test def powerwindow() { __parseNoErrors('input/powerwindow.sa') }
-	@Ignore @Test def powerwindow_inline() { __parseNoErrors('input/powerwindow_inline.sa') }
-	
-	def __parseNoErrors(String filename) {
-		val root = __parse(filename)
-		__assertNoParseErrors(root, filename)
-	}
-	
-	def __parseNoErrorsPrint(String filename) {
-		val root = __parse(filename)
-		print_ast(root)
-		__assertNoParseErrors(root, filename)
-	}
-	
-	def __parse(String filename) {
-		val model = readFile('input/powerwindow_controller_delay.sa').parse
-		val controller = readFile('input/powerwindow_model_only.sa').parse(model.eResource.resourceSet)
-		val algebraicloop = readFile('input/powerwindow_algebraic_loop_delay.sa').parse(controller.eResource.resourceSet)
-		return readFile(filename).parse(algebraicloop.eResource.resourceSet)
-	}
-	
-	def __assertNoParseErrors(EObject root, String filename) {
-		try {
-			root.assertNoErrors
-		} catch (AssertionError e) {
-			val p = Pattern.compile(".*, offset (?<offset>[0-9]+), length (?<length>[0-9]+)")
-			val code = readFile(filename)
-			for (String line : e.message.split("\n")) {
-				val m = p.matcher(line)
-				m.matches()
-				val count = __occurrencesInString(code.subSequence(0, Integer.valueOf(m.group("offset"))).toString(), "\n")
-				print(filename + " at line " + (count+1) + ": ")
-				println(line)
-			}
-			throw e
-		}
+	@Test
+	def void loadModel() {
+		Assert.assertTrue(true)
 	}
-	
-	def __occurrencesInString(String str, String findstr) {
-		var lastIndex = 0
-		var count = 0
-		while (lastIndex != -1) {
-			lastIndex = str.indexOf(findstr,lastIndex)
-			if (lastIndex != -1) {
-		        count ++
-		        lastIndex += findstr.length()
-		    }
-		}
-		return count
-	}
-
 }

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/SingleFolderTest.xtend

@@ -20,7 +20,7 @@ class SingleFolderTest extends ParserFolderTest {
 		
 		val List<Object[]> tests = new Vector
 		
-		for (file : new File("testInputs/single_folder_spec".replace('/',File.separatorChar)).listFiles) {
+		for (file : new File("input/single_folder_spec".replace('/',File.separatorChar)).listFiles) {
 			tests.add(#[file]);
 		}
 		

+ 0 - 13
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_algebraic_loop_delay.sa

@@ -1,13 +0,0 @@
-import PowerWindowModel
-import Controller_SA
-
-module Algebraic_Loop_SA
-
-// this one could be joined with the one below, if we assume certain priorities in executing the rules
-semantic adaptation WindowSA window_sa
-at "./path/to/WindowSA.fmu"
-for fmu window
-out rules {
-	reaction_torque := -reaction_torque;
-	delay at reaction_torque and height;
-}

+ 0 - 23
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/testInputs/single_folder_spec/window/powerwindow_controller_delay.sa

@@ -1,23 +0,0 @@
-import PowerWindowModel
-
-module Controller_SA
-
-semantic adaptation ArmatureCurrentSA armature_current_sa
-at "./path/to/ArmatureCurrentSA.fmu"
-for fmu controller
-triggered by signal == true
-in rules with crossing absolute tolerance = 1e-8 and relative tolerance = 0.0001, no hold {
-	armature_current >! 5 -> obj_detected := true;
-	otherwise -> obj_detected := false;
-}
-
-semantic adaptation InOutSA in_out_sa
-at "./path/to/InOutSA.fmu"
-for fmu controller
-out rules with zero order hold {
-	"up" -> up := 1;
-	"stop" -> { up := 0; down := 0; };
-	"down" -> down := 1;
-	delay at up and down;
-}
-

+ 2 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/DEPRECATED.txt

@@ -0,0 +1,2 @@
+This folder is deprecated.
+It will be cleaned out after the syntactic examples have been all implemented and tested in the tests directory of this project.

+ 6 - 6
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/algorithm.c

@@ -86,7 +86,7 @@ code AdaptedFMU:
 		out_condition_executed := empty map // force output computation.
 	end function
 	
-	function do_inner_step(fmu, t, inner_t, h) 
+	function do_inner_step(fmu, t, inner_t, some_step_size) 
 		/*
 		Evaluate each update_in block of the rules that were successfully evaluated before the doStep was called.
 		This is because the window.doStep will be called immediately afterward.
@@ -96,17 +96,17 @@ code AdaptedFMU:
 			These variables are available in the scope of the update_in block.
 				It's not a good idea to have t also in that scope, because it is not available when getValues/setValues is called.
 			*/
-			var h = h
+			var h = some_step_size
 			var dt = inner_t - t
 			<update_in_1>
 		end if
 		if (in_condition_executed[IN_COND_2]) then
-			var h = h
+			var h = some_step_size
 			var dt = inner_t - t
 			<update_in_2>
 		end if
 		...
-		fmi2DoStep(fmu1, inner_t, h)
+		fmi2DoStep(fmu1, inner_t, some_step_size)
 		/*
 		Executes the update_out blocks.
 		These always execute after a doStep is called on an internal FMU.
@@ -116,7 +116,7 @@ code AdaptedFMU:
 		*/
 		if (<out_condition_1>) then
 			out_condition_executed[OUT_COND_1] = true
-			var h = h
+			var h = some_step_size
 			var dt = inner_t - t
 			<update_out_1>
 		end if
@@ -139,7 +139,7 @@ code AdaptedFMU:
 		
 		<control_block_part_1>
 		
-		do_inner_step(fmu1, t, inner_t, h);
+		do_inner_step(fmu1, t, inner_t, some_step_size);
 		
 		<control_block_part_2>
 		

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/sketch.BASE.sa

@@ -45,7 +45,7 @@ in rules {
 
 control rules {
 	control_block_part_1
-	do_step(fmu1, inner_t, h)
+	do_step(fmu1, inner_t, some_step_size)
 	control_block_part_2
 	
 	return step_size;

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/examples/window_obstacle_sa.BASE.sa

@@ -47,7 +47,7 @@ in rules {
 		Upon execution, this block must call setValues of the original FMUs (window_sa and obstacle).
 		The correct thing then is to execute the next block and then do the setValues of the original FMUs.
 		*/
-		current_speed := speed
+		current_speed := speed;
 	} --> {
 		/*
 		This block will be called whenever any of the input ports that are unconnected in the original FMUs is read, in the control rules block.

+ 7 - 7
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/SemanticAdaptation.xtext

@@ -53,7 +53,7 @@ Adaptation:
 	inner=InnerFMUDeclaration
 	('input' 'ports' inports+=Port ("," inports+=Port)*)? // only in case of instance-specific SA
 	('output' 'ports' outports+=Port ("," outports+=Port)* )? // only in case of instance-specific SA
-	(params+=ParamDeclaration)*
+	(params+=ParamDeclarations)*
 //	(globalvars+=Declaration)*
 	// algebraic loop generates an FMU encapsulating the loop
 	// note that the order of semantic adaptations is prefixed in case of a algebraic loop:
@@ -117,7 +117,7 @@ OutRulesBlock:
 	{OutRulesBlock} ('out' globalOutVars+=Declaration)* 'out' 'rules' ('with' setting+=GeneralSetting (',' setting+=GeneralSetting)*)? '{' iterationvars+=Declaration* rules+=DataRule* '}';
 
 ControlRuleBlock:
-	('ctrl' globalCtrlVars+=Declaration)* rule=ControlRule; // TODO: multiple rules or just one?
+	('control' globalCtrlVars+=Declaration)* rule=ControlRule; // TODO: multiple rules or just one?
 
 DataRule: // condition -> state transition --> output function
 	(((condition=RuleCondition "->" statetransitionfunction=StateTransitionFunction) | ConditionStateTransition | ConditionLessRule) ("-->" outputfunction=OutputFunction)? | AlgebraicLoopSolution) ';';
@@ -165,19 +165,19 @@ OutputFunction:
 	{FirstOrderHold} (('first' 'order' 'hold') | 'FOH') |
 	{CustomOutputFunction} expr=Expression |
 	{CompositeOutputFunction} '{' statements+=Statement* (returnstatement=ReturnStatement)? '}';
-	
+
 ControlRule:
 	{ImpliedControlRule} 'implied' | // the default
 	{TriggeredControlRule} 'triggered' 'by' condition=Expression |
 	{PeriodicControlRule} 'periodic' ('at' init_time=REALTYPE)? 'every' period=REALTYPE | 
 	{MultipliedControlRule} 'multiplied' multiplication=INT 'times' | 
-	{CustomControlRule} 'control' '{' ControlRulestatements+=Statement* returnstatement=ReturnStatement '}'; // TODO: how do we know if control is given?
+	{CustomControlRule} 'control' 'rules' '{' ControlRulestatements+=Statement* returnstatement=ReturnStatement '}';
 
 AnonymousFunction: // has access to ports
 	{FunctionExpression} '{=' code=Expression '}'| 
 	{FunctionBody} '{' statements+=Statement* returnstatement=ReturnStatement '}' |  // should return something
 	FunctionDeclaration; // TODO: should return something
-	
+
 SpecifiedPort: // if ports need owners
 	(owner=[FMU] '.' )? port=[Port];
 
@@ -236,7 +236,7 @@ SingleVarDeclaration:
 	name=ID (':=' expr=Expression)?
 ;
 
-ParamDeclaration:
+ParamDeclarations:
 	//'param' name=ID ':=' expr=Expression ';';
 	'param' declarations+=SingleParamDeclaration ("," declarations+=SingleParamDeclaration)* ';'
 ;
@@ -361,7 +361,7 @@ BuiltinFunction:
 	{Abs} name='abs' '(' args=ArithmeticExpression ')' |
 	{Close} name='is_close' '(' args+=ArithmeticExpression ',' args+=ArithmeticExpression ',' args+=ArithmeticExpression ',' args+=ArithmeticExpression ')' |  // a, b, relative tolerance, absolute tolerance 
 	{IsSet} name='is_set' '(' args=Var ')' | 
-//	{DoStepFun} name='do_step' '(' fmu=[FMU] ',' t=ArithmeticExpression ',' h=ArithmeticExpression ')' |
+	{DoStepFun} name='do_step' '(' fmu=[FMU] ',' t=ArithmeticExpression ',' h=ArithmeticExpression ')' |
 	{GetNextInternalTimeStep} name='get_next_time_step' '(' fmu=[FMU] ')' | // is actually the time step returned by do_step(fmu), preceded by get_state and succeeded by set_state
 	{Elapsed} name='elapsed' '(' fmu=[FMU] ')' |
 	{LastExecutionTime} name='last_execution_time' '(' fmu=[FMU] ')';

+ 2 - 2
ModelicaModels/NoObstacle_Test.mo

@@ -4,8 +4,8 @@ model NoObstacle_Test
 equation
   power.u = 1.0;
   power.d = 0.0;
-  window.omega_input = power.omega;
-  window.theta_input = power.theta;
+  window.speed = power.omega;
+  window.displacement = power.theta;
   power.tau = - window.tau;
   annotation(
     experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.001));

+ 3 - 3
ModelicaModels/Obstacle.mo

@@ -1,12 +1,12 @@
 model Obstacle
   parameter Real c = 1e10;
   parameter Real fixed_x = 0.45;
-  input Real x;
+  input Real disp;
   output Real F;
   Real compression;
 equation
-  compression = x - fixed_x;
-  F = if x > fixed_x then c * compression else 0;
+  compression = disp - fixed_x;
+  F = if disp > fixed_x then c * compression else 0;
   annotation(
     experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.002));
 end Obstacle;

+ 4 - 16
ModelicaModels/PowerSystemStandAlone.mo

@@ -1,21 +1,9 @@
 model PowerSystemStandAlone
-  parameter Real J = 0.01;
-  parameter Real b = 0.1;
-  parameter Real K = 0.01;
-  parameter Real R = 1;
-  parameter Real L = 0.5;
-  parameter Real V = 12;
-  Real theta;
-  Real e;
-  Real i;
-  Real T;
-  Real omega;
+  PowerSystem power;
 equation
-  T = K * i;
-  e = K * omega;
-  J * der(omega) + b * omega = T;
-  L * der(i) + R * i = V - e;
-  der(theta) = omega;
+  power.tau = 0;
+  power.u = 0;
+  power.d = 1;
 annotation(
   experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)
 );

+ 4 - 4
ModelicaModels/UncontrolledScenario.mo

@@ -5,11 +5,11 @@ model UncontrolledScenario
 equation
   power.u = 1.0;
   power.d = 0.0;
-  window.omega_input = power.omega;
-  window.theta_input = power.theta;
-  window.obj_F = obstacle.F;
+  window.speed = power.omega;
+  window.displacement = power.theta;
+  window.reaction_force = obstacle.F;
   power.tau = window.tau;
-  obstacle.x = window.x;
+  obstacle.disp = window.height;
   annotation(
     experiment(StartTime = 0, StopTime = 6, Tolerance = 1e-06, Interval = 0.0024),
     __OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"));

+ 113 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/.cproject

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.1589967115">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1589967115" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1589967115" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug">
+					<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.1589967115." name="/" resourcePath="">
+						<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.2065198422" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
+							<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.710302017" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
+							<builder buildPath="${workspace_loc:/pw_case}/Debug" id="cdt.managedbuild.tool.gnu.builder.mingw.base.692255892" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1564201794" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
+								<inputType id="cdt.managedbuild.tool.gnu.assembler.input.822854060" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.491915181" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.1422720996" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug">
+								<option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.255528101" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+								<option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.441545821" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.338201069" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug">
+								<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.1911017642" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
+								<option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.652346632" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+								<option id="gnu.c.compiler.option.include.paths.1252884278" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/fmi2}&quot;"/>
+								</option>
+								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.161528920" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.793124615" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug">
+								<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.337727223" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
+									<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+									<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+								</inputType>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.1466756633" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+		<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.1502470385">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.1502470385" moduleId="org.eclipse.cdt.core.settings" name="Release">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.1502470385" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release">
+					<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.1502470385." name="/" resourcePath="">
+						<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.842114339" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release">
+							<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.21663748" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/>
+							<builder buildPath="${workspace_loc:/pw_case}/Release" id="cdt.managedbuild.tool.gnu.builder.mingw.base.93633296" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.2081075908" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release">
+								<inputType id="cdt.managedbuild.tool.gnu.assembler.input.699941151" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1708225123" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.2070140754" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release">
+								<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.1917586500" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+								<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.1081975185" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.1857559091" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
+								<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.272324535" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
+								<option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.344004096" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1530750796" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.265163382" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release">
+								<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1794226632" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
+									<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+									<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+								</inputType>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.2002347536" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="pw_case.cdt.managedbuild.target.gnu.mingw.exe.2039998570" name="Executable" projectType="cdt.managedbuild.target.gnu.mingw.exe"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.1589967115;cdt.managedbuild.config.gnu.mingw.exe.debug.1589967115.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.338201069;cdt.managedbuild.tool.gnu.c.compiler.input.161528920">
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+		</scannerConfigBuildInfo>
+		<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1502470385;cdt.managedbuild.config.gnu.mingw.exe.release.1502470385.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.1857559091;cdt.managedbuild.tool.gnu.c.compiler.input.1530750796">
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+		</scannerConfigBuildInfo>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope"/>
+	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
+</cproject>

+ 1 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/.gitignore

@@ -1,3 +1,4 @@
 /log.txt
 /passing_log.txt
 /*.csv
+/Debug/

+ 26 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/.project

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>PowerWindowCaseStudy</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>

+ 3 - 12
SemanticAdaptationForFMI/Experiments/power_window_case_study/README.txt

@@ -1,14 +1,5 @@
 Author of these instructions: Claudio Gomes (claudio.gomes@uantwerp.be)
 
-Before following the installation instructions in the doc folder, you need to install Visual Studio 2015 Community.
-I've ported the libxml and the .bat files to work with that compiler.
-
-Then you just have to run build_all.bat
-
-Then run_all.bat
-
-
-
-Some problems that you may encounter:
-	- Incapable of loading a specific dll.
-		I had a similar issue due to the way OpenModelica exports the FMUs. I had to copy the missing dlls from the OpenModelica installation. I copied them to the bin directory.
+Development Instructions:
+- Run setup.pd1
+- Run build.ps1

+ 0 - 57
SemanticAdaptationForFMI/Experiments/power_window_case_study/bin/License.txt

@@ -1,57 +0,0 @@
-  7-Zip
-  ~~~~~
-  License for use and distribution
-  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-  7-Zip Copyright (C) 1999-2007 Igor Pavlov.
-
-  Licenses for files are:
-
-    1) 7z.dll: GNU LGPL + unRAR restriction
-    2) All other files:  GNU LGPL
-
-  The GNU LGPL + unRAR restriction means that you must follow both 
-  GNU LGPL rules and unRAR restriction rules.
-
-
-  Note: 
-    You can use 7-Zip on any computer, including a computer in a commercial 
-    organization. You don't need to register or pay for 7-Zip.
-
-
-  GNU LGPL information
-  --------------------
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-  unRAR restriction
-  -----------------
-
-    The decompression engine for RAR archives was developed using source 
-    code of unRAR program.
-    All copyrights to original unRAR code are owned by Alexander Roshal.
-
-    The license for original unRAR code has the following restriction:
-
-      The unRAR sources cannot be used to re-create the RAR compression algorithm, 
-      which is proprietary. Distribution of modified unRAR sources in separate form 
-      or as a part of other software is permitted, provided that it is clearly
-      stated in the documentation and source comments that the code may
-      not be used to develop a RAR (WinRAR) compatible archiver.
-
-
-  --
-  Igor Pavlov

+ 29 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/build.ps1

@@ -0,0 +1,29 @@
+$LibAbsolutionPath = (Get-Item -Path ".\lib" -Verbose).FullName
+
+Echo "Building FMUs and getting their dlls..."
+
+Push-Location .\fmus
+    $FMUSources = Get-ChildItem -Filter FMI_*
+    ForEach ($fmu In $FMUSources){
+        Push-Location $fmu
+            & .\build.ps1
+            $generated_dlls = Get-ChildItem Debug -Filter *.dll
+            ForEach ($dll In $generated_dlls){
+                copy "Debug\$dll" "$LibAbsolutionPath"
+            }
+        Pop-Location
+    }
+Pop-location
+
+Echo "Building FMUs and getting their dlls... DONE."
+
+Echo "Gettings dlls from third party FMUs..."
+Push-Location .\fmus\ThirdParty
+    $FMUSources = Get-ChildItem -dir -Filter FMI_*
+    ForEach ($fmu In $FMUSources){
+        Push-Location $fmu\binaries\win32
+            copy * "$LibAbsolutionPath"
+        Pop-Location
+    }
+Pop-location
+Echo "Gettings dlls from third party FMUs... DONE."

+ 0 - 10
SemanticAdaptationForFMI/Experiments/power_window_case_study/build_all.bat

@@ -1,10 +0,0 @@
-@echo off 
-
-echo -----------------------------------------------------------
-echo Making the simulators and models for FMI 2.0 ...
-copy ..\hierarchical_fmu\fmu20\fmu\cs\mass_spring_damper.fmu .\fmu20\fmu\cs\
-pushd fmu20\src
-call build_all %1
-popd
-echo Making the simulators and models for FMI 2.0 ... DONE!
-echo -----------------------------------------------------------

+ 0 - 26
SemanticAdaptationForFMI/Experiments/power_window_case_study/build_run_all.bat

@@ -1,26 +0,0 @@
-@echo off 
-
-mode 200,1000
-
-call build_all %1
-
-setlocal
-
-set FMUSDK_HOME=.
-
-rem enhance path to include open modelica dlls. THis is needed due to a bug in loading the dlls
-set PREV_PATH=%PATH%
-rem set PATH=%PATH%;C:\OpenModelica1.12.0-dev-32bit\bin
-
-echo Running Scenario
-
-bin\fmu20sim_cs.exe
-
-rem restore path
-set PATH=%PREV_PATH%
-
-endlocal
-
-if "%1"=="nopause" goto skip
-	pause
-:skip

File diff suppressed because it is too large
+ 0 - 1735
SemanticAdaptationForFMI/Experiments/power_window_case_study/crashedlog1.txt


File diff suppressed because it is too large
+ 0 - 1735
SemanticAdaptationForFMI/Experiments/power_window_case_study/crashedlog2.txt


SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_Window_sa/fmi2/fmi2.h → SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2.h


SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/fmi2/fmi2FunctionTypes.h → SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2FunctionTypes.h


SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/fmi2/fmi2Functions.h → SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2Functions.h


SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/fmi2/fmi2TypesPlatform.h → SemanticAdaptationForFMI/Experiments/power_window_case_study/fmi2/fmi2TypesPlatform.h


+ 0 - 7
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/.gitignore

@@ -1,7 +0,0 @@
-/log_echo.txt
-/log_example.txt
-/log_msd.txt
-/log_obstacle.txt
-/log_power_standalone.txt
-/log_window.txt
-/*.csv

BIN
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/Debug/libFMI_SEL.dll


+ 0 - 542
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/FMI_SEL/FMI_SEL.c

@@ -1,542 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * Sample implementation of an FMU - a power window controller
- * The code is generated from a Yakindu SC
- * ---------------------------------------------------------------------------*/
-/*
-Template for a sc FMU
-*/
-
-#define MODEL_IDENTIFIER SEL
-#define MODEL_GUID "{41f87101-edf2-4eef-90f3-42db56d4565f}"
-#define FMI2_FUNCTION_PREFIX PW_SEL
-
-
-#include <stdio.h>
-#include "string.h"
-#include "fmi2Functions.h"
-#include <float.h>
-#include "FMI_SEL.h"
-#include <math.h>
-
-
-#define NUMBER_OF_REALS 2
-#define NUMBER_OF_STRINGS 0
-#define NUMBER_OF_BOOLEANS 17
-#define NUMBER_OF_INTEGERS 0
-/*
- * The input Signals (Real)
- */
-#define _in_armature_current 0
-
-/*
- * The input events
- */
-#define _in_driver_up 0
-#define _in_driver_up_stop 1
-#define _in_driver_down 2
-#define _in_driver_down_stop 3
-#define _in_passenger_up 4
-#define _in_passenger_up_stop 5
-#define _in_passenger_down 6
-#define _in_passenger_down_stop 7
-
-/*
- * The store
- */
-#define _stored_armature_current 1
-
-/*
- * The output events:
- * */
-
-#define _out_obj_detected 8
-#define _out_driver_up 9
-#define _out_driver_up_stop 10
-#define _out_driver_down 11
-#define _out_driver_down_stop 12
-#define _out_passenger_up 13
-#define _out_passenger_up_stop 14
-#define _out_passenger_down 15
-#define _out_passenger_down_stop 16
-/*
- * Control Signal
- */
-#define _out_control 17
-
-/*
- * Helper function for relative error
- */
- double relativeError(double a, double b){
-	return fabs((a - b) / a);
-}
-
-/*
- * Helper function for absolute error
- */
- double absoluteError(double a, double b){
-	return fabs(a - b);
-}
-
-/*
- * is_close function for double comparison
- */
- int is_close(double a, double b, double REL_TOL, double ABS_TOL){
-	return ((absoluteError(a,b)<ABS_TOL) && (relativeError(a,b)<REL_TOL));
-}
-
-
-fmi2Status fmi2SetDebugLogging(fmi2Component fc, fmi2Boolean loggingOn, size_t nCategories, const fmi2String categories[])
-{
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetString(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[])
-{
-    return fmi2Error;
-}
-
-fmi2Status fmi2GetString(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2String value[])
-{
-    return fmi2Error;
-}
-
-fmi2Status fmi2SetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[])
-{
-	FMUInstance* comp = (FMUInstance *)fc;
-		int i;
-	    for (i = 0; i < nvr; i++)
-		{
-	    	if(vr[i]>=5){
-	    		printf("Value reference: %d, cannot be set, it is a store element\n", vr[i]);
-	    	}else{
-	    		 printf("Value reference: %d\n", vr[i]);
-	    		 comp->r[vr[i]] = value[i];
-	    	}
-
-	        //setExposedReal(vr[i], value[i]);
-	        //comp->r[vr[i]] = value[i];
-	    }
-	    return fmi2OK;
-}
-
-fmi2Status fmi2GetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[])
-{
-
-    FMUInstance* comp = (FMUInstance *)fc;
-	int i;
-    for (i = 0; i < nvr; i++)
-	{
-        value[i] = comp->r[(vr[i])];
-    }
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetBoolean(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[])
-{
-	FMUInstance* comp = (FMUInstance *)fc;
-	int i;
-	for (i = 0; i < nvr; i++)
-	{
-		comp->b[vr[i]] = value[i];
-	}
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetBoolean(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[])
-{
-	FMUInstance* comp = (FMUInstance *)fc;
-	int i;
-	for (i = 0; i < nvr; i++)
-	{
-		value[i] = comp->b[vr[i]];
-	}
-    return fmi2OK;
-}
-
-fmi2Component fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID, fmi2String fmuLocation, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
-{
-
-	//Declare data structure for fmu instance
-    FMUInstance* fi;
-	printf("%s in fmiInstantiate\n",instanceName);
-
-    //Perform checks on passed callback functions
-    if (loggingOn) {
-
-        if (!functions->logger);
-        //return NULL;
-	}
-    //Check for instanceName
-    if (!instanceName || strlen(instanceName)==0) {
-
-        // print (and/or log) instanceName is missing
-        //return NULL;
-    }
-    //Check passed GUID to defined model GUID
-    if (strcmp(fmuGUID, MODEL_GUID))
-	{
-        // print (and/or log) GUID doesn't match
-        //return NULL;
-    }
-
-    //Allocate fmu instance Memory
-    // TODO check if "canNotUseMemoryManagementFunctions == true/false". If false memory allocation not possible
-    fi = (FMUInstance *)functions->allocateMemory(1, sizeof(FMUInstance));
-    fi->functions = functions;
-    if (fi) {
-        // Think about what to do with variable values. Using these structs and pointers slows down simulation computations. Maybe only necessary for input, output and tunable parameters??
-        fi->r = functions->allocateMemory(NUMBER_OF_REALS, sizeof(fmi2Real));
-        fi->i = functions->allocateMemory(NUMBER_OF_INTEGERS, sizeof(fmi2Integer));
-        fi->b = functions->allocateMemory(NUMBER_OF_BOOLEANS, sizeof(fmi2Boolean));
-        fi->s = functions->allocateMemory(NUMBER_OF_STRINGS,  sizeof(fmi2String));
-    } // variables in predefined arrays (performance issue) --> makes multiple instances of fmu impossible
-
-
-    fi->instanceName = functions->allocateMemory(1 + strlen(instanceName), sizeof(char));
-    fi->GUID = functions->allocateMemory(1 + strlen(fmuGUID), sizeof(char));
-
-    strcpy((char*)fi->instanceName, instanceName);
-    strcpy((char*)fi->GUID, fmuGUID);
-    fi->functions = functions;
-    fi->loggingOn = loggingOn;
-    fi->isVisible = visible;
-    fi->state = fmuInstantiated;
-    return fi;
-}
-
-fmi2Status fmi2SetupExperiment(fmi2Component fc, fmi2Boolean toleranceDefined, fmi2Real tolerance,
-                            fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime) {
-
-
-    FMUInstance* fi = (FMUInstance*) fc;
-	printf("%s in fmiSetupExperiment\n",fi->instanceName);
-	if (fi->state != fmuInstantiated)
-	{
-		printf("fmu: %s was not instatiated before calling fmiSetupExperiment\n", fi->instanceName);
-		return fmi2Error;
-	}
-	fi->currentTime = startTime;
-	fi->stopTimeDefined = stopTimeDefined;
-	fi->toleranceDefined = toleranceDefined;
-	if (stopTimeDefined)
-	{
-		fi->stopTime = stopTime;
-	}
-
-	if (toleranceDefined)
-	{
-		fi->tolerance = tolerance;
-	}
-	//TODO
-	//fi->stepSize = getStepSize();
-	fi->state = fmuExperimentSettedUp;
-    return fmi2OK;
-}
-
-fmi2Status fmi2EnterInitializationMode(fmi2Component fc)
-{
-	FMUInstance* fi = (FMUInstance*) fc;
-	printf("%s in fmiEnterInitializationMode\n",fi->instanceName);
-	if (fi->state != fmuExperimentSettedUp)
-	{
-		printf("fmu: %s experiment was not set-up before calling fmiEnterInitializationMode\n", fi->instanceName);
-		return fmi2Error;
-	}
-
-    fi->state = fmuInitMode;
-    return fmi2OK;
-}
-
-fmi2Status fmi2ExitInitializationMode(fmi2Component fc)
-{
-	FMUInstance* fi = (FMUInstance*) fc;
-	fmi2Status initStatus = fmi2OK;
-	printf("%s in fmiExitInitializationMode\n",fi->instanceName);
-	if (fi->state != fmuInitMode)
-	{
-		printf("fmu: %s did not enter Initialization Mode before calling fmiExitInitializationMode\n", fi->instanceName);
-		return fmi2Error;
-	}
-	// TODO
-	//initStatus = calculateInitialUnknownValues();
-	//initialize();
-    fi->state = fmuInitialized;
-    return initStatus;
-}
-
-fmi2Status fmi2DoStep(fmi2Component fc , fmi2Real currentCommPoint, fmi2Real commStepSize, fmi2Boolean noPrevFMUState)
-{
-	FMUInstance* fi = (FMUInstance *)fc;
-	fmi2Status simStatus = fmi2OK;
-    printf("%s in fmiDoStep()\n",fi->instanceName);
-
-    /*
-     * true -> {
-		obj_detected := ""; // or null value or something else
-		if (not
-			(not is_close(stored_armature_current, 5, REL_TOL, ABS_TOL) and stored_armature_current > 5)
-					and (not is_close(armature_current, 5, REL_TOL, ABS_TOL) and armature_current > 5)) {
-			var negative_value := stored_armature_current - 5;
-			var positive_value := armature_current - 5;
-			var new_step_size := (h * (- negative_value)) / (positive_value - negative_value);
-			discard(new_step_size);
-		} else {
-			if (not (not is_close(stored_armature_current, 5, REL_TOL, ABS_TOL) and stored_armature_current > 5)
-						and is_close(armature_current, 5, REL_TOL, ABS_TOL)) { // crossing found
-				obj_detected := "obj";
-			}
-		}
-		stored_armature_current := armature_current; // as there exists a target port obj_detected, the source port armature_current is used. If ports would have the same name (and thus same type), the value resulting from the crossing would be stored
-	} --> {
-	};*/
-    fi->b[_out_obj_detected] = 0;
-    if(!(! is_close(fi->r[_stored_armature_current], 5 , 0.0001, 1e-8) && fi->r[_stored_armature_current] > 5)
-    		&& (!is_close(fi->r[_in_armature_current],5, 0.0001, 1e-8) && fi->r[_in_armature_current] > 5)){ // should this be <
-    		double negative_value = fi->r[_stored_armature_current] - 5;
-    		double positive_value = fi->r[_in_armature_current] - 5;
-    		double new_step_size = (commStepSize * (-negative_value)) / (positive_value - negative_value);
-    		fi->currentTime = currentCommPoint + new_step_size;
-    		simStatus = fmi2Discard;
-
-    }else{
-    	if(!(! is_close(fi->r[_stored_armature_current],5,0.0001,1e-8) && fi->r[_stored_armature_current] > 5)
-    			&& is_close(fi->r[_in_armature_current],5, 0.0001, 1e-8)){
-    			fi->b[_out_obj_detected] = 1;
-    	}
-    }
-    /* Set out:*/
-    fi->b[_out_driver_down] = fi->b[_in_driver_down];
-    fi->b[_out_driver_down_stop] = fi->b[_in_driver_down_stop];
-    fi->b[_out_driver_up] = fi->b[_in_driver_up];
-    fi->b[_out_driver_up_stop] = fi->b[_in_driver_up_stop];
-    fi->b[_out_passenger_down] = fi->b[_in_passenger_down];
-    fi->b[_out_passenger_down_stop] = fi->b[_in_passenger_down_stop];
-    fi->b[_out_passenger_up] = fi->b[_in_passenger_up];
-    fi->b[_out_passenger_up_stop] = fi->b[_in_passenger_up_stop];
-
-    /*Control signal*/
-    if(fi->b[_out_driver_down] || fi->b[_out_driver_down_stop]|| fi->b[_out_driver_up] ||
-    		 fi->b[_out_driver_up_stop] || fi->b[_out_obj_detected] ||
-			 fi->b[_out_passenger_down] || fi->b[_out_passenger_down_stop] ||
-			 fi->b[_out_passenger_up] || fi->b[_out_passenger_up_stop]){
-    	fi->b[_out_control] = 1;
-    }
-	return simStatus;
-}
-
-fmi2Status fmi2Terminate(fmi2Component fc)
-{
-	FMUInstance* fi = (FMUInstance *)fc;