#!/usr/bin/perl -T
#$Id: Check_alert.pl,v 1.3 2016/05/27 13:24:23 sqko Exp $
use strict;
use warnings;
use RFC::Rig;
use SemaforeFile;
die "No rig specified!\n" unless (@ARGV);
sleep(20);
my $r = shift;
if ($r && $r =~ /(\d+)/)
{
    $r = $1;
}
else
{
    exit;
}
my $file = '/tmp/dummy.txt';
my $lockfile = '/home/celltest/PID_slow_Rig_'.$r;
my $lock = SemaforeFile->new($file,$lockfile);
### Only allow one instance for each rig! ###
exit unless ($lock->lock_ex_nb());

my $rig = RFC::Rig->new($r);
$rig->check_run;
foreach my $name ($rig->list_devices('Alert'))
{
    my $d = $rig->get_device('Alert',$name);
    next unless ($d);
    $d->check();
}
$rig->DESTROY();


