From 10dae4d620f9081647784843bbb2551d99f1fb81 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Mon, 14 Oct 2013 19:28:05 +0200 Subject: [PATCH] some more changes to xml-db --- web/htdocs/commands/xmlpage.pm | 9 +- web/htdocs/network/trbnet.pl | 2 +- web/htdocs/scripts/scriptsnew.js | 14 ++- xml-db/database/TrbNet.xml | 48 +++++++++- xml-db/get.pl | 147 +++++++++++++++++-------------- xml-db/schema/TrbNetCommon.xsd | 5 +- 6 files changed, 148 insertions(+), 77 deletions(-) diff --git a/web/htdocs/commands/xmlpage.pm b/web/htdocs/commands/xmlpage.pm index b17b3ba..3ad93bd 100644 --- a/web/htdocs/commands/xmlpage.pm +++ b/web/htdocs/commands/xmlpage.pm @@ -2,17 +2,18 @@ package xmlpage; -my $active = -1; +my $active = 0; +my $n = 0; my @setup; sub getView { my ($n) = @_; - $active = $n; +# $active = $n; if($setup[$n]->{refresh}) { print qq||; } - print qq||; + print qq||; print qq|
|; @@ -49,7 +50,7 @@ EOF
); for ( my $s = 0; $s < scalar @setup; $s++) { - print qq||.$setup[$s]->{name}.qq||; + print qq||.$setup[$s]->{name}.qq||; } print qq(
); diff --git a/web/htdocs/network/trbnet.pl b/web/htdocs/network/trbnet.pl index 3d177a5..63c8adf 100755 --- a/web/htdocs/network/trbnet.pl +++ b/web/htdocs/network/trbnet.pl @@ -14,7 +14,7 @@ my @setup; $setup[0]->{name} = "StatusRegisters"; $setup[0]->{cmd} = "TrbNet-0xffff-StatusRegisters"; $setup[0]->{refresh} = 1; -$setup[0]->{period} = 0; +$setup[0]->{period} = 10000; $setup[1]->{name} = "BoardInfo"; $setup[1]->{cmd} = "TrbNet-0xffff-BoardInformation"; diff --git a/web/htdocs/scripts/scriptsnew.js b/web/htdocs/scripts/scriptsnew.js index dfdf5a4..1bc169f 100644 --- a/web/htdocs/scripts/scriptsnew.js +++ b/web/htdocs/scripts/scriptsnew.js @@ -17,7 +17,7 @@ function getdata(command,callback) { } -function getdataprint(command,dId,async) { +function getdataprint(command,dId,async,time) { //async==true : do what you can when you can do it :D //async==false : do the task after you finished the previous task! @@ -29,13 +29,19 @@ function getdataprint(command,dId,async) { xmlhttp=new XMLHttpRequest(); //cb = callback; var destId = dId; + var cmd = command; + var asynci = async; + var timei = time; xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 && xmlhttp.status==200) { //if(cb) - if(document.getElementById(destId)){ - document.getElementById(destId).innerHTML = xmlhttp.responseText; - } + if(document.getElementById(destId)){ + document.getElementById(destId).innerHTML = xmlhttp.responseText; + } + if(time) { + setTimeout("getdataprint('"+cmd+"','"+destId+"','"+asynci+"','"+timei+"')",timei); + } //cb(xmlhttp.responseText); //document.getElementById(destId).innerHTML = xmlhttp.responseText; } diff --git a/xml-db/database/TrbNet.xml b/xml-db/database/TrbNet.xml index 301fb2d..46264fd 100644 --- a/xml-db/database/TrbNet.xml +++ b/xml-db/database/TrbNet.xml @@ -82,13 +82,57 @@ Number of received network resets - + Number of retransmit requests received - + Number of retransmit requests sent + + + Information abotu the last received trigger + + The lower 16 Bit of the trigger information + + + The last trigger type + + + Lower four bits of last trigger number + + + The last trigger code + + + + + Trigger input statistics + + Number of invalid triggers. I.e. LVL1 triggers not preceeded by a reference time signal + + + Count of multiple reference time signals before a LVL1 trigger, i.e. additional edges on the input which were not sent by the CTS + + + + + Trigger input statistics + + Number of short signals on the reference time input. E.g. signals detected by the synchronous logic, but shorter than the 100 ns reference time signal + + + Number of occurences of reference time signals before a calibration trigger which should not sent a reference time + + + + + Trigger input statistics + + Number of edges on the reference time input. Sampled using asynchronous circuitry. Not available in all designs + + + diff --git a/xml-db/get.pl b/xml-db/get.pl index 02dcd49..3383c86 100755 --- a/xml-db/get.pl +++ b/xml-db/get.pl @@ -12,98 +12,113 @@ use File::chdir; use Storable qw(lock_retrieve); use Text::TabularDisplay; use feature "switch"; +use CGI::Carp qw(fatalsToBrowser); +my ($db,$data,$once,$slice); my $help = 0; my $verbose = 0; my $isbrowser = 0; - +my $server = $ENV{'SERVER_SOFTWARE'} || ""; +my @request; my ($file,$netaddr,$name, $style); + + $ENV{'DAQOPSERVER'}="localhost:7" unless (defined $ENV{'DAQOPSERVER'}); +die "can not connect to trbnet-daemon on $ENV{'DAQOPSERVER'}: ".trb_strerror() unless (defined &trb_init_ports()); + + + +if (defined $ENV{'QUERY_STRING'}) { + @request = split("&",$ENV{'QUERY_STRING'}); + unless ($server =~ /HTTPi/i) { + print "Content-type: text/html\n\n"; + } + } +else { + $request[0] = ""; #Dummy entry to run foreach + } + +foreach my $req (@request) { ############################### #### Check if browser or command line ############################### -if(defined $ENV{'QUERY_STRING'}) { - if($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { - $isbrowser = 1; - ($file,$netaddr,$name,$style) = split("-",$ENV{'QUERY_STRING'}); - $file = "htdocs/xml-db/cache/$file.entity"; - use CGI::Carp qw(fatalsToBrowser); + + if(defined $ENV{'QUERY_STRING'}) { + if($server =~ /HTTPi/i) { + $isbrowser = 1; + ($file,$netaddr,$name,$style) = split("-",$req); + $file = "htdocs/xml-db/cache/$file.entity"; + } + else { + # use FindBin qw($RealBin); + my $RealBin = "."; + $isbrowser = 1; + ($file,$netaddr,$name,$style) = split("-",$req); + $file = "$RealBin/cache/$file.entity"; + } } else { -# use FindBin qw($RealBin); + # use FindBin qw($RealBin); my $RealBin = "."; - $isbrowser = 1; - ($file,$netaddr,$name,$style) = split("-",$ENV{'QUERY_STRING'}); - $file = "$RealBin/cache/$file.entity"; - use CGI::Carp qw(fatalsToBrowser); - print "Content-type: text/html\n\n"; + Getopt::Long::Configure(qw(gnu_getopt)); + GetOptions( + 'help|h' => \$help, + 'verbose|v+' => \$verbose, + ) or pod2usage(2); + pod2usage(1) if $help; + + $file = "$RealBin/cache/$ARGV[0].entity"; + $netaddr = $ARGV[1] || ""; + $name = $ARGV[2] || ""; + $style = $ARGV[3] || ""; } - } -else { -# use FindBin qw($RealBin); - my $RealBin = "."; - Getopt::Long::Configure(qw(gnu_getopt)); - GetOptions( - 'help|h' => \$help, - 'verbose|v+' => \$verbose, - ) or pod2usage(2); - pod2usage(1) if $help; - - $file = "$RealBin/cache/$ARGV[0].entity"; - $netaddr = $ARGV[1] || ""; - $name = $ARGV[2] || ""; - $style = $ARGV[3] || ""; - } - $style = "" unless $style; -my $isInline = $style =~ /inline/i; -my $isColor = $style =~ /color/i; -my $sortAddr = $style =~ /sortaddr/i; - $verbose = ($style =~ /verbose/i) ||$verbose; + $style = "" unless $style; + my $isInline = $style =~ /inline/i; + my $isColor = $style =~ /color/i; + my $sortAddr = $style =~ /sortaddr/i; + $verbose = ($style =~ /verbose/i) ||$verbose; ############################### #### Check arguments for validity ############################### -die "Entity $file not found.\n" unless(-e $file) ; -die "DAQOPSERVER not set in environment" unless (defined $ENV{'DAQOPSERVER'}); -die "can not connect to trbnet-daemon on $ENV{'DAQOPSERVER'}: ".trb_strerror() unless (defined &trb_init_ports()); - -if ($netaddr=~ m/0x([0-9a-fA-F]{4})/) {$netaddr = hex($1);} -elsif ($netaddr=~ m/([0-9]{1,5})/) {$netaddr = $1;} -else {die "Could not parse address $netaddr\n";} + die "Entity $file not found.\n" unless(-e $file) ; + + if ($netaddr=~ m/0x([0-9a-fA-F]{4})/) {$netaddr = hex($1);} + elsif ($netaddr=~ m/([0-9]{1,5})/) {$netaddr = $1;} + else {die "Could not parse address $netaddr\n";} -my $slice = undef; -if ($name =~ m/^([a-zA-Z0-9]+)\.(\d+)$/) {$name = $1; $slice = $2;} -elsif ($name =~ m/^([a-zA-Z0-9]+)$/) {$name = $1; $slice = undef;} -else {die "Could not parse name $name \n";} + $slice = undef; + if ($name =~ m/^([a-zA-Z0-9]+)\.(\d+)$/) {$name = $1; $slice = $2;} + elsif ($name =~ m/^([a-zA-Z0-9]+)$/) {$name = $1; $slice = undef;} + else {die "Could not parse name $name \n";} -my $db = lock_retrieve($file); -die "Unable to read cache file\n" unless defined $db; + $db = lock_retrieve($file); + die "Unable to read cache file\n" unless defined $db; -die "Name not found in entity file\n" unless(exists $db->{$name}); + die "Name not found in entity file\n" unless(exists $db->{$name}); ############################### #### Main "do the job" ############################### -my $data; -my $once = (defined $slice)?1:0; -if ($isbrowser) { - requestdata($db->{$name},$name,$slice); - print DumpTree($data) if $verbose; - generateoutput($db->{$name},$name,$slice,$once); - writeoutput($db->{$name},$name,$slice,$once); - } -else { - runandprint($db->{$name},$name,$slice,$once); - } - + $once = (defined $slice)?1:0; + if ($isbrowser) { + requestdata($db->{$name},$name,$slice); + print DumpTree($data) if $verbose; + generateoutput($db->{$name},$name,$slice,$once); + writeoutput($db->{$name},$name,$slice,$once); + } + else { + runandprint($db->{$name},$name,$slice,$once); + } +} ############################### #### Formatting of values @@ -116,8 +131,10 @@ sub FormatPretty { my $ret, my $cl; if (defined $cont) { - $cl = "class=\"".($value?"bad":"good")."\"" if ($obj->{errorflag}); - $cl = "class=\"".($value?"high":"low")."\"" unless ($obj->{errorflag}); + $cl = "class=\"".($value?"bad":"good")."\"" if ( $obj->{errorflag} && !$obj->{invertflag}); + $cl = "class=\"".($value?"good":"bad")."\"" if ( $obj->{errorflag} && $obj->{invertflag}); + $cl = "class=\"".($value?"high":"low")."\"" if (!$obj->{errorflag} && !$obj->{invertflag}); + $cl = "class=\"".($value?"low":"high")."\"" if (!$obj->{errorflag} && $obj->{invertflag}); $ret = "<$cont "; for($obj->{format}) { when ("boolean") { @@ -202,7 +219,7 @@ sub requestdata { } } } - elsif($obj->{type} eq "register" || $obj->{type} eq "registerfield") { + elsif($obj->{type} eq "register" || $obj->{type} eq "registerfield" || $obj->{type} eq "field") { my $stepsize = $obj->{stepsize} || 1; $slice = 0 unless defined $slice; do { @@ -366,9 +383,9 @@ sub runandprint { } +print "\n"; - - +1; ############################### diff --git a/xml-db/schema/TrbNetCommon.xsd b/xml-db/schema/TrbNetCommon.xsd index f84ff20..cc4aecd 100644 --- a/xml-db/schema/TrbNetCommon.xsd +++ b/xml-db/schema/TrbNetCommon.xsd @@ -85,9 +85,11 @@ + + - + + -- 2.43.0