window_sa_canonical.BASE.sa 1.8 KB

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