def shutDown(self): if self.good: pidevice.StopAll(noraise=True) pitools.waitonready( pidevice ) # there are controllers that need some time to halt all axes pidevice.CloseConnection()
def runwavegen(pidevice): """Configure two wave forms, move to start position and start the wave generators. @type pidevice : pipython.gcscommands.GCSCommands """ assert 2 == len(pidevice.axes[:2]), 'this sample requires two connected axes' wavegens = (1, 2) wavetables = (1, 2) print('define sine and cosine waveforms for wave tables {}'.format(wavetables)) pidevice.WAV_SIN_P(table=wavetables[0], firstpoint=0, numpoints=NUMPOINTS, append='X', center=NUMPOINTS / 2, amplitude=AMPLITUDE[0], offset=STARTPOS[0], seglength=NUMPOINTS) pidevice.WAV_SIN_P(table=wavetables[1], firstpoint=NUMPOINTS / 4, numpoints=NUMPOINTS, append='X', center=NUMPOINTS / 2, amplitude=AMPLITUDE[1], offset=STARTPOS[1], seglength=NUMPOINTS) pitools.waitonready(pidevice) if pidevice.HasWSL(): # you can remove this code block if your controller does not support WSL() print('connect wave generators {} to wave tables {}'.format(wavegens, wavetables)) pidevice.WSL(wavegens, wavetables) if pidevice.HasWGC(): # you can remove this code block if your controller does not support WGC() print('set wave generators {} to run for {} cycles'.format(wavegens, NUMCYLES)) pidevice.WGC(wavegens, [NUMCYLES] * len(wavegens)) if pidevice.HasWTR(): # you can remove this code block if your controller does not support WTR() print('set wave table rate to {} for wave generators {}'.format(TABLERATE, wavegens)) pidevice.WTR(wavegens, [TABLERATE] * len(wavegens), interpol=[0] * len(wavegens)) startpos = (STARTPOS[0], STARTPOS[1] + AMPLITUDE[1] / 2.0) print('move axes {} to their start positions {}'.format(pidevice.axes[:2], startpos)) pidevice.MOV(pidevice.axes[:2], startpos) pitools.waitontarget(pidevice, pidevice.axes[:2]) print('start wave generators {}'.format(wavegens)) pidevice.WGO(wavegens, mode=[1] * len(wavegens)) while any(list(pidevice.IsGeneratorRunning(wavegens).values())): print('.', end='') sleep(1.0) print('\nreset wave generators {}'.format(wavegens)) pidevice.WGO(wavegens, mode=[0] * len(wavegens)) print('done')
def shutDown(self): # Disconnect from the stage if self.good: self.pidevice.StopAll(noraise=True) pitools.waitonready( self.pidevice ) # there are controllers that need some time to halt all axes
def waitonalign(pidevice, routines=None, timeout=60, predelay=0, postdelay=0, polldelay=0.1): """Wait until all fast align 'routines' are finished, i.e. do not run or are paused. @type pidevice : pipython.gcscommands.GCSCommands @param routines : Name of the routines as int, string or list, or None to wait for all routines. @param timeout : Timeout in seconds as float, defaults to 60 seconds. @param predelay : Time in seconds as float until querying any state from controller. @param postdelay : Additional delay time in seconds as float after reaching desired state. @param polldelay : Delay time between polls in seconds as float. """ waitonready(pidevice, timeout, predelay) maxtime = time() + timeout while 2 in list(pidevice.qFRP(routines).values()): if time() > maxtime: raise SystemError('waitonalign() timed out after %.1f seconds' % timeout) sleep(polldelay) sleep(postdelay)
print(pidevice.qDRT()) wavegens = (1, 2) wavetables = (1, 2) pidevice.WAV_LIN(table=wavetables[0], firstpoint=0, numpoints=NUMPOINTS, append='X', speedupdown=100, amplitude=AMPLITUDE, offset=STARTPOS, seglength=NUMPOINTS) # pidevice.WAV_SIN_P(table=wavetables[1], firstpoint=0, numpoints=NUMPOINTS, append='X', # center=NUMPOINTS/2, amplitude=AMPLITUDE, offset=STARTPOS, seglength=NUMPOINTS) pitools.waitonready(pidevice) if pidevice.HasWSL( ): # you can remove this code block if your controller does not support WSL() print('connect wave generators {} to wave tables {}'.format( wavegens, wavetables)) pidevice.WSL(wavegens, wavetables) if pidevice.HasWGC( ): # you can remove this code block if your controller does not support WGC() print('set wave generators {} to run for {} cycles'.format( wavegens, NUMCYLES)) pidevice.WGC(wavegens, [NUMCYLES] * len(wavegens)) # if pidevice.HasWTR(): # you can remove this code block if your controller does not support WTR() # print('set wave table rate to {} for wave generators {}'.format(TABLERATE, wavegens)) # pidevice.WTR(wavegens, [TABLERATE] * len(wavegens), interpol=[0] * len(wavegens)) # startpos = (STARTPOS[0], STARTPOS[1] + AMPLITUDE[1] / 2.0) # print('move axes {} to their start positions {}'.format(pidevice.axes[:2], startpos))