OUT_SVG => 2, #n/a
OUT_SCREEN => 3}; #n/a
-my @color= ('#2222dd','#dd2222','#22dd22','#dd8822','#dd22dd','#22dddd','#dddd22','#8888dd','#dddd88');
+my @color= ('#2222dd','#dd2222','#22dd22','#dd8822','#dd22dd','#22dddd','#dddd22','#8888dd','#8822bb');
sub plot_write {
my ($file,$str,$no) = @_;
return unless $str;
if($no || 0) {
print $file $str;
+# print $str;
}
else {
print $file $str."\n";
+# print $str."\n";
}
}
$p->{$name} = $c;
$p->{$name}->{fh} = $fh;
$p->{$name}->{run} = 0;
+ $p->{$name}->{buffer} = $p->{$name}->{buffer} || 0;
$p->{$name}->{sizex} = $p->{$name}->{sizex} || 600 ;
$p->{$name}->{sizey} = $p->{$name}->{sizey} || 400 ;
$p->{$name}->{file} = $p->{$name}->{file} || "dummy" ;
if($p->{$name}->{output} == OUT_PNG) {
$p->{$name}->{file} or die "No filename specified";
plot_write($fh,"set term png size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey}." font \"monospace,8\"");
- plot_write($fh,"set out \"".$p->{$name}->{file}.".png\"");
+ plot_write($fh,"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\"");
}
elsif($p->{$name}->{output} == OUT_SCREEN) {
plot_write($fh,"set term x11 size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey});
plot_write($fh,"set style fill solid 1.00 border -1");
plot_write($fh,"set grid noxtics ytics");
plot_write($fh,"set boxwidth 2 absolute");
- plot_write($fh,"set xtics ('MDC12' 0,'MDC34' 1,'TOF' 2, 'RPC' 3, 'RICH' 4, 'SHW' 5, 'Start' 6, 'FW' 7) offset 2,0 scale 0");
+ plot_write($fh,"set xtics (",1);
+ for(my $j=0; $j<scalar @{$p->{$name}->{bartitle}};$j++) {
+ plot_write($fh,', ',1) if $j;
+ plot_write($fh,"'".$p->{$name}->{bartitle}->[$j]."' $j ",1);
+ }
+ plot_write($fh,") offset 2,0 scale 0");
plot_write($fh,"set style histogram title offset character 0, 0, 0");
plot_write($fh,"set style data histograms");
plot_write($fh,"plot ",1);
for(my $j=0; $j<$p->{$name}->{curves};$j++) {
+ plot_write($fh,', ',1) if $j;
plot_write($fh,"'-' lt rgb \"$color[$j]\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
}
plot_write($fh," ");
sub PlotDraw {
my($name) = @_;
+ if($p->{$name}->{buffer} && -e $p->{$name}->{file}."tmp.png") {
+ rename $p->{$name}->{file}."tmp.png", $p->{$name}->{file}.".png";
+ }
if($p->{$name}->{run}>=1) {
- plot_write($p->{$name}->{fh},"set out \"".$p->{$name}->{file}.".png\"");
+ plot_write($p->{$name}->{fh},"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\"");
plot_write($p->{$name}->{fh},makeTimeString());
plot_write($p->{$name}->{fh},"replot");
}
for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
- for(my $i=0; $i< scalar @{$p->{$name}->{value}->[$j]}; $i++) {
- plot_write($p->{$name}->{fh},(($i-$p->{$name}->{entries})/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]) unless $p->{$name}->{countup};
- plot_write($p->{$name}->{fh},($i/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]) if $p->{$name}->{countup};
-# print $j." ".$i." ".$p->{$name}->{entries}." ".$p->{$name}->{xscale}." ".$p->{$name}->{value}->[$j]->[$i]."\n";
+ if($p->{$name}->{type} == TYPE_HISTORY) {
+ for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
+ if ($p->{$name}->{countup}) {
+ plot_write($p->{$name}->{fh},($i/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]);
+ }
+ else {
+ plot_write($p->{$name}->{fh},(($i-$p->{$name}->{entries})/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]);
+ }
+ }
+ }
+ elsif($p->{$name}->{type} == TYPE_BARGRAPH) {
+ for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
+ plot_write($p->{$name}->{fh},$p->{$name}->{value}->[$j]->[$i]);
+ }
}
plot_write($p->{$name}->{fh},"e");
}
my($name,$value,$curve) = @_;
$curve = 0 unless $curve;
- if($p->{$name}->{type} == TYPE_HISTORY) {
- push(@{$p->{$name}->{value}->[$curve]},$value||0);
- shift(@{$p->{$name}->{value}->[$curve]});
- }
+ push(@{$p->{$name}->{value}->[$curve]},$value||0);
+ shift(@{$p->{$name}->{value}->[$curve]});
}
+sub PlotFill {
+ my($name,$value,$slot,$curve) = @_;
+ $curve = 0 unless $curve;
+ $p->{$name}->{value}->[$curve]->[$slot] = $value||0;
+ }
+
1;
$plot->{sizey} = 420;
$plot->{nokey} = 0;
$plot->{xscale} = 4;
+$plot->{ymin} = -1;
+$plot->{ymax} = 101;
+$plot->{buffer} = 1;
HPlot::PlotInit($plot);
-my $plot2=();
+my $plot2 = ();
$plot2->{name} = "BusyTimeBars";
$plot2->{file} = "files/BusyTimeBars";
$plot2->{curves} = 1;
$plot2->{type} = HPlot::TYPE_BARGRAPH;
$plot2->{output} = HPlot::OUT_PNG;
$plot2->{ylabel} = "Deadtime (%)";
-$plot2->{sizex} = 265;
-$plot2->{sizey} = 380;
+$plot2->{sizex} = 380;
+$plot2->{sizey} = 265;
$plot2->{nokey} = 1;
+$plot2->{entries} = 9;
+$plot2->{ymin} = -1;
+$plot2->{ymax} = 101;
+$plot2->{bartitle}->[0] = "M12";
+$plot2->{bartitle}->[1] = "M34";
+$plot2->{bartitle}->[2] = "Shw";
+$plot2->{bartitle}->[3] = "RPC";
+$plot2->{bartitle}->[4] = "Ric";
+$plot2->{bartitle}->[5] = "TOF";
+$plot2->{bartitle}->[6] = "FW";
+$plot2->{bartitle}->[7] = "Sta";
+$plot2->{bartitle}->[8] = "Pi";
+$plot2->{buffer} = 1;
+HPlot::PlotInit($plot2);
-my $str = Hmon::MakeTitle(12,9,"BusyTimesNew",0);
+my $str = Hmon::MakeTitle(12,9,"Busy Times",0);
$str .= qq@<img src="%ADDPNG files/BusyTimes.png%" type="image/png">@;
$str .= Hmon::MakeFooter();
- Hmon::WriteFile("BusyTimesNew",$str);
+ Hmon::WriteFile("busyhist",$str);
+ $str = Hmon::MakeTitle(5,6,"Busy Times",0);
+ $str .= qq@<img src="%ADDPNG files/BusyTimeBars.png%" width="380" height="265" type="image/png">@;
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("busy",$str);
+
my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile";
trb_init_ports() or die trb_strerror();
my $iter=0;
while (1) {
- my $o;
my $t = trb_registertime_read_mem(0x8000,0x4030,0,8);
- $o->{0x8000} = $t->{0x8000};
+ my $o->{0x8000} = $t->{0x8000};
$t = trb_registertime_read_mem(0x8001,0x4030,0,8);
$o->{0x8001} = $t->{0x8001};
$t = trb_registertime_read_mem(0x8002,0x4030,0,8);
HPlot::PlotAdd('BusyTimes',$diff->{0x8000}->[6],0); #MDC12
HPlot::PlotAdd('BusyTimes',$diff->{0x8000}->[7],1); #MDC34
HPlot::PlotAdd('BusyTimes',$diff->{0x8000}->[3],2); #Shower
-
HPlot::PlotAdd('BusyTimes',max($diff->{0x8001}->[1],$diff->{0x8001}->[2]),3); #RPC
HPlot::PlotAdd('BusyTimes',max($diff->{0x8001}->[3],$diff->{0x8001}->[4],$diff->{0x8001}->[5]),4); #Rich
HPlot::PlotAdd('BusyTimes',$diff->{0x8002}->[1],5); #Tof
HPlot::PlotAdd('BusyTimes',$diff->{0x8001}->[6],6); #Wall
HPlot::PlotAdd('BusyTimes',$diff->{0x8002}->[2],7); #Start/Cts
HPlot::PlotAdd('BusyTimes',max($diff->{0x8003}->[1],$diff->{0x8003}->[2]),8); #Pion
+
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8000}->[6],0,0); #MDC12
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8000}->[7],1,0); #MDC34
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8000}->[3],2,0); #Shower
+ HPlot::PlotFill('BusyTimeBars',max($diff->{0x8001}->[1],$diff->{0x8001}->[2]),3,0); #RPC
+ HPlot::PlotFill('BusyTimeBars',max($diff->{0x8001}->[3],$diff->{0x8001}->[4],$diff->{0x8001}->[5]),4,0); #Rich
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8002}->[1],5,0); #Tof
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8001}->[6],6,0); #Wall
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8002}->[2],7,0); #Start/Cts
+ HPlot::PlotFill('BusyTimeBars',max($diff->{0x8003}->[1],$diff->{0x8003}->[2]),8,0); #Pion
+
+ HPlot::PlotDraw('BusyTimeBars');
+ unless(++$iter % 4) {
+ HPlot::PlotDraw('BusyTimes');
+ }
}
- unless(++$iter % 4) {
- HPlot::PlotDraw('BusyTimes');
- }
$old = $o;
usleep(250000);
}