From: hadaq <hadaq@hades33.gsi.de>
Date: Sun, 6 Feb 2022 18:14:31 +0000 (+0100)
Subject: add JSON dump to HPlot
X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=2e87ac9112cad59864508ceaaf45c5173fe12281;p=daqtools.git

add JSON dump to HPlot
---

diff --git a/tools/HPlot.pm b/tools/HPlot.pm
index 8dd5dcc..3a75d0e 100755
--- a/tools/HPlot.pm
+++ b/tools/HPlot.pm
@@ -5,6 +5,7 @@ use warnings;
 use strict;
 use FileHandle;
 use Storable qw(lock_store lock_retrieve);
+use JSON;
 
 my $p;
 my $storefile;
@@ -106,7 +107,7 @@ sub PlotInit {
 
   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}." truecolor font \"monospace,8\"");
+    plot_write($fh,"set term png size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey}." truecolor font \"monospace,9\"");
     plot_write($fh,"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\"");
     }
   elsif($p->{$name}->{output} == OUT_SCREEN) {
@@ -361,5 +362,22 @@ sub PlotLimitEntries {
   $p->{$name}{limitentries} = $entries;
   }
 
+sub PlotJsonDump {
+  my ($name,$file) = @_;
+  waitpid($p->{$name}->{pidJSON},0) if $p->{$name}->{pidJSON};
+  my $pid = fork;
+  unless ($pid) {
+    my $fh;
+    my $json = new JSON;
+    $json = $json->utf8;
+    $json = $json->allow_unknown();
+    open($fh, ">", $file);
+    print $fh   $json->encode($p->{$name});
+    close $fh;
+    exit;
+    }
+  $p->{$name}->{pidJSON} = $pid;
+    
+  }
   
 1;