Subs::SwiftSub (version 0.0)


package Subs::SwiftSub;

##############################################################################
# 
# HISTORY: 
# HISTORY: $Log: SwiftSub.pm,v $
# HISTORY: Revision 1.5  2006/04/28 18:41:46  apsop
# HISTORY: Fix bug in testing for presence of queue file.
# HISTORY:
# HISTORY: Revision 1.4  2005/11/08 19:22:28  apsop
# HISTORY: Populate the TIMELIST and DATALIST hashes. Used to be an SWCheckInput.
# HISTORY:
# HISTORY: Revision 1.3  2004/05/06 20:02:34  dah
# HISTORY: Add version number back into the header comments.
# HISTORY:
# HISTORY: Revision 1.2  2004/04/16 20:21:18  dah
# HISTORY: Begin using embedded history records
# HISTORY:
#
# VERSION: 0.0
#
#
##############################################################################


use Subs::Sub;
use Util::AttTool;

@ISA = ("Subs::Sub");
use strict;

sub BEGIN {
  my $procpar  = Subs::Sub->procpar();
  my $filename = Subs::Sub->filename();
  my $log      = Subs::Sub->log();
  my $jobpar   = Subs::Sub->jobpar();

  Util::AttTool->dirs($procpar->read('acs2fits'), $procpar->read('headas').'/lib');

  ###############################################
  # Put info on data already processed into hash
  ###############################################
  my @data = split(' ', $jobpar->read('datalist'));
  @{$jobpar->{DATALIST}}{@data} = (1) x @data;

  #####################################################
  # Hash about relative times, ie time since burst and
  # final processing
  #####################################################
  $jobpar->{TIMELIST} = {};
  foreach (glob('day_*.flag')){
    $jobpar->{TIMELIST}->{ (/(day_\w+)\.flag/)[0] } = 1;
  }

  if(-f 'final_for_archive.lock'){
    $jobpar->{TIMELIST}->{final} = 1;
    $jobpar->set({finalproc => 'yes'});
  }

  #####################################################
  # Get the earliest and latest times from the queue 
  # file
  #####################################################
  my $qname = $jobpar->read('sequence') . '.queue';
  if( -f $qname && open(QUEUE, "$qname") ){
    my (@starts, @stops);
    while(<QUEUE>){
      my @fields = split(' ');
      push @starts, $fields[2];
      push @stops,  $fields[3];
    }
    close QUEUE;
    $jobpar->{TIMELIST}->{start} = (sort {$a <=> $b} @starts)[0];
    $jobpar->{TIMELIST}->{stop}  = (sort {$b <=> $a} @stops)[0];
  }else{
    $log->error(1, "Unable to open $qname, $!");
  }
}