The following piece of code simulates a scan using toPyspLocal(). The syntax is the same as for toPyspMonitor, see 7.2.2 and 7.2.2.
#!/usr/bin/env python3
#
# this script simulates a scan. Pairs of x- and y-values are plotted
# via toPyspLocal()
#
import random, time
import PySpectra, HasyUtils
def main():
ret = PySpectra.toPyspLocal( { 'command': ["cls", "delete"]})
if ret[ 'result'].upper() != 'DONE':
print( "error from pyspMonitor %s" % ret[ 'result'])
return
ret = PySpectra.toPyspLocal( { 'command': ["setTitle \"An important title\"",
"setComment \"An interesting comment\""]})
max = 101
name = "TestScan"
ret = PySpectra.toPyspLocal( {'Scan': { 'name': name,
'xMin': 0., 'xMax': 100.,
'yMin': 0., 'yMax': 1.,
'symbol': '+','symbolColor': 'red',
'symbolSize': 7, 'lineColor': 'blue',
'nPts': max,
'autoscaleX': False, 'autoscaleY': True}})
for i in range( max):
pos = float(i)
posY = random.random()*10
PySpectra.toPyspLocal( { 'command': ['setXY %s %d %s %s' % (name, i, repr(pos), repr(posY))]})
PySpectra.toPyspLocal( { 'command': ["display"]})
time.sleep( 0.1)
print( "Press <space> to quit")
while 1:
PySpectra.processEvents()
key = HasyUtils.inkey()
if key == 32:
return
time.sleep( 0.1)
return
if __name__ == "__main__":
main()