power_canonical_generated_algorithm.sa 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. This file is deprecated
  3. */
  4. code power_sa:
  5. var in_condition_executed;
  6. var out_condition_executed;
  7. var power; //FMU power ref
  8. var time_last_window;
  9. var stored_windowsa_u,
  10. stored_windowsa_d;
  11. var stored_window_reaction_torque,
  12. stored_window_height;
  13. var init_armature_current = 0,
  14. init_displacement = 0,
  15. init_speed = 0;
  16. var stored_armature_current,
  17. stored_displacement,
  18. stored_speed;
  19. function instantiate()
  20. power.instantiate()
  21. return
  22. end function
  23. function setup_experiment(t, ...)
  24. time_last_window := t;
  25. end function
  26. function enter_init()
  27. power.enter_init()
  28. return
  29. end function
  30. function exit_init()
  31. power.exit_init()
  32. return
  33. end function
  34. function setValues(ports, values)
  35. in_condition_executed = empty map
  36. if (true) then
  37. in_condition_executed[cond1] = true
  38. stored_windowsa_u = values["u"]
  39. stored_windowsa_d = values["d"]
  40. // power_sa is moore, so nothing else to do.
  41. end if
  42. out_condition_executed := empty map // force output computation.
  43. end function
  44. function doStep(t, H)
  45. var e := t - time_last_window;
  46. { // new scope
  47. var t := t
  48. var h := H
  49. var dt := 0
  50. power.setValues("u", stored_windowsa_u)
  51. power.setValues("d", stored_windowsa_d)
  52. }
  53. power.doStep(t, H);
  54. time_last_window := t;
  55. out_condition_executed := empty map
  56. end function
  57. function getValues(ports)
  58. var values = empty map
  59. if out_condition_executed == empty map then
  60. if true then
  61. stored_armature_current = power.getValues("armature_current")
  62. out_condition_executed[cond1] := true
  63. end if
  64. if true then
  65. stored_displacement = power.getValues("displacement")
  66. out_condition_executed[cond2] := true
  67. end if
  68. if true then
  69. stored_speed = power.getValues("speed")
  70. out_condition_executed[cond3] := true
  71. end if
  72. end if
  73. if out_condition_executed[cond1] then
  74. values["armature_current"] := stored_armature_current
  75. end if
  76. if out_condition_executed[cond2] then
  77. values["displacement"] := stored_displacement
  78. end if
  79. if out_condition_executed[cond3] then
  80. values["speed"] := stored_speed
  81. end if
  82. return values
  83. end function