calibration.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. print(self.state_clearname())
  29. def next_state_gui(self):
  30. print("next_state_gui",self.state_clearname())
  31. self.log_handler.add_item("next_state_gui",self.state_clearname())
  32. if self.state == self.WAITING_POS_1 or self.state == self.WAITING_POS_2:
  33. self.next_state()
  34. def get_state(self):
  35. return self.state
  36. def reset_state(self):
  37. self.state = 0
  38. self.progress = 0