#!/usr/bin/perl -T
#$Id: fastlog_type.pl,v 1.3 2016/12/12 08:05:23 sqko Exp $
use strict;
use warnings;
use RFC::Rig;
my $r = RFC::Rig->new(shift);
my $type = 'simplechannel';
my @names = ();
my $debug = 0;
my $interval = 1;
foreach my $i (@ARGV)
{
    if ($i =~ /--/)
    {
	if ($i =~ /type\=(\w+)/)
	{
	    $type = $1;
	}
	if ($i =~ /debug/)
	{
	    $debug = 1;
	}
	if ($i =~ /interval\=(\d+)/)
	{
	    $interval = $1;
	}
    }
    else
    {
	push @names,$i;
    }
}
$interval = 1 unless ($interval && $interval > 1);
my @devs = ();
foreach my $n (@names)
{
    my $d = $r->get_device($type,$n);
    if ($d)
    {
	push @devs,$d;
    }
    else
    {
	warn "Device $n of type $type was not found for $r!\n";
    }
}
while (1)
{
    my $t = time;
    my $lt = localtime();
    my @l = ($t,$lt);
    for my $d (@devs)
    {
	push @l,$d,$d->read();
    }
    print join("\t",@l),"\n";
    sleep($interval);
}
