#!/usr/bin/perl
use strict;
use warnings;
use RFC::Rig;
use RFC::Visitor;
my $rig = RFC::Rig->new(shift);
die "No rig specified!\n" unless ($rig);
$rig->check_run();
my $name = shift;
my $debug = 0;
for(my $x = 0; $x < scalar(@ARGV);$x++)
{
    if ($ARGV[$x] =~ /--debug/)
    {
	$debug = 1;
    }
}
my $dev = $rig->get_device('PID',$name);
$dev = $rig->init_device('PID',$name) unless ($dev);
die "No PID evice with name '$name' found for rig ".$rig->name."\n" unless ($dev);
my $v = RFC::DebugVisitor->new($debug);
$dev->Accept($v);
while (1)
{
    $dev->init();
    $dev->control();
    my $str = $dev->monitor();
    print $str,"\n" unless ($debug); ## No need as monitor prints if debug is set ##
    $dev->store();
    select(undef,undef,undef,0.3);
}
exit;
