File indexing completed on 2025-08-02 08:21:07
0001
0002
0003 use Tk;
0004
0005
0006 sub daq_begin
0007 {
0008
0009 $result = `rcdaq_client daq_begin`;
0010 }
0011
0012 sub daq_end
0013 {
0014
0015 $result = `rcdaq_client daq_end`;
0016 }
0017
0018 sub daq_open
0019 {
0020
0021 $result = `rcdaq_client daq_open`;
0022 }
0023
0024 sub daq_close
0025 {
0026
0027 $result = `rcdaq_client daq_close`;
0028 }
0029
0030 sub dummy
0031 {
0032
0033 }
0034
0035
0036 $time_used = 2;
0037
0038
0039
0040 $color1 = "#CCCC99";
0041 $okcolor = "#00cc99";
0042 $errorcolor= "#ff6666";
0043 $neutralcolor ="#cc9900";
0044 $panelcolor = "#336633";
0045 $warncolor = "IndianRed4";
0046 $graycolor = "#666666";
0047
0048 $buttonbgcolor='#33CCCC';
0049
0050 $smalltextfg = '#00CCFF';
0051 $smalltextbg = '#333366';
0052
0053 $slinebg='#cccc00';
0054 $sline2bg='#bbbb00';
0055
0056
0057 $oncolor = "orange2";
0058 $offcolor = "yellow4";
0059
0060
0061
0062 $bgcolor = "#990000";
0063
0064 $runstatcolor = "aquamarine";
0065 $stopstatcolor = "palegreen";
0066 $neutralcolor = "khaki";
0067
0068
0069
0070 $titlefontsize=13;
0071 $fontsize=12;
0072 $subtitlefontsize=10;
0073 $smallfont = ['arial', $subtitlefontsize];
0074 $normalfont = ['arial', $fontsize];
0075 $bigfont = ['arial', $titlefontsize, 'bold'];
0076
0077
0078 $old_run = "-1";
0079
0080 $name = `rcdaq_client daq_getname 2>&1`;
0081 my $status = $?;
0082 if ( $status != 0 )
0083 {
0084 $name=" ";
0085 }
0086
0087
0088 $mw = MainWindow->new();
0089
0090 $smallfont = $mw->fontCreate('code', -family => 'fixed',-size => 10);
0091
0092
0093 $mw->title("RCDAQ Control");
0094
0095
0096 $label{'sline'} = $mw->Label(-text => "RCDAQ Control", -background=>$slinebg, -font =>$bigfont);
0097 $label{'sline'}->pack(-side=> 'top', -fill=> 'x', -ipadx=> '15m', -ipady=> '1m');
0098
0099 $label{'sline2'} = $mw->Label(-text => $name, -background=>$sline2bg, -font =>$smallfont);
0100 $label{'sline2'}->pack(-side=> 'top', -fill=> 'x', -ipadx=> '15m', -ipady=> '0.2m');
0101
0102
0103
0104
0105
0106 $frame{'center'} = $mw->Frame()->pack(-side => 'top', -fill => 'x');
0107
0108
0109 $framename = $frame{'center'}->Label(-bg => $color1, -relief=> 'raised')->pack(-side =>'left', -fill=> 'x', -ipadx=>'15m');
0110
0111
0112 $outerlabel = $framename->Label(-bg => $color1)->pack(-side =>'top', -fill=> 'x', -padx=> '1m', -pady=> '1m');
0113
0114
0115 $runstatuslabel = $outerlabel->
0116 Label(-text=> "Status", -font => $bigfont, -fg =>'red', -bg => $neutralcolor, -relief=> 'raised')->
0117 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0118
0119 $runnumberlabel = $outerlabel->
0120 Label(-text => "runnumber", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0121 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0122
0123 $eventcountlabel = $outerlabel->
0124 Label(-text => "eventcount", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0125 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0126
0127 $volumelabel = $outerlabel->
0128 Label(-text => "volume", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0129 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0130
0131 $filenamelabel = $outerlabel->
0132 Label(-text => "", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0133 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0134
0135
0136 $button_open = $outerlabel->
0137 Button( -bg => $buttonbgcolor, -text => "Open", -command => [\&daq_open,$b], -relief =>'raised', -font=> $normalfont)->
0138 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0139
0140 $button_begin = $outerlabel->
0141 Button(-bg => $buttonbgcolor, -text => "Begin", -command => [\&daq_begin, $b], -relief =>'raised', -font=> $normalfont)->
0142 pack(-side =>'top', -fill=> 'x', -ipadx=> '1m', -ipady=> '1m');
0143
0144
0145
0146
0147
0148 $prev_evt = 0;
0149 $delta_evt = 0;
0150 $rate = 0;
0151
0152 update();
0153
0154
0155
0156
0157
0158 $mw->repeat($time_used * 1000,\&update);
0159
0160 MainLoop();
0161
0162
0163
0164
0165 sub update()
0166 {
0167
0168
0169 my $res = `rcdaq_client daq_status -s 2>&1`;
0170
0171
0172 my $status = $?;
0173 if ( $status != 0 )
0174 {
0175 $runstatuslabel->configure(-text =>"RCDAQ not running");
0176 $run = "n/a";
0177 $evt = "n/a";
0178 $v = "n/a";
0179 $duration = 0;
0180 $name=" ";
0181 }
0182 else
0183 {
0184
0185 ($run, $evt, $v, $openflag, $serverflag, $duration , $fn)= split (/\s/ ,$res);
0186 ($junk, $name )= split (/\"/ ,$res);
0187 #print " run $run evt $evt vol $v open $openflag file $fn $name \n";
0188 $delta_evt = $evt - $prev_evt;
0189 $rate = $delta_evt/2; # assuming 2s update, should use variable in case this changes
0190 $prev_evt = $evt;
0191
0192 if ( $run < 0)
0193 {
0194 $button_begin->configure(-text =>"Begin");
0195 $button_begin->configure(-command => [\&daq_begin]);
0196
0197 if ( $old_run < 0)
0198 {
0199 $runstatuslabel->configure(-text =>"Stopped");
0200 }
0201 else
0202 {
0203 $runstatuslabel->configure(-text =>"Stopped Run $old_run");
0204 }
0205
0206 $button_open->configure(-bg => $buttonbgcolor );
0207
0208 if ( $openflag)
0209 {
0210 $button_open->configure(-text => "Close");
0211 $button_open->configure(-command => [\&daq_close] );
0212 }
0213 else
0214 {
0215 $button_open->configure(-text => "Open");
0216 $button_open->configure(-command => [\&daq_open] );
0217 }
0218
0219
0220 if ( $openflag == 1)
0221 {
0222 if ( $serverflag == 1 )
0223 {
0224 $filenamelabel->configure(-text =>"Logging enabled (Server)");
0225 }
0226 else
0227 {
0228 $filenamelabel->configure(-text =>"Logging enabled");
0229 }
0230 }
0231
0232 else
0233 {
0234 $filenamelabel->configure(-text =>"Logging Disabled");
0235 }
0236 }
0237 else # we are running
0238 {
0239 $old_run = $run;
0240
0241 $button_begin->configure(-text =>"End");
0242 $button_begin->configure(-command => [\&daq_end]);
0243
0244 $runstatuslabel->configure(-text =>"Running for $duration s");
0245 $button_open->configure(-bg => $graycolor );
0246 $button_open->configure(-command => [\&dummy] );
0247
0248 if ( $openflag == 1 )
0249 {
0250 if ( $serverflag == 1 )
0251 {
0252 $filenamelabel->configure(-text =>"File on Server: $fn");
0253 }
0254 else
0255 {
0256 $filenamelabel->configure(-text =>"File: $fn");
0257 }
0258 }
0259 else
0260 {
0261 $filenamelabel->configure(-text =>"Logging Disabled");
0262 }
0263 }
0264
0265 }
0266
0267 $label{'sline2'}->configure( -text => $name);
0268 $runnumberlabel->configure(-text => "Run: $run");
0269
0270 $eventcountlabel->configure(-text =>"Events: $evt ($rate Hz)");
0271
0272 $volumelabel->configure(-text => "Volume: $v MB");
0273
0274
0275 }
0276