*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 70f9c602 authored by Leolab Cavity CAD PC's avatar Leolab Cavity CAD PC
Browse files

Improven timitgs when Fastcomtec is stopped and started (maybe not completely working)

parent 7ed2e33f
No related branches found
No related tags found
1 merge request!5Added Fastcomtec MCS8A timetagger for measurements with SPCM
......@@ -25,6 +25,8 @@ class MCS8AWorker(Worker):
self.device = fastcomtec_api.FastComTec()
# print("Status: ", self.device.get_acq_status())
if getattr(self.device.get_acq_status(),"started") == 1:
time.sleep(1)
self.device.halt_measurement()
# load (default) config
......@@ -42,7 +44,7 @@ class MCS8AWorker(Worker):
# Set how long each measurement lasts, i.e. how ofen a new file is started.
# We don't want it too long, because then the single files get huge, but we also don't
# want it too often, because each stopping and starting takes some time.
self.maxduration = 300 # seconds
self.maxduration = 600 # seconds
self.device._send_dll_command("bitshift=18") # 400ps * 2^0x18 = 0.0067 s
range_int = np.ceil(self.maxduration / (400e-12 * 2**0x18) / 64) * 64
self.device._send_dll_command(f"range={int(range_int)}")
......@@ -55,8 +57,13 @@ class MCS8AWorker(Worker):
# If device is already started, we leave it running and just save the datapath and index in the h5file.
# If the device is not running, or already longer than the defined duration, send the stop command, set new datafile and start new measurement.
# TODO: How to handle parameters (start new measurment when they changed, or treat parameters statically)
if getattr(self.device.get_acq_status(),"started") != 1 or time.perf_counter()-getattr(self,"start_time",-self.maxduration)>self.maxduration:
time.sleep(1) # TODO: Do we need this wait? What's the minumum?
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-0.1:
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)
print("Wait until last measurement stopped...", end="\r")
self.device.halt_measurement()
mpapath = self.get_new_mpapath()
self.device._send_dll_command(f"mpaname={mpapath}")
......@@ -67,7 +74,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(0.2) # some buffer time to make sure the measurement already started for sure
time.sleep(0.1) # 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment