WIP: Still problems to get the stddaq to work according to configuration
This commit is contained in:
@@ -38,10 +38,14 @@ class StdDaqMixin(CustomDeviceMixin):
|
|||||||
d = {}
|
d = {}
|
||||||
if 'kwargs' in self.parent.scaninfo.scan_msg.info:
|
if 'kwargs' in self.parent.scaninfo.scan_msg.info:
|
||||||
scanargs = self.parent.scaninfo.scan_msg.info['kwargs']
|
scanargs = self.parent.scaninfo.scan_msg.info['kwargs']
|
||||||
|
print('kwargs')
|
||||||
|
print(scanargs)
|
||||||
if 'image_width' in scanargs and scanargs['image_width'] != None:
|
if 'image_width' in scanargs and scanargs['image_width'] != None:
|
||||||
d['image_width'] = scanargs['image_width']
|
d['image_width'] = scanargs['image_width']
|
||||||
if 'image_height' in scanargs and scanargs['image_height'] != None:
|
if 'image_height' in scanargs and scanargs['image_height'] != None:
|
||||||
d['image_height'] = scanargs['image_height']
|
d['image_height'] = scanargs['image_height']
|
||||||
|
if 'nr_writers' in scanargs and scanargs['nr_writers'] != None:
|
||||||
|
d['nr_writers'] = scanargs['nr_writers']
|
||||||
if 'file_path' in scanargs and scanargs['file_path']!=None:
|
if 'file_path' in scanargs and scanargs['file_path']!=None:
|
||||||
self.parent.file_path.set(scanargs['file_path']).wait()
|
self.parent.file_path.set(scanargs['file_path']).wait()
|
||||||
|
|
||||||
@@ -67,9 +71,13 @@ class StdDaqMixin(CustomDeviceMixin):
|
|||||||
|
|
||||||
# Perform bluesky-style configuration
|
# Perform bluesky-style configuration
|
||||||
if len(d) > 0:
|
if len(d) > 0:
|
||||||
|
print('Reconfiguring')
|
||||||
# Stop if current status is not idle
|
# Stop if current status is not idle
|
||||||
if self.parent.state() != "idle":
|
if self.parent.state() != "idle":
|
||||||
self.parent.surestop()
|
self.parent.surestop()
|
||||||
|
print(self.parent.state())
|
||||||
|
print(self.parent.state())
|
||||||
|
print(self.parent.state())
|
||||||
# Configure new run (will restart the stdDAQ)
|
# Configure new run (will restart the stdDAQ)
|
||||||
logger.warning(f"[{self.parent.name}] Configuring with:\n{d}")
|
logger.warning(f"[{self.parent.name}] Configuring with:\n{d}")
|
||||||
self.parent.configure(d=d)
|
self.parent.configure(d=d)
|
||||||
@@ -77,7 +85,7 @@ class StdDaqMixin(CustomDeviceMixin):
|
|||||||
# Try to start a new run
|
# Try to start a new run
|
||||||
file_path = self.parent.file_path.get()
|
file_path = self.parent.file_path.get()
|
||||||
num_images = self.parent.num_images.get()
|
num_images = self.parent.num_images.get()
|
||||||
message = {"command": "start", "path": file_path, "n_image": num_images}
|
message = {"command": "start", "path": file_path, "n_image": num_images, }
|
||||||
ii = 0
|
ii = 0
|
||||||
while True:
|
while True:
|
||||||
self.parent.connect()
|
self.parent.connect()
|
||||||
@@ -111,6 +119,7 @@ class StdDaqMixin(CustomDeviceMixin):
|
|||||||
def on_unstage(self):
|
def on_unstage(self):
|
||||||
""" Stop a running acquisition and close connection
|
""" Stop a running acquisition and close connection
|
||||||
"""
|
"""
|
||||||
|
self.parent.create_virtual_dataset()
|
||||||
self.parent.surestop()
|
self.parent.surestop()
|
||||||
|
|
||||||
def on_stop(self):
|
def on_stop(self):
|
||||||
@@ -295,6 +304,7 @@ class StdDaqClient(PSIDeviceBase):
|
|||||||
* 4: Invert pixel values, but do not apply any linearity correction
|
* 4: Invert pixel values, but do not apply any linearity correction
|
||||||
* 5: Apply the full linearity correction
|
* 5: Apply the full linearity correction
|
||||||
"""
|
"""
|
||||||
|
print('This is d')
|
||||||
print(d)
|
print(d)
|
||||||
if 'image_width' in d and d['image_width']!=None:
|
if 'image_width' in d and d['image_width']!=None:
|
||||||
self.cfg_pixel_width.set(d['image_width']).wait()
|
self.cfg_pixel_width.set(d['image_width']).wait()
|
||||||
@@ -302,31 +312,45 @@ class StdDaqClient(PSIDeviceBase):
|
|||||||
self.cfg_pixel_height.set(d['image_height']).wait()
|
self.cfg_pixel_height.set(d['image_height']).wait()
|
||||||
if 'num_points_total' in d:
|
if 'num_points_total' in d:
|
||||||
self.num_images.set(d['num_points_total']).wait()
|
self.num_images.set(d['num_points_total']).wait()
|
||||||
if 'file_path' in d and d['file_path']!=None:
|
|
||||||
self.file_path.set(d['file_path']).wait()
|
|
||||||
if 'nr_writers' in d and d['nr_writers']!=None:
|
if 'nr_writers' in d and d['nr_writers']!=None:
|
||||||
|
print('Setting number of writers ' + str(d['nr_writers']))
|
||||||
self.cfg_nr_writers.set(d['nr_writers']).wait()
|
self.cfg_nr_writers.set(d['nr_writers']).wait()
|
||||||
|
|
||||||
# Restart the DAQ if resolution changed
|
# Restart the DAQ if resolution changed
|
||||||
cfg = self.get_daq_config()
|
cfg = self.get_daq_config()
|
||||||
if cfg['image_pixel_height'] != self.cfg_pixel_height.get() or
|
print(cfg)
|
||||||
cfg['image_pixel_width'] != self.cfg_pixel_width.get() or
|
print(cfg['number_of_writers'])
|
||||||
cfg['bit_depth'] != self.cfg_bit_depth.get() or
|
print(self.cfg_nr_writers.get())
|
||||||
|
if cfg['image_pixel_height'] != self.cfg_pixel_height.get() or \
|
||||||
|
cfg['image_pixel_width'] != self.cfg_pixel_width.get() or \
|
||||||
|
cfg['bit_depth'] != self.cfg_bit_depth.get() or \
|
||||||
cfg['number_of_writers'] != self.cfg_nr_writers.get():
|
cfg['number_of_writers'] != self.cfg_nr_writers.get():
|
||||||
|
|
||||||
# Stop if current status is not idle
|
# Stop if current status is not idle
|
||||||
if self.state() != "idle":
|
status = self.state()
|
||||||
|
print(status)
|
||||||
|
|
||||||
|
# if self.state() != "idle":
|
||||||
|
if status != "idle":
|
||||||
self.surestop()
|
self.surestop()
|
||||||
|
|
||||||
|
status = self.state()
|
||||||
|
print(status)
|
||||||
|
|
||||||
# Stop running acquisition
|
# Stop running acquisition
|
||||||
|
print('Before unstage')
|
||||||
self.unstage()
|
self.unstage()
|
||||||
|
print('After unstage')
|
||||||
# Update retrieved config
|
# Update retrieved config
|
||||||
cfg['image_pixel_height'] = int(self.cfg_pixel_height.get())
|
cfg['image_pixel_height'] = int(self.cfg_pixel_height.get())
|
||||||
cfg['image_pixel_width'] = int(self.cfg_pixel_width.get())
|
cfg['image_pixel_width'] = int(self.cfg_pixel_width.get())
|
||||||
cfg['bit_depth'] = int(self.cfg_bit_depth.get())
|
cfg['bit_depth'] = int(self.cfg_bit_depth.get())
|
||||||
cfg['number_of_writers'] = int(self.cfg_nr_writers.get())
|
cfg['number_of_writers'] = int(self.cfg_nr_writers.get())
|
||||||
self.set_daq_config(cfg)
|
print(cfg)
|
||||||
self.read_daq_config()
|
r = self.set_daq_config(cfg)
|
||||||
|
print(r)
|
||||||
|
cfg=self.read_daq_config()
|
||||||
|
print(cfg)
|
||||||
|
|
||||||
def get_daq_config(self) -> dict:
|
def get_daq_config(self) -> dict:
|
||||||
"""Read the current configuration from the DAQ
|
"""Read the current configuration from the DAQ
|
||||||
@@ -372,10 +396,10 @@ class StdDaqClient(PSIDeviceBase):
|
|||||||
"""
|
"""
|
||||||
url = self.rest_url.get() + '/api/h5/create_interleaved_vds'
|
url = self.rest_url.get() + '/api/h5/create_interleaved_vds'
|
||||||
|
|
||||||
r = requests.pos(
|
r = requests.post(
|
||||||
url,
|
url,
|
||||||
params = {'user': 'ioc'},
|
params = {'user': 'ioc'},
|
||||||
data = {'base_path': self.file_path. 'output_file': 'fede_virtual_test'},
|
data = {'base_path': self.file_path, 'output_file': 'fede_virtual_test'},
|
||||||
timeout = 2,
|
timeout = 2,
|
||||||
headers = {'Content-type': 'application/json'}
|
headers = {'Content-type': 'application/json'}
|
||||||
)
|
)
|
||||||
@@ -419,7 +443,8 @@ class StdDaqClient(PSIDeviceBase):
|
|||||||
reply = client.recv(timeout=1)
|
reply = client.recv(timeout=1)
|
||||||
reply = json.loads(reply)
|
reply = json.loads(reply)
|
||||||
|
|
||||||
if reply['status'] in ['idle', 'stoped']:
|
print(reply['status'])
|
||||||
|
if reply['status'] in ['idle', 'stoped']:
|
||||||
logger.warning(f"[{self.name}] Stop-all command finished in {reply['status']}")
|
logger.warning(f"[{self.name}] Stop-all command finished in {reply['status']}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ class Measurement:
|
|||||||
|
|
||||||
self.build_filename()
|
self.build_filename()
|
||||||
|
|
||||||
def acquire_darks(self,nimages_dark, exposure_time=None, exposure_period=None, roix=None, roiy=None, acq_mode=None,
|
def acquire_darks(self,nimages_dark, exposure_time=None, exposure_period=None,
|
||||||
file_path=None):
|
roix=None, roiy=None, acq_mode=None, file_path=None):
|
||||||
"""
|
"""
|
||||||
Acquire a set of dark images with shutters closed.
|
Acquire a set of dark images with shutters closed.
|
||||||
|
|
||||||
@@ -111,11 +111,11 @@ class Measurement:
|
|||||||
--------
|
--------
|
||||||
fede_darks(100, exposure_time=5)
|
fede_darks(100, exposure_time=5)
|
||||||
"""
|
"""
|
||||||
dev.es1_tasks.enabled = False
|
# dev.es1_tasks.enabled = False
|
||||||
dev.es1_psod.enabled = False
|
# dev.es1_psod.enabled = False
|
||||||
dev.es1_ddaq.enabled = False
|
# dev.es1_ddaq.enabled = False
|
||||||
dev.es1_ismc.enabled = False
|
# dev.es1_ismc.enabled = False
|
||||||
dev.es1_roty.enabled = False
|
# dev.es1_roty.enabled = False
|
||||||
dev.gfcam.enabled = True
|
dev.gfcam.enabled = True
|
||||||
dev.gfdaq.enabled = True
|
dev.gfdaq.enabled = True
|
||||||
dev.daq_stream0.enabled = True
|
dev.daq_stream0.enabled = True
|
||||||
@@ -142,6 +142,15 @@ class Measurement:
|
|||||||
# Commit changes to GF
|
# Commit changes to GF
|
||||||
dev.gfcam.cmdSetParam.set(1).wait()
|
dev.gfcam.cmdSetParam.set(1).wait()
|
||||||
|
|
||||||
|
if exposure_time != None:
|
||||||
|
self.exposure_time = exposure_time
|
||||||
|
if exposure_period != None:
|
||||||
|
self.exposure_period = exposure_period
|
||||||
|
if roix != None:
|
||||||
|
self.roix = roix
|
||||||
|
if roiy != None:
|
||||||
|
self.roiy = roiy
|
||||||
|
|
||||||
if file_path!=None:
|
if file_path!=None:
|
||||||
if os.path.isdir(file_path):
|
if os.path.isdir(file_path):
|
||||||
pass
|
pass
|
||||||
@@ -150,5 +159,5 @@ class Measurement:
|
|||||||
|
|
||||||
### TODO: camera reset
|
### TODO: camera reset
|
||||||
print("Handing over to 'scans.acquire_dark")
|
print("Handing over to 'scans.acquire_dark")
|
||||||
scans.acquire_dark(exp_burst=nimages_dark, exp_time=exposure_time, exp_period=exposure_period, image_width=roix,
|
scans.acquire_dark(exp_burst=nimages_dark, exp_time=self.exposure_time, exp_period=self.exposure_period, image_width=self.roix,
|
||||||
image_height=roiy, acq_mode=acq_mode, file_path=file_path, nr_writers=1)
|
image_height=self.roiy, acq_mode=acq_mode, file_path=file_path, nr_writers=1)
|
||||||
Reference in New Issue
Block a user