window_sa_commented.BASE.sa 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. module Window_SA
  2. semantic adaptation reactive mealy WindowSA windowSA
  3. at "./path/to/WindowSA.fmu"
  4. /*
  5. Reactive means that the unit expects the following treatment:
  6. Supose the external master is at time t, and that there is an FMU f providing inputs to windowsa.
  7. Then,
  8. f.doStep(t, H) // f goes from t->t+H
  9. u := f.getValues(...)
  10. windowsa.setValues(u) // Input provided from the future (t+H)
  11. windowsa.doStep(t, H) // windowsa goes from t->t+H
  12. v := windowsa.getValues(...)
  13. Delayed unit means that the unit expects the following treatment:
  14. Supose the external master is at time t, and that there is an FMU f providing inputs to windowsa.
  15. Then,
  16. pu := f.getValues(...)
  17. f.doStep(t, H) // f goes from t->t+H
  18. windowsa.setValues(pu) // Input provided at the time t
  19. windowsa.doStep(t, H) // windowsa goes from t->t+H and does not need input at time (t+H)
  20. v := windowsa.getValues(...)
  21. Mealy unit means the following:
  22. windowsa.setValues(v1) // values set at time t
  23. o1 = windowsa.getValues() // values set at time t
  24. assert v2 <> v1 // Assumption
  25. windowsa.setValues(v2) // values set at time t
  26. o2 = windowsa.getValues() // values set at time t
  27. It is probably the case that o1 <> o2
  28. Moore unit means the following:
  29. windowsa.setValues(v1) // values set at time t
  30. o1 = windowsa.getValues() // values set at time t
  31. assert v2 <> v1 // Assumption
  32. windowsa.setValues(v2) // values set at time t
  33. o2 = windowsa.getValues() // values set at time t
  34. It must be the case that o1 == o2
  35. In other words, the output at time t, only depends on the state at time t.
  36. */
  37. /*
  38. The definition for the wrapped FMU is now done here.
  39. 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).
  40. */
  41. for inner fmu Window window
  42. at "./path/to/WindowSA.fmu"
  43. with input ports displacement (rad), speed (rad/s), reaction_force (N)
  44. with output ports height (cm), reaction_torque (N.m)
  45. /*
  46. No need to have input ports declared for this model.
  47. Every input port of the original FMU will be automatically assumed to be an input port of the adapted FMU.
  48. 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.
  49. */
  50. /*
  51. Declares two output ports, and specified how height is mapped to disp.
  52. Here, the units need to be specified, so that the conversion can take place.
  53. The units of disp can be either obtained from the scenario, or specified explicitly here.
  54. */
  55. output ports disp (m) <- height, tau
  56. /*
  57. There are alternative ways that this can be interpreted:
  58. disp := arbitrary_function(height) * 100 or arbitrary_function(height * 100) (they are not necessarily equal)
  59. We pick the first one, so what we have is this:
  60. aux_var := arbitrary_function(height);
  61. disp := aux_var*100; // This part never has to be coded.
  62. */
  63. out rules {
  64. true -> {} --> {
  65. tau := -reaction_force;
  66. };
  67. }