scheduling_MM.od 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. abstract class Exec
  2. association Conn_exec [0..*] Exec -> Exec [0..*] {
  3. String from;
  4. String to;
  5. }
  6. abstract class Data
  7. association Conn_data [0..*] Data -> Data [0..*] {
  8. String from;
  9. String to;
  10. }
  11. class Start [1..1] (Exec, Data) {
  12. optional ActionCode ports_exec_out;
  13. optional ActionCode ports_data_out;
  14. ```
  15. err = check_slot_code_type(this, "ports_exec_out", list[str] | set[str], True)
  16. err.extend(check_slot_code_type(this, "ports_data_out", list[str] | set[str], True))
  17. if len(err) == 0:
  18. err = check_all_connections(this, [
  19. [],
  20. eval(get_slot_value_default(this, "ports_exec_out", "['out']")),
  21. [],
  22. eval(get_slot_value_default(this, "ports_data_out", "[]"))
  23. ])
  24. err
  25. ```;
  26. }
  27. class End [1..1] (Exec, Data) {
  28. optional ActionCode ports_exec_in;
  29. optional ActionCode ports_data_in;
  30. ```
  31. err = check_slot_code_type(this, "ports_exec_in", list[str] | set[str], True)
  32. err.extend(check_slot_code_type(this, "ports_data_in", list[str] | set[str], True))
  33. if len(err) == 0:
  34. err = check_all_connections(this, [
  35. eval(get_slot_value_default(this, "ports_exec_in", "['in']")),
  36. [],
  37. eval(get_slot_value_default(this, "ports_data_in", "[]")),
  38. []
  39. ])
  40. err
  41. ```;
  42. }
  43. abstract class Rule (Exec, Data)
  44. {
  45. String file;
  46. }
  47. class Match (Rule)
  48. {
  49. optional Integer n;
  50. ```
  51. check_all_connections(this, [
  52. ["in"],
  53. ["success", "fail"],
  54. ["in"],
  55. ["out"]
  56. ])
  57. ```;
  58. }
  59. class Rewrite (Rule)
  60. {
  61. ```
  62. check_all_connections(this, [
  63. ["in"],
  64. ["out"],
  65. ["in"],
  66. ["out"]
  67. ])
  68. ```;
  69. }
  70. class Action (Exec, Data)
  71. {
  72. optional ActionCode ports_exec_in;
  73. optional ActionCode ports_exec_out;
  74. optional ActionCode ports_data_in;
  75. optional ActionCode ports_data_out;
  76. optional ActionCode init `check_code_syntax(get_value(get_target(this)))`;
  77. ActionCode action `check_code_syntax(get_value(get_target(this)))`;
  78. ```
  79. err = check_slot_code_type(this, "ports_exec_in", list[str] | set[str], True)
  80. err.extend(check_slot_code_type(this, "ports_exec_out", list[str] | set[str], True))
  81. err.extend(check_slot_code_type(this, "ports_data_in", list[str] | set[str], True))
  82. err.extend(check_slot_code_type(this, "ports_data_out", list[str] | set[str], True))
  83. if len(err) == 0:
  84. err = check_all_connections(this, [
  85. eval(get_slot_value_default(this, "ports_exec_in", "['in']")),
  86. eval(get_slot_value_default(this, "ports_exec_out", "['out']")),
  87. eval(get_slot_value_default(this, "ports_data_in", "[]")),
  88. eval(get_slot_value_default(this, "ports_data_out", "[]"))
  89. ])
  90. err
  91. ```;
  92. }
  93. class Modify (Data)
  94. {
  95. optional ActionCode rename;
  96. optional ActionCode delete;
  97. ```
  98. err = check_slot_code_type(this, "rename", dict[str,str])
  99. err.extend(check_slot_code_type(this, "delete", list[str] | set[str]))
  100. if len(err) == 0:
  101. if not (eval(get_slot_value_default(this, "rename", "dict()")).keys().isdisjoint(
  102. eval(get_slot_value_default(this, "delete", "set()")))
  103. ):
  104. err.append("rename and delete should be disjoint.")
  105. err.extend(check_all_connections(this, [
  106. [],
  107. [],
  108. ["in"],
  109. ["out"]
  110. ]))
  111. err
  112. ```;
  113. }
  114. class Merge (Data)
  115. {
  116. ActionCode ports_data_in;
  117. ```
  118. err = check_slot_code_type(this, "ports_data_in", list[str] | set[str], True, mandatory = True)
  119. if len(err) == 0:
  120. err = check_all_connections(this, [
  121. [],
  122. [],
  123. eval(get_slot_value(this, "ports_data_in")),
  124. ["out"]
  125. ])
  126. err
  127. ```;
  128. }
  129. class Store (Exec, Data)
  130. {
  131. ActionCode ports;
  132. ```
  133. err = check_slot_code_type(this, "ports", list[str] | set[str], True, mandatory = True, blacklist = ["in", "out"])
  134. if len(err) == 0:
  135. err = check_all_connections(this, [
  136. [*(ports:= eval(get_slot_value(this, "ports"))), "in"],
  137. [*ports, "out"],
  138. ports,
  139. ["out"]
  140. ])
  141. err
  142. ```;
  143. }
  144. class Schedule (Exec, Data)
  145. {
  146. String file;
  147. ```
  148. check_all_connections(this, [
  149. {get_slot_value(conn, "to") for conn in get_incoming(this, "Conn_exec")},
  150. {get_slot_value(conn, "from") for conn in get_outgoing(this, "Conn_exec")},
  151. {get_slot_value(conn, "to") for conn in get_incoming(this, "Conn_data")},
  152. {get_slot_value(conn, "from") for conn in get_outgoing(this, "Conn_data")}
  153. ])
  154. ```;
  155. }
  156. class Loop(Exec, Data)
  157. {
  158. ```
  159. check_all_connections(this, [
  160. ["in"],
  161. ["it", "out"],
  162. ["in"],
  163. ["out"]
  164. ])
  165. ```;
  166. }
  167. class Print(Exec, Data)
  168. {
  169. optional Boolean event;
  170. optional String label;
  171. optional ActionCode custom `check_jinja2_code(get_source(this), "custom")`;
  172. ```
  173. check_all_connections(this, [
  174. ["in"],
  175. ["out"],
  176. ["in"],
  177. []
  178. ])
  179. ```;
  180. }