calibration.py 1.3 KB

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