moved checker logic into checker (checker needs to be cleaned up still)
This commit is contained in:
@@ -12,9 +12,9 @@ class CAChecker:
|
||||
def check_now(self):
|
||||
cv = self.PV.get()
|
||||
if cv > self.thresholds[0] and cv < self.thresholds[1]:
|
||||
return True
|
||||
return True #good shot
|
||||
else:
|
||||
return False
|
||||
return False #bad shot
|
||||
|
||||
def append_to_data(self, **kwargs):
|
||||
self.data.append(kwargs["value"])
|
||||
@@ -36,6 +36,24 @@ class CAChecker:
|
||||
return fraction >= self.required_fraction
|
||||
|
||||
|
||||
|
||||
def get_ready(self):
|
||||
while True:
|
||||
first_check = time()
|
||||
checker_unhappy = False
|
||||
while not self.checker.check_now():
|
||||
print(colorama.Fore.RED + f"Condition checker is not happy, waiting for OK conditions since {time()-first_check:5.1f} seconds." + colorama.Fore.RESET, end="\r")
|
||||
sleep(self.checker_sleep_time)
|
||||
checker_unhappy = True
|
||||
if checker_unhappy:
|
||||
print(colorama.Fore.RED + f"Condition checker was not happy and waiting for {time()-first_check:5.1f} seconds." + colorama.Fore.RESET)
|
||||
self.checker.clear_and_start_counting()
|
||||
|
||||
def is_happy(self):
|
||||
return self.stop_and_analyze()
|
||||
|
||||
|
||||
|
||||
# checker_obj = Checker_obj(checkerPV)
|
||||
|
||||
|
||||
|
||||
@@ -43,30 +43,14 @@ class ScanSimple:
|
||||
self.change_to_initial_values()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def do_checked_step(self, *args, **kwargs):
|
||||
while True: #TODO: this needs to move to checker
|
||||
first_check = time()
|
||||
checker_unhappy = False
|
||||
while not self.checker.check_now():
|
||||
print(colorama.Fore.RED + f"Condition checker is not happy, waiting for OK conditions since {time()-first_check:5.1f} seconds." + colorama.Fore.RESET, end="\r")
|
||||
sleep(self.checker_sleep_time)
|
||||
checker_unhappy = True
|
||||
if checker_unhappy:
|
||||
print(colorama.Fore.RED + f"Condition checker was not happy and waiting for {time()-first_check:5.1f} seconds." + colorama.Fore.RESET)
|
||||
self.checker.clear_and_start_counting()
|
||||
|
||||
while True:
|
||||
self.checker.get_ready()
|
||||
self.do_step(*args, **kwargs)
|
||||
|
||||
if self.checker.stop_and_analyze():
|
||||
if self.checker.is_happy():
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def do_step(self, n_step, step_values, step_info=None):
|
||||
set_all_target_values_and_wait(self.adjustables, step_values)
|
||||
step_readbacks = get_all_current_values(self.adjustables)
|
||||
|
||||
Reference in New Issue
Block a user