The script below uses the state from an input register to sense whether the MoveLoop() should be paused() or resumed().
#!/usr/bin/env python import time, sys import HasyUtils, Spectra import PyTango def main(): # # x - the sweep motor # (nameX, startX, stopX, sweepTime) = ("d1_mot66", 0., 0.2, 2.) (nameY, startY, stopY, deltaY) = ("d1_mot67", 0.1, 0.21, 0.01) # # use sleepTime and sweepTime to estimate the no. of points in x # sleepTime = 0.1 overHead = 0.1 npX = 2.*sweepTime/(sleepTime + overHead) npY = abs(int((stopY - startY)/deltaY + 1)) + 10 iregProxy = PyTango.DeviceProxy( "p09/register/d1.in01") try: o = HasyUtils.moveLoop( nameX, startX, stopX, sweepTime, nameY, startY, stopY, deltaY) except Exception, e: print "Exception from moveLoop() constructor" print repr( e) sys.exit( 255) try: o.toStart() except Exception, e: print "Exception from ToStart" print repr( e) sys.exit( 255) while o.state() == PyTango.DevState.MOVING: print "toStart: posX %g, posY %g" % ( o.proxyX.Position, o.proxyY.Position) time.sleep( 1.0) startTime = time.time() o.runNormal() print "runNormal takes %gs" % (time.time() - startTime) scanMesh = HasyUtils.scanMesh( nameX = nameX, nameY = nameY, comment = "%s: (%g, %g, %g), %s: (%g, %g, %g)" %\ (nameX, startX, stopX, sweepTime, nameY, startY, stopY, deltaY), startX = min( startX, stopX), stopX = max( startX, stopX), npX = npX, startY = min( startY, stopY) , stopY = max( startY, stopY), npY = npY) try: o.toStart() except Exception, e: print "Exception from ToStart" print repr( e) sys.exit( 255) while o.state() == PyTango.DevState.MOVING: print "toStart: posX %g, posY %g" % ( o.proxyX.Position, o.proxyY.Position) time.sleep( 1.0) o.run() startTime = time.time() count = 0 paused = False while paused or o.state() == PyTango.DevState.MOVING: if not paused: scanMesh.setX( count, o.proxyX.Position) scanMesh.setY( count, o.proxyY.Position) scanMesh.display() count += 1 time.sleep( sleepTime) else: time.sleep( 1.0) if not paused and iregProxy.Value == 1: o.pause() paused = True elif paused and iregProxy.Value == 0: o.resume() paused = False print "run takes %gs" % (time.time() - startTime) (sts, result) = Spectra.gra_yesno( "Enter Spectra") if result == 1: Spectra.gra_input() if __name__ == "__main__": main()