diff --git a/FastComtecMCS8A/blacs_workers.py b/FastComtecMCS8A/blacs_workers.py index d7c93d2db06e050ffe4fd8c7f701f96980bd0c44..538e683c99d7c0ec6a2fd4f82e86687bea54afbd 100644 --- a/FastComtecMCS8A/blacs_workers.py +++ b/FastComtecMCS8A/blacs_workers.py @@ -28,6 +28,7 @@ class MCS8AWorker(Worker): if getattr(self.device.get_acq_status(),"started") == 1: time.sleep(1) self.device.halt_measurement() + self.dataindex=0 # load (default) config if not os.path.realpath(self.config_path) == self.config_path.replace("/","\\"): @@ -59,7 +60,9 @@ class MCS8AWorker(Worker): # TODO: How to handle parameters (start new measurment when they changed, or treat parameters statically) with h5py.File(h5_file,'r') as f: stop_time = f["devices/" + f["connection table"].attrs["master_pseudoclock"]].attrs["stop_time"] - if getattr(self.device.get_acq_status(),"started") != 1 or time.perf_counter()-getattr(self,"start_time",-self.maxduration)>self.maxduration-stop_time-2: + if getattr(self.device.get_acq_status(),"started") != 1 or time.perf_counter()-getattr(self,"start_time",-self.maxduration)>self.maxduration-stop_time-3: + if self.dataindex==0: + self.device.halt_measurement() while getattr(self.device.get_acq_status(),"started") == 1: # If the current measurement doesn't have enought time left for this shot, wait until measurment ends. time.sleep(0.1) @@ -74,7 +77,7 @@ class MCS8AWorker(Worker): # self.device.erase_measruement() # Don't erase because this takes super long for some reason self.device.start_measurement() self.start_time = time.perf_counter() - time.sleep(1) # some buffer time to make sure the measurement already started for sure + time.sleep(2) # some buffer time to make sure the measurement already started for sure # TODO: What's the minimum time to wait here? # Save where to find the measurement data (which file and within file)