source: moxy/trunk/src/moxy/vc_set.py @ 781

Last change on this file since 781 was 781, checked in by jemian, 11 years ago

less printout, strip off .VAL for revert button

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision Url
File size: 3.7 KB
Line 
1#!/usr/bin/env python
2
3########### SVN repository information ###################
4# $Date: 2012-02-04 05:27:01 +0000 (Sat, 04 Feb 2012) $
5# $Author: jemian $
6# $Revision: 781 $
7# $URL$
8# $Id: vc_set.py 781 2012-02-04 05:27:01Z jemian $
9########### SVN repository information ###################
10
11'''
12demo view for EPICS PV connection class: m_set.AxesSet()
13
14Copyright (c) 2009 - 2011, UChicago Argonne, LLC.
15See LICENSE file for details.
16'''
17
18
19# - - - - - - - - - - - - - - - - - - Imports
20
21
22import wx
23import wx.lib.buttons
24import wx.lib.stattext
25import m_pv
26import m_axis
27import m_set
28import vc_axis
29
30
31# - - - - - - - - - - - - - - - - - - Global
32
33
34__svnid__ = "$Id: vc_set.py 781 2012-02-04 05:27:01Z jemian $"
35
36
37# - - - - - - - - - - - - - - - - - - classes
38
39
40class MultiAxisPanel(wx.Panel):
41    '''
42    Show a set of motion axes in a panel.
43    The EPICS CA connections must be made here to get the callbacks.
44   
45    Some buttons (Configure, Connect, Disconnect) are optional
46    and can be suppressed by adding  ``show_buttons = False``
47    '''
48    def __init__(self, parent, axis_set):
49        self.parent = parent
50        self.aset = axis_set
51
52        wx.Panel.__init__(self, id=wx.ID_ANY, parent=parent)
53        #self.SetToolTipString( "self" )
54       
55        self.panel = self._Make_Axes_Panel(self)
56       
57        sizer = wx.BoxSizer( orient=wx.VERTICAL )
58        sizer.AddSizer( self.panel, 1, flag=wx.EXPAND )
59        self.SetSizer( sizer )
60        self.Fit()
61   
62    def _Make_Axes_Panel(self, parent):
63        panel = wx.Panel( parent )
64       
65        self.members = []
66        for axis in self.aset.axes:
67            obj = vc_axis.SingleAxisPanel(panel, axis, show_buttons=True)
68            self.members.append( obj )
69       
70        sizer = wx.BoxSizer( orient=wx.HORIZONTAL )
71        panel.SetSizer( sizer )
72        for obj in self.members:
73            sizer.AddSizer(obj, 1, flag=wx.EXPAND)
74
75        panel.Fit()
76        return panel
77   
78    def connect(self):
79        for obj in self.members:
80            obj.connect()
81   
82    def disconnect(self):
83        for obj in self.members:
84            obj.disconnect()
85
86
87class DemoFrame(wx.Frame):
88    '''
89    Put the standard panel in a frame
90    '''
91    def __init__(self, parent, axis_set):
92        self.axis_set = axis_set
93        # frame cannot be maximized
94        style = wx.MINIMIZE_BOX | \
95                wx.SYSTEM_MENU | \
96                wx.CAPTION | \
97                wx.CLOSE_BOX | \
98                wx.CLIP_CHILDREN | \
99                wx.RESIZE_BORDER
100        wx.Frame.__init__(self, parent, wx.ID_ANY, 'DemoView', style=style)
101        self.SetSize( (150*len(axis_set.axes),350) )
102        self.SetToolTipString(u'Multiple Axis Set DemoFrame')
103        self.panel = MultiAxisPanel(parent=self, axis_set = axis_set)
104        self.Bind(wx.EVT_CLOSE, self.OnClose)
105        self.panel.connect()
106
107    def OnClose(self, event):
108        dlg = wx.MessageDialog(self, 
109            "Do you really want to close this application?",
110            "Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
111        result = wx.ID_OK               # development
112        #result = dlg.ShowModal()        # TODO: production
113        dlg.Destroy()
114        if result == wx.ID_OK:
115            self.axis_set.disconnect()
116            self.Destroy()
117
118
119# - - - - - - - - - - - - - - - - - - methods
120
121
122# - - - - - - - - - - - - - - - - - - main
123
124
125if __name__ == '__main__':
126    config = [
127        {'name': "*X*", 'val': "prj:m1", 'isMotorRecord': True},
128        {'name': "*Y*", 'val': "prj:m2", 'isMotorRecord': True},
129        {'name': "*Z*", 'val': "prj:m3", 'isMotorRecord': True},
130    ]
131    axes = []
132    for item in config:
133        axes.append( m_axis.SingleAxis(**item) )
134    aset = m_set.AxesSet( name = 'test XYZ axis set', axes = axes )
135    aset.connect()
136    #aset.report()
137
138    app = wx.App()
139    DemoFrame( None, aset ).Show()
140    app.MainLoop()
141
Note: See TracBrowser for help on using the repository browser.