my $p;
-use constant {TYPE_HISTORY => 1, TYPE_BARGRAPH => 2};
+use constant {TYPE_HISTORY => 1, TYPE_BARGRAPH => 2, TYPE_HEATMAP => 3};
use constant {OUT_PNG => 1,
OUT_SVG => 2, #n/a
plot_write($fh,"set yrange [".$p->{$name}->{ymin}.":]");
}
+ if(defined $p->{$name}->{xmin} && defined $p->{$name}->{xmax}) {
+ plot_write($fh,"set xrange [".$p->{$name}->{xmin}.":".$p->{$name}->{xmax}."]");
+ }
+ elsif(defined $p->{$name}->{xmax}) {
+ plot_write($fh,"set xrange [:".$p->{$name}->{xmax}."]");
+ }
+ elsif(defined $p->{$name}->{xmin}) {
+ plot_write($fh,"set xrange [".$p->{$name}->{xmin}.":]");
+ }
+
if($p->{$name}->{type} == TYPE_HISTORY) {
if($p->{$name}->{fill}) {
plot_write($fh,"set style fill solid 1.00");
plot_write($fh,"set style fill solid 1.00 border -1");
plot_write($fh,"set grid noxtics ytics");
plot_write($fh,"set boxwidth 4 absolute");
- 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);
+ if(defined $p->{$name}->{bartitle} && scalar @{$p->{$name}->{bartitle}}) {
+ 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.5,0 scale 0");
}
- plot_write($fh,") offset 2.5,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);
}
plot_write($fh," ");
}
+ elsif($p->{$name}->{type} == TYPE_HEATMAP) {
+ plot_write($fh,"set view map");
+ plot_write($fh,"splot '-' matrix with image");
+ }
else {
die "Plot type not supported";
}
plot_write($p->{$name}->{fh},makeTimeString());
plot_write($p->{$name}->{fh},"replot");
}
- for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
- if($p->{$name}->{type} == TYPE_HISTORY) {
+
+ if($p->{$name}->{type} == TYPE_HISTORY) {
+ for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
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]);
plot_write($p->{$name}->{fh},(($i-$p->{$name}->{entries})/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]);
}
}
+ plot_write($p->{$name}->{fh},"e");
}
- elsif($p->{$name}->{type} == TYPE_BARGRAPH) {
+ }
+
+
+ if($p->{$name}->{type} == TYPE_BARGRAPH) {
+ for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
plot_write($p->{$name}->{fh},$p->{$name}->{value}->[$j]->[$i]+1E-9);
}
+ plot_write($p->{$name}->{fh},"e");
+ }
+ }
+
+
+ if($p->{$name}->{type} == TYPE_HEATMAP) {
+ for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
+ for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
+ plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)." ",1);
+ }
+ plot_write($p->{$name}->{fh}," ",0);
}
- plot_write($p->{$name}->{fh},"e");
+ plot_write($p->{$name}->{fh},"e");
+ plot_write($p->{$name}->{fh},"e");
}
+
+
$p->{$name}->{run}++;
}
--- /dev/null
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use Data::Dumper;
+use Data::TreeDumper;
+use Hmon;
+use QA;
+use HADES::TrbNet;
+use HPlot;
+use Time::HiRes qw(usleep time);
+use List::Util qw[min max];
+
+
+my $plot2 = ();
+$plot2->{name} = "DiamondRate";
+$plot2->{file} = "files/DiamondRate";
+$plot2->{curves} = 1;
+$plot2->{entries} = 6;
+$plot2->{curves} = 6;
+$plot2->{type} = HPlot::TYPE_HEATMAP;
+$plot2->{output} = HPlot::OUT_PNG;
+$plot2->{zlabel} = "Hitrate";
+$plot2->{sizex} = 580;
+$plot2->{sizey} = 465;
+$plot2->{nokey} = 1;
+$plot2->{buffer} = 1;
+$plot2->{xmin} = -0.5;
+$plot2->{xmax} = 5.5;
+$plot2->{ymin} = -0.5;
+$plot2->{ymax} = 5.5;
+
+HPlot::PlotInit($plot2);
+
+
+
+# Nino 1: FPGA 1, connector 1
+# Nino 2: FPGA 1, connector 2
+#
+# Nino 3: FPGA 3, connector 1
+# Nino 4: FPGA 3, connector 2
+#
+# Nino 5: FPGA 4, connector 1
+# Nino 6: FPGA 4, connector 2
+
+# y x NNo Nch FPGA channel
+# 1 1 1 2 1 13 13 2 8 5000 1f
+# 1 2 2 2 2 5 5 4 4 5002 17
+# 1 3 3 1 2 5 5 3 4 5002 07
+# 1 4 4 1 2 1 1 3 2 5002 03
+# 1 5 5 2 2 7 7 4 5 5002 19
+# 1 6 6 2 2 11 11 4 7 5002 1d
+
+# 2 1 7 2 1 11 11 2 7 5000 1d
+# 2 2 8 2 1 9 9 2 6 5000 1b
+# 2 3 9 1 1 13 13 1 8 5000 0f
+# 2 4 10 1 2 3 3 3 3 5002 05
+# 2 5 11 2 2 3 3 4 3 5002 15
+# 2 6 12 2 2 13 13 4 8 5002 1f
+
+# 3 1 13 1 1 3 3 1 3 5000 05
+# 3 2 14 1 1 11 11 1 7 5000 0d
+# 3 3 15 2 2 1 1 4 2 5002 13
+# 3 4 16 2 2 9 9 4 6 5002 1b
+# 3 5 17 1 2 11 11 3 7 5002 0d
+# 3 6 18 1 2 9 9 3 6 5002 0b
+
+# 4 1 19 1 1 1 1 1 2 5000 03
+# 4 2 20 1 1 9 9 1 6 5000 0b
+# 4 3 21 2 1 7 7 2 5 5000 19
+# 4 4 22 2 3 13 13 6 8 5003 1f
+# 4 5 23 1 3 7 7 6 5 5003 19 !!!!!!
+# 4 6 24 1 2 13 13 3 8 5002 0f
+
+# 5 1 25 2 1 5 5 2 4 5000 17
+# 5 2 26 2 3 11 11 6 7 5003 1d
+# 5 3 27 1 1 5 5 1 4 5000 07
+# 5 4 28 1 3 9 9 5 4 5003 07
+# 5 5 29 2 3 1 3 6 3 5003 15
+# 5 6 30 2 3 3 5 6 4 5003 17
+
+# 6 1 31 2 1 1 1 2 2 5000 13
+# 6 2 32 2 1 3 3 2 3 5000 15
+# 6 3 33 1 3 13 13 5 2 5003 03
+# 6 4 34 1 3 11 11 5 3 5003 05
+# 6 5 35 2 3 9 9 6 6 5003 1b
+# 6 6 36 2 3 7 7 6 5 5003 19 !!!!!!
+
+my $fpga = [[0, 2, 2, 2, 2, 2 ],[0, 0, 0, 2, 2, 2 ],[0, 0, 2, 2, 2, 2 ],
+ [0, 0, 0, 3, 3, 2 ],[0, 3, 0, 3, 3, 3 ],[0, 0, 3, 3, 3, 3 ]];
+my $chan = [[0x1f,0x17,0x07,0x03,0x19,0x1d],[0x1d,0x1b,0x0f,0x05,0x15,0x1f],[0x05,0x0d,0x13,0x1b,0x0d,0x0b],
+ [0x03,0x0b,0x19,0x1f,0x19,0x0f],[0x17,0x1d,0x07,0x07,0x15,0x17],[0x13,0x15,0x03,0x05,0x1b,0x19]];
+
+my $old;
+my $oldtime = time();
+my $time = time();
+my $diff;
+my $iter = 0;
+
+trb_init_ports() or die trb_strerror();
+
+
+while (1) {
+ my $o;
+ foreach my $b (0x5000,0x5002,0x5003) {
+ my $t = trb_register_read_mem($b,0xc000,0,33);
+ $o->{$b} = $t->{$b};
+ }
+
+ if (defined $old) {
+ foreach my $b (keys %$o) {
+ for my $v (0..32) {
+ my $tdiff = time() - $oldtime;
+ my $vdiff = ($o->{$b}->[$v]&0xffffff) - ($old->{$b}->[$v]&0xffffff);
+ if ($vdiff < 0) { $vdiff += 2**24;}
+ $diff->{$b}->[$v] = $vdiff/($tdiff|1);
+ }
+ }
+
+ for my $x (0..5) {
+ for my $y (0..5) {
+ HPlot::PlotFill('DiamondRate',$diff->{$fpga->[$y]->[$x]+0x5000}->[$chan->[$y]->[$x]],5-$y,$x);
+ }
+ }
+ HPlot::PlotDraw('DiamondRate');
+ }
+
+ $old = $o;
+ $oldtime = time();
+ sleep(1);
+ }
\ No newline at end of file