From 0bdca70cdd3646989d9977907310b0c624093ff5 Mon Sep 17 00:00:00 2001 From: Michael Traxler Date: Sat, 15 Nov 2014 00:20:38 +0100 Subject: [PATCH] Added Labels to Heatmap --- dmon/code/monitor.pl | 26 +++++++++++++++++++++++++ dmon/scripts/dmon_heatmaprich.pl | 33 ++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/dmon/code/monitor.pl b/dmon/code/monitor.pl index 04dbced..11b3293 100755 --- a/dmon/code/monitor.pl +++ b/dmon/code/monitor.pl @@ -116,6 +116,8 @@ function reload() { reloadevery = setTimeout('reload()',$.($delay*1000).qq$); delete xmlhttp; delete saveScrollTop; + + heatmapRegister(); } }; if(document.getElementById('logbox')) { @@ -171,6 +173,30 @@ function blink() { blinkcnt++; } + function heatmapRegister() { + if (!document.getElementById('heatmap-img')) return; + + if (typeof HeatmapDef === 'undefined') { + var js = document.createElement("script"); + js.type = "text/javascript"; + js.src = '../HeatmapRichDefs.js'; + document.body.appendChild(js); + } + + document.getElementById('heatmap-img').onmousemove = document.getElementById('heatmap-img').onmouseover = function(e) { + var cx = e.clientX; + var cy = e.clientY; + + if (!cx || !cy) return; + + var ix = parseInt((cx - HeatmapDef.x) / HeatmapDef.w); + var iy = 32- parseInt((cy - HeatmapDef.y) / HeatmapDef.h); + if (ix < 0 || ix > 31 || iy < 0 || iy > 31) return; + + document.getElementById('heatmap-caption').innerHTML = HeatmapDef.labels[ix][iy]; + } + } + $; } $out .= qq$ diff --git a/dmon/scripts/dmon_heatmaprich.pl b/dmon/scripts/dmon_heatmaprich.pl index b50974e..11b45b9 100755 --- a/dmon/scripts/dmon_heatmaprich.pl +++ b/dmon/scripts/dmon_heatmaprich.pl @@ -35,17 +35,46 @@ $plot2->{xmin} = 0.5; $plot2->{xmax} = 32.5; $plot2->{ymin} = 0.5; $plot2->{ymax} = 32.5; +$plot2->{cbmin} = "0"; +$plot2->{cbmax} = "100<*<1000000"; $plot2->{showvalues} = 0; $plot2->{xlabel} = "column"; $plot2->{ylabel} = "row"; -$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.85\nset bmargin at screen 0.07\nset tmargin at screen 0.95"; +$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.80\nset bmargin at screen 0.07\nset tmargin at screen 0.95"; HPlot::PlotInit($plot2); my $str = Dmon::MakeTitle(9,14,"HeatmapRich",0); - $str .= qq@@; + $str .= qq@
@; $str .= Dmon::MakeFooter(); Dmon::WriteFile("HeatmapRich",$str); +sub generateDef { + my $x = 55; my $y = 50; my $w = (566-$x) / 32.0; my $h = (619-$y) / 32.0; + + $str = qq@ + var HeatmapDef = { + 'x': $x, 'y': $y, 'w': $w, 'h': $h, + 'labels': [ + @; + + for my $ix (1..32) { + $str .= '['; + for my $iy (1..32) { + my $fpga = $ChannelMapping::chanmap->{fpga}->[$ix]->[$iy]; + my $channel = ($ChannelMapping::chanmap->{chan}->[$ix]->[$iy]-1) / 2; + + $str .= sprintf("'0x%04x CH: %d'", $fpga, $channel) . ($iy == 32 ? '' : ','); + } + $str .= ']' . ($ix == 32 ? '' : ',') . "\n"; + } + + $str .= ']};'; + return $str; +} + +open FH, ">", Dmon::DMONDIR . '/HeatmapRichDefs.js'; +print FH generateDef; +close FH; my $old; my $oldtime = time(); -- 2.43.0