From 963bb6d60226fe4b41766c8bd91854efa5757997 Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Wed, 31 Jul 2013 13:29:16 +0200 Subject: [PATCH] test --- tools/preview/{testgui.pl => prevImg.pl} | 10 +- tools/testgui.pl | 146 +++++++++++++++++++---- tools/xmlOperations.pm | 4 +- 3 files changed, 130 insertions(+), 30 deletions(-) rename tools/preview/{testgui.pl => prevImg.pl} (76%) diff --git a/tools/preview/testgui.pl b/tools/preview/prevImg.pl similarity index 76% rename from tools/preview/testgui.pl rename to tools/preview/prevImg.pl index b081038..49e5f54 100755 --- a/tools/preview/testgui.pl +++ b/tools/preview/prevImg.pl @@ -24,13 +24,13 @@ print start_html( -style=>{'src'=>'../layout/styles.css'} ); -print h2("testgui"); -print "

still more to come

"; +# print h2("testgui"); +# print "

still more to come

"; -print escapeHTML("hallo<<<>>>&&&!!"),br; -print escapeHTML($here); +# print escapeHTML("hallo<<<>>>&&&!!"),br; +# print escapeHTML($here); $ENV{'PATH'}=$ENV{'PATH'}.":/home/hadaq/bin"; -print br,$ENV{'PATH'},br; +# print br,$ENV{'PATH'},br; system("./run.pl -t 0.1 -id ccc1ccc1"); print img{src=>'image_recalibrated_1.png'}; diff --git a/tools/testgui.pl b/tools/testgui.pl index a4fe94a..e03894f 100755 --- a/tools/testgui.pl +++ b/tools/testgui.pl @@ -22,7 +22,7 @@ our $confDir = '../config'; our $specDir = '../specs'; my $setupFileName = "testsetup.xml"; -my $setupFile = $setupDir.$setupFileName; +my $setupFile = $setupDir."/".$setupFileName; # the file that tells me what fields should be printed in the quick edit area # for each sensor @@ -33,6 +33,7 @@ my $quickEditMaskFile = $confDir."/".$quickEditMaskFileName; #### globals: my $quickEditMaskTree; +my $setupTree; ####################### @@ -68,6 +69,14 @@ unless($q->param()) { ################################## #### Subs ################################## + +sub parse_setupFile { + my $parser = XML::LibXML->new(); + unless( -e $setupFile) { + die "setup file $setupFile does not exist!\n"; + } + $setupTree = $parser->parse_file($setupFile); +} sub parse_quickEditMaskFile { @@ -78,29 +87,7 @@ sub parse_quickEditMaskFile { $quickEditMaskTree = $parser->parse_file($quickEditMaskFile); } -sub print_quickEditArea { - - unless(defined($quickEditMaskTree)) { - parse_quickEditMaskFile(); - } - - print ""; - my @fields = $quickEditMaskTree->findnodes("/MAPS/register/field"); - for my $field (@fields) { - print ""; - - - } - print "
"; - print $field->findvalue("./\@name"); - print "
"; - print "print_registers();",br; - parseConfigAndSpec("0.xml"); - integrateAncestry(); - print_registers(getConfigFile()); - -} sub init_html{ @@ -129,8 +116,9 @@ print h2("testgui"); print "
"; -print_quickEditArea(); +print_quickEditArea("0.xml"); print "
"; +print_setupStructure(); print end_html; @@ -140,7 +128,56 @@ print end_html; +sub print_setupStructure { + unless(defined($setupTree)) { + parse_setupFile(); + } + my $setup = $setupTree->findnodes("/DetectorSetup")->shift(); + unless(defined($setup)) { die "did not find DetectorSetup node in setup file!\n";} + my $setupDesc = $setup->findvalue("./description"); + my $setupName = $setup->findvalue("./\@name"); + print h2("Setup: $setupName"); + print "

description: $setupDesc

"; + + my @controllers = $setup->findnodes("./controller"); + unless(scalar(@controllers) > 0) { die "no controllers in setup file!\n";} + for my $controller (@controllers) { + my $controllerName = $controller->findvalue("./\@name"); + my $controllerAddress = $controller->findvalue("./\@address"); + my $controllerId = $controller->findvalue("./\@id"); + print h3("Controller name:$controllerName id:$controllerId address:$controllerAddress"); + + my @chains = $controller->findnodes("./chain"); + unless(scalar(@chains)>0) {die "no chains attached to controller $controllerName\n";} + + for my $chain (@chains) { + my $chainName = $chain->findvalue("./\@name"); + my $chainId = $chain->findvalue("./\@id"); + print h4("Chain name:$chainName id:$chainId"); + + my @sensors = $chain->findnodes("./sensor"); + unless(scalar(@sensors)>0) { die "no sensors attached to chain $chainName\n";} + for my $sensor (@sensors) { + + my $sensorId = $sensor->findvalue("./\@id"); + my $sensorName = $sensor->findvalue("./\@name"); + my $sensorConfig = $sensor->findvalue("./\@config"); + my $sensorEnabled = $sensor->findvalue("./\@enabled"); + my $sensorSerial = $sensor->findvalue("./\@serial"); + my $sensorPosition = $sensor->findnodes("./position")->shift(); + my $sensorDescription = $sensor->findvalue("./description"); + + print h5("Sensor name:$sensorName id:$sensorId"); + print "

description: $sensorDescription

"; + print_sensorArea($sensor); + } + + } + + } + +} sub report_param { @@ -162,6 +199,67 @@ sub report_param { #### html output subs ########### + +sub print_sensorArea { + + my $sensor = $_[0]; + # this is an xml object that contains the sensor node + # from the setup file + my $sensorId = $sensor->findvalue("./\@id"); + my $sensorName = $sensor->findvalue("./\@name"); + my $sensorConfig = $sensor->findvalue("./\@config"); + my $sensorEnabled = $sensor->findvalue("./\@enabled"); + my $sensorSerial = $sensor->findvalue("./\@serial"); + my $sensorPosition = $sensor->findnodes("./position")->shift(); + my $sensorDescription = $sensor->findvalue("./description"); + + my $sensorAreaId = $sensorId; + print "
"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "
$sensorName
blah"; + print_quickEditArea($sensorConfig); + print "
"; + print ""; + + +} +# description the block that is printed for each sensor, +# containing the preview plot and the quick edit area + + +sub print_quickEditArea { + + my $argumentConfigFile = $_[0]; + + unless(defined($quickEditMaskTree)) { + parse_quickEditMaskFile(); + } + +# print "
"; +# my @fields = $quickEditMaskTree->findnodes("/MAPS/register/field"); +# for my $field (@fields) { +# print ""; +# +# +# } +# print "
"; +# print $field->findvalue("./\@name"); +# print "
"; +# print "print_registers();",br; + parseConfigAndSpec($argumentConfigFile); + integrateAncestry(); + print_registers(getConfigFile()); + + +} + + sub print_registers { my $configFile = getConfigFile(); diff --git a/tools/xmlOperations.pm b/tools/xmlOperations.pm index 37274d7..2db824b 100644 --- a/tools/xmlOperations.pm +++ b/tools/xmlOperations.pm @@ -109,6 +109,7 @@ sub parseConfigAndSpec { #args: configFileName #globs: $specFileName,$configTree,$specFile,$specDir,$specTree,$parser #calls: parseConfigFile() sub parseConfigFile { + $configFileName = $_[0]; $configFile = $confDir . "/" . $_[0]; $configTree = $parser->parse_file($configFile); @@ -257,7 +258,8 @@ sub buildAncestry { sub integrateAncestry { - + undef @ancestryList; + undef $ancestryTree; buildAncestry($configFileName,""); my $counter = 1; -- 2.43.0