Exemplo n.º 1
0
 def rawAsynchronousMoveTo(self, mode):
     if mode not in SourceMode.SOURCE_MODES:
         print "mode string is wrong: legal values are %s" % (
             SourceMode.SOURCE_MODES)
         return
     self.amIBusy = True  # need to block to ensure script run complete before any other actions
     if mode == SourceMode.SOURCE_MODES[0]:
         GeneralCommands.run(self.remove_zacscan_script)
         sleep(1)
         if installation.isLive():
             GeneralCommands.run(self.idd_fast_energy_scan_script)
         else:
             print("zacscan is not available in DUMMY mode")
     elif mode == SourceMode.SOURCE_MODES[1]:
         GeneralCommands.run(self.remove_zacscan_script)
         sleep(1)
         if installation.isLive():
             GeneralCommands.run(self.idu_fast_energy_scan_script)
         else:
             print("zacscan is not available in DUMMY mode")
     elif mode == SourceMode.SOURCE_MODES[
             2] or mode == SourceMode.SOURCE_MODES[3]:
         GeneralCommands.run(self.remove_zacscan_script)
         sleep(1)
     else:
         print "Input mode is wrong: legal values %s or [SourceModeScannable.idd, SourceModeScannable.idu, SourceModeScannable.dpu, SourceModeScannable.dmu]." % (
             SourceMode.SOURCE_MODES)
         self.mode = SourceMode.SOURCE_MODES[4]
         raise ValueError("Input mode %s is not supported." % (str(mode)))
     self.mode = mode
     self.amIBusy = False
 def pescan(self, frequency=0.1,exposure=0.5,amplitude=5.0,numPoints=40, func=2, bncycle=1):
     self.directory=PathConstructor.createFromDefaultProperty()
     self.scanNumber=scanNumTracker.incrementNumber()
     self.filename=self.directory+(str(self.scanNumber))
     print self.filename
     if self.adc.getMode()=="Continuous":
         self.setupADC2()
     elif self.adc.getMode()=="Trigger":
         self.configADC(200, self.adcClockRate(frequency))
     self.calculateExperimentParameters(frequency, exposure, numPoints)
     self.setupFG(freq=frequency,amp=amplitude,bncycle=self.numGates)
     self.sampleConditioning(func=6, bncycle=1)
     self.configTFG(frequency)
     #self.setupDataCapturer()
     print "open fast shutter %d" % time()
     self.fastshutter.moveTo("OPEN")
     if self.adc.getMode()=="Trigger":
         print "enable adc sampling"
         self.adc.enable()
     try:
         for i in range(self.numCycles):
             GeneralCommands.pause()
             #while not self.gateDetectorCompleted or not self.adcStreamerCompleted:
                 #if not self.gateDetectorCompleted:
                     # print "wait PSD to complete..."
                 #if not self.adcStreamerCompleted:
                     #    print "wait ADC to finish PE data capture..."
                 #sleep(1.0)
             self.startDetector(frequency, self.scanNumber, i)
             #sleep(1.0)
             if self.adc.getMode()=="Trigger":
                 print "enable adc sampling"
                 self.adc.enable()
             elif self.adc.getMode()=="Continuous":
                 if frequency<=0.1:
                     self.startPEDataStreamer(self.filename+"_peg_"+str(i)+".h5", 1/frequency+TIME_FUDGE_FACTOR_IN_SECONDS)
                 else:
                     self.startPEDataStreamer(self.filename+"_peg_"+str(i)+".h5", 1/frequency*self.numGates*self.numFrames*self.numDefinedSequency+TIME_FUDGE_FACTOR_IN_SECONDS)
             self.tfg.start()
             if frequency<=0.1:
                 sleep(1/frequency+GDAPROCESSTIME)
             else:
                 sleep(1/frequency*self.numGates*self.numFrames*self.numDefinedSequency+GDAPROCESSTIME*self.numDefinedSequency)
             # while self.tfg.status() != "RUNNING":
                 # sleep(0.025)
             # while self.tfg.status() != "IDLE":
                 # print self.tfg.progress()
                 # sleep(self.livetime)
             #self.pedata.save(self.filename, i)
     except:
         raise
     finally:
         print "close fast shutter %d" % time()
         self.fastshutter.moveTo("CLOSE")
         print "collection completed at %d" % time()
         self.stop()
 def stop(self): 
     print "%s: stop called at %d" % (self.getName(),time())
     GeneralCommands.pause()
     self.pedata.removeMonitors()        # ensure monitor removed
     self.tfg.stop()
     self.fg.setOutput(0)
     self.adc.disable()
     self.detector.stop()
     self.resetDetector()
     self.gateDetectorCompleted=True
     self.adcStreamerCompleted=True
Exemplo n.º 4
0
 def recollect(self, startCycleNumber,startSeqNumber,frequency, numGates,numDefinedSequency,numCycles, filename):
     self.fastshutter.moveTo("OPEN")
     self.pedata.removeMonitors()
     self.setupDataCapturer(filename, numGates)
     for j in range(startCycleNumber,numCycles):
                 self.pedata.reset()
                 self.pedata.setCollectionNumber(j)
                 #self.startDetector(frequency, self.scanNumber, j)
                 for i in range(startSeqNumber, numDefinedSequency):
                     GeneralCommands.pause()
                     sleep(4.0)
                     self.tfg.config_cycle_for_seq(i, numGates, 1)
                     sleep(4.0)
                     if self.adc.getMode()=="Trigger":
                         print "enable adc sampling"
                         self.adc.enable()
                     #elif self.adc.getMode()=="Continuous":
                     self.startPEDataStreamer(filename+"_pe_"+str(i)+".h5", 1/frequency*self.numGates+TIME_FUDGE_FACTOR_IN_SECONDS)
                     self.tfg.start()
                     sleep(1/frequency*self.numGates+GDAPROCESSTIME)
     self.pedata.removeMonitors()
Exemplo n.º 5
0
 def __init__(self, name, defaultmode='unknown'):
     '''
     Constructor - default source mode is 'idd'
     '''
     self.setName(name)
     self.amIBusy = False
     self.mode = defaultmode
     self.idd_fast_energy_scan_script = str(
         gda_git_loc +
         "/gda-diamond.git/configurations/i06-shared/scripts/i06shared/scan/idd_fast_energy_scan.py"
     )
     self.idu_fast_energy_scan_script = str(
         gda_git_loc +
         "/gda-diamond.git/configurations/i06-shared/scripts/i06shared/scan/idu_fast_energy_scan.py"
     )
     self.remove_zacscan_script = str(
         gda_git_loc +
         "/gda-diamond.git/configurations/i06-shared/scripts/i06shared/scan/remove_zacscan.py"
     )
     if installation.isLive():
         GeneralCommands.run(self.idd_fast_energy_scan_script)
Exemplo n.º 6
0
 def pescan(self, frequency=0.1,exposure=0.5,amplitude=5.0,numPoints=40, function=2, bncycle=1):
     self.directory=PathConstructor.createFromDefaultProperty()
     self.scanNumber=scanNumTracker.incrementNumber()
     self.filename=self.directory+(str(self.scanNumber))
     print self.filename
     if self.adc.getMode()=="Gate":
         self.setupADC2()
     elif self.adc.getMode()=="Trigger":
         self.configADC(200, self.adcClockRate(frequency))
     self.calculateExperimentParameters(frequency, exposure, numPoints)
     self.setupFG(freq=frequency,amp=amplitude,bncycle=self.numGates, func=function)
     # must in following order
     if self.isSampleConditioning():
         self.sampleConditioning(func=6, bncycle=1)
     self.configTFG(frequency)
     self.setupDataCapturer(self.filename, self.numGates)
     print "open fast shutter %d" % time()
     self.fastshutter.moveTo("OPEN")
     try:
         if frequency <= self.boundaryFrequency:
             for i in range(self.numCycles):
                 GeneralCommands.pause()
                 self.pedata.reset()
                 self.pedata.setCollectionNumber(i)
                 print "\ncollecting %d frames, %d gates per frame, Scan number %d, Collection number %d" % (self.numFrames*self.numDefinedSequency, self.numGates, self.scanNumber, i)
                 Thread(target=self.gateDetector, name="MythenGatedCollection", args=(self.numFrames, self.numGates, self.scanNumber, i), kwargs={}).start()
                 sleep(1)
                 #self.startDetector(frequency, self.scanNumber, i)
                 if self.adc.getMode()=="Trigger":
                     print "enable adc sampling"
                     self.adc.enable()
                 #elif self.adc.getMode()=="Continuous":
                 self.startPEDataStreamer(self.filename+"_pe_"+str(i)+".h5", 1/frequency+TIME_FUDGE_FACTOR_IN_SECONDS)
                 self.tfg.start()
                 sleep(1/frequency+GDAPROCESSTIME)
         else:
             finder=Finder.getInstance()
             print "\nPlease start PSD collection from Mythen QT client ..."
             print "    1. select 'Gated' option in the 'Runs' box first"
             print "    2. then set 'Acquisition time' to %d, 'Repetitions' to %d" % (self.numGates, self.numFrames * self.numDefinedSequency*self.numCycles)
             print "    3. set 'Output Directory' to subdirector %s under 'processing' directory, 'File name root' to %d, 'Start index' to %d" % (finder.find("GDAMetadata").getMetadataValue("subdirectory"), self.scanNumber, 0)
             target = requestInput("Is PSD ready, Yes or No?")
             print str(target)
             if str(target)!="Yes":
                 raise "Exiting program"
             for j in range(self.startCycleNumber,self.numCycles):
                 self.pedata.reset()
                 self.pedata.setCollectionNumber(j)
                 #self.startDetector(frequency, self.scanNumber, j)
                 for i in range(self.startSeqNumber, self.numDefinedSequency):
                     GeneralCommands.pause()
                     sleep(4.0)
                     self.tfg.config_cycle_for_seq(i, self.numGates, 1)
                     sleep(4.0)
                     if self.adc.getMode()=="Trigger":
                         print "enable adc sampling"
                         self.adc.enable()
                     #elif self.adc.getMode()=="Continuous":
                     self.startPEDataStreamer(self.filename+"_pe_"+str(i)+".h5", 1/frequency*self.numGates+TIME_FUDGE_FACTOR_IN_SECONDS)
                     self.tfg.start()
                     sleep(1/frequency*self.numGates+GDAPROCESSTIME)
     except:
         self.stop()
         raise
     finally:
         print "close fast shutter %d" % time()
         self.fastshutter.moveTo("CLOSE")
         self.pedata.removeMonitors()
         print "collection completed at %d" % time()
 def stop(self):
     print "    %s: stop called at %d" % (self.getName(), time())
     GeneralCommands.pause()
     self.tfg.stop()
     self.detector.stop()
Exemplo n.º 8
0
def interruptable():
    GeneralCommands.pause()