Beispiel #1
0
sys.path.append('/afs/slac/g/testfac/extras/scripts/pvScan/prod/modules/')
import pvscan

#--- Experiment ---------------------------------------
# Create Experiment object.  Sets default filepath and gets experiment name from PV.
# First argument (optional) is an experiment name, leave blank to get from pvScan IOC.
# Second arg (optional) is a filepath, leave blank to get from pvScan IOC.
# Third arg (optional) is a scan name, leave blank to get from pvScan IOC.
exp1 = pvscan.Experiment()
exp1.targetname = PV(pvPrefix + ':SCAN:TARGETNAME').get()
if ' ' in exp1.targetname: exp1.targetname = exp1.targetname.replace(' ', '_')

#--- Log file ------------------------------
# Create log file object.  Writes to stdout and to a log file.
# First arg (optional) is a filename, leave blank to get from pvScan IOC.
logFile1 = pvscan.Tee()

#--- Scan PVs ------------------------------------------
# Create ScanPv objects, one for each PV you are scanning.
# First argument (required) is the scan PV, leave as empty string to get from pvScan IOC.
# Second arg (required) is an index which should be unique.
# Third arg (optional) is an RBV pv name.
scanPv1 = pvscan.ScanPv('', 1)
scanPv2 = pvscan.ScanPv('', 2)
scanPv3 = pvscan.ScanPv('ESB:XPS1:m6:MOTR', 3, pvtype=1)  # Motor
scanPv4 = pvscan.ScanPv('ESB:XPS1:m3:MOTR', 4, pvtype=1)  # Motor

#--- Shutters -----------------------------------------
# Create Shutter objects.
# Create Shutter objects.
# First argument (required) is the shutter control PV.
### Main program ##########################################################3

if __name__ == "__main__":
    "Do scan routine; log PV data to file as a separate thread if enabled"
    try:
        args='PV_PREFIX'
        def show_usage():
            "Prints usage"
            print 'Usage: %s %s' %(sys.argv[0], args)
        if len(sys.argv) != 2:
            show_usage()
            sys.exit(1)
        pid=os.getpid()
        pvscan.pidPV.put(pid)
        if dataLog1.dataEnable:
            pvscan.Tee(dataLog1.logFilename, 'w')
            pvscan.dataFlag=1  # Start logging data when thread starts
            datalogthread=Thread(target=dataLog1.datalog,args=())
            datalogthread.start()
        scanRoutine()
        sleep(2) # Log data for a little longer
    finally:
        pvscan.dataFlag=0  # Stop logging data 

        
### End ##########################################################################
        

exit