-
Notifications
You must be signed in to change notification settings - Fork 14
/
rcdaq_runtypechooser.pl
executable file
·161 lines (105 loc) · 3.23 KB
/
rcdaq_runtypechooser.pl
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#! /usr/bin/perl
use Tk;
sub getList
{
open (L, "rcdaq_client daq_list_runtypes |");
while (<L>)
{
chop;
my ( $name, $dummy, $value) = split;
# print "$name $value\n";
$typelist{$name} = 0;
$namelist{$name} = $value;
}
close L;
}
sub set_type
{
my $t = shift;
$result = `rcdaq_client daq_set_runtype $t`;
}
sub dummy
{
}
$time_used = 2;
#$color1 = "#cccc99";
#$color1 = "#999900";
$color1 = "#CCCC99";
$okcolor = "#00cc99";
$errorcolor= "#ff6666";
$neutralcolor ="#cc9900";
$panelcolor = "#336633";
$warncolor = "IndianRed4";
$graycolor = "#666666";
$buttonbgcolor='#33CCCC';
$smalltextfg = '#00CCFF';
$smalltextbg = '#333366';
$slinebg='#cccc00';
$oncolor = "orange2";
$offcolor = "yellow4";
#$bgcolor = "#cccc66";
$bgcolor = "#990000";
$runstatcolor = "aquamarine";
$stopstatcolor = "palegreen";
$neutralcolor = "khaki";
$titlefontsize=15;
$fontsize=13;
$subtitlefontsize=11;
$smallfont = ['arial', $subtitlefontsize];
$normalfont = ['arial', $fontsize];
$bigfont = ['arial', $titlefontsize, 'bold'];
&getList;
$mw = MainWindow->new();
$mw->title("Run Type Control");
$label{'sline'} = $mw->Label(-text => "Run Type Control", -background=>$slinebg, -font =>$bigfont);
$label{'sline'}->pack(-side=> 'top', -fill=> 'x', -ipadx=> '15m', -ipady=> '1m');
$frame{'center'} = $mw->Frame()->pack(-side => 'top', -fill => 'x');
$framename = $frame{'center'}->Label(-bg => $color1, -relief=> 'raised')->pack(-side =>'left', -fill=> 'x', -ipadx=>'15m');
$label_a = $framename->Label(-bg => $color1, -relief=> 'raised')->pack(-side =>'top', -fill=> 'x');
$label_c = $framename->Label(-bg => $color1, -relief=> 'raised')->pack(-side =>'bottom', -fill=> 'x');
$label_b = $framename->Label(-bg => $color1, -relief=> 'raised')->pack(-side =>'bottom', -fill=> 'x');
$currenttypelabel = $label_a->
Label(-font => $bigfont, -fg =>'red', -bg => $neutralcolor)->
pack(-side =>'top', -fill=> 'x', -expand => 1, -ipadx=> '3m', -ipady=> '3m');
$currentnamelabel = $label_b->
Label( -font => $smallfont, -fg =>'black', -bg => $neutralcolor)->
pack(-side =>'top', -fill=> 'x', -expand => 1, -ipadx=> '2m', -ipady=> '2m');
foreach $type ( sort keys %typelist )
{
$button{$type} = $label_c->
Button( -bg => $buttonbgcolor, -text => $type, -command => [\&set_type,$type], -relief =>'raised', -font=> $normalfont)->
pack(-side =>'left', -fill=> 'x',-expand => 1, -ipadx=>'1m', -ipady=> '1m');
}
# update once to fill all the values in
update();
#and schedule an update every 5 seconds
$mw->repeat($time_used * 1000,\&update);
MainLoop();
sub update()
{
my $res = `rcdaq_client daq_get_runtype 2>&1`;
# print $res;
if ( $res =~ /system error/ || $res =~ /Program not registered/ )
{
$currenttypelabel->configure(-text =>"RCDAQ not running");
}
else
{
foreach $type ( sort keys %typelist )
{
$button{$type}->configure( -bg => $buttonbgcolor);
}
chomp $res;
if ($res eq "")
{
$currenttypelabel->configure(-text => "( no run type set )");
$currentnamelabel->configure(-text => "");
}
else
{
$currenttypelabel->configure(-text => $res);
$currentnamelabel->configure(-text => $namelist{$res});
$button{$res}->configure( -bg => $oncolor);
}
}
}