toPyspMonitor()

Here is a code snippet demonstrating the use of toPyspMonitor():

# 
# this piece of code can only be executed,   
# if the pyspMonitor.py is running
#
import PySpectra as pysp
import random
MAX = 5
pos = [float(n)/MAX for n in range( MAX)]
d1 = [random.random() for n in range( MAX)]
d2 = [random.random() for n in range( MAX)]

print "pos", repr( pos)
print "d1:", repr( d1)

hsh = { 'putData': 
           {'title': "Important Data", 
            'columns': 
            [ { 'name': "d1_mot01", 'data' : pos},
              { 'name': "d1_c01", 'data' : d1},
              { 'name': "d1_c02", 'data' : d2},
           ]}}

hsh = pysp.toPyspMonitor( hsh)
print "return values of putData:", repr( hsh) 

hsh = pysp.toPyspMonitor( { 'getData': True})
for i in range( MAX):
    if pos[i] != hsh[ 'getData']['d1_c01']['x'][i]:
        print "error: pos[i] != x[i]"
    if d1[i] != hsh[ 'getData'][ 'd1_c01'][ 'y'][i]:
        print "error: d1[i] != y[i]"
        
print "getData, pos:", hsh[ 'getData']['d1_c01']['x']
print "getData, pos:", hsh[ 'getData']['d1_c01']['y']
return



2019-11-13