#!/usr/bin/perl 

# print a summary of analyzed events, collected with
#  Lab::Connection::Trace
# Not that this uses 'default' analyzers, such as TekTDS, and WaveRunner
# usage:
#   Summary [options] infile
# options:
#       -d --debug             turn on debugging
#       -v --verbose           verbose output
#       -h -? --help           show usage
#
#
use Lab::Generic::CLOptions;    # reclaim --debug switch
use Lab::Data::Analysis;
use Carp;
use Getopt::Long qw(:config bundling auto_version no_ignore_case);
use Data::Dumper;
use strict;

our $DEBUG   = $Lab::Generic::CLOptions::DEBUG;
our $VERSION = '3.544';
our $VERBOSE = 1;

main();

sub main {

    my $help;

    Getopt::Long::GetOptions(
        "verbose|v" => \$VERBOSE,
        "debug|d+"  => \$DEBUG,
        "h|?|help"  => \$help,
    );

    if ( defined($help) ) {
        usage();
        exit(0);
    }

    my $infile = shift(@ARGV);
    if ( !defined($infile) ) {
        croak("missing input file parameter");
    }

    my $a = Lab::Data::Analysis->new($infile);
    croak("error opening input file '$infile'") unless defined $a;

    print "File: $infile\n";

    my $event;
    my $analysis_options = {
        print_summary => 1,
        interpolate   => 0,
        dropraw       => 1,
    };

    $a->ConnectAnalyzer();

    while ( defined( $event = $a->ReadEvent() ) ) {
        $a->Analyze( event => $event, options => $analysis_options );
    }

}
