From: Jan Michel Date: Tue, 10 Dec 2013 17:10:20 +0000 (+0100) Subject: some optimization X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=ded0535fc79bc3a172b9633e4aba338cd42c13eb;p=daqtools.git some optimization --- diff --git a/web/htdocs/tools/scaler.pl b/web/htdocs/tools/scaler.pl index 13fcbef..cf10547 100755 --- a/web/htdocs/tools/scaler.pl +++ b/web/htdocs/tools/scaler.pl @@ -20,9 +20,9 @@ if($ENV{'QUERY_STRING'} =~ /get/) { print "Content-type: text/html\r\n\r\n"; my $q = $ENV{'QUERY_STRING'}; - $q = substr($q,3); - if(-e "/tmp/scalers.$q.store") { - $olddata = lock_retrieve("/tmp/scalers.$q.store"); + @p = split('\.',$q); + if(-e "/tmp/scalers.$p[1].store") { + $olddata = lock_retrieve("/tmp/scalers.$p[1].store"); } my $data = trb_registertime_read_mem(0x3820,0xc001,0,64) or die trb_strerror(); my $delay = ($data->{0x3820}->{time}->[0]||0) - ($olddata->{values}->{0x3820}->{time}->[0]||60000); @@ -57,7 +57,7 @@ if($ENV{'QUERY_STRING'} =~ /get/) { $avgsum /= 1-$start; print "

"; $t = sprintf("
Diamond $iAverageCurrentRatio"); - $t .= sprintf("",$i,$q,time()/5); + $t .= sprintf("",$i,$p[1],time()/5); $t .= sprintf("
Sum%d%d",$avgsum,$sum); for(my $j=0;$j<4;$j++) { my $avgrate = $rate->[2*$j+8+$i*16]; @@ -77,14 +77,14 @@ if($ENV{'QUERY_STRING'} =~ /get/) { } - printf("

Time between last two readings (mod 1.6s) %d ms",$delay/1000.); + printf("


Time between last two readings (mod 1.31s) %d ms",$delay/1000.); printf(". %d entries",scalar @{$olddata->{rate}}); if((scalar @{$olddata->{rate}}) >= 100) { shift(@{$olddata->{rate}}); } push(@{$olddata->{rate}},$rate); $olddata->{values} = $data; - lock_store($olddata,"/tmp/scalers.$q.store"); + lock_store($olddata,"/tmp/scalers.$p[1].store"); } @@ -95,13 +95,11 @@ elsif($ENV{'QUERY_STRING'} =~ /plot/) { &htsponse(200, "OK"); print "Content-type: image/png\r\n\r\n"; my $q = $ENV{'QUERY_STRING'}; - $num = substr($q,4,1); - $q = substr($q,5); - @p = split('\.',$q); -# print $q.".".$p[0]; - if(-e "/tmp/scalers.$p[0].store") { - $data = lock_retrieve("/tmp/scalers.$p[0].store"); + my @p = split('\.',$q); + + if(-e "/tmp/scalers.$p[2].store") { + $data = lock_retrieve("/tmp/scalers.$p[2].store"); } if(! ref($data) eq "ARRAY") { return; @@ -115,14 +113,12 @@ elsif($ENV{'QUERY_STRING'} =~ /plot/) { $cmd .= "plot '-' with lines,'-' with lines,'-' with lines, '-' with lines\n"; for(my $j=0; $j<4; $j++) { foreach my $r (@{$data->{rate}}) { - $cmd .= ($r->[$num*16+8+2*$j]/1000.)."\n"; + $cmd .= ($r->[$p[1]*16+8+2*$j]/1000.)."\n"; } $cmd .= "\ne\n"; } $cmd = "echo \"$cmd\" | gnuplot"; - my @o = qx($cmd); - print @o; - return 1; + print qx($cmd); } @@ -141,10 +137,12 @@ else { my @setup; $setup[0]->{name} = "Scalers"; - $setup[0]->{cmd} = "get".$ts; + $setup[0]->{cmd} = "get.".$ts; $setup[0]->{period} = 1000; $setup[0]->{generic} = 0; xmlpage::initPage(\@setup,$page); } + +return 1; \ No newline at end of file