calibration.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. class CalibrationStateMashine():
  2. def __init__(self,log_handler):
  3. self.state = 0
  4. self.progress = 0
  5. self.NOT_CALIBRATED = 0
  6. self.WAITING_POS_1 = 1
  7. self.ACCUMULATING_1 = 2
  8. self.WAITING_POS_2 = 3
  9. self.ACCUMULATING_2 = 4
  10. self.CALIBRATION_DONE = 5
  11. self.log_handler = log_handler
  12. def state_clearname(self):
  13. if self.state == self.NOT_CALIBRATED:
  14. return "not calibrated"
  15. elif self.state == self.WAITING_POS_1:
  16. return "Waiting for Position one"
  17. elif self.state == self.ACCUMULATING_1:
  18. return "gathering values on position one"
  19. elif self.state == self.WAITING_POS_2:
  20. return "Waiting for position two"
  21. elif self.state == self.ACCUMULATING_2:
  22. return "gathering values on position two"
  23. elif self.state == self.CALIBRATION_DONE:
  24. return "calibration done"
  25. def next_state(self):
  26. if self.state < self.CALIBRATION_DONE:
  27. self.state += 1
  28. self.log_handler.log_and_print("calibration state: ",self.state_clearname())
  29. def next_state_gui(self):
  30. if self.state == self.WAITING_POS_1 or self.state == self.WAITING_POS_2:
  31. self.next_state()
  32. def get_state(self):
  33. return self.state
  34. def reset_state(self):
  35. self.state = 0
  36. self.progress = 0