Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 08:21:08

0001 #! /usr/bin/perl
0002 
0003 use Tk;
0004 
0005 use Getopt::Long qw(:config no_ignore_case);
0006 GetOptions('help','display:s','geometry:s','small','large', 'Large','huge','Huge');
0007 
0008 if ($opt_help)
0009 {
0010     print"
0011     hv_display.pl [ options ... ]
0012     --help                      this text
0013     --display=<remote_display>  display on the remote display, e.g over.head.display:0.
0014     --geometry=<geometry>       set a geometry, e.g. +200+400
0015     --small                     make the display small if you want it to just sit unobtrusively on your desktop
0016     --large --Large --{hH}uge   size increases suitable for showing on an overhead display (following the Latex conventions)
0017 
0018 \n";
0019     exit(0);
0020 }
0021 
0022 if ($opt_display)
0023 {
0024     $ENV{"DISPLAY"} = $opt_display;
0025 }
0026 
0027 $time_used = 2;
0028 
0029 $name =  `rcdaq_client daq_getname  2>&1`;
0030 my $status = $?;
0031 if ( $status != 0  )
0032 {
0033     $name=" ";
0034 }
0035 
0036 
0037 #$color1 = "#cccc99";
0038 #$color1 = "#999900";
0039 $color1 = "#CCCC99";
0040 $okcolor = "#00cc99";
0041 $errorcolor= "#ff6666";
0042 $neutralcolor ="#cc9900";
0043 $panelcolor = "#336633";
0044 $warncolor = "IndianRed4";
0045 $graycolor = "#666666";
0046 
0047 $buttonbgcolor='#33CCCC';
0048 
0049 $smalltextfg = '#00CCFF';
0050 $smalltextbg = '#333366';
0051 
0052 $slinebg='#cccc00';
0053 $sline2bg='#bbbb00';
0054 #$sline2bg='#ffb90f';
0055 
0056 $oncolor = "orange2";
0057 $offcolor = "yellow4";
0058 
0059 
0060 #$bgcolor = "#cccc66";
0061 $bgcolor = "#990000";
0062 
0063 $runstatcolor = "aquamarine";
0064 $stopstatcolor = "palegreen";
0065 $neutralcolor = "khaki";
0066 
0067 $old_run = -1;
0068 
0069 if ($opt_Huge)
0070 {
0071     $ipadx='90m';
0072     $ipady='45m';
0073     $padx='15m';
0074     $pady='15m';
0075 
0076 
0077     $titlefontsize=90;
0078     $fontsize=60;
0079     $subtitlefontsize=50;
0080 
0081 }
0082 elsif ($opt_huge)
0083 {
0084     $ipadx='70m';
0085     $ipady='35m';
0086     $padx='12m';
0087     $pady='12m';
0088 
0089 
0090     $titlefontsize=70;
0091     $fontsize=50;
0092     $subtitlefontsize=40;
0093 
0094 }
0095 elsif ($opt_Large)
0096 {
0097     $ipadx='50m';
0098     $ipady='24m';
0099     $padx='8m';
0100     $pady='8m';
0101 
0102 
0103     $titlefontsize=50;
0104     $fontsize=35;
0105     $subtitlefontsize=30;
0106 
0107 }
0108 elsif ($opt_large)
0109 {
0110     $ipadx='35m';
0111     $ipady='18m';
0112     $padx='5m';
0113     $pady='5m';
0114 
0115 
0116     $titlefontsize=30;
0117     $fontsize=27;
0118     $subtitlefontsize=22;
0119 
0120 }
0121 elsif ($opt_small)
0122 {
0123     $ipadx='10m';
0124     $ipady='5m';
0125     $padx='1m';
0126     $pady='1m';
0127 
0128 
0129     $titlefontsize=8;
0130     $fontsize=7;
0131     $subtitlefontsize=6;
0132 
0133 }
0134 else
0135 {
0136     $ipadx='15m';
0137     $ipady='8m';
0138     $padx='1m';
0139     $pady='1m';
0140 
0141     $titlefontsize=13;
0142     $fontsize=12;
0143     $subtitlefontsize=10;
0144 }
0145 
0146 
0147 $smallfont = ['arial', $subtitlefontsize];
0148 $normalfont = ['arial', $fontsize];
0149 $bigfont = ['arial', $titlefontsize, 'bold'];
0150 
0151 
0152 $mw = MainWindow->new();
0153 
0154 if ($opt_geometry)
0155 {
0156     $mw->geometry($opt_geometry);
0157 }
0158 
0159 
0160 $mw->title("RCDAQ Status");
0161 
0162 
0163 $label{'sline'} = $mw->Label(-text => "RCDAQ Status", -background=>$slinebg, -font =>$bigfont);
0164 $label{'sline'}->pack(-side=> 'top', -fill=> 'x', -ipadx=> $ipadx, -ipady=> $pady);
0165 
0166 $label{'sline2'} = $mw->Label(-text => $name, -background=>$sline2bg, -font =>$smallfont);
0167 $label{'sline2'}->pack(-side=> 'top', -fill=> 'x', -ipadx=> '15m', -ipady=> '0.2m');
0168 
0169 
0170 $frame{'center'} = $mw->Frame()->pack(-side => 'top', -fill => 'x');
0171 
0172 
0173 $framename = $frame{'center'}->Label(-bg => $color1, -relief=> 'raised')->pack(-side =>'left', -fill=> 'x', -ipadx=>$ipadx);
0174 
0175 
0176 $outerlabel = $framename->Label(-bg => $color1)->pack(-side =>'top', -fill=> 'x', -padx=> $padx,  -pady=> $pady);
0177 
0178 
0179 $runstatuslabel = $outerlabel->
0180       Label(-text=> "Status", -font => $bigfont, -fg =>'red', -bg => $neutralcolor)->
0181       pack(-side =>'top', -fill=> 'x', -ipadx=> $padx,  -ipady=> $pady);
0182 
0183 $runnumberlabel = $outerlabel->
0184       Label(-text => "runnumber", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0185       pack(-side =>'top', -fill=> 'x', -ipadx=> $padx,  -ipady=> $pady);
0186 
0187 $eventcountlabel = $outerlabel->
0188       Label(-text => "eventcount", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0189       pack(-side =>'top', -fill=> 'x', -ipadx=> $padx,  -ipady=> $pady);
0190 
0191 $volumelabel = $outerlabel->
0192       Label(-text => "volume", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0193       pack(-side =>'top', -fill=> 'x', -ipadx=> $padx,  -ipady=> $pady);
0194 
0195 $filenamelabel = $outerlabel->
0196       Label(-text => "filename", -font => $normalfont, -bg => $okcolor, -relief=> 'raised')->
0197       pack(-side =>'top', -fill=> 'x', -ipadx=> $padx,  -ipady=> $pady);
0198 
0199 
0200 
0201 # update once to fill all the values in
0202 $prev_evt = 0;
0203 $delta_evt = 0;
0204 $rate = 0;
0205 update();
0206 
0207 #and schedule an update every 5 seconds
0208 
0209 
0210 
0211 $mw->repeat($time_used * 1000,\&update);
0212 
0213 MainLoop();
0214 
0215 
0216 
0217 
0218 sub update()
0219 {
0220 
0221 
0222     my $res = `rcdaq_client daq_status -s 2>&1`;
0223 #    print $res;
0224 
0225     my $status = $?;
0226     if ( $status != 0  )
0227     {
0228     $runstatuslabel->configure(-text =>"RCDAQ not running");
0229     $run = "n/a";
0230     $evt =  "n/a";
0231     $v =  "n/a";
0232     $duration = 0;
0233     $name=" ";
0234     }
0235     else
0236     {
0237     ($run, $evt, $v, $openflag, $serverflag, $duration, $fn  )= split (/\s/ ,$res);
0238     ($junk, $name )= split (/\"/ ,$res);
0239 #    print " run $run  evt $evt  vol $v open  $openflag file  $fn \n";
0240     
0241     $delta_evt = $evt - $prev_evt;
0242     $rate = $delta_evt/2;       # assuming 2s update, should use variable in case this changes
0243     $prev_evt = $evt;
0244 
0245     if ( $run < 0)
0246     {
0247         if ( $old_run < 0)
0248         {
0249         $runstatuslabel->configure(-text =>"Stopped");
0250         }
0251         else
0252         {
0253         $runstatuslabel->configure(-text =>"Stopped   Run $old_run");
0254         }
0255         
0256         if ( $openflag == 1)
0257         {       
0258         if ( $serverflag == 1 )
0259         {
0260             $filenamelabel->configure(-text =>"Logging enabled (Server)");
0261         }
0262         else
0263         {
0264             $filenamelabel->configure(-text =>"Logging enabled");
0265         }
0266         }
0267 
0268         else
0269         {
0270         $filenamelabel->configure(-text =>"Logging Disabled");
0271         }
0272 
0273     }
0274     else
0275     {
0276         $old_run = $run;
0277         
0278         $runstatuslabel->configure(-text =>"Running for $duration s");
0279         
0280         if ( $openflag == 1 )
0281         {
0282         if ( $serverflag == 1 )
0283         {
0284             $filenamelabel->configure(-text =>"File on Server: $fn");
0285         }
0286         else
0287         {
0288             $filenamelabel->configure(-text =>"File: $fn");
0289         }
0290         }
0291         else
0292         {
0293         $filenamelabel->configure(-text =>"Logging Disabled");
0294         }
0295 
0296     }
0297     
0298     }
0299 
0300     $label{'sline2'}->configure( -text =>  $name);
0301     $runnumberlabel->configure(-text => "Run:    $run");
0302     
0303     $eventcountlabel->configure(-text =>"Events: $evt  ($rate Hz)");
0304     
0305     $volumelabel->configure(-text =>    "Volume: $v MB");
0306     
0307     
0308 }
0309