#!/usr/bin/env perl -w # -*- perl -*- # # Purpose: Take LRO Secondary Science packets and verifies # Coincidence Mask test of Long Form Functional # Inputs: SecScience packets processed into ASCII by rtlm # Outputs: Errors as detected #----------------------------------------------------------------------- $DIR = $ENV{CRATERTOOLS}; $TIME = 'Time'; @SecSci = ( "SeqCoount", "TestMode", "OneHertz", "SerialNumber", "BiasCntrl", "BiasCmd", "CalLow", "CalHigh", "CalRate", "ProcD1", "ProcD2", "ProcD3", "ProcD4", "ProcD5", "ProcD6", "LastCmd", 'LastValue', # Last command value 'DiscThin', # LowLevel Discriminator for Thin Detectors 'DiscThick', # LowLevel Discriminator for Thick Detectors 'Mask', # Coincidence Mask High Word 'Single1', # Singles rates 'Single2', 'Single3', 'Single4', 'Single5', 'Single6', 'Good', # Stall Counter 'Reject', # Reject Counter 'Total', # Total Event Counter ); $Verbose = 0; $Mark = 20; # default threshold $| = 1; # Speak immediately ######################################################################## # The master program is here ######################################################################## &Setup; &Run; exit 0; ######################################################################## ######################################################################## ######################################################################## # Help message ######################################################################## sub Help { print STDOUT "Usage: $0 [-d2 \#] [-h] [-m \#] [-v] filename Processes LRO spacecraft data to verify singles rates flag -h prints out this help message -d2 sets threshold level for D2 counts (only) [$Mark] -m sets global threshold level [$Mark] -v verbose operation "; } ######################################################################## # Run the program ######################################################################## sub Run { my ($foo,$now,$date,$bias,$loc,$s1,$s2,$s3,$s4,$s5,$s6); my $first = 0; my $ii = 0; my $hvon = 0; while () { if ($_ =~ /^$TIME/) { ($foo,$now,$date,$loc) = split; print "STAT Start Time : $now $date $loc\n" if (!$first++ && $Verbose); } if ($_ =~ /^$SecSci[4]/) { ($foo,$bias) = split; if ($bias==0) { if ($hvon) { print "STAT HV bias off: $now $date $loc\n" if $Verbose; $hvon = 0; } } else { if (!$hvon) { print "STAT HV bias on : $now $date $loc\n" if $Verbose; $hvon++; } } next; } next if (!$hvon); # we only look at singles if HV on if ($_ =~ /^$SecSci[20]/) { ($foo,$s1) = split; next; } if ($_ =~ /^$SecSci[21]/) { ($foo,$s2) = split; next; } if ($_ =~ /^$SecSci[22]/) { ($foo,$s3) = split; next; } if ($_ =~ /^$SecSci[23]/) { ($foo,$s4) = split; next; } if ($_ =~ /^$SecSci[24]/) { ($foo,$s5) = split; next; } if ($_ =~ /^$SecSci[25]/) { ($foo,$s6) = split; if ($s1>$Mark || $s2>$MarkD2 || $s3>$Mark || $s4>$Mark || $s5>$Mark || $s6>$Mark) { printf " D1 D2 D3 D4 D5 D6\n" if (!$first); printf "%6d %6d %6d %6d %6d %6d %s %s UTC\n", $s1, $s2, $s3, $s4, $s5, $s6,$now,$date; } printf " SS Packets: $ii\r" if (!(++$ii%100) && $Verbose>1); next; } } print "\nSTAT End time $now $date $loc\n" if $Verbose; } ######################################################################## # Setup the program ######################################################################## sub Setup { my $foo; while ($foo = shift(@ARGV)) { if ($foo =~ /^-[hH]/) { &Help; exit 0; } if ( $foo =~ /^-[dD]2/ ) { if ( !defined($ARGV[0]) ) { print STDERR "flag $foo requires an argument\n"; &Help; exit 1; } if (($MarkD2=shift(@ARGV)) !~ /[0-9]{1,3}/) { print STDERR "File_ID provided with $foo flag must be integer less than 1000\n"; } next; } if ( $foo =~ /^-[mM]/ ) { if ( !defined($ARGV[0]) ) { print STDERR "flag $foo requires an argument\n"; &Help; exit 1; } if (($Mark=shift(@ARGV)) !~ /[0-9]{1,3}/) { print STDERR "File_ID provided with $foo flag must be integer less than 1000\n"; } next; } if ($foo =~ /^-[vV]/) { $Verbose++; next; } if ($foo =~ /^-/) { print STDERR "Unknown flag $foo\n"; &Help; exit 1; } if (-r $foo) { $InputFile = $foo; next; } else { print STDERR "Could not read $foo as input\n"; exit 2; } } if (!$InputFile) { print STDERR "$0 requires an input file name\n"; &Help; exit 2; } if (! -r $InputFile) { print STDERR "Could not find $InputFile\n"; &Help; exit 2; } open(GET,"$DIR/rtlm -r $InputFile -a -t -u |") || die "open() failed"; $MarkD2 = $Mark if (!defined($MarkD2)); print "STAT Noise threshold set at $Mark\n" if $Verbose; print "STAT Noise threshold for D2 only set at $MarkD2\n" if ($Verbose && $MarkD2!=$Mark); } ######################################################################## # Pod follows ######################################################################## =for html CRaTER -- ar_singles_check =head2 NAME B -- Threshold the singles rates =head2 USAGE print STDOUT "Usage: ar_singles_check [-d2 \#] [-h] [-m \#] [-v] filename =head2 FLAGS -d2 sets threshold level for (only) D2 noise [20] -h provides help message -m sets global threshold level [20] -v verbose mode =head2 DESCRIPTION This script scans a single input file to report noise on the singles counters. It tests only when the high voltage bias has been commanded on. =head2 ENVIRONMENT perl5.002 Minimum version of Perl interpreter required CRATERTOOLS Environment variable containing path to CRaTER utilities CRATER_GSE Environment variable containing EGSE machine name =head2 BUGS =head2 SEE ALSO rtlm =head2 AUTHOR Bob Goeke =head2 RCS Information $Id: ar_singles_check,v 1.2 2008/09/30 14:37:20 goeke Exp goeke $ =cut ######################################################################## # history follows ######################################################################## # $Log: ar_singles_check,v $ # Revision 1.2 2008/09/30 14:37:20 goeke # Only process singles limit when HV bias is on # # Revision 1.1 2008/09/12 19:50:29 goeke # Initial revision # # Revision 1.1 2008/09/04 17:34:56 goeke # Initial revision # # Revision 1.2 2008/08/29 19:13:44 goeke # Added error processing for missing packets # # Revision 1.1 2008/08/29 18:37:01 goeke # Initial revision #