Changeset 836


Ignore:
Timestamp:
Apr 26, 2012 12:00:14 PM (10 years ago)
Author:
jemian
Message:

refactoring complete, copyrights updated to this year

Location:
moxy/trunk/src/moxy
Files:
4 edited
5 moved

Legend:

Unmodified
Added
Removed
  • moxy/trunk/src/moxy/model/axis.py

    r835 r836  
    1212details about a model single axis
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
     
    2020
    2121
    22 import m_pv
    23 import paxis
     22from pv import GetBasePv, pvIsAvailable, pvIsMotorRec, GetRTYP
     23import pseudo_axis
    2424
    2525
     
    6060        self.axis = None
    6161        if isMotorRecord:
    62             pv = m_pv.GetBasePv(val)
    63             if not m_pv.pvIsAvailable(pv, timeout = 0.5):
     62            pv = GetBasePv(val)
     63            if not pvIsAvailable(pv, timeout = 0.5):
    6464                raise Exception, "Could not connect with PV: " + pv
    65             if not m_pv.pvIsMotorRec(pv):
    66                 raise Exception, "%s.RTYP = %s, must be 'motor'" % (pv, m_pv.GetRTYP(pv))
    67             self.axis = paxis.Motor(val)
     65            if not pvIsMotorRec(pv):
     66                raise Exception, "%s.RTYP = %s, must be 'motor'" % (pv, GetRTYP(pv))
     67            self.axis = pseudo_axis.Motor(val)
    6868        else:
    6969            # elegant, but hard to read, need better feedback if PV not found
     
    7171            #ready = reduce(lambda x, y: x and y, status)
    7272            for pv in (val, rbv, desc, egu, dmov, stop):
    73                 if not m_pv.pvIsAvailable(pv):
     73                if not pvIsAvailable(pv):
    7474                    raise Exception, "Could not connect with PV: " + pv
    75             self.axis = paxis.PAxis(val, rbv, desc, egu, dmov, stop)
     75            self.axis = pseudo_axis.PAxis(val, rbv, desc, egu, dmov, stop)
    7676        if self.axis is None:
    7777            raise Exception, "Did not connect axis: " + name
     
    126126    '''demonstrate use of this module'''
    127127    from time import sleep
    128     pv = "prj:m1"
     128    pvname = "prj:m1"
    129129   
    130     motor = SingleAxis( name = "test axis", val = pv, isMotorRecord = True, )
     130    motor = SingleAxis( name = "test axis", val = pvname, isMotorRecord = True, )
    131131    motor.connect(handler=handler)
    132     name = motor.axis.DESC
     132    description = motor.axis.DESC
    133133    motor.axis.DESC = "new name"
    134134    sleep(1)
    135     motor.axis.DESC = name
     135    motor.axis.DESC = description
    136136    sleep(1)
    137137
     
    145145   
    146146    non_motor = SingleAxis( name = "second axis", isMotorRecord = False,
    147                             val = pv + '.VAL',
    148                             rbv = pv + '.RBV',
    149                             desc = pv + '.DESC',
    150                             egu = pv + '.EGU',
    151                             dmov = pv + '.DMOV',
    152                             stop = pv + '.STOP',
     147                            val  = pvname + '.VAL',
     148                            rbv  = pvname + '.RBV',
     149                            desc = pvname + '.DESC',
     150                            egu  = pvname + '.EGU',
     151                            dmov = pvname + '.DMOV',
     152                            stop = pvname + '.STOP',
    153153                            )
    154154    non_motor.connect(handler=handler)
  • moxy/trunk/src/moxy/model/pseudo_axis.py

    r834 r836  
    1111'''
    1212Pseudo-motor (axis, positioner, whatever) object.
     13
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
     15See LICENSE file for details.
     16
     17
    1318Provides abstraction for an EPICS motor record and
    1419a more generic "axis" positioner, defined by individual EPICS PVs.
  • moxy/trunk/src/moxy/model/pv.py

    r835 r836  
    1212details about a model single PV connection
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
  • moxy/trunk/src/moxy/model/set.py

    r835 r836  
    1212details about a model set of coordinated axes
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
     
    2020
    2121
    22 from m_axis import SingleAxis
     22from axis import SingleAxis
    2323
    2424
  • moxy/trunk/src/moxy/model/settings.py

    r834 r836  
    1010
    1111'''
    12 comment
     12provides for a table of user-labeled axis positions
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
  • moxy/trunk/src/moxy/moxy_wx/axis.py

    r834 r836  
    1010
    1111'''
    12 demo view for EPICS PV connection class: m_axis.SingleAxis()
    13 
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     12demo view for EPICS PV connection class: moxy.model.axis.SingleAxis()
     13
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
     
    2222import wx.lib.buttons
    2323import wx.lib.stattext
    24 import m_pv
    25 import m_axis
     24import moxy.model.pv
     25from moxy.model.axis import SingleAxis
    2626import epics.wx
    2727
     
    5757    :param obj parent: panel or frame that contains this panel
    5858    :param axis: set of PVs that describe the operation of this axis
    59     :type axis: m_axis.SingleAxis object
     59    :type axis: moxy.model.axis.SingleAxis object
    6060    '''
    6161   
     
    126126        position_sizer = self._Make_Positions_Sizer( panel )
    127127       
    128         controlsButton = Make_My_Button(panel,
     128        controlsButton = axis_Button(panel,
    129129                                         label=u'more',
    130130                                         name='controlsButton',
     
    132132                                         binding=self.doMotorControlsButton)
    133133       
    134         stopButton = Make_My_Button(panel,
     134        stopButton = axis_Button(panel,
    135135                                         label=u'Stop',
    136136                                         name='stopButton',
     
    186186        self.w_readback.SetToolTipString(u'readback value')
    187187   
    188         self.w_target = Make_My_TextEntry(parent, '',
     188        self.w_target = axis_TextEntry(parent, '',
    189189                False, u'target value', self.doTargetEntry)
    190190       
     
    234234            pv = self.axis_parent.axis.axis.get_pv('VAL').pvname
    235235            parent = wx.GetTopLevelParent(self.axis_parent)
    236             MotorControlsFrame(parent, m_pv.GetBasePv(pv))
     236            MotorControlsFrame(parent, moxy.model.pv.GetBasePv(pv))
    237237        else:
    238238            msg = "This axis is not an EPICS motor record."
     
    368368       
    369369        this_axis = self.axis_parent.axis
    370         self.w_name = Make_My_TextEntry(parent, this_axis.name,
     370        self.w_name = axis_TextEntry(parent, this_axis.name,
    371371                        True, u'local name for this axis',
    372372                        self.doConfigureHandler)
    373         self.w_VAL_pv = Make_My_TextEntry(parent,
     373        self.w_VAL_pv = axis_TextEntry(parent,
    374374                            this_axis.axis.get_pv('VAL').pvname,
    375375                            True, u'EPICS PV name for target position',
     
    381381        self.w_isMotor.Bind(wx.EVT_CHECKBOX, self.doCheckboxClick)
    382382       
    383         self.w_RBV_pv = Make_My_TextEntry(parent,
     383        self.w_RBV_pv = axis_TextEntry(parent,
    384384                            this_axis.axis.get_pv('RBV').pvname,
    385385                            True, u'EPICS PV name for readback position',
    386386                            self.doConfigureHandler)
    387         self.w_EGU_pv = Make_My_TextEntry(parent,
     387        self.w_EGU_pv = axis_TextEntry(parent,
    388388                            this_axis.axis.get_pv('EGU').pvname,
    389389                            True, u'EPICS PV name for engineering units',
    390390                            self.doConfigureHandler)
    391         self.w_DESC_pv = Make_My_TextEntry(parent,
     391        self.w_DESC_pv = axis_TextEntry(parent,
    392392                            this_axis.axis.get_pv('DESC').pvname,
    393393                            True, u'EPICS PV name for description',
    394394                            self.doConfigureHandler)
    395         self.w_DMOV_pv = Make_My_TextEntry(parent,
     395        self.w_DMOV_pv = axis_TextEntry(parent,
    396396                            this_axis.axis.get_pv('DMOV').pvname,
    397397                            True, u'EPICS PV name for motion is done',
    398398                            self.doConfigureHandler)
    399         self.w_STOP_pv = Make_My_TextEntry(parent,
     399        self.w_STOP_pv = axis_TextEntry(parent,
    400400                            this_axis.axis.get_pv('STOP').pvname,
    401401                            True, u'EPICS PV name for STOP moving command',
     
    403403        if this_axis.isMotorRecord:
    404404            val_pv = this_axis.axis.get_pv('VAL').pvname
    405             self.w_VAL_pv.SetValue( m_pv.GetBasePv(val_pv) )
     405            self.w_VAL_pv.SetValue( moxy.model.pv.GetBasePv(val_pv) )
    406406            self.w_RBV_pv.SetValue( '' )
    407407            self.w_EGU_pv.SetValue( '' )
     
    434434        build a buttons row and place it in a sizer, return the sizer
    435435        '''
    436         self.connectButton = Make_My_Button(parent,
     436        self.connectButton = axis_Button(parent,
    437437              label=u'Connect', name='connectButton',
    438438              tip=u'Connect this axis with EPICS',
    439439              binding=self.doConnnectButton)
    440         self.disconnectButton = Make_My_Button(parent,
     440        self.disconnectButton = axis_Button(parent,
    441441              label=u'Disconnect', name='disconnectButton',
    442442              tip=u'Disconnect this axis from EPICS',
     
    452452        build a buttons row and place it in a sizer, return the sizer
    453453        '''
    454         self.acceptButton = Make_My_Button(parent,
     454        self.acceptButton = axis_Button(parent,
    455455              label=u'Accept', name='acceptButton',
    456456              tip=u'Accept the new PV names',
    457457              binding=self.doAcceptButton)
    458         self.revertButton = Make_My_Button(parent,
     458        self.revertButton = axis_Button(parent,
    459459              label=u'Revert', name='revertButton',
    460460              tip=u'Revert to previous PV names',
     
    529529       
    530530        self.axis_parent.disconnect()
    531         self.axis_parent.axis = m_axis.SingleAxis(name, val, isMotorRecord, desc, dmov, egu, rbv, stop)
     531        self.axis_parent.axis = SingleAxis(name, val, isMotorRecord, desc, dmov, egu, rbv, stop)
    532532        self.axis_parent.connect()
    533533        self.operate_panel.SetVAL( str(self.axis_parent.axis.axis.VAL) )
     
    541541        self.w_isMotor.SetValue( this_axis.isMotorRecord )
    542542        if this_axis.isMotorRecord:
    543             self.w_VAL_pv.SetValue( m_pv.GetBasePv(val) )
     543            self.w_VAL_pv.SetValue( moxy.model.pv.GetBasePv(val) )
    544544            self.w_RBV_pv.SetValue( '' )
    545545            self.w_EGU_pv.SetValue( '' )
     
    586586            color = COLOR_PV_NOT_DEFINED
    587587        else:
    588             valid = m_pv.pvIsAvailable( pv, CONNECT_TEST_TIMEOUT )
     588            valid = moxy.model.pv.pvIsAvailable( pv, CONNECT_TEST_TIMEOUT )
    589589            color = {True: COLOR_PV_OK, False: COLOR_PV_NOT_OK}[valid]
    590590        wx.CallAfter( obj.SetBackgroundColour, color )
     
    621621        if len( val_pv ) == 0:
    622622            return "Must define a PV name for the VAL field"
    623         if not m_pv.pvIsAvailable(val_pv, CONNECT_TEST_TIMEOUT):
     623        if not moxy.model.pv.pvIsAvailable(val_pv, CONNECT_TEST_TIMEOUT):
    624624            return '''cannot connect to PV "%s"''' % val_pv
    625625        if self.w_isMotor.GetValue():
    626             if not m_pv.pvIsMotorRec(val_pv):
    627                 rtyp = m_pv.GetRTYP(val_pv)
     626            if not moxy.model.pv.pvIsMotorRec(val_pv):
     627                rtyp = moxy.model.pv.GetRTYP(val_pv)
    628628                return "%s is an EPICS %s record, must be 'motor'" % (val_pv, rtyp)
    629629            for obj in (self.w_RBV_pv,
     
    634634                pv = obj.GetValue()
    635635                if len(pv) > 0:
    636                     if not m_pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT):
     636                    if not moxy.model.pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT):
    637637                        return '''cannot connect to PV "%s"''' % pv
    638638        else:
     
    645645                if len(pv) == 0:
    646646                    return "Must define a PV name for all fields"
    647                 if not m_pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT):
     647                if not moxy.model.pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT):
    648648                    return '''cannot connect to PV "%s"''' % val_pv
    649649        return None
     
    706706
    707707
     708class axis_Button(wx.lib.buttons.GenButton):
     709    '''custom Button widget'''
     710   
     711    def __init__(self, parent, label, name, tip, binding):
     712        wx.lib.buttons.GenButton.__init__(self, id=wx.ID_ANY,
     713                              label=label, name=name, parent=parent)
     714        self.SetToolTipString(tip)
     715        self.Bind(wx.EVT_BUTTON, binding)
     716
     717
     718class axis_TextEntry(wx.TextCtrl):
     719    '''custom wx.TextCtrl widget'''
     720   
     721    def __init__(self, parent, value='',
     722                       editable=True, tooltip='', handler=None):
     723        '''
     724        Create and return a TextCtrl object.
     725        [Enter] key event is bound to widget to call handler.
     726       
     727        :param obj parent: widget panel that will contain this TextCtrl
     728        :param str|float value: initial value to set in the entry field
     729        :param bool editable: should the entry field be editable?
     730        :param str tooltip: short description of this field
     731        :param obj handler: None or method to be called when [Enter] is pressed in this field
     732        :return: wx.TextCtrl object
     733        '''
     734        style = wx.TE_PROCESS_ENTER
     735        wx.TextCtrl.__init__(self, parent, wx.ID_ANY, 'DemoView', style=style)
     736        self.SetEditable( editable )
     737        if value is not None:
     738            self.SetValue( str(value) )
     739        self.SetToolTipString( tooltip )
     740        if handler is not None:
     741            self.Bind(wx.EVT_TEXT_ENTER, handler)
     742
     743
    708744# - - - - - - - - - - - - - - - - - - methods
    709745
     
    718754
    719755
    720 def Make_My_Button(parent, label, name, tip, binding):
    721     '''
    722     Create a button and bind it to a method.
    723     Return the button object
    724     '''
    725     button = wx.lib.buttons.GenButton(id=wx.ID_ANY,
    726           label=label, name=name, parent=parent,)
    727     button.SetToolTipString(tip)
    728     button.Bind(wx.EVT_BUTTON, binding)
    729     return button
    730 
    731 
    732 def Make_My_TextEntry(parent, value='',
    733                        editable=True, tooltip='', handler=None):
    734     '''
    735     Create and return a TextCtrl object.
    736     [Enter] key event is bound to widget to call handler.
    737    
    738     :param obj parent: widget panel that will contain this TextCtrl
    739     :param str|float value: initial value to set in the entry field
    740     :param bool editable: should the entry field be editable?
    741     :param str tooltip: short description of this field
    742     :param obj handler: None or method to be called when [Enter] is pressed in this field
    743     :return: wx.TextCtrl object
    744     '''
    745     style = wx.TE_PROCESS_ENTER
    746     entry = wx.TextCtrl(parent=parent, id=wx.ID_ANY, style=style)
    747     entry.SetEditable( editable )
    748     if value is not None:
    749         entry.SetValue( str(value) )
    750     entry.SetToolTipString( tooltip )
    751     if handler is not None:
    752         entry.Bind(wx.EVT_TEXT_ENTER, handler)
    753     return entry
    754 
    755 
    756756def _demo_():
    757757    '''demonstrate use of this module'''
    758     axis = m_axis.SingleAxis( name='test axis', val='prj:m1' )
     758    axis = SingleAxis( name='test axis', val='prj:m1' )
    759759    app = wx.App()
    760760    DemoFrame( None, axis ).Show()
  • moxy/trunk/src/moxy/moxy_wx/pv.py

    r834 r836  
    1212demo view for EPICS PV connection class: m_pv.PvConnection()
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
     
    2323import wx.lib.buttons
    2424import wx.lib.stattext
    25 from m_pv import PvConnection
     25from moxy.model.pv import PvConnection
    2626
    2727
     
    3535COLOR_LIGHTGREEN = wx.Colour(200, 255, 200)     # my name for this
    3636COLOR_LIGHTRED = wx.Colour(255, 200, 200)       # my name for this
    37 COLOR_BACKGROUND = wx.Colour(237, 233, 227)        # boa-constructor uses this
     37COLOR_BACKGROUND = wx.Colour(237, 233, 227)     # boa-constructor uses this
    3838
    3939
  • moxy/trunk/src/moxy/moxy_wx/set.py

    r834 r836  
    1010
    1111'''
    12 demo view for EPICS PV connection class: m_set.AxesSet()
     12demo view for EPICS PV connection class: moxy.model.set.AxesSet()
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
     
    2121
    2222import wx                   #@UnusedImport
    23 import wx.lib.buttons       #@UnusedImport
    24 import wx.lib.stattext      #@UnusedImport
    25 import m_pv                 #@UnusedImport
    26 import m_axis
    27 import m_set
    28 import vc_axis
     23from moxy.model.axis import SingleAxis
     24from moxy.model.set import AxesSet
     25from moxy.moxy_wx.axis import SingleAxisPanel
    2926
    3027
     
    6461       
    6562        self.members = []
    66         for axis in self.aset.axes:
    67             obj = vc_axis.SingleAxisPanel(panel, axis, show_buttons=True)
     63        for theAxis in self.aset.axes:
     64            obj = SingleAxisPanel(panel, theAxis, show_buttons=True)
    6865            self.members.append( obj )
    6966       
     
    8683
    8784class DemoFrame(wx.Frame):
    88     '''
    89     Put the standard panel in a frame
    90     '''
     85    '''Put the standard panel in a frame'''
     86
    9187    def __init__(self, parent, axis_set):
    9288        self.axis_set = axis_set
     
    129125    axes = []
    130126    for item in config:
    131         axes.append( m_axis.SingleAxis(**item) )
    132     aset = m_set.AxesSet( name = 'test XYZ axis set', axes = axes )
     127        axes.append( SingleAxis(**item) )
     128    aset = AxesSet( name = 'test XYZ axis set', axes = axes )
    133129    aset.connect()
    134130    #aset.report()
  • moxy/trunk/src/moxy/template.py

    r833 r836  
    1212comment
    1313
    14 Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
     14Copyright (c) 2009 - 2012, UChicago Argonne, LLC.
    1515See LICENSE file for details.
    1616'''
Note: See TracChangeset for help on using the changeset viewer.