]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
work on plot service backend invocation and communication
authorwww@jspc55 <www@jspc55>
Wed, 22 Jan 2014 10:15:35 +0000 (11:15 +0100)
committerwww@jspc55 <www@jspc55>
Wed, 22 Jan 2014 10:15:35 +0000 (11:15 +0100)
tools/PlotScheduler.pm
tools/adcmon.pl
tools/plotService.pl

index 09dacd5fc04b6f77c86314ddbff6f3bee2bd3436..5294449b52637429e08d4b0c08e49851b335d229 100644 (file)
@@ -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
index 609c63668d5d1daf8a63da331a654f1ab3ee0841..811998bfbda5c792fe54e9c58d56bfcbd97b298d 100755 (executable)
@@ -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");
index 59594a1829f03d7c4015dfe6d4dfeebe14e405d7..d5ba12f1f03985d49057c64cf5487dcfb58c932c 100755 (executable)
@@ -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();