schedule_template_wrap.j2 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from examples.schedule.schedule_lib import *
  2. class Schedule:
  3. def __init__(self, rule_executer):
  4. self.start: Start
  5. self.cur: ExecNode = None
  6. self.rule_executer = rule_executer
  7. def __call__(self, od):
  8. self.cur = self.cur.nextState()
  9. while not isinstance(self.cur, NullNode):
  10. action_gen = self.cur.execute(od)
  11. if action_gen is not None:
  12. # if (action_gen := self.cur.execute(od)) is not None:
  13. return action_gen
  14. self.cur = self.cur.nextState()
  15. return NullNode.terminate(od)
  16. @staticmethod
  17. def get_matchers():
  18. return [
  19. {% for file in match_files %}
  20. "{{ file }}.od",
  21. {% endfor %}
  22. ]
  23. def init_schedule(self, matchers):
  24. {% for block in blocks%}
  25. {{ block }}
  26. {% endfor %}
  27. {% for conn in exec_conn%}
  28. {{ conn }}
  29. {% endfor %}
  30. {% for conn_d in data_conn%}
  31. {{ conn_d }}
  32. {% endfor %}
  33. self.start = {{ start }}
  34. self.cur = {{ start }}
  35. {% for match in matchers %}
  36. {{ match["name"] }}.init_rule(matchers["{{ match["file"] }}.od"], self.rule_executer)
  37. {% endfor %}
  38. return None
  39. def generate_dot(self, *args, **kwargs):
  40. return self.start.generate_dot(*args, **kwargs)