def on_back(self): self.count = 0 def while_state1(self): self.count += 1 logging.warning("{}: {}".format(self.name, self.count)) def while_state2(self): self.count -= 1 logging.warning("{}: {}".format(self.name, self.count)) app = Rackio() machine1 = TwoStep("machine 1") machine2 = TwoStep("machine 2") app.append_machine(machine1, 1, "async") app.append_machine(machine2, 2, "async") if __name__ == "__main__": app.set_log(file="app.log") app.run()
def while_state1(self): self.count += 1 logging.warning("{}: {}".format(self.name, self.count)) if self.count == 5: self.forward() def while_state2(self): self.count += 1 logging.warning("{}: {}".format(self.name, self.count)) if self.count >= 10: self.back() app = Rackio() machine1 = TwoStep("machine 1") machine2 = TwoStep("machine 2") app.append_machine(machine1, 1) app.append_machine(machine2, 2) if __name__ == "__main__": app.set_log(file="app.log") app.run()