From bb984d0908e1028bd420afef7ff965a58d2acfa8 Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Fri, 19 Dec 2014 14:50:37 +0100 Subject: [PATCH] added init_system button to testgui, fixed scrolling issue --- tools/init_system.pl | 30 +++++++++++++++++++++++++----- tools/testgui.js | 35 +++++++++++++++++++++++++++-------- tools/testgui.pl | 3 +++ 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/tools/init_system.pl b/tools/init_system.pl index 2bb3c43..05bc119 100755 --- a/tools/init_system.pl +++ b/tools/init_system.pl @@ -3,7 +3,9 @@ use warnings; use File::chdir; use XML::LibXML; -use Getopt::Long; +# use Getopt::Long; +use CGI ':standard'; +use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; use FileHandle; use Pod::Usage; @@ -14,7 +16,6 @@ use FindBin; use lib "$FindBin::Bin/.."; use Environment; use HADES::TrbNet; -trb_init_ports() or die trb_strerror(); sub trb_write { my($a,$r,$v) = @_; @@ -24,11 +25,22 @@ sub trb_write { sub run { my($c) = @_; print $c."\n"; - system("DAQOPSERVER=".DAQOPSERVER." ".$c); +# system("DAQOPSERVER=".DAQOPSERVER." ".$c); + system($c); } -my $system = $ARGV[0]; +my $isHttpReq = $ENV{HTTP_USER_AGENT}; +print header('text/plain') if $isHttpReq; +print "
" if $isHttpReq;
+my $q = CGI->new;
+my $system=$q->param('system');
+
+# only for backwards compatibility
+unless(defined($system)){
+  $system = $ARGV[0];
+}
+
 unless (defined $system) {die "No system name given\n";}
 my $systemFile = SYSTEMDIR."/".$system.".xml";
 unless(-e $systemFile) {die "System file $systemFile not found\n";}
@@ -46,11 +58,17 @@ for my $n ($db->findnodes("//gbe")) {
 for my $n ($db->findnodes("//roc")) {
   push(@roc,hex($n->findvalue("./\@address")));
   }  
+my $daqopserver = $db->findvalue("//daqopserver");
+$ENV{'DAQOPSERVER'} = $daqopserver if (defined($daqopserver));
+
+print "DAQOPSERVER:\t$daqopserver\n";
 printf("CCU:\t%04x\n",$ccu);
 print("ROC:\t".join(", ", map {sprintf("%04x",$_)} @roc)."\n");
 print("HUB:\t".join(", ", map {sprintf("%04x",$_)} @hub)."\n");
 print("GBE:\t".join(", ", map {sprintf("%04x",$_)} @gbe)."\n");
- 
+
+trb_init_ports() or die trb_strerror();
+
 run("trbcmd reset");
 
 sleep 2;
@@ -79,3 +97,5 @@ if($system eq 'ELab') {
 
 #Send arbiter start signal
 trb_write($ccu,0xa000,0x00000001);
+
+print "
" if $isHttpReq; diff --git a/tools/testgui.js b/tools/testgui.js index ebf56bf..8f63ab4 100644 --- a/tools/testgui.js +++ b/tools/testgui.js @@ -38,15 +38,25 @@ function run(time) { function startupOnly(){ - - - var setupFile_ = encodeURIComponent(setupFile); getdata("run.pl?startupOnly=true&runtime=0&setupFile="+setupFile_,"theConsole",false); - +} - - + + +function exec_init_system(){ + $.ajax({ + url: "init_system.pl", + cache: false, + async: false, + dataType: "text", + data: { + system : systemName + }, + success: function(result) { + $("#theConsole").html(result); + } + }); } function delete_file(){ @@ -158,16 +168,25 @@ $(document).ready(function(){ $("#advoptbtn").click(function(){ // toggleVis("advancedOptionsContainer"); $("#advancedOptionsContainer").fadeToggle(); - var $target = $('html,body'); + $('html, body').animate({ + scrollTop: $("#advancedOptionsContainer").offset().top + }, 2000); +// var $target = $('html,body'); // $target.animate({scrollTop: $target.height()}, 1000); }); $("#debugbtn").click(function(){ // toggleVis("theConsoleContainer"); $("#theConsoleContainer").fadeToggle(); - var $target = $('html,body'); + $('html, body').animate({ + scrollTop: $("#theConsoleContainer").offset().top + }, 2000); +// var $target = $('html,body'); // $target.animate({scrollTop: $target.height()}, 1000); }); + $("#button_init_system").click(function(){ + exec_init_system(); + }); timer = $.timer(function() { clear_report(); diff --git a/tools/testgui.pl b/tools/testgui.pl index deaa28b..9ff4389 100755 --- a/tools/testgui.pl +++ b/tools/testgui.pl @@ -200,6 +200,7 @@ sub init_html{ # so the javascript knows which placeholders to fill with actual plots print "