#!/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'; $MARK = 20; # default singles threshold $D2 = 100; # default D2 singles threshold # This array is { "Mnemonic","RedLo","YellowLo","YellowHi","RedHi" } # The limits are in engineering units derived from rtlm -a | calcurve # Only mnemonics with active limits are in list; rest are commented out # Only Tref has absolute temperature limits; # the remaining temperatures are /deltas/ from Tref # We will define $NOCARE as "don't care" $NOCARE = -9999; $BIASTHIN = "BiasVoltThin"; $BIASTHICK = "BiasVoltThick"; $SINGLE = "Single"; @nomHouse = ( # 'V28bus', 'V5digital', 4.8, 4.9, 5.1, 5.2, 'V5plus', 4.8, 4.9, 5.1, 5.2, 'V5neg', -5.2, -5.1, 5.1, -4.8, # 'I28bus', 'BiasCurrentD1', $NOCARE, $NOCARE, 0.06, 0.50, 'BiasCurrentD2', $NOCARE, $NOCARE, 0.30, 2.50, 'BiasCurrentD3', $NOCARE, $NOCARE, 0.06, 0.50, 'BiasCurrentD4', $NOCARE, $NOCARE, 0.30, 2.50, 'BiasCurrentD5', $NOCARE, $NOCARE, 0.06, 0.50, 'BiasCurrentD6', $NOCARE, $NOCARE, 0.30, 2.50, "$BIASTHIN", 1.0, 2.0, 3.0, 4.0, "$BIASTHICK", 1.0, 2.0, 3.0, 4.0, 'Thin-alt', 65, 70, 80, 85, 'Thick-alt', 205, 210, 225, 230, # 'CalAmp', # 'LLDThin', # 'LLDThick', 'Tref', -40, -30, 30, 40, 'Ttel-Tref', -4, -2, 2, 4, 'Tana-Tref', -2, -1, 4, 6, 'Tdig-Tref', -2, -1, 5, 7, 'Tpwr-Tref', -2, -1, 5, 7, # 'RadHighSens', # 'RadMedSens', # 'RadLowSens', # 'Tprt', # 'Purge' # ); # @SecSci = ( # 'LastValue', # 'DiscThin', # 'DiscThick', # 'Mask', # 'Mask2', # 'Mask3', # 'Mask4', 'Single1', $NOCARE, $NOCARE, 0, 0, # limits adjusted by &Setup 'Single2', $NOCARE, $NOCARE, 0, 0, 'Single3', $NOCARE, $NOCARE, 0, 0, 'Single4', $NOCARE, $NOCARE, 0, 0, 'Single5', $NOCARE, $NOCARE, 0, 0, 'Single6', $NOCARE, $NOCARE, 0, 0, 'Good', $NOCARE, $NOCARE, 2000, 3000, 'Reject', $NOCARE, $NOCARE, 12, 20, 'Total', $NOCARE, $NOCARE, 2000, 3000, # ); # @SC = ( 'BusVoltage', 27, 28, 34, 35, # 'BusCurrent', 'BusPower', 5.9, 6.0, 6.6, 6.7 # NB no comma at end of list # 'BusCmd' ); @tvHouse = ( # 'V28bus', 'V5digital', 4.8, 4.9, 5.1, 5.2, 'V5plus', 4.8, 4.9, 5.1, 5.2, 'V5neg', -5.2, -5.1, 5.1, -4.8, # 'I28bus', 'BiasCurrentD1', $NOCARE, $NOCARE, 0.25, 0.50, 'BiasCurrentD2', $NOCARE, $NOCARE, 1.25, 2.50, 'BiasCurrentD3', $NOCARE, $NOCARE, 0.25, 0.50, 'BiasCurrentD4', $NOCARE, $NOCARE, 1.25, 2.50, 'BiasCurrentD5', $NOCARE, $NOCARE, 0.25, 0.50, 'BiasCurrentD6', $NOCARE, $NOCARE, 1.25, 2.50, "$BIASTHIN", 1.0, 2.0, 3.0, 4.0, "$BIASTHICK", 1.0, 2.0, 3.0, 4.0, 'Thin-alt', 65, 70, 80, 85, 'Thick-alt', 205, 210, 225, 230, # 'CalAmp', # 'LLDThin', # 'LLDThick', 'Tref', -40, -30, 35, 40, 'Ttel-Tref', -4, -2, 3, 5, 'Tana-Tref', -2, -1, 7, 10, 'Tdig-Tref', -2, -1, 12, 16, 'Tpwr-Tref', -2, -1, 8, 11, # 'RadHighSens', # 'RadMedSens', # 'RadLowSens', # 'Tprt', # 'Purge' # ); # @SecSci = ( # 'LastValue', # 'DiscThin', # 'DiscThick', # 'Mask', # 'Mask2', # 'Mask3', # 'Mask4', 'Single1', $NOCARE, $NOCARE, 0, 0, # limits adjusted by &Setup 'Single2', $NOCARE, $NOCARE, 0, 0, 'Single3', $NOCARE, $NOCARE, 0, 0, 'Single4', $NOCARE, $NOCARE, 0, 0, 'Single5', $NOCARE, $NOCARE, 0, 0, 'Single6', $NOCARE, $NOCARE, 0, 0, 'Good', $NOCARE, $NOCARE, 2000, 3000, 'Reject', $NOCARE, $NOCARE, 12, 20, 'Total', $NOCARE, $NOCARE, 2000, 3000, # ); # @SC = ( 'BusVoltage', 27, 28, 34, 35, # 'BusCurrent', 'BusPower', 5.9, 6.0, 6.6, 6.7 # NB no comma at end of list # 'BusCmd' ); $| = 1; # Speak immediately ######################################################################## # The master program is here ######################################################################## &Setup; &Run; exit 0; ######################################################################## ######################################################################## ######################################################################## # Adjust the limit table based on setup flags ######################################################################## sub FixLimits { for ($ii=0; $ii<=$#House; $ii+=5) { if ($House[$ii] =~ /^$SINGLE/) { $House[$ii+3] = ($House[$ii] =~ /2/) ? $MarkD2 : $Mark; $House[$ii+4] = 2*$House[$ii+3]; } if ($House[$ii] =~ /^Tref/) { $House[$ii+3] += $Ambient; } } } ######################################################################## # Run the high/low checks and report if appropriate ######################################################################## sub Flag { if ($_[1]<$_[2]) { print "*RED-LO*: $_[0] = $_[1], limit is $_[2], at $Now\n"; return; } if ($_[1]>$_[5]) { print "*RED-HI*: $_[0] = $_[1], limit is $_[5], at $Now\n"; return; } if ($_[1]<$_[3]) { print "Yellow-lo: $_[0] = $_[1], limit is $_[3], at $Now\n"; return; } if ($_[1]>$_[4]) { print "Yellow-hi: $_[0] = $_[1], limit is $_[4], at $Now\n"; return; } } ######################################################################## # Help message ######################################################################## sub Help { print STDOUT "Usage: $0 [-a] [-d2 \#] [-h] [-m \#] [-s] [-T] [-v] filename Processes LRO spacecraft data to check red/yellow limits flag -a use ambient pressure temperature limits -d2 sets yellow singles threshold level for D2 counts [$D2] -h prints out this help message -m sets global yellow singles threshold level [$MARK] -s enables singles checking; this is enabled by implication if -m or -d2 flag is given -T use expanded limits for Thermal/Vacuum testing -v verbose operation; multiple -v to see limit table "; } ######################################################################## # Run the program ######################################################################## sub Run { my ($ii,$jj,$name,$value,$hex,$eng,$rhi,$rlo,$yhi,$ylo); IN: while () { ($name,$value,$hex,$eng) = split; if ($name =~ /^$TIME/) { $Now = $value . " " . $hex . " " . $eng; # save flag reporting print "STAT Start time $Now\n" if (!defined($jj) && $Verbose); printf " SS Packets: $jj\r" if (!(++$jj%100) && $Verbose>1); } next if ($name =~ /^$SINGLE/ && !$Single); $value = $eng if (defined($eng)); for ($ii=0; $ii<=$#House; $ii+=5) { next if ($name ne $House[$ii]); if ($name =~ /^T/) { # dealing with temperatures if ($name ne "Tref") { goto IN if (!defined($reftemp)); # skip if no ref $rlo = $reftemp + $House[$ii+1]; # but test if ref $ylo = $reftemp + $House[$ii+2]; $yhi = $reftemp + $House[$ii+3]; $rhi = $reftemp + $House[$ii+4]; } else { $reftemp = $value; # save the ref $rlo = $House[$ii+1]; # and test $ylo = $House[$ii+2]; $yhi = $House[$ii+3]; $rhi = $House[$ii+4]; } } else { if (($name eq $BIASTHIN || $name eq $BIASTHICK) && $value > 10) { $rlo = $House[$ii+10+1]; $ylo = $House[$ii+10+2]; $yhi = $House[$ii+10+3]; $rhi = $House[$ii+10+4]; } else { $rlo = $House[$ii+1]; $ylo = $House[$ii+2]; $yhi = $House[$ii+3]; $rhi = $House[$ii+4]; }} &Flag($name,$value,$rlo,$ylo,$yhi,$rhi); } } print "\nSTAT End time $Now\n" if $Verbose; } ######################################################################## # Setup the program ######################################################################## sub Setup { my ($foo,$ii); $Verbose = 0; my $help = 0; $Mark = $MARK; # singles threshold $MarkD2 = $D2; # D2 singles threshold $Ambient = 0; # set for ambient pressure thermal limits $Single = 0; # set to enable singles checking @House = @nomHouse; # default is on-orbit limits while ($foo = shift(@ARGV)) { if ($foo =~ /^-[aA]/) { $Ambient = 5; # raise yellow temp limit by 5C next; } if ($foo =~ /^-[hH]/) { $help++; # delayed; see below next; } 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 "arg provided with $foo flag must be integer less than 1000\n"; } $Singles++; 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"; } $Singles++; next; } if ($foo =~ /^-[sS]/) { $Single++; # Do singles /only/ if requested next; } if ($foo =~ /^-T/) { @House = @tvHouse; # Thermal/Vacuum limits 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; } &FixLimits; if ($Verbose>1) { print "\nMnemonic RedLo YellowLo YellowHi RedHi\n"; print "-------------- ----- -------- -------- -----\n"; for ($ii=0;$ii<=$#House;$ii+=5) { printf "%14s %5s %8s %8s %5s\n", $House[$ii], $House[$ii+1]==$NOCARE ? "" : $House[$ii+1], $House[$ii+2]==$NOCARE ? "" : $House[$ii+2], $House[$ii+3]==$NOCARE ? "" : $House[$ii+3], $House[$ii+4]==$NOCARE ? "" : $House[$ii+4] ; } print "\n"; } if ($help) { &Help; exit 0; } open(GET,"$DIR/rtlm -r $InputFile -a -t -u | calcurve |"); # NB pipe openings never fail, hence no die print "STAT Singles threshold set at $Mark\n" if ($Verbose && $Singles); print "STAT D2 Singles threshold set at $MarkD2\n" if ($Verbose && $Singles); } ######################################################################## # Pod follows ######################################################################## =for html CRaTER -- ar_limits_check =head2 NAME B -- Check Red/Yellow Limits =head2 USAGE ar_limits_check [-a] [-d2 #] [-h] [-m] [-s] [-T] [-v] filename =head2 FLAGS -a use ambient pressure temperature limits -d2 sets yellow singles threshold level for D2 counts [100] -h provides help message -m sets global yellow singles threshold level [20] -s enables singles checking; this is enabled my implication if -m or -d2 flag is given -T use expanded limits for Thermal/Vacuum testing -v verbose mode =head2 DESCRIPTION This script scans a single input file to report red/yellow limit violations of many CRaTER housekeeping parameters. Giving two B<-v> flags will display the current limit table (after incorporating the effects of any B<-a>, B<-d2>, or B<-m> flags). Singles rates are checked if requested. In some environments, these messages can obscure any analog messages being displayed, so the default behavoir is to ignore these. The default singles thresholds are set to accomodate the primary flight unit, S/N 2. The "red" thresholds are arbitrarily set to be twice the respective "yellow" threshold. Note that LLD and Calibration Amplitudes are not checked because all possible settings are valid. =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 The concept of "RED-HI" for singles rates is a tad overdone, but it does provide a useful flag. =head2 SEE ALSO rtlm =head2 AUTHOR Bob Goeke =head2 RCS Information $Id: ar_limits_check,v 1.2 2008/11/04 16:29:50 goeke Exp goeke $ =cut ######################################################################## # history follows ######################################################################## # $Log: ar_limits_check,v $ # Revision 1.2 2008/11/04 16:29:50 goeke # Add -T flag for expanded thermal-vac limits # # Revision 1.1 2008/09/12 19:46:27 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 #