From: www@jspc55 Date: Wed, 22 Jan 2014 10:15:35 +0000 (+0100) Subject: work on plot service backend invocation and communication X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=a0c7a32c040bdfb07f7702acecf4259e1d381f73;p=mvdsensorcontrol.git work on plot service backend invocation and communication --- diff --git a/tools/PlotScheduler.pm b/tools/PlotScheduler.pm index 09dacd5..5294449 100644 --- a/tools/PlotScheduler.pm +++ b/tools/PlotScheduler.pm @@ -24,6 +24,7 @@ sub new { timeout => 10, requests => {}, maxRepeats => 5, + startTimeout => 2, %options }; bless($self, $class); @@ -107,6 +108,7 @@ sub listRequests { sub deleteShm { my $self = shift; unlink $self->{shm}; + system("rm -rf ".$self->{plotDir}); } sub plotServiceRunning { @@ -114,9 +116,34 @@ sub plotServiceRunning { return (-e $self->{shm}); } +sub startPlotService { + my $self = shift; + + if (-e $self->{shm}) { + die "service already running!\n"; + } else { + system("./plotService.pl --shm ".$self->{shm}." 1>/dev/null 2>&1 & disown"); + for (my $i = 0; $i< $self->{startTimeout}*100; $i++){ + if( -e $self->{shm} ) { + return 1; + } else { + Time::HiRes::sleep(0.01); + } + } + die "could not start Service\n"; + return 0; + } +} + sub createShm { my $self = shift; + die "shm ".$self->{shm}." already exists!\n" if( -e $self->{shm} ); lock_store({},$self->{shm}); + unless (defined( $self->{plotDir} )){ + $self->{plotDir} = $self->{shm}."_plots"; + } + die "plot directory ".$self->{plotDir}." already exists!\n" if( -e $self->{plotDir} ); + mkdir $self->{plotDir}; }; 1; \ No newline at end of file diff --git a/tools/adcmon.pl b/tools/adcmon.pl index 609c636..811998b 100755 --- a/tools/adcmon.pl +++ b/tools/adcmon.pl @@ -27,9 +27,11 @@ use Environment; -my $ps = PlotScheduler->new( shm => "/dev/shm/DQ55_88" ); +my $ps = PlotScheduler->new( shm => "/dev/shm/DQ55_88", timeout=> 3 ); # $ps->addRequest( FPGA => "0xd882", CB => "0", chip => "1", channel => "TEMP"); -$ps->storeRequests(); +# $ps->storeRequests(); +$ps->startPlotService() unless $ps->plotServiceRunning(); + while(1){ $ps->retrieveRequests(); $ps->addRequest( FPGA => "0xd882", CB => "0", chip => "1", channel => "VDDA"); diff --git a/tools/plotService.pl b/tools/plotService.pl index 59594a1..d5ba12f 100755 --- a/tools/plotService.pl +++ b/tools/plotService.pl @@ -46,13 +46,13 @@ while(1) { $ps->listRequests() if $verbose; print "number of requests:".$ps->requestCount()."\n" if $verbose; - checkForSuicide($ps->requestCount()); + keepAlive($ps->requestCount()); sleep 1; } -sub checkForSuicide { +sub keepAlive { my $argument = shift; if($argument) { $suicideTimer = time();