Definition at line 37 of file dstp_data_fit.py. 00037 : 00038 if data.quit_server: 00039 s.close() 00040 #tell the server to pass shutdown commands to this routine 00041 s.listen("quit_server", quit_server) 00042 00043 try: 00044 loopcount=0 00045 00046 def run_fit(string): 00047 global loopcount 00048 00049 try: 00050 #note that arrays get passed flattened, and with the original dimensioning info in a tuple with the array. I will fix this later. 00051 (xl,x),(yl,y)=data.XY 00052 00053 #print x,y 00054 loopcount += 1 #make sure each time we send data, this is different, so LabVIEW notices the change 00055 00056 y*=7.0 #bogus data processing (put real fitting here) 00057 00058 data.fitparms=[loopcount,y,math.sqrt(Numeric.sum((y-1)*(y-1))), y-1] #send computed results back to LabVIEW 00059 00060 except: #clean up on errors 00061 traceback.print_exc() #dump what went wrong, then close the server so we can edit the program 00062 s.close() 00063 00064 #tell the server that any time new data appears in 'xyvals' to call 'run_fit' 00065 s.listen("xyvals", run_fit) 00066 00067 #start server 00068 s.serve() 00069 00070 finally: #clean up on exit or errors 00071 s.close() 00072 time.sleep(1) time.sleep(1)
|