This piece of code simulates a scan with two plots overlaid. The data being sent to pyspMonitor. See figure 7.1.4
#!/usr/bin/env python3
import time, sys, random
import HasyUtils, PySpectra
import math
def main():
(status, wasLaunched) = PySpectra.assertPyspMonitorRunning()
ret = PySpectra.toPyspMonitor( { 'command': ["cls", "delete"]})
if ret[ 'result'].upper() != 'DONE':
print( "error from pyspMonitor %s" % ret[ 'result'])
return
ret = PySpectra.toPyspMonitor( { 'command': ["setTitle \"An important title\"",
"setComment \"An interesting comment\""]})
max = 101
ret = PySpectra.toPyspMonitor( {'Scan': { 'name': 'sinus',
'xMin': 0., 'xMax': 10.,
'yMin': -1., 'yMax': 1.,
'lineColor': 'red',
'nPts': max,
'autoscaleX': False, 'autoscaleY': False}})
ret = PySpectra.toPyspMonitor( {'Scan': { 'name': 'cosinus',
'xMin': 0., 'xMax': 10.,
'yMin': -1., 'yMax': 1.,
'lineColor': 'blue',
'nPts': max,
'autoscaleX': False, 'autoscaleY': False}})
PySpectra.toPyspMonitor( { 'command': ['overlay cosinus sinus']})
for i in range( max):
pos = float(i/10.)
posY = math.sin( i/10.)
PySpectra.toPyspMonitor( { 'command': ['setXY sinus %d %s %s' % (i, repr(pos), repr(posY))]})
posY = math.cos( i/10.)
PySpectra.toPyspMonitor( { 'command': ['setXY cosinus %d %s %s' % (i, repr(pos), repr(posY))]})
PySpectra.toPyspMonitor( { 'command': ["display"]})
time.sleep( 0.1)
return
if __name__ == "__main__":
import PySpectra.pySpectraGuiClass
app = PySpectra.QApplication(sys.argv)
gui = PySpectra.pySpectraGuiClass.pySpectraGui( flagExitOnClose = True)
gui.show()
main()