window_sa_canonical.BASE.sa 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. module Window_SA
  2. semantic adaptation reactive mealy WindowSA windowSA
  3. at "./path/to/WindowSA.fmu"
  4. for inner fmu Window window
  5. at "test_input/single_folder_spec/window/Window.fmu"
  6. with input ports displacement (rad), speed (rad/s), reaction_force (N)
  7. with output ports height (m), reaction_torque (N.m)
  8. /*
  9. 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.
  10. In the canonical version, the input and output ports are all declared explicitly, and their bindings are implemented in the in/out rules.
  11. */
  12. input ports reaction_force,
  13. displacement,
  14. speed
  15. output ports disp,
  16. tau
  17. control {
  18. do_step(window, t, H); // includes update_in rules and update_out (update-in rules do not update state)
  19. return H;
  20. }
  21. in var stored_windowsa_reaction_force := 0.0,
  22. stored_windowsa_displacement := 0.0,
  23. stored_windowsa_speed := 0.0;
  24. in rules {
  25. /*
  26. is_set checks whether the input value is given in the setValues call of the adapted FMU.
  27. Notice that in the canonical version, all ports are prefixed.
  28. */
  29. true -> {
  30. if (is_set(windowSA.reaction_force)){
  31. stored_windowsa_reaction_force := windowSA.reaction_force;
  32. }
  33. } --> {
  34. window.reaction_force := stored_windowsa_reaction_force;
  35. };
  36. true -> {
  37. if (is_set(windowSA.displacement)){
  38. stored_windowsa_displacement := windowSA.displacement;
  39. }
  40. } --> {
  41. window.displacement := stored_windowsa_displacement;
  42. };
  43. true -> {
  44. if (is_set(windowSA.speed)){
  45. stored_windowsa_speed := windowSA.speed;
  46. }
  47. } --> {
  48. window.speed := stored_windowsa_speed;
  49. };
  50. }
  51. out var stored_window_reaction_torque := 0.0,
  52. stored_window_height := 0.0;
  53. out rules {
  54. true -> {
  55. stored_window_reaction_torque := window.reaction_torque;
  56. } --> {
  57. windowSA.tau := - stored_window_reaction_torque;
  58. };
  59. true -> {
  60. stored_window_height := window.height;
  61. } --> {
  62. windowSA.disp := stored_window_height * 100;
  63. };
  64. }