def _control_secular( self, on ): driver = NiDriver( "Dev1/port0/line1" ) driver.write_single( on ) driver.close() self.secular = on
val = 0 for ox in range( -sum_dist, sum_dist ): for oy in range( -sum_dist, sum_dist ): val += image[ (p[1] + oy) * camera.width + p[0] + ox ] data.append( val ) if not i % 10: flourescence = sum( d-data[-1] for d in data[:-1] ) flourescence /= float( len(data)-1 ) print( flourescence ) tlock.request( 'POST', '/feedback', 'ch=0&err={0}'. format( int((flourescence - 45000) / 1000.) ) ) response = tlock.getresponse() if response.status != 200: print( "Could not communicate with temperature lock." ) output.write( '\t'.join( str(d) for d in data ) + '\n' ) output.flush() ni.write_single( False ) time.sleep( 0.001 * wait ) ni.write_single( True ) time.sleep(3.0) finally: #tlock.close() camera.shutdown() ni.close()