IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30293


Ignore:
Timestamp:
Jan 18, 2011, 6:44:51 PM (15 years ago)
Author:
watersc1
Message:

another pass at fixing the diff queuing bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/nightly_science.pl

    r30280 r30293  
    278278
    279279$metadata_out{nsObservingState} = &get_observing_state($date);
     280$metadata_out{nsRegistrationState} = &get_registration_state($date);
    280281#
    281282# Mode selection
     
    11001101    my $Nqueued = 0;
    11011102    my $is_processing = 0;
     1103    my $is_registering;
     1104    if ($metadata_out{nsRegistrationState} eq 'REGISTERED') {
     1105        $is_registering = 0;
     1106    }
     1107    else {
     1108        $is_registering = 1;
     1109    }
     1110
    11021111    foreach my $target (sort (keys %science_config)) {
    11031112        if ($science_config{$target}{STACKABLE} == 1) {
     
    11611170    $metadata_out{nsStackPotential} = $Npotential;
    11621171    $metadata_out{nsStackQueued}    = $Nqueued;
    1163     if (($Npotential == $Nqueued)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) {
     1172    if (($Npotential == $Nqueued)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)&&($is_registering == 0)) {
    11641173        $metadata_out{nsStackState} = 'FINISHED_STACKS';
    11651174    }   
     
    12941303    my $Nnoexp     = 0;
    12951304    my $is_processing = 0;
     1305    my $is_registering;
     1306    if ($metadata_out{nsRegistrationState} eq 'REGISTERED') {
     1307        $is_registering = 0;
     1308    }
     1309    else {
     1310        $is_registering = 1;
     1311    }
     1312
    12961313    foreach my $target (sort (keys %science_config)) {
    12971314        if ($science_config{$target}{DIFFABLE} == 1) {
     
    13341351        }
    13351352    }
    1336     if (($Npotential == $Nnoexp)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) {
    1337         $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
    1338     }   
    1339 
     1353    if ($metadata_out{nsObservingState} eq 'END_OF_NIGHT') {
     1354        if ($is_processing == 0) {
     1355            $metadata_out{nsDiffState} = 'DIFFING';
     1356        }
     1357        elsif ($is_registering == 0) {
     1358            if ($Npotential == $Nnoexp) {
     1359                $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
     1360            }
     1361            elsif ($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued}) {
     1362                $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
     1363            }
     1364        }
     1365        else {
     1366            $metadata_out{nsDiffState} = 'DIFFING';
     1367        }
     1368    }
     1369    else {
     1370        $metadata_out{nsDiffState} = 'DIFFING';
     1371    }
     1372
     1373#     if (($Npotential == $Nnoexp)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) {
     1374#       $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
     1375#     }
     1376
     1377#     if ($is_processing == 1) {
     1378#       $metadata_out{nsDiffState} = 'DIFFING';
     1379#     }
    13401380}
    13411381
     
    14611501    $metadata_out{nsDiffPotential} += $Npotential;
    14621502    $metadata_out{nsDiffQueued}    += $Nqueued;
    1463     if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) {
    1464         $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
    1465     }   
     1503    if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) {
     1504     $metadata_out{nsDiffState} = 'FINISHED_DIFFS';
     1505    }       
    14661506
    14671507}
     
    15801620        }
    15811621    }   
    1582 
     1622#    print "$datetime $eon_dt\n";
    15831623    if (DateTime->compare($datetime,$eon_dt) < 1) {
    15841624        return("OBSERVING");
     
    15881628    }
    15891629}
     1630
     1631# This basically does the end of night check, but does it "the hard way," to prevent the time from fooling us.
     1632sub get_registration_state {
     1633    my $date = shift;
     1634
     1635    foreach my $eon (keys %eon_config) {
     1636        my $command = "$regtool -processedexp -simple ";
     1637        $command .= " -dbname $dbname ";
     1638        $command .= " -dateobs_begin ${date}T00:00:00 -dateobs_end ${date}T23:59:59 ";
     1639        $command .= " -object $eon_config{$eon}{OBJECT} " if defined($eon_config{$eon}{OBJECT});
     1640        $command .= " -obs_mode $eon_config{$eon}{OBSMODE} " if defined($eon_config{$eon}{OBSMODE});
     1641        $command .= " -exp_type $eon_config{$eon}{EXPTYPE} " if defined($eon_config{$eon}{EXPTYPE});
     1642        $command .= " -comment $eon_config{$eon}{COMMENT} " if defined($eon_config{$eon}{COMMENT});
     1643
     1644        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1645            run ( command => $command, verbose => $verbose );
     1646        unless ($success) {
     1647            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     1648            &my_die("Unable to perform regtool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     1649        }
     1650        my @eon_exposures = split /\n/, (join '', @$stdout_buf);
     1651        if ($#eon_exposures >= 0) {
     1652            return("REGISTERED");
     1653        }
     1654    }   
     1655    return("NOT_REGISTERED");
     1656}
     1657
     1658   
    15901659
    15911660sub get_tool_parameters {
Note: See TracChangeset for help on using the changeset viewer.