From f00ae66dbf314ecebb434a8baca0fb931b47f673 Mon Sep 17 00:00:00 2001 From: "www@jspc55" Date: Fri, 28 Feb 2014 14:36:51 +0100 Subject: [PATCH] minor fixes, added scaleoffset compatibility to adcread and plotService/adcmon --- tools/adcread.pl | 16 +++++++++++++--- tools/changeConfigVal.pl | 3 ++- tools/plotService.pl | 6 +++--- tools/xmlOperations.pm | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/adcread.pl b/tools/adcread.pl index c032c3b..67b703f 100755 --- a/tools/adcread.pl +++ b/tools/adcread.pl @@ -39,6 +39,7 @@ my $DAQOPSERVER = $q->param('DAQOPSERVER') || $ENV{'DAQOPSERVER'}; my $n = $q->param('n') || 10; my $delay = $q->param('delay') || 5 ; #ms my $verbose = $q->param('verbose') || 0; +my $unit = $q->param('unit') || 0; print header('text/plain') if $isHttpReq; print_usage() unless ( defined($channel) && defined($chip) && defined($FPGA)); @@ -60,6 +61,13 @@ $ENV{'DAQOPSERVER'} = $DAQOPSERVER; my $self = $xmldb->channelParm($chip,$channel); + +if ($unit) { + print $self->{unit}; + exit; +} + + $self->{FPGA} = any2dec($FPGA); trb_init_ports() or die trb_strerror(); @@ -89,7 +97,7 @@ print "$mean\t$stdev\t$min\t$max\n"; sub getVal{ my $read = trb_register_read($self->{FPGA},$self->{address}); - my $value = ($read->{$self->{FPGA}} & 0xFFFF ) * $self->{scale}; + my $value = ($read->{$self->{FPGA}} & 0xFFFF ) * $self->{scale} + $self->{scaleoffset}; return $value; } @@ -97,8 +105,8 @@ sub minMax{ # read min and max my $read = trb_register_read($self->{FPGA},$self->{address}+0x30); my $minmax = ($read->{$self->{FPGA}} ) ; - my $min = ($minmax & 0x0000FFFF) * $self->{scale}; # lower 16 bit - my $max = ($minmax >> 16 ) * $self->{scale}; # upper 16 bit + my $min = ($minmax & 0x0000FFFF) * $self->{scale} + $self->{scaleoffset}; # lower 16 bit + my $max = ($minmax >> 16 ) * $self->{scale} + $self->{scaleoffset}; # upper 16 bit return ($min, $max); } @@ -122,6 +130,8 @@ Options: if left out, will use DAQOPSERVER ENV variable verbose = <0|1> if verbose=1 then script will print all sampled values as well as the channel unit and other debug data + unit = <0|1> if unit=1 then only the selected channel unit is + printed available ADC channels: diff --git a/tools/changeConfigVal.pl b/tools/changeConfigVal.pl index e605dca..2272a24 100755 --- a/tools/changeConfigVal.pl +++ b/tools/changeConfigVal.pl @@ -164,7 +164,8 @@ Register/Field=Value Options: -h, --help brief help message -v, --verbose detailed debugging info about ongoing actions - -c, --config specifies the input config xml file + -c, --config specifies the input config xml file + (including path if necessary!) =back diff --git a/tools/plotService.pl b/tools/plotService.pl index 8f40700..6fb4782 100755 --- a/tools/plotService.pl +++ b/tools/plotService.pl @@ -206,12 +206,12 @@ sub sample { # sample random number for debug # HPlot::PlotAdd($self->{requestString},rand()); my $read = trb_register_read($self->{FPGA},$self->{address}); - my $value = ($read->{$self->{FPGA}} & 0xFFFF ) * $self->{scale}; + my $value = ($read->{$self->{FPGA}} & 0xFFFF ) * $self->{scale} + $self->{scaleoffset}; # read min and max my $read = trb_register_read($self->{FPGA},$self->{address}+0x30); my $minmax = ($read->{$self->{FPGA}} ) ; - my $min = ($minmax & 0x0000FFFF) * $self->{scale}; # lower 16 bit - my $max = ($minmax >> 16 ) * $self->{scale}; # upper 16 bit + my $min = ($minmax & 0x0000FFFF) * $self->{scale} + $self->{scaleoffset}; # lower 16 bit + my $max = ($minmax >> 16 ) * $self->{scale} + $self->{scaleoffset}; # upper 16 bit # print $value."\n" if $myverbose; HPlot::PlotAdd($self->{requestString},$value,0); HPlot::PlotAdd($self->{requestString},$min,1); diff --git a/tools/xmlOperations.pm b/tools/xmlOperations.pm index b7c7369..62b3147 100644 --- a/tools/xmlOperations.pm +++ b/tools/xmlOperations.pm @@ -352,7 +352,7 @@ sub save { my $xmlfile = $configFile; my $newValue; $newValue = $_[2]; - my $base = $_[3]; + my $base = $_[3] || ""; my $xmltree = $configTree; -- 2.43.0