1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- class CalibrationStateMashine():
- def __init__(self,log_handler):
- self.state = 0
- self.progress = 0
- self.NOT_CALIBRATED = 0
- self.WAITING_POS_1 = 1
- self.ACCUMULATING_1 = 2
- self.WAITING_POS_2 = 3
- self.ACCUMULATING_2 = 4
- self.CALIBRATION_DONE = 5
- self.log_handler = log_handler
-
- def state_clearname(self):
- if self.state == self.NOT_CALIBRATED:
- return "not calibrated"
- elif self.state == self.WAITING_POS_1:
- return "Waiting for Position one"
- elif self.state == self.ACCUMULATING_1:
- return "gathering values on position one"
- elif self.state == self.WAITING_POS_2:
- return "Waiting for position two"
- elif self.state == self.ACCUMULATING_2:
- return "gathering values on position two"
- elif self.state == self.CALIBRATION_DONE:
- return "calibration done"
-
- def next_state(self):
- if self.state < self.CALIBRATION_DONE:
- self.state += 1
- print(self.state_clearname())
- def next_state_gui(self):
- print("next_state_gui",self.state_clearname())
- self.log_handler.add_item("next_state_gui",self.state_clearname())
- if self.state == self.WAITING_POS_1 or self.state == self.WAITING_POS_2:
- self.next_state()
- def get_state(self):
- return self.state
- def reset_state(self):
- self.state = 0
- self.progress = 0
|