source: bcdaqwidgets/trunk/src/demos/vlinac.py @ 1402

Last change on this file since 1402 was 1402, checked in by jemian, 10 years ago

fixes #50

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision Author HeadURL Id
File size: 5.4 KB
Line 
1#!/usr/bin/env python
2
3########### SVN repository information ###################
4# $Date: 2013-07-05 22:25:23 +0000 (Fri, 05 Jul 2013) $
5# $Author: jemian $
6# $Revision: 1402 $
7# $URL: bcdaqwidgets/trunk/src/demos/vlinac.py $
8# $Id: vlinac.py 1402 2013-07-05 22:25:23Z jemian $
9########### SVN repository information ###################
10
11'''
12comment
13
14Copyright (c) 2009 - 2013, UChicago Argonne, LLC.
15See LICENSE file for details.
16'''
17
18
19# - - - - - - - - - - - - - - - - - - Imports
20
21
22import os
23import sys
24from PySide import QtGui, QtCore
25
26sys.path.insert(0, os.path.abspath('..'))
27import bcdaqwidgets
28
29
30# - - - - - - - - - - - - - - - - - - Global
31
32
33__svnid__ = "$Id: vlinac.py 1402 2013-07-05 22:25:23Z jemian $"
34
35
36# - - - - - - - - - - - - - - - - - - class
37
38
39class DemoView(QtGui.QWidget):
40   
41    def __init__(self, parent=None, prefix='unknown'):
42        QtGui.QWidget.__init__(self, parent)
43       
44        layout = QtGui.QVBoxLayout()
45        self.setLayout(layout)
46       
47        self.setWindowTitle('Virtual Linac Controls')
48        widget = QtGui.QLabel('Virtual Linac Controls')
49        layout.addWidget(widget)
50        widget.setAlignment(QtCore.Qt.AlignHCenter)
51        sty = bcdaqwidgets.StyleSheet(widget, {'font':'bold 16px'})
52        sty.updateStyleSheet()
53       
54        widget = bcdaqwidgets.BcdaQMomentaryButton()
55        widget.ca_connect(prefix+':initAllSQ')
56        widget.setText('Reset')
57        widget.SetReleasedValue(1)
58        layout.addWidget(widget)
59       
60        layout.addWidget(self.source(prefix))
61        layout.addWidget(self.zone1(prefix))
62        layout.addWidget(self.zone2(prefix))
63       
64        widget = bcdaqwidgets.BcdaQToggleButton()
65        widget.ca_connect(prefix+':autoC')
66        widget.SetReleasedValue(1)
67        layout.addWidget(widget)
68   
69    def source(self, prefix):
70        panel = QtGui.QGroupBox()
71        layout = QtGui.QGridLayout()
72        panel.setLayout(layout)
73        panel.setFlat(True)
74        panel.setTitle('source')
75       
76        layout.setColumnStretch(1, 1)
77        layout.setColumnStretch(2, 1)
78       
79        widget = QtGui.QLabel('cathode')
80        layout.addWidget(widget, 0, 0)
81       
82        widget = bcdaqwidgets.BcdaQLineEdit()
83        widget.ca_connect(prefix+':cathodeCurrentC')
84        layout.addWidget(widget, 0, 1)
85       
86        widget = bcdaqwidgets.BcdaQLabel()
87        widget.ca_connect(prefix+':cathodeTempM')
88        widget.useAlarmState = True
89        layout.addWidget(widget, 0, 2)
90       
91        return panel
92   
93    def zone1(self, prefix):
94        panel = QtGui.QGroupBox()
95        layout = QtGui.QGridLayout()
96        panel.setLayout(layout)
97        panel.setFlat(True)
98        panel.setTitle('zone 1')
99       
100        for col in range(1, 6):
101            layout.setColumnStretch(col, 1)
102       
103        widget = QtGui.QLabel('CM')
104        layout.addWidget(widget, 0, 0)
105       
106        widget = bcdaqwidgets.BcdaQToggleButton()
107        layout.addWidget(widget, 0, 1, 1, 2)
108        widget.ca_connect(prefix+':gunOnC')
109       
110        widget = bcdaqwidgets.BcdaQLabel()
111        layout.addWidget(widget, 0, 3, 1, 2)
112        widget.ca_connect(prefix+':gunOnC')
113        widget.useAlarmState = True
114       
115        widget = bcdaqwidgets.BcdaQLabel()
116        widget.ca_connect(prefix+':CM1:intensityM')
117        layout.addWidget(widget, 0, 5)
118       
119        for row in (1, 2):
120            self.defineMagnetRow(prefix, row, row, layout)
121       
122        return panel
123   
124    def zone2(self, prefix):
125        panel = QtGui.QGroupBox()
126        layout = QtGui.QGridLayout()
127        panel.setLayout(layout)
128        panel.setFlat(True)
129        panel.setTitle('zone 2')
130       
131        for col in range(1, 6):
132            layout.setColumnStretch(col, 1)
133       
134        widget = QtGui.QLabel('GV1')
135        layout.addWidget(widget, 0, 0)
136       
137        widget = bcdaqwidgets.BcdaQToggleButton()
138        layout.addWidget(widget, 0, 1, 1, 2)
139        widget.ca_connect(prefix+':GV1:positionC')
140       
141        widget = bcdaqwidgets.BcdaQLabel()
142        layout.addWidget(widget, 0, 3, 1, 2)
143        widget.ca_connect(prefix+':GV1:positionM')
144        widget.useAlarmState = True
145       
146        for row in (3, 4, 5):
147            self.defineMagnetRow(prefix, row, row-2, layout)
148       
149        return panel
150   
151    def defineMagnetRow(self, prefix, magnet_number, row, layout):
152        widget = QtGui.QLabel('PM%d' % magnet_number)
153        layout.addWidget(widget, row, 0)
154   
155        widget = bcdaqwidgets.BcdaQLineEdit()
156        widget.ca_connect(prefix+':H%d:setCurrentC' % magnet_number)
157        layout.addWidget(widget, row, 1)
158       
159        widget = bcdaqwidgets.BcdaQLabel()
160        widget.ca_connect(prefix+':PM%d:X:positionM' % magnet_number)
161        widget.useAlarmState = True
162        layout.addWidget(widget, row, 2)
163       
164        widget = bcdaqwidgets.BcdaQLineEdit()
165        widget.ca_connect(prefix+':V%d:setCurrentC' % magnet_number)
166        layout.addWidget(widget, row, 3)
167       
168        widget = bcdaqwidgets.BcdaQLabel()
169        widget.ca_connect(prefix+':PM%d:Y:positionM' % magnet_number)
170        widget.useAlarmState = True
171        layout.addWidget(widget, row, 4)
172       
173        widget = bcdaqwidgets.BcdaQLabel()
174        widget.ca_connect(prefix+':PM%d:intensityM' % magnet_number)
175        layout.addWidget(widget, row, 5)
176
177
178# - - - - - - - - - - - - - - - - - - methods
179
180def _demo_():
181    '''demonstrate use of this module'''
182    user = os.environ['USER']
183    app = QtGui.QApplication(sys.argv)
184    view = DemoView(prefix=user)
185    view.show()
186    sys.exit(app.exec_())
187
188
189# - - - - - - - - - - - - - - - - - - main
190
191
192if __name__ == '__main__':
193    _demo_()
Note: See TracBrowser for help on using the repository browser.