calibration.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. class CalibrationStateMashine():
  2. def __init__(self):
  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. def state_clearname(self):
  12. if self.state == self.NOT_CALIBRATED:
  13. return "not calibrated"
  14. elif self.state == self.WAITING_POS_1:
  15. return "Waiting for Position one"
  16. elif self.state == self.ACCUMULATING_1:
  17. return "gathering values on position one"
  18. elif self.state == self.WAITING_POS_2:
  19. return "Waiting for position two"
  20. elif self.state == self.ACCUMULATING_2:
  21. return "gathering values on position two"
  22. elif self.state == self.CALIBRATION_DONE:
  23. return "calibration done"
  24. def next_state(self):
  25. if self.state < self.CALIBRATION_DONE:
  26. self.state += 1
  27. print(self.state_clearname())
  28. def next_state_gui(self):
  29. print("next_state_gui",self.state)
  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