-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathepicsCounterChannelLabel.py
executable file
·76 lines (56 loc) · 2.42 KB
/
epicsCounterChannelLabel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
This module provides a class library for a GUI label field widget bound to an Epics scaler counter channel. The counter channel is monitored
and the field is updated and lit up green when the count changes.
Author: John Skinner
Created: Nov, 2 2009
Modifications:
"""
import epicsPV
from mtTkinter import *
import Pmw
from beamline_support import *
class epicsCounterChannelLabel:
"""
This module provides a class library for a GUI label field widget bound to an Epics scaler counter channel. The counter channel is monitored
and the field is updated and lit up green when the count changes.
"""
is_drawn = 0
def __init__(self, pvname,parent,channel_number,input_width):
"""
Inputs:
pvname:
The name of the epics scaler record
parent:
The container to place the entry widget.
channel_number:
input_width:
Example to monitor counter channel 2 on x12c:scaler1
counter_channel = epicsCounterChannelLabel("x12c:scaler1",counter_output_frame,2,9)
counter_channel.pack(side=LEFT)
"""
self.entry_var = StringVar()
self.entry_pv = pvCreate(pvname+".S"+str(channel_number))
self.entry_dmov_pv = pvCreate(pvname+".CNT")
self.entry_var.set(str(pvGet(self.entry_pv)))
self.entry = Label(parent,textvariable=self.entry_var,width=input_width)
add_callback(self.entry_pv,self._entry_pv_movingCb,self.entry_var)
add_callback(self.entry_dmov_pv,self._entry_pv_dmovCb,[])
def _entry_pv_movingCb(self,epics_args, user_args):
# print "in callback " + str(epics_args['pv_value'])
if not (epicsCounterChannelLabel.is_drawn):
return
user_args[0].set(str(epics_args['pv_value']))
def _entry_pv_dmovCb(self,epics_args, user_args):
# print "in callback " + str(epics_args['pv_value'])
if not (epicsCounterChannelLabel.is_drawn):
return
if (epics_args['pv_value'] == 0):
self.entry.configure(background="#729fff")
else:
self.entry.configure(background="green")
def pack(self,side=LEFT,padx=0,pady=0): #pass the params in
self.entry.pack(side=side,padx=padx,pady=pady)
def getField():
return self.entry_var.get()
def setColor(color_string):
self.entry.configure(background=color_string)