Lab-Measurement-Legacy

 view release on metacpan or  search on metacpan

examples/Legacy/DAQ/TDplot_WR640  view on Meta::CPAN

#!/usr/bin/perl -I ../../blib/lib

# use Topdrawer to show trace data

use Lab::Data::Analysis;
use Getopt::Long qw(:config bundling auto_version no_ignore_case);
use Carp;
use Data::Dumper;

sub usage {
    print "usage $0: [options] datafile\n";
    print "  options:\n";
    print "        --t0='start time' [def: earliest]\n";
    print "        --t1='end time'   [def: latest]\n";
    print "        -o --output=file  output file for non-interactive plot\n";
    print "        -f --force        force otuput file overwriting\n";
    print "        -n --nevents=N    number of events to plot [def: all]\n";
    print "        -s --start=N      first event to plot [def: 1]\n";
    print "        -r --run=N        run number [def: first in file]\n";
    print "        -c --chan=chans   channels to plot [def: all]\n";
    print "        -I --ID           include trace ID on plot title\n";
    print "        -T --Tag          tag plots with processing info\n";
    print "        -d --debug        debug printouts\n";
    print "        -v --verbose      verbose\n";
    print "        -h -? --help      print this help\n";

    print "The following are substituted when generating output filenames:\n";
    print "   %R -> run number \n";
    print "The default 'output file format' is .td\n";
}

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

my $user = getlogin || getpwuid($<) || '?';
our $TAGINIT = join( ' ', $0, @ARGV, "($user @", scalar localtime, ")" );

main();

sub main {
    my $nev = 0;
    my $chans;
    my (@acqch);
    my $t0;
    my $t1;
    my $start = 1;
    my $outfile;
    my $force = 0;
    my $help  = 0;
    my $tag   = 0;
    my $run;
    my $id = 0;

    Getopt::Long::GetOptions(
        "nevents|n=i" => \$nev,
        "start|s=i"   => \$start,
        "chan|c=s"    => \$chans,
        "debug|d+"    => \$DEBUG,
        "verbose|v+"  => \$VERBOSE,
        "help|h|?"    => \$help,
        "output|o=s"  => \$outfile,
        "force|f"     => \$force,
        "ID|I"        => \$id,
        "t0=s"        => \$t0,
        "t1=s"        => \$t1,
        "run|r=i"     => \$run,
        "Tag|T"       => \$tag,
    );

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

    my $infile = shift(@ARGV);
    croak("no input file given") unless defined $infile;
    croak("unable to find input file") unless -e $infile;

    $nev = 0 if $nev < 0;
    if ( defined($first) && $first <= 0 ) {
        carp("starting at first event (event=1)");
        $first = 1;
    }

    if ( defined($outfile) ) {
        if ( $outfile !~ /(\.\w+)$/i ) {
            $outfile .= '.td';
        }
    }
    else {
        $outfile = 'TDplot_WR640.td';
    }

    if ( defined($chans) ) {    # 'ch1,ch2'  (ch1,ch2) etc.
        $chans =~ s/^\s*(.*)\s*/$1/;



( run in 1.212 second using v1.01-cache-2.11-cpan-39bf76dae61 )