Changeset 708 for moxy/trunk/src
- Timestamp:
- Dec 8, 2011 4:56:00 PM (13 years ago)
- Location:
- moxy/trunk/src
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified moxy/trunk/src/moxy/axes_set.py ¶
r707 r708 20 20 21 21 from traits.api import * 22 from traitsui.api import * 22 23 23 24 from single_axis import SingleAxis … … 52 53 def _stopButton_fired(self): 53 54 for axis in self.axes: 54 axis.stop() 55 axis.stopMotion() 56 57 ''' should show something like this:: 58 59 vgrid = VGrid( 60 Label('field'), Label('X axis'), Label('Y axis'), 61 Label('readback (RBV)'), UReadonly('x_RBV'), UReadonly('y_RBV'), 62 Label('target (VAL)'), UItem('x_VAL'), UItem('y_VAL'), 63 columns = 3, 64 show_border=True, 65 ) 66 View( vgrid, UItem('stopButton'), ) 67 68 ''' 69 70 axes_set_view = View( 71 UItem('name', springy=True), 72 UItem('configButton'), 73 UItem('axes', springy=True, style='custom'), 74 UItem('stopButton'), 75 UItem('axes[0]', springy=True, style='custom'), 76 ) 55 77 56 78 -
TabularUnified moxy/trunk/src/moxy/connection.py ¶
r707 r708 38 38 39 39 def connect(self, callback = None): 40 if len(self.pvname.strip()) > 0: 40 if len(self.pvname.strip()) > 0: # PV name must not be an empty string 41 41 self.channel = epics.PV(self.pvname) 42 42 #self.channel.get() … … 46 46 def disconnect(self): 47 47 '''stop monitoring the PV for CA callbacks and drop the channel''' 48 if self.cb_index != 0 :48 if self.cb_index != 0 and self.channel is not None: 49 49 self.channel.remove_callback(self.cb_index) 50 self.cb_index = 0 50 51 self.channel = None 51 52 -
TabularUnified moxy/trunk/src/moxy/moxy.py ¶
r707 r708 25 25 26 26 27 from traits.api import * 28 from traitsui.api import * 29 from traitsui.menu import * 27 from traits.api import * #@UnusedWildImport 28 from traitsui.api import * #@UnusedWildImport 29 from traitsui.menu import * #@UnusedWildImport 30 30 31 31 from axes_set import AxesSet 32 32 from single_axis import SingleAxis 33 from connection import PvConnection 34 import about 33 35 34 36 __svnid__ = "$Id$" … … 40 42 41 43 def show_about(self, uinfo): 42 '''About this application''' 43 import about 44 '''About this application ...''' 44 45 about.About().edit_traits() 45 46 … … 50 51 a table of user-defined positions 51 52 ''' 52 axes_ sets= List(53 axes_list = List( 53 54 Instance( AxesSet ), 54 55 help='One or more sets of axes that describe an instrument setting (or settings).' 55 56 ) 56 #axes_sets = [ AxesSet( axes=[SingleAxis()] ) ]57 thing = List( Instance( Str ) )58 57 59 58 status_label = Str('status:') … … 82 81 def connect(self): 83 82 '''Connect all the axes sets with EPICS''' 84 for a_set in self.axes_ sets:83 for a_set in self.axes_list: 85 84 a_set.connect() 86 85 87 86 def disconnect(self): 88 87 '''Disconnect all the axes sets from EPICS''' 89 for a_set in self.axes_ sets:88 for a_set in self.axes_list: 90 89 a_set.disconnect() 91 90 92 91 view = View( 93 92 Group( 94 93 UItem( 'axes_sets' ), 95 label = 'Moxy axis set',96 94 show_border = True, 97 95 scrollable = True, 96 layout = 'tabbed', 97 ), 98 Group( 99 UItem( 'axes_sets' ), 100 label = 'again', 101 show_border = True, 102 scrollable = True, 103 layout = 'tabbed', 98 104 ), 99 105 title="Moxy (development) GUI", -
TabularUnified moxy/trunk/src/moxy/runner.py ¶
r707 r708 38 38 39 39 40 # ================================================================================= 41 42 40 43 def demo_moxy_plain(): 41 44 Moxy().configure_traits() 42 45 43 46 44 def demo_moxy(): 45 kw = { 'name' : 'test set of axes'} 46 axes = single_axis_setup(x='prj:m1', y='prj:m2') # two test motor records 47 kw[ 'axes' ] = axes 48 axes_sets = [AxesSet(**kw) ] 49 50 outer = { 51 'axes_sets' : axes_sets, 52 } 53 54 mxy = Moxy( **outer ) 55 mxy.connect() 56 for axis in axes: 57 print axis.desc.channel.get() 58 mxy.configure_traits() # needs a custom view 59 mxy.disconnect() 47 # ================================================================================= 48 60 49 61 50 # TODO: need a view more like the prototype … … 83 72 ) 84 73 74 def demo_moxy(): 75 kw = { 'name' : 'test set of axes'} 76 axes_xy = single_axis_setup(x='prj:m1', y='prj:m2') # two test motor records 77 axes_uvw = single_axis_setup(u='prj:m3', v='prj:m4', w='prj:m5') # three test motor records 78 kw[ 'axes' ] = axes_xy 79 axes_sets = [AxesSet(**{'name': 'xy ', 'axes': axes_xy}), 80 AxesSet(**{'name': 'uvw', 'axes': axes_uvw}) ] 81 82 outer = { 83 'axes_sets' : axes_sets, 84 } 85 86 mxy = Moxy( **outer ) 87 mxy.connect() 88 for a_set in axes_sets: 89 for axis in a_set.axes: 90 print a_set.name + ", ", axis.desc.channel.get(), ' = ', axis.rbv.channel.get() 91 mxy.configure_traits() # needs a custom view 92 mxy.disconnect() 93 94 95 # ================================================================================= 96 97 85 98 def demo_axes_set(): 86 kw = { 'name' : 'test set of axes'} 87 global_axes = single_axis_setup(x='prj:m1', y='prj:m2') # two test motor records 88 kw[ 'axes' ] = global_axes 99 axes = single_axis_setup(x='prj:m1', y='prj:m2') # two test motor records 89 100 90 101 # build the test view on-the-fly, based on the number of defined axes 91 102 vg_args = [] 92 qty = len( global_axes)103 qty = len(axes) 93 104 grid = [] 94 105 grid.append( Heading('motor') ) 95 for axis in global_axes:106 for axis in axes: 96 107 grid.append( Heading(axis.name) ) 97 108 grid.append( Label('readback') ) … … 107 118 traits_context = {} 108 119 for i in range(qty): 109 axis = global_axes[i]120 axis = axes[i] 110 121 traits_context['a%d'%i] = axis 111 122 112 #AxesSet().configure_traits() 113 114 # use_notebook = True 115 123 kw = { 'name' : 'test set of axes'} 124 kw[ 'axes' ] = axes 116 125 a_set = AxesSet(**kw) 117 126 a_set.connect() … … 132 141 ) 133 142 # TODO: Can I make a green border appear if moving? That's in the View! 143 # Easier (not as compact) to make text appear/not based on a Bool 134 144 135 145 single_axis_view = View( … … 144 154 ) 145 155 156 157 # ================================================================================= 158 159 146 160 def demo_single_axis(): 147 161 # test routine … … 154 168 single.configure_traits() 155 169 single.disconnect() 170 171 172 # ================================================================================= 156 173 157 174 … … 173 190 174 191 192 # ================================================================================= 193 194 175 195 def pv_connections(axis_name, base_pv): 176 196 '''standardize the connection setup''' … … 193 213 194 214 215 # ================================================================================= 216 217 195 218 if __name__ == '__main__': 196 219 #demo_connection() 197 demo_single_axis()220 #demo_single_axis() 198 221 #demo_axes_set() 199 222 demo_moxy() -
TabularUnified moxy/trunk/src/moxy/single_axis.py ¶
r707 r708 69 69 pv.disconnect() 70 70 71 def stop (self):71 def stopMotion(self): 72 72 '''tell EPICS to stop moving this axis''' 73 73 if self.stop is not None and self.stop.channel is not None: -
TabularUnified moxy/trunk/src/test/test4.py ¶
r707 r708 74 74 ), 75 75 label = 'group: One', 76 layout = 'tabbed', 76 77 ), 77 78 Group( … … 81 82 82 83 83 #DemoLower().configure_traits()84 DemoLower().configure_traits() 84 85 85 86 #-------------------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.