Beispiel #1
0
 def update(self):
     self.sim.update()
     self.current_state.var.set(f"State: {self.sim.current_state}")
     self.current_conditions.delete(0, "end")
     for condition in self.sim.get_state_object().conditions:
         test_string = decompile(condition.test_ezl, ESDType.TALK)
         condition_string = f"{self.sim.current_state} -> {condition.next_state_index}: {test_string}"
         self.current_conditions.insert("end", condition_string)
     while not self.sim.unprocessed_commands.empty():
         command = self.sim.unprocessed_commands.get()
         self.output_log.insert("end", "\n" + command)
Beispiel #2
0
 def update(self):
     """Checks all test conditions in the current state and initiates a change in state if appropriate."""
     # TODO: call automatically if some relevant input is changed (if set up to do so, which is the default).
     # TODO: call ongoing commands (before or after tests?)
     conditions = self.esd.state_machines[self.sm][self.current_state].conditions
     for condition in conditions:
         test_string = decompile(condition.test_ezl, ESDType.TALK, func_prefix="self.")
         try:
             test_result = eval(test_string, {"self": self})
         except AttributeError as e:
             attr_name = str(e).split("has no attribute '")[1][-1]
             raise AttributeError(f"\ndef {attr_name}:\n    return ...")
         if test_result:
             self.change_state(condition.next_state_index)
     print(f"# UPDATED (State {self.current_state})")