From 58fa1cab2a9903c7b7ce17f6e3cb23047f3860eb Mon Sep 17 00:00:00 2001 From: Hades DAQ Date: Thu, 31 Jan 2013 00:29:07 +0100 Subject: [PATCH] added a working help, mt --- web/CtsConfig.pm | 2 +- web/README.txt | 1 + web/cts_gui | 126 +++++++++++++++++++++++++---------------------- 3 files changed, 68 insertions(+), 61 deletions(-) diff --git a/web/CtsConfig.pm b/web/CtsConfig.pm index 69fb254..5863cc4 100644 --- a/web/CtsConfig.pm +++ b/web/CtsConfig.pm @@ -2,7 +2,7 @@ package CtsConfig; #default cts endpoint. can be overriden by a command line parameter sub getDefaultEndpoint { - return 0xf3c0; + return 0x8000; } 1; diff --git a/web/README.txt b/web/README.txt index f44174c..f5f012b 100644 --- a/web/README.txt +++ b/web/README.txt @@ -1 +1,2 @@ If you need a CTS monitor, use the cts script to start, if you just want the webserver use httpi. +test diff --git a/web/cts_gui b/web/cts_gui index 76e07d0..f7d5e0b 100755 --- a/web/cts_gui +++ b/web/cts_gui @@ -8,88 +8,95 @@ use Getopt::Long; # exit this function is by user interaction, e.g. by pressing # CTRL+C sub execServerAndMonitor { - my $host = shift; - my $port = shift; - my $htdocsDumpDir = shift; - my $quiteParam = shift; - -# Start Webserver - print "\n\nStart Webserver. Navigate to http://$host:$port\n"; - print "If you want to access the page from another PC, \n"; - print "please ensure there's no firewall blocking port $port\n\n"; - system("./httpi $host $port &"); - - sleep 1; - - $SIG{ 'INT' } = \&clean_up; - -# Exec Monitor - while(1) { - system "./cts $quiteParam m $htdocsDumpDir"; - system "clear"; - print "If you willingly killed the monitoring script press CTRL+C again!"; - - for(my $i=5; $i; $i--) { - print "\n Monitor will restart in $i second(s)\a"; - sleep 1; - } - } + my $host = shift; + my $port = shift; + my $htdocsDumpDir = shift; + my $quietParam = shift; + + # Start Webserver + print "\n\nStart Webserver. Navigate to http://$host:$port\n"; + print "If you want to access the page from another PC, \n"; + print "please ensure there's no firewall blocking port $port\n\n"; + system("./httpi $host $port &"); + + sleep 1; + + $SIG{ 'INT' } = \&clean_up; + + # Exec Monitor + while (1) { + system "./cts $quietParam m $htdocsDumpDir"; + system "clear"; + print "If you willingly killed the monitoring script press CTRL+C again!"; + + for (my $i=5; $i; $i--) { + print "\n Monitor will restart in $i second(s)\a"; + sleep 1; + } + } } # Print help sub help { - print <<"HELP" + print < \$openxterm, - 'port=i' => \$port, - 'monitor!' => \$monitor, - 'help!' => \$help, - 'quite!' => \$quite - ); +my $host = 'localhost'; +my $port = 1234; +my $openxterm = 0; +my $monitor = 0; +my $help = 0; +my $quiet = 0; + +GetOptions( + 'openxterm!' => \$openxterm, + 'port=i' => \$port, + 'monitor!' => \$monitor, + 'help!' => \$help, + 'quiet!' => \$quiet + ); + + +if ($help) { +help(); +exit; +} my $sharedDir = "/dev/shm/cts-monitor-$port"; my $htdocsDumpDir = "htdocs/monitor-$port"; - my $quiteParam = $quite ? '--quite ' : ''; - + my $quietParam = $quiet ? '--quiet ' : ''; + sub clean_up { print "\n\n\n CLEAN UP\n"; system "rm -rf $sharedDir $htdocsDumpDir"; exit; }; - -# If this script was started within xterm - start monitor + +# If this script was started within xterm - start monitor if ($monitor) { - execServerAndMonitor $host, $port, $htdocsDumpDir, $quiteParam; + execServerAndMonitor $host, $port, $htdocsDumpDir, $quietParam; exit; } @@ -107,14 +114,13 @@ HELP system( "ln -s $sharedDir $htdocsDumpDir || mkdir -p $htdocsDumpDir"); system( "cp htdocs/layout/empty_plot.png $htdocsDumpDir/plot.png" ); system( "cp htdocs/layout/empty_plot.png $htdocsDumpDir/plotshort.png" ); - - + # Start Monitor (either directly or indirectly via XTERM)" print "\n\nStart monitoring script"; if ($openxterm) { - system("xterm -fn '-misc-fixed-medium-r-normal--8-*-*-*-*-*-iso8859-15' +sb -geometry 200x100 +aw +bc -bg LightCoral -j -e '$0 --monitor --port=$port $quiteParam'"); + system("xterm -fn '-misc-fixed-medium-r-normal--8-*-*-*-*-*-iso8859-15' +sb -geometry 200x100 +aw +bc -bg LightCoral -j -e '$0 --monitor --port=$port $quietParam'"); } else { - execServerAndMonitor $host, $port, $htdocsDumpDir, $quiteParam; + execServerAndMonitor $host, $port, $htdocsDumpDir, $quietParam; } - + clean_up; -- 2.43.0