From: www@jspc55 Date: Wed, 5 Feb 2014 12:14:24 +0000 (+0100) Subject: bugfix in adcmon.pl UI X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=637dd98484a61763ba60e2c43222a3f51fbb06f6;p=mvdsensorcontrol.git bugfix in adcmon.pl UI --- diff --git a/layout/adcmon.css b/layout/adcmon.css index 7228c59..1f99875 100644 --- a/layout/adcmon.css +++ b/layout/adcmon.css @@ -21,7 +21,7 @@ float:right; position:absolute; position:fixed; - top: 0px; + top: 50px; left: 640px; width:280px; padding:10px; @@ -36,7 +36,7 @@ /* position:fixed; */ /* width:320px; */ left:0px; - top:0px; + top:50px; min-width: 600px; min-height: 400px; padding:10px; diff --git a/tools/Common.pm b/tools/Common.pm index 87ababc..b75f921 100644 --- a/tools/Common.pm +++ b/tools/Common.pm @@ -245,6 +245,32 @@ sub writeFieldInRegister { ## misc utilities ############################### +sub average{ + my($data) = @_; + if (not @$data) { + die("Empty array\n"); + } + my $total = 0; + foreach (@$data) { + $total += $_; + } + my $average = $total / @$data; + return $average; +} + +sub stdev{ + my($data) = @_; + if(@$data == 1){ + return 0; + } + my $average = &average($data); + my $sqtotal = 0; + foreach(@$data) { + $sqtotal += ($average-$_) ** 2; + } + my $std = ($sqtotal / (@$data-1)) ** 0.5; + return $std; +} diff --git a/tools/adcmon.pl b/tools/adcmon.pl index 97bbd72..1cd0e10 100755 --- a/tools/adcmon.pl +++ b/tools/adcmon.pl @@ -1,6 +1,24 @@ #!/usr/bin/perl -w +############## +## CGI options to this tool +############## + +# adcmon.pl?option1=value1&option2=value2 ... +# +# options: +# DAQOPSERVER = hostname:ports +# FGPA = FPGA address in hex (with leading 0x) +# CB = number of ConverterBoard connected to selected FPGA [0,1] +# chip = number of Sensor connected to selected ConverterBoard [0,1] +# channel = comma separated list of ADC channels. These channels get +# preselected in the selection checkbox list. + +# Example: +# http://jspc55/mvdsensorcontrol/tools/adcmon.pl?DAQOPSERVER=jspc55:88&FPGA=0xd882&CB=0&chip=0&channel=CurrentDigital,CurrentAnalog + + my $me = "adcmon.pl"; use strict; @@ -74,6 +92,9 @@ sub page_body{ init_html(); my $q = shift; +print h2 "Converter Board ADC Monitor"; + + print '
'; print_selectors($q); print '
'; @@ -91,6 +112,7 @@ print '
'; print_debugStuff($q); print '
'; + } sub print_selectors { @@ -99,7 +121,7 @@ sub print_selectors { my $FPGA = $q->param('FPGA'); my $CB = $q->param('CB'); my $chip = $q->param('chip'); - my $channel = $q->param('channel'); + print "
Settings
"; @@ -187,17 +209,26 @@ sub print_selectors { print ""; - my $xmldb = AccessXmlDb->new( entityFile => $xmldbEntityFile ); - for my $element ( @{$xmldb->channelList()}) { - print ""; - print ""; - print ""; - print ""; + my @channels = split(",",$q->param('channel')) if defined($q->param('channel')); + my %channel_hash; + for my $channel (@channels){ + $channel_hash{$channel} = 1; + } + if(defined($FPGA) && defined($CB) && defined($chip)){ + my $xmldb = AccessXmlDb->new( entityFile => $xmldbEntityFile ); + for my $element ( @{$xmldb->channelList()}) { + print ""; + print ""; + print ""; + print ""; + } } print "
"; - print "$element"; - print ""; - print ""; - print "
"; + print "$element"; + print ""; + print ""; + print "
"; @@ -228,7 +259,8 @@ sub plot_request { print "
Plots
"; my $q= shift; - my @requestStrings = split(",",$q->param('requestStrings')); + my @requestStrings = (); + @requestStrings = split(",",$q->param('requestStrings')) if defined($q->param('requestStrings')); return if (@requestStrings == 0); $ENV{'DAQOPSERVER'} = $q->param('DAQOPSERVER') if defined $q->param('DAQOPSERVER');