timeout => 10,
requests => {},
maxRepeats => 5,
+ startTimeout => 2,
%options
};
bless($self, $class);
sub deleteShm {
my $self = shift;
unlink $self->{shm};
+ system("rm -rf ".$self->{plotDir});
}
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
-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");
$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();