Files
x10da/script/PumpProbeXES_W1_v2.py
2019-03-19 12:07:31 +01:00

92 lines
3.0 KiB
Python

import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
import ch.psi.pshell.epics.ChannelDoubleArray as ChannelDoubleArray
import ch.psi.pshell.epics.ChannelInteger as ChannelInteger
#Script imported from: XES_W1.xml
#Pre-actions
caput('X10DA-ES1:START-CSMPL', '0')
sleep(0.1)
caput('X10DA-ES1:TOTAL-CYCLES', '1')
sleep(0.1)
caput('X10DA-PILATUS-1:cam1:AcquireTime', '1')
caput('X10DA-PILATUS-1:cam1:AcquirePeriod', '1.1')
caput('X10DA-ES1-MA1:TRX.VAL', '-18')
caput('X10DA-ES1-MA1:TRX1.VAL', '-15')
ROI1size=487
ROI2size=487
DELAY = ChannelInteger('X10DA-ES2-TIM:SET1-DELAY','X10DA-ES2-TIM:SET1-DELAY')
DELAY.initialize()
#Creating channels: dimension 1
#PseudoPositioner Pseudo
#ScalarDetector SAI01-MEAN
SAI01 = ChannelDouble('X10DA-ES1-SAI_01:MEAN', 'X10DA-ES1-SAI_01:MEAN')
#ScalarDetector SAI02
SAI02 = ChannelDouble('X10DA-ES1-SAI_02:MEAN', 'X10DA-ES1-SAI_02:MEAN')
#ScalarDetector Ring-current
RingCurrent = ChannelDouble('ARIDI-PCT:CURRENT', 'ARIDI-PCT:CURRENT')
#ScalarDetector PilExpTime
PilExpTime = ChannelDouble('X10DA-PILATUS-1:cam1:AcquireTime_RBV', 'X10DA-PILATUS-1:cam1:AcquireTime_RBV')
#Timestamp Timestamp
#ScalarDetector PilFileNum
PilFileNum = ChannelDouble('X10DA-PILATUS-1:cam1:FileNumber_RBV', 'X10DA-PILATUS-1:cam1:FileNumber_RBV')
#ScalarDetector TotalCounts
TotalCounts = ChannelDouble('X10DA-PILATUS-1:Stats1:Total_RBV', 'X10DA-PILATUS-1:Stats1:Total_RBV')
#ScalarDetector TiffFileNumber
TiffFileNumber = ChannelDouble('X10DA-PILATUS-1:Magick1:FileNumber_RBV', 'X10DA-PILATUS-1:Magick1:FileNumber_RBV')
#ScalarDetector ROI4
ROI4 = ChannelDouble('X10DA-PILATUS-1:Stats4:Total_RBV', 'X10DA-PILATUS-1:Stats4:Total_RBV')
#ArrayDetector ROI1
ROI1_On = ChannelDoubleArray('X10DA-PILATUS-1:Stats1:ProfileCursorX_RBV', 'X10DA-PILATUS-1:Stats1:ProfileCursorX_RBV', ROI1size)
#ArrayDetector ROI2
ROI2_On = ChannelDoubleArray('X10DA-PILATUS-1:Stats2:ProfileCursorX_RBV', 'X10DA-PILATUS-1:Stats2:ProfileCursorX_RBV' , ROI2size)
#Pseudo-devices
class Roi1_Off(Readable, ReadableArray):
def read(self):
DELAY.write(100)
time.sleep(0.1)
self.cache = caget('X10DA-PILATUS-1:Stats1:ProfileCursorX_RBV', '[d')
DELAY.write(0)
return self.cache
def getSize(self):
return ROI1.getSize()
ROI1_Off=Roi1_Off()
class Roi1Diff(Readable, ReadableArray):
def read(self):
return arrsub(ROI1_On.take(), ROI1_Off.cache)
def getSize(self):
return ROI1.getSize()
ROI1_Diff=Roi1Diff()
detectors = [SAI01, SAI02, RingCurrent, PilExpTime, PilFileNum, TotalCounts, TiffFileNumber, TiffFileNumber, ROI4, ROI1_On, ROI1_On]
for det in detectors:
det.initialize()
def before_sample():
DELAY.write(0)
caputq('X10DA-PILATUS-1:cam1:Acquire', 1)
caputq('X10DA-ES1:SMPL', '1')
sleep(0.1)
cawait('X10DA-PILATUS-1:cam1:Acquire', 0, type = 'l')
cawait('X10DA-ES1:SMPL-DONE', 1, type = 'l')
sleep(0.1)
try:
tscan(detectors + [ROI1_Off, ROI1_Diff], 30, 0, before_read = before_sample)
finally:
for det in detectors:
det.close()