Script execution

This commit is contained in:
gac-x03da
2022-02-01 17:34:36 +01:00
parent 55e9d8b8dd
commit e2bdc4f37c

View File

@@ -100,6 +100,11 @@ def check_region(region):
print("region {0}: setting default cis = {1}".format(region['name'], region['cis']))
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
"""
pseudo-device class to acquire and read out a Scienta spectrum per region.
this devices starts the spectrum acquisition and organises the data file.
"""
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
@@ -136,8 +141,6 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
if self.scan_index != get_exec_pars().index:
self.scan_index = get_exec_pars().index
self.create_datasets()
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
print "scan {0}, region {1}".format(self.scan_index, self.region_index)
@@ -195,11 +198,6 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
Scienta.update()
def read_scales(self):
# print("spectrum.read_scales")
append_dataset(self.channel_begin_dataset_name, Scienta.getChannelBegin().getValue()) # ???
append_dataset(self.channel_end_dataset_name, Scienta.getChannelEnd().getValue()) # ???
def read(self):
# print("spectrum.read")
global current_region_index
@@ -209,7 +207,8 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
trig_scienta()
time.sleep(0.1)
sp = Scienta.getSpectrum().read()
self.read_scales()
append_dataset(self.channel_begin_dataset_name, Scienta.getChannelBegin().getValue())
append_dataset(self.channel_end_dataset_name, Scienta.getChannelEnd().getValue())
return sp
def getSize(self):
@@ -222,7 +221,12 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
return nx
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
"""
pseudo-device class to read out the Scienta image per region.
this device just reads out the Scienta image that has been acquired by SpectrumReader.
"""
def read(self):
# print("image.read")
return Scienta.getDataMatrix().read()
@@ -241,6 +245,15 @@ class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
ny = Scienta.slices.read()
return ny
class SimpleDeviceReader(Readable):
"""
pseudo-device class to read out another device once per region.
the device must be set assigned to the device attribute.
"""
def read(self):
return device.read()
def setup_live_plots(regions):
global live_plots
global current_region_index
@@ -265,6 +278,13 @@ def update_live_plots():
print "Stopping live spectra"
def do_scan(scan, motors, positions, regions, latency):
"""
set up detectors and run the scan
for each region we have to add a SpectrumReader and an ImageReader pseudo-device to the SENSORS list.
the order SpectrumReader, ImageReader is important because the SpectrumReader triggers the Scienta,
whereafter the ImageReader reads the image.
"""
global SENSORS
SENSORS = []
@@ -277,18 +297,28 @@ def do_scan(scan, motors, positions, regions, latency):
reader.region_name = "region{0}".format(index + 1)
reader.region = region
reader.initialize()
set_device_alias(reader, reader.region_name + "/ScientaSpectrum")
reader.set_alias(reader.region_name + "/ScientaSpectrum")
SENSORS.append(reader)
image = ImageReader()
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, reader.region_name + "/ScientaImage")
image.set_alias(reader.region_name + "/ScientaImage")
SENSORS.append(image)
SENSORS.append(SampleCurrent)
SENSORS.append(RefCurrent)
dev = SimpleDeviceReader()
dev.device = SampleCurrent
dev.set_alias(reader.region_name + "/SampleCurrent")
SENSORS.append(dev)
dev = SimpleDeviceReader()
dev.device = RefCurrent
dev.set_alias(reader.region_name + "/RefCurrent")
SENSORS.append(dev)
#SENSORS.append(SampleCurrent)
#SENSORS.append(RefCurrent)
adjust_sensors()
set_adc_averaging()