Closedown

This commit is contained in:
gac-x03da
2019-01-25 15:18:12 +01:00
parent 0d447cc4fd
commit 26184ef69a

View File

@@ -41,6 +41,7 @@ import ch.psi.pshell.device.ReadonlyRegister.ReadonlyRegisterArray as ReadonlyRe
import ch.psi.pshell.device.ReadonlyRegister.ReadonlyRegisterMatrix as ReadonlyRegisterMatrix
from startup import *
import local
def check_region(region):
"""
@@ -57,13 +58,16 @@ def check_region(region):
region['cis'] = False
print("region {0}: setting default cis = {1}".format(region['name'], region['cis']))
if 'slit' not in region:
region['slit'] = ExitSlit.read()
region['slit'] = get_device("ExitSlit").read()
print("region {0}: setting default slit = {1}".format(region['name'], region['slit']))
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
#super(SpectrumReader, self).initialize()
self.scan_index = -1
self.Scienta = get_device("Scienta")
self.ExitSlit = get_device("ExitSlit")
self.Eph = get_device("Eph")
def create_datasets(self):
path = get_exec_pars().scanPath + self.region_name + "/"
@@ -93,7 +97,7 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
if self.region_index == 0:
print "scan {0}".format(self.scan_index)
ephot = Eph.read()
ephot = self.Eph.read()
try:
if self.region['cis']:
edelta = ephot - self.ephot_start
@@ -107,19 +111,19 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
ehi = self.region['ehi'] + edelta
if self.region['fixed']:
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed)
Scienta.centerEnergy.write(elo)
self.Scienta.setAcquisitionMode(self.Scienta.AcquisitionMode.Fixed)
self.Scienta.centerEnergy.write(elo)
else:
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
self.Scienta.setAcquisitionMode(self.Scienta.AcquisitionMode.Swept)
self.Scienta.lowEnergy.write(elo)
self.Scienta.highEnergy.write(ehi)
self.Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
ExitSlit.write(self.region['slit'])
Scienta.update()
self.Scienta.setPassEnergy(self.region['epass'])
self.Scienta.stepTime.write(self.region['tstep'])
self.Scienta.setIterations(self.region['iter'])
self.ExitSlit.write(self.region['slit'])
self.Scienta.update()
if self.region['fixed']:
append_dataset(self.channel_center_dataset_name, elo)
@@ -138,9 +142,9 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
current_region_index = self.region_index
self.setup()
print("Acquiring region {0}.".format(self.region['name']))
trig_scienta()
local.trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
sp = self.Scienta.getSpectrum().read()
return sp
def getSize(self):
@@ -152,8 +156,11 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def initialize(self):
self.Scienta = get_device("Scienta")
def read(self):
return Scienta.getDataMatrix().read()
return self.Scienta.getDataMatrix().read()
def getWidth(self):
if self.region['fixed']:
@@ -163,7 +170,7 @@ class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
return nx
def getHeight(self):
ny = Scienta.slices.read()
ny = self.Scienta.slices.read()
return ny
def setup_live_plots(regions):
@@ -176,6 +183,7 @@ def setup_live_plots(regions):
def update_live_plots():
global live_plots
global current_region_index
Scienta = get_device("Scienta")
try:
while get_context().state.running:
y = Scienta.spectrum.take(100)
@@ -214,10 +222,10 @@ def do_scan(motors, positions, regions, latency):
SENSORS.append(get_device("SampleCurrent"))
SENSORS.append(get_device("RefCurrent"))
adjust_sensors()
set_adc_averaging()
local.adjust_sensors()
local.set_adc_averaging()
vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read=after_readout)
vscan(motors, SENSORS, positions, True, latency,False, before_read=local.wait_beam, after_read=local.after_readout)
for (index, region) in enumerate(regions):
set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name'])