]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
minor fixes, added scaleoffset compatibility to adcread and plotService/adcmon
authorwww@jspc55 <www@jspc55>
Fri, 28 Feb 2014 13:36:51 +0000 (14:36 +0100)
committerwww@jspc55 <www@jspc55>
Fri, 28 Feb 2014 13:36:51 +0000 (14:36 +0100)
tools/adcread.pl
tools/changeConfigVal.pl
tools/plotService.pl
tools/xmlOperations.pm

index c032c3b54296fc0edf9988966a9c01119098cab5..67b703f90613b595a0ce249c143173fb53a8d642 100755 (executable)
@@ -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:
 
index e605dca2b008f16d1d80b497e131c7c694f927f9..2272a242d38b0506e1e7e19409a24bf82ed5b2a4 100755 (executable)
@@ -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
 
index 8f40700be805bbe2e4fe6f79ab437bbcf4069b65..6fb47821f65b0971d2dac3928a09568316e82690 100755 (executable)
@@ -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);
index b7c736908dc9fa4d51fbf455290bf6134d734b2e..62b3147e2df77128a1d1cd200bc293cece332a6b 100644 (file)
@@ -352,7 +352,7 @@ sub save {
   my $xmlfile      = $configFile;
   my $newValue;
   $newValue        = $_[2];
-  my $base         = $_[3];
+  my $base         = $_[3] || "";
   
   my $xmltree = $configTree;