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

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

periodic SPCM measurements in labscript are working with these configurations

parent 6be6276f
No related branches found
No related tags found
1 merge request!5Added Fastcomtec MCS8A timetagger for measurements with SPCM
......@@ -18,24 +18,31 @@ import numpy as np
class MCS8AWorker(Worker):
def init(self):
self.data_path_tmp = "C:\\mcs8x64\\MCS8A_measurement.tmp.mpa"
self.base_dir = "C:/mcs8x64/"
self.data_mame_tmp = "CHN2_tmp"
self.data_path_tmp = self.base_dir + self.data_mame_tmp + ".dat"
self.device = fastcomtec_api.FastComTec()
print("Connected...")
print("Status: ", self.device.get_acq_status())
# print("Status: ", self.device.get_acq_status())
# load (default) config
if not os.path.realpath(self.config_path) == self.config_path.replace("/","\\"):
self.config_path = os.path.dirname(os.path.realpath(__file__)) + "\\" + self.config_path
self.device.load_config(self.config_path)
print("test123")
# self.device.load_config(self.config_path)
print(f"Data file path: {self.data_mame_tmp}")
# self.device._send_dll_command(f"mpaname={self.data_path_tmp}") # mpa might be slow
self.device._send_dll_command("MC_B")
self.device._send_dll_command(f"datname={self.data_mame_tmp}")
self.device._send_dll_command("fmt=dat")
self.smart_cache = {}
print('init completed')
def transition_to_buffered(self, device_name, h5_file, initial_values, fresh):
self.h5file = h5_file # save for 'transition_to_manual'
"""
with h5py.File(h5_file,'r') as f:
command_group = f[f"devices/{self.device_name}/commands"]
for command in command_group.attrs:
......@@ -44,14 +51,19 @@ class MCS8AWorker(Worker):
self.smart_cache[command] = command_group.attrs[command]
if command_group.attrs[command] is not None:
command = f"{command}={command_group.attrs[command]}"
print(f"sending: {command}")
self.device._send_dll_command(command)
print(f"Programmed command '{command}'")
"""
try:
os.remove(self.data_path_tmp)
os.remove(self.base_dir + self.data_mame_tmp + ".mp")
except FileNotFoundError:
pass
self.device.erase_measruement()
# self.device.erase_measruement()
# self.device._send_dll_command("bitshift=11")
ran = 256
self.device._send_dll_command(f"range={ran}")
self.device.start_measurement()
return {}
......@@ -60,12 +72,15 @@ class MCS8AWorker(Worker):
# load data and write to file
# .... TODO
self.device._send_dll_command("savedat")
with h5py.File(self.h5file, 'r+') as f:
group = f.require_group(f"data/{self.device_name}/")
# save photon counts
data = np.random.randint(0,2,size=1000) # testing
# data = np.random.randint(0,2,size=1000) # testing
# data = np.loadtxt(self.data_path_tmp)
data = np.fromfile(self.data_path_tmp, dtype=np.uint32)
print(data.sum())
group.create_dataset("photon_counts", compression = config.compression, data=data) # maybe save as binary dtype
# save parameters
......
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