Changeset 708 for moxy/trunk/src


Ignore:
Timestamp:
Dec 8, 2011 4:56:00 PM (13 years ago)
Author:
jemian
Message:

added EPD example of traitsui with dynamic view as test6, can modify and adapt test5 which is direct copy of current moxy gui

Location:
moxy/trunk/src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified moxy/trunk/src/moxy/axes_set.py

    r707 r708  
    2020
    2121from traits.api import *
     22from traitsui.api import *
    2223
    2324from single_axis import SingleAxis
     
    5253    def _stopButton_fired(self):
    5354        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       )
    5577
    5678
  • TabularUnified moxy/trunk/src/moxy/connection.py

    r707 r708  
    3838   
    3939    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
    4141            self.channel = epics.PV(self.pvname)
    4242            #self.channel.get()
     
    4646    def disconnect(self):
    4747        '''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:
    4949            self.channel.remove_callback(self.cb_index)
     50            self.cb_index = 0
    5051        self.channel = None
    5152
  • TabularUnified moxy/trunk/src/moxy/moxy.py

    r707 r708  
    2525
    2626
    27 from traits.api import *
    28 from traitsui.api import *
    29 from traitsui.menu import *
     27from traits.api import *      #@UnusedWildImport
     28from traitsui.api import *    #@UnusedWildImport
     29from traitsui.menu import *   #@UnusedWildImport
    3030
    3131from axes_set import AxesSet
    3232from single_axis import SingleAxis
     33from connection import PvConnection
     34import about
    3335
    3436__svnid__ = "$Id$"
     
    4042
    4143    def show_about(self, uinfo):
    42         '''About this application'''
    43         import about
     44        '''About this application ...'''
    4445        about.About().edit_traits()
    4546
     
    5051    a table of user-defined positions
    5152    '''
    52     axes_sets = List(
     53    axes_list = List(
    5354                    Instance( AxesSet ),
    5455                    help='One or more sets of axes that describe an instrument setting (or settings).'
    5556                )
    56     #axes_sets = [ AxesSet( axes=[SingleAxis()] ) ]
    57     thing = List( Instance( Str ) )
    5857
    5958    status_label = Str('status:')
     
    8281    def connect(self):
    8382        '''Connect all the axes sets with EPICS'''
    84         for a_set in self.axes_sets:
     83        for a_set in self.axes_list:
    8584            a_set.connect()
    8685
    8786    def disconnect(self):
    8887        '''Disconnect all the axes sets from EPICS'''
    89         for a_set in self.axes_sets:
     88        for a_set in self.axes_list:
    9089            a_set.disconnect()
    91    
     90
    9291    view = View(
    9392                Group(
    9493                    UItem( 'axes_sets' ),
    95                     label = 'Moxy axis set',
    9694                    show_border = True,
    9795                    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',
    98104                ),
    99105                title="Moxy (development) GUI",
  • TabularUnified moxy/trunk/src/moxy/runner.py

    r707 r708  
    3838
    3939
     40# =================================================================================
     41
     42
    4043def demo_moxy_plain():
    4144    Moxy().configure_traits()
    4245
    4346
    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
    6049
    6150# TODO: need a view more like the prototype
     
    8372       )
    8473
     74def 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
    8598def 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
    89100   
    90101    # build the test view on-the-fly, based on the number of defined axes
    91102    vg_args = []
    92     qty = len(global_axes)
     103    qty = len(axes)
    93104    grid = []
    94105    grid.append( Heading('motor') )
    95     for axis in global_axes:
     106    for axis in axes:
    96107        grid.append( Heading(axis.name) )
    97108    grid.append( Label('readback') )
     
    107118    traits_context = {}
    108119    for i in range(qty):
    109         axis = global_axes[i]
     120        axis = axes[i]
    110121        traits_context['a%d'%i] = axis
    111122   
    112     #AxesSet().configure_traits()
    113    
    114     # use_notebook  = True
    115    
     123    kw = { 'name' : 'test set of axes'}
     124    kw[ 'axes' ] = axes
    116125    a_set = AxesSet(**kw)
    117126    a_set.connect()
     
    132141              )
    133142    # 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
    134144
    135145single_axis_view = View(
     
    144154    )
    145155
     156
     157# =================================================================================
     158
     159
    146160def demo_single_axis():
    147161    # test routine
     
    154168    single.configure_traits()
    155169    single.disconnect()
     170
     171
     172# =================================================================================
    156173
    157174
     
    173190
    174191
     192# =================================================================================
     193
     194
    175195def pv_connections(axis_name, base_pv):
    176196    '''standardize the connection setup'''
     
    193213
    194214
     215# =================================================================================
     216
     217
    195218if __name__ == '__main__':
    196219    #demo_connection()
    197     demo_single_axis()
     220    #demo_single_axis()
    198221    #demo_axes_set()
    199222    demo_moxy()
  • TabularUnified moxy/trunk/src/moxy/single_axis.py

    r707 r708  
    6969            pv.disconnect()
    7070   
    71     def stop(self):
     71    def stopMotion(self):
    7272        '''tell EPICS to stop moving this axis'''
    7373        if self.stop is not None and self.stop.channel is not None:
  • TabularUnified moxy/trunk/src/test/test4.py

    r707 r708  
    7474            ),
    7575                label = 'group: One',
     76                layout = 'tabbed',
    7677        ),
    7778        Group(
     
    8182
    8283
    83 #DemoLower().configure_traits()
     84DemoLower().configure_traits()
    8485
    8586#-------------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.