]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Added Labels to Heatmap
authorMichael Traxler <M.Traxler@gsi.de>
Fri, 14 Nov 2014 23:20:38 +0000 (00:20 +0100)
committerMichael Traxler <M.Traxler@gsi.de>
Fri, 14 Nov 2014 23:20:38 +0000 (00:20 +0100)
dmon/code/monitor.pl
dmon/scripts/dmon_heatmaprich.pl

index 04dbcedcb7fdb993eb04966de1b8e7da8d2a5d6b..11b3293e275237833f81bc962160243e7cd51017 100755 (executable)
@@ -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];
+  }
+ }
+
 </script>$;
              }
 $out .= qq$
index b50974eb820c4683f39cccaecaea7f564c77d7d3..11b45b98965639ee7a0e3e3a6a65c22b4cb70eca 100755 (executable)
@@ -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@<img src="%ADDPNG HeatmapRich.png%" type="image/png">@;
+   $str .= qq@<img src="%ADDPNG HeatmapRich.png%" type="image/png" id="heatmap-img"><div id="heatmap-caption" style="margin-top: -5px;"></div>@;
    $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();