Browse files

things are not working right no

  • Loading branch information...
1 parent 49278dc commit d76511b88f905d5f864279bdc4b1d4382008d28f Mathias S committed Mar 11, 2012
View
20 Devices/NEWPORT_AG_UC2.py
@@ -2,6 +2,7 @@
Created on Feb 13, 2012
@author: Mathias
+
'''
import visa
@@ -35,7 +36,6 @@ def __init__(self,port):
self.port = port
self.device = visa.SerialInstrument(self.port, baud_rate=921600)
print self.device.ask('VE').strip()
- print self.getAxisStatus(1)
self.setToRemoteControl()
except:
@@ -46,7 +46,7 @@ def __del__(self):
try:
self.setToLocalMode()
self.device.close()
- print('AG-UC2 connection closed')
+ print('AG-UC2' + '@Port:' + self.port + ' connection closed.')
except:
print 'Unexpected error: ', sys.exc_info()[0]
@@ -104,11 +104,21 @@ def StopMotion(self,AxisNumber):
self.CheckForErrorOfPreviousCommand()
- def getAxisStatus(self,AxisNumber):
+ def get_axis_status(self,AxisNumber):
'''
Returns the axis status
'''
- return self.device.ask(str(AxisNumber)+'TS')
+ return self.device.ask(str(AxisNumber)+'TS').strip()
+ def get_limit_status(self):
+ '''
+ Returns the status of the limits
+ Possible return messages:
+ PH0: No limit switch is active
+ PH1: Limit switch of channel #1 is active, limit switch of channel #2 is not active
+ PH2: Limit switch of channel #2 is active, limit switch of channel #1 is not active
+ PH3: Limit switch of channel #1 and channel #2 are active
+ '''
+ return self.device.ask('PH').strip()
def CheckForErrorOfPreviousCommand(self):
'''
@@ -133,7 +143,7 @@ def setToLocalMode(self):
self.CheckForErrorOfPreviousCommand()
def waitUntilMovementDone(self):
- while self.device.ask('2TS') != '\n2TS0' and self.device.ask('1TS') != '\n1TS0':
+ while self.device.ask('2TS') != '\n2TS0' or self.device.ask('1TS') != '\n1TS0':
time.sleep(0.1)
class PreviousCommandError(Error):
View
21 Devices/Thorlabs_PM100D.py
@@ -16,18 +16,29 @@ def __init__(self,port):
'''
Constructor
'''
- self.port = port
- self.device=visa.Instrument(self.port)
- print self.device.ask('*idn?').strip()
-
+ try:
+ self.port = port
+ self.device=visa.Instrument(self.port)
+ print self.device.ask('*idn?').strip()
+ except:
+ print 'Unexpected error: ', sys.exc_info()[0]
+
def __del__(self):
+ '''
+ Destructor
+ '''
try:
self.device.close()
- print('PM100D connection closed')
+ print('PM100D' + '@Port:' + self.port + ' connection closed')
except:
print 'Unexpected error: ', sys.exc_info()[0]
def getPower(self):
+ '''
+ return:
+ Power in Watt
+ '''
+ self.device.write('pow:unit W')
self.device.write('conf:pow')
return float(self.device.ask("read?"))
View
BIN Documents/17654-D02.pdf
Binary file not shown.
View
49 Experiments/FieldMeasurment_Application.py
@@ -31,8 +31,8 @@
from enthought.traits.ui.menu import Action, CloseAction, Menu, \
MenuBar, NoButtons, Separator
-from numpy import array, linspace, meshgrid, nanmin, nanmax, pi, zeros, ones, save, load
-
+from numpy import array, linspace, meshgrid, nanmin, nanmax, pi, zeros, ones, save, load, \
+ append
from enthought.chaco.tools.api import LineInspector, PanTool, RangeSelection, \
RangeSelectionOverlay, ZoomTool, DragZoom
@@ -47,7 +47,7 @@ class FieldData(HasTraits):
intensity_map = Array
data = Array
index = Array
-
+
class CaptureThread(Thread):
def run(self):
try:
@@ -56,18 +56,39 @@ def run(self):
except:
print "Exception raised: Devices not available"
return
- i = 0
- while i < 100 and not self.wants_abort:
- for j in xrange(0,100):
- self.fd.intensity_map[i,j] = power_meter.getPower()
+ i=0
+ self.fd = array([])
+ while not self.wants_abort: #needs to be improved
+ while stage.AG_UC2_1.get_limit_status() == 'PH0':
stage.left(1, self.step_amplitude)
- stage.up(1,self.step_amplitude)
- i+=1
- for j in xrange(99,-1,-1):
- self.fd.intensity_map[i,j] = power_meter.getPower()
- stage.right(1,self.step_amplitude)
- #stage.up(1,self.step_amplitude)
+ self.fd[i] = append( self.fd[i], [power_meter.getPower()])
stage.forwards(1, self.step_amplitude)
+ i+=1
+ for k in range(1,100): #moving out of the limit
+ stage.right(1, self.step_amplitude)
+ self.fd[i] = append([power_meter.getPower()],self.fd[i])
+ while stage.AG_UC2_1.get_limit_status() == 'PH0':
+ stage.right(1, self.step_amplitude)
+ self.fd[i] = append([power_meter.getPower()], self.fd[i])
+ i+=1
+
+ #i = 0
+ #=======================================================================
+ # while i < 99 and not self.wants_abort:
+ # for j in xrange(0,100):
+ # self.fd.intensity_map[i,j] = power_meter.getPower()*1e6
+ # stage.left(1, self.step_amplitude)
+ # stage.forwards(1, self.step_amplitude)
+ # i+=1
+ # for j in xrange(99,-1,-1):
+ # self.fd.intensity_map[i,j] = power_meter.getPower()*1e6
+ # stage.right(1,self.step_amplitude)
+ # #stage.up(1,self.step_amplitude)
+ # stage.forwards(1, self.step_amplitude)
+ # i+=1
+ #=======================================================================
+
+
print self.fd.intensity_map
class CustomTool(BaseTool):
@@ -179,7 +200,9 @@ def _step_amplitude_changed(self):
@on_trait_change('model.intensity_map')
def updatePlot(self,name,old,new):
if self.plot_data:
+ print 'update plot'
self.plot_data.set_data('imagedata',self.model.intensity_map)
+ self.plot.request_redraw()
def save(self):
"""

0 comments on commit d76511b

Please sign in to comment.