Skip to content

Commit 5555c85

Browse files
committed
Final updates for DAE.
1 parent c31f227 commit 5555c85

File tree

7 files changed

+345
-60
lines changed

7 files changed

+345
-60
lines changed

asta/pvScan-ued-1motor.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
# Create Shutter objects.
3838
# First argument is shutter PV.
3939
# Second arg (optional) is an RBV PV, for example an ADC channel.
40-
shutter1=pvscan.LSCShutter('ASTA:LSC01','ADC:AS01:12:V') # (UED Drive laser)
41-
shutter2=pvscan.LSCShutter('ASTA:LSC02','ADC:AS01:13:V') # (UED pump laser)
42-
shutter3=pvscan.LSCShutter('ASTA:LSC03','ADC:AS01:14:V') # (UED HeNe laser)
40+
# Third arg (optional) is a unique shutter number index, which allows enabling/disabling from PVs.
41+
shutter1=pvscan.LSCShutter('ASTA:LSC01','ADC:AS01:13:V',1) # (UED Drive laser)
42+
shutter2=pvscan.LSCShutter('ASTA:LSC02','ADC:AS01:14:V',2) # (UED pump laser)
43+
shutter3=pvscan.LSCShutter('ASTA:LSC03','ADC:AS01:15:V',3) # (UED HeNe laser)
4344
#
4445
# Create ShutterGroup object to use common functions on all shutters.
4546
# Argument is a list of shutter objects.
@@ -79,15 +80,28 @@ def scanRoutine():
7980
"This is the scan routine"
8081
pvscan.printMsg('Starting')
8182
sleep(0.5) # Collect some initial data first
82-
# Open shutters
83-
#pvscan.printMsg('Opening shutters')
84-
#pvscan.shutterFunction(shutterGroup1.open,1)
83+
# Open all shutters, but only if enabled from PV.
84+
if shutter1.enabled:
85+
pvscan.printMsg('Opening drive shutter')
86+
shutter1.open.put(1)
87+
if shutter2.enabled:
88+
pvscan.printMsg('Opening pump shutter')
89+
shutter2.open.put(1)
90+
if shutter3.enabled:
91+
pvscan.printMsg('Opening shutter 3')
92+
shutter3.open.put(1)
8593
# Scan delay stage and grab images...
8694
pvscan.Motor.motor1DScan(motor1,grab1)
87-
#pvscan.Motor.pv1DScan(motor1,grab1)
88-
# Close shutters
89-
#pvscan.printMsg('Closing shutters')
90-
#pvscan.shutterFunction(shutterGroup1.close,0)
95+
# Close all shutters, but only if enabled from PV.
96+
if shutter1.enabled:
97+
pvscan.printMsg('Closing drive shutter')
98+
shutter1.close.put(1)
99+
if shutter2.enabled:
100+
pvscan.printMsg('Closing pump shutter')
101+
shutter2.close.put(1)
102+
if shutter3.enabled:
103+
pvscan.printMsg('Closing shutter 3')
104+
shutter3.close.put(1)
91105
pvscan.printMsg('Done')
92106

93107
### Main program ##########################################################3

asta/pvScan-ued-1pv.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
# Create Shutter objects.
3535
# First argument is shutter PV.
3636
# Second arg (optional) is an RBV PV, for example an ADC channel.
37-
shutter1=pvscan.LSCShutter('ASTA:LSC01','ADC:AS01:13:V') # (UED Drive laser)
38-
shutter2=pvscan.LSCShutter('ASTA:LSC02','ADC:AS01:14:V') # (UED pump laser)
39-
shutter3=pvscan.LSCShutter('ASTA:LSC03','ADC:AS01:15:V') # (UED HeNe laser)
37+
# Third arg (optional) is a unique shutter number index, which allows enabling/disabling from PVs.
38+
shutter1=pvscan.LSCShutter('ASTA:LSC01','ADC:AS01:13:V',1) # (UED Drive laser)
39+
shutter2=pvscan.LSCShutter('ASTA:LSC02','ADC:AS01:14:V',2) # (UED pump laser)
40+
shutter3=pvscan.LSCShutter('ASTA:LSC03','ADC:AS01:15:V',3) # (UED HeNe laser)
4041
#
4142
# Create ShutterGroup object to use common functions on all shutters.
4243
# Argument is a list of shutter objects.
@@ -76,14 +77,28 @@ def scanRoutine():
7677
"This is the scan routine"
7778
pvscan.printMsg('Starting')
7879
sleep(0.5) # Collect some initial data first
79-
# Open shutters
80-
#pvscan.printMsg('Opening shutters')
81-
#pvscan.shutterFunction(shutterGroup1.open,1)
80+
# Open all shutters, but only if enabled from PV.
81+
if shutter1.enabled:
82+
pvscan.printMsg('Opening drive shutter')
83+
shutter1.open.put(1)
84+
if shutter2.enabled:
85+
pvscan.printMsg('Opening pump shutter')
86+
shutter2.open.put(1)
87+
if shutter3.enabled:
88+
pvscan.printMsg('Opening shutter 3')
89+
shutter3.open.put(1)
8290
# Scan delay stage and grab images...
8391
pvscan.ScanPv.pv1DScan(scanPv1,grab1)
84-
# Close shutters
85-
#pvscan.printMsg('Closing shutters')
86-
#pvscan.shutterFunction(shutterGroup1.close,0)
92+
# Close all shutters, but only if enabled from PV.
93+
if shutter1.enabled:
94+
pvscan.printMsg('Closing drive shutter')
95+
shutter1.close.put(1)
96+
if shutter2.enabled:
97+
pvscan.printMsg('Closing pump shutter')
98+
shutter2.close.put(1)
99+
if shutter3.enabled:
100+
pvscan.printMsg('Closing shutter 3')
101+
shutter3.close.put(1)
87102
pvscan.printMsg('Done')
88103

89104
### Main program ##########################################################3

asta/pvScan-ued-dae.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
# First argument is shutter PV.
3939
# Second arg (optional) is an RBV PV, for example an ADC channel.
4040
# Third arg (optional) is a unique shutter number index, which allows enabling/disabling from PVs.
41-
shutter1=pvscan.LSCShutter('ASTA:LSC01','ADC:AS01:12:V',1) # (UED Drive laser)
42-
shutter2=pvscan.LSCShutter('ASTA:LSC02','ADC:AS01:13:V',2) # (UED pump laser)
43-
shutter3=pvscan.LSCShutter('ASTA:LSC03','ADC:AS01:14:V',3) # (UED HeNe laser)
41+
shutter1=pvscan.LSCShutter('ASTA:LSC01','ADC:AS01:13:V',1) # (UED Drive laser)
42+
shutter2=pvscan.LSCShutter('ASTA:LSC02','ADC:AS01:14:V',2) # (UED pump laser)
43+
shutter3=pvscan.LSCShutter('ASTA:LSC03','ADC:AS01:15:V',3) # (UED HeNe laser)
4444
#
4545
# Create ShutterGroup object to use common functions on all shutters.
4646
# Argument is a list of shutter objects.
@@ -52,11 +52,13 @@
5252
#toroid0355Pv=PV('ESB:A01:ADC1:AI:CH4')
5353
#toroid2150Pv=PV('ESB:A01:ADC1:AI:CH5')
5454
#structureChargePv=PV('ESB:A01:ADC1:CALC:CH1:CONV')
55+
andorTimestampRBVPv=PV('ANDOR1:TIFF1:TimeStamp_RBV')
56+
andorCaptureRBVPv=PV('ANDOR1:TIFF1:Capture_RBV')
5557

5658
#---- Data logging --------------------------
5759
# List of PV() objects to be monitored during scan.
5860
# Example: dataLogPvList=shutterGroup1.rbv + [motor1.rbv,lsrpwrPv,PV('MY:PV1')] + [PV('MY:PV2')]
59-
dataLogPvList=shutterGroup1.rbv + [motor1.rbv,motor2.rbv,motor3.rbv,motor4.rbv,motor5.rbv]
61+
dataLogPvList= [andorTimestampRBVPv,andorCaptureRBVPv] + shutterGroup1.rbv + [motor1.rbv,motor2.rbv,motor3.rbv,motor4.rbv,motor5.rbv]
6062
#
6163
# Create DataLogger object.
6264
# Argument is the list of PVs to monitor.

modules/pvscan.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pvScan module
33

44
from epics import PV,ca
5-
from time import sleep
5+
from time import sleep,time
66
import datetime,math,os,sys
77

88
try:
@@ -254,34 +254,40 @@ def datalog(self):
254254
"Logs PV data to a file; designed to be run in a separate thread. Uses dataFlag global variable which is shared between threads. PVs must be in pvlist."
255255
global dataFlag
256256
with open(self.dataFilename, 'w') as datafile:
257-
datafile.write('Timestamp ')
257+
datafile.write('%-30s %s' %('PV name', 'PV description\n'))
258258
for pv in self.pvlist:
259-
datafile.write(pv.pvname)
260-
datafile.write(' ')
259+
datafile.write('%-30s %s' %(pv.pvname, str(PV(pv.pvname + '.DESC').get()) + '\n'))
260+
datafile.write('#####################################################################\n')
261+
datafile.write('%-22s ' %('Timestamp'))
262+
for pv in self.pvlist:
263+
datafile.write(pv.pvname + ' ')
261264
datafile.write('\n')
262265
count=0
263266
#chids=[ca.create_channel(pv.pvname) for pv in self.pvlist]
264267
#[ca.connect_channel(chid) for chid in chids]
265268
while dataFlag and count < self.nPtsMax:
266269
datafile.write(str(timestamp(1)))
270+
start=time()
267271
datafile.write(' ')
268272
for pv in self.pvlist:
269273
#for chid in chids:
270274
try:
271-
#datafile.write(str(pv.value))
275+
datafile.write(str(pv.value) + ' ')
272276
#datafile.write(str(pv.get(timeout=0.8*self.dataInt,use_monitor=False)))
273277
# Must use epics.ca here since PV() timeout doesn't seem to work.
274-
chid = ca.create_channel(pv.pvname)
275-
pvValue = ca.get(chid,timeout=0.9*self.dataInt/len(self.pvlist))
278+
#chid = ca.create_channel(pv.pvname)
279+
#pvValue = ca.get(chid,timeout=0.9*self.dataInt/len(self.pvlist))
276280
#pvValue = ca.get(chid)
277-
datafile.write(str(pvValue) + ' ')
281+
#datafile.write(str(pvValue) + ' ')
278282
except KeyError:
279283
datafile.write('Invalid ')
280284
except TypeError:
281285
datafile.write('Invalid ')
286+
elapsedTime=time()-start
282287
datafile.write('\n')
283-
sleep(self.dataInt)
284288
count+=1
289+
if self.dataInt-elapsedTime > 0:
290+
sleep(self.dataInt - elapsedTime)
285291

286292
class ImageGrabber(Experiment):
287293
"Sets things up to grab images"

nlcta/pvScan-nlcta-1pv.py

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# mdunning 1/7/16
44

55
from epics import PV
6-
from time import sleep
6+
from time import sleep,time
77
import datetime,os,sys
88
from threading import Thread
99

@@ -14,34 +14,44 @@
1414
os.environ['PVSCAN_PVPREFIX']=pvPrefix
1515

1616
# Import pvScan module
17+
start=time()
1718
sys.path.append('/afs/slac/g/testfac/extras/scripts/pvScan/prod/modules/')
18-
import pvscan
19+
import pvscan2
20+
end=time()
21+
print 'Import: ', end-start
1922

2023
#--- Experiment ---------------------------------------
2124
# Create Experiment object. Sets default filepath and gets experiment name from PV.
2225
# First argument (optional) is an experiment name.
2326
# Second arg (optional) is a filepath.
24-
exp1=pvscan.Experiment()
25-
sleep(2)
27+
start=time()
28+
exp1=pvscan2.Experiment()
29+
end=time()
30+
print 'Exp.: ', end-start
31+
#sleep(2)
2632

2733
#--- Scan PVs ------------------------------------------
2834
# Create ScanPv objects, one for each PV you are scanning.
29-
# First argument is the scan PV, leave blank to get from pvScan IOC.
35+
# First argument is the scan PV, leave as empty string to get from pvScan IOC.
3036
# Second arg is an index which should be unique.
31-
scanPv1=pvscan.ScanPv('',1) # (UED Solenoid)
37+
start=time()
38+
scanPv1=pvscan2.ScanPv('',1)
39+
end=time()
40+
print 'scanPv: ', end-start
3241

3342
#--- Shutters -----------------------------------------
3443
# Create Shutter objects.
3544
# First argument is shutter PV.
3645
# Second arg (optional) is an RBV PV, for example an ADC channel.
37-
shutter1=pvscan.DummyShutter('ESB:GP01:VAL01','ESB:GP01:VAL01') # (UED Drive laser)
38-
shutter2=pvscan.DummyShutter('ESB:GP01:VAL02','ESB:GP01:VAL02') # (UED pump laser)
39-
shutter3=pvscan.DummyShutter('ESB:GP01:VAL03','ESB:GP01:VAL03') # (UED HeNe laser)
46+
# Third arg (optional) is a unique shutter number index, which allows enabling/disabling from PVs.
47+
shutter1=pvscan2.DummyShutter('ESB:GP01:VAL01','ESB:GP01:VAL01',1) # (UED Drive laser)
48+
shutter2=pvscan2.DummyShutter('ESB:GP01:VAL02','ESB:GP01:VAL02',2) # (UED pump laser)
49+
shutter3=pvscan2.DummyShutter('ESB:GP01:VAL03','ESB:GP01:VAL03',3) # (UED HeNe laser)
4050
#
4151
# Create ShutterGroup object to use common functions on all shutters.
4252
# Argument is a list of shutter objects.
43-
shutterGroup1=pvscan.ShutterGroup([shutter1,shutter2,shutter3])
44-
#
53+
shutterGroup1=pvscan2.ShutterGroup([shutter1,shutter2,shutter3])
54+
4555
#--- Other PVs -----------------
4656
# Define as PV objects. Example PV('MY:RANDOM:PV')
4757
#lsrpwrPv=PV('ESB:A01:ADC1:AI:CH3')
@@ -52,39 +62,59 @@
5262
#---- Data logging --------------------------
5363
# List of PV() objects to be monitored during scan.
5464
# Example: dataLogPvList=shutterGroup1.rbv + [scanPv1,lsrpwrPv,PV('MY:PV1')] + [PV('MY:PV2')]
55-
dataLogPvList=shutterGroup1.rbv + [scanPv1]
65+
dataLogPvList=shutterGroup1.rbv + [scanPv1.scanpv]
5666
#
5767
# Create DataLogger object.
5868
# Argument is the list of PVs to monitor.
59-
dataLog1=pvscan.DataLogger(dataLogPvList)
69+
start=time()
70+
dataLog1=pvscan2.DataLogger(dataLogPvList)
71+
end=time()
72+
print 'dataLog: ', end-start
6073
#-------------------------------------------------
6174

6275
# --- Image grabbing --------------------------
6376
# Override saved camera settings here. Leave empty list to use the default; otherwise add PVs with single quotes.
6477
grabImagesSettingsPvList=[]
6578
#
6679
# Create ImageGrabber object.
67-
# First arg is the camera PV prefix.
80+
# First arg is the camera PV prefix, leave as empty string to get from pvScan IOC.
6881
# Second arg (optional) is a list of camera setting PVs to be dumped to a file.
6982
# Third arg (optional) is the image grabbing plugin.
70-
grab1=pvscan.ImageGrabber('13PS10')
83+
start=time()
84+
grab1=pvscan2.ImageGrabber('')
85+
end=time()
86+
print 'grab: ', end-start
7187
#-------------------------------------------------------------
7288

7389
### Define scan routine #####################################################
7490

7591
def scanRoutine():
7692
"This is the scan routine"
77-
pvscan.printMsg('Starting')
93+
pvscan2.printMsg('Starting')
7894
sleep(0.5) # Collect some initial data first
79-
# Open shutters
80-
pvscan.printMsg('Opening shutters')
81-
pvscan.shutterFunction(shutterGroup1.open,1)
95+
# Open all shutters, but only if enabled from PV.
96+
if shutter1.enabled:
97+
pvscan2.printMsg('Opening drive shutter')
98+
shutter1.open.put(1)
99+
if shutter2.enabled:
100+
pvscan2.printMsg('Opening pump shutter')
101+
shutter2.open.put(1)
102+
if shutter3.enabled:
103+
pvscan2.printMsg('Opening shutter 3')
104+
shutter3.open.put(1)
82105
# Scan delay stage and grab images...
83-
pvscan.ScanPv.pv1DScan(scanPv1,grab1)
84-
# Close shutters
85-
pvscan.printMsg('Closing shutters')
86-
pvscan.shutterFunction(shutterGroup1.close,0)
87-
pvscan.printMsg('Done')
106+
pvscan2.pv1DScan(scanPv1.scanpv,grab1)
107+
# Close all shutters, but only if enabled from PV.
108+
if shutter1.enabled:
109+
pvscan2.printMsg('Closing drive shutter')
110+
shutter1.close.put(0)
111+
if shutter2.enabled:
112+
pvscan2.printMsg('Closing pump shutter')
113+
shutter2.close.put(0)
114+
if shutter3.enabled:
115+
pvscan2.printMsg('Closing shutter 3')
116+
shutter3.close.put(0)
117+
pvscan2.printMsg('Done')
88118

89119
### Main program ##########################################################3
90120

@@ -99,16 +129,16 @@ def show_usage():
99129
show_usage()
100130
sys.exit(1)
101131
pid=os.getpid()
102-
pvscan.pidPV.put(pid)
103-
pvscan.Tee(dataLog1.logFilename, 'w')
104-
pvscan.dataFlag=1 # Start logging data when thread starts
132+
pvscan2.pidPV.put(pid)
133+
pvscan2.Tee(dataLog1.logFilename, 'w')
134+
pvscan2.dataFlag=1 # Start logging data when thread starts
105135
if dataLog1.dataEnable==1:
106136
datalogthread=Thread(target=dataLog1.datalog,args=())
107137
datalogthread.start()
108138
scanRoutine()
109139
sleep(2) # Log data for a little longer
110140
finally:
111-
pvscan.dataFlag=0 # Stop logging data
141+
pvscan2.dataFlag=0 # Stop logging data
112142

113143

114144
### End ##########################################################################

0 commit comments

Comments
 (0)