Index: trunk/ippScripts/scripts/ipp_serial_chip.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 18446)
+++ trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 24234)
@@ -13,26 +13,26 @@
 use Pod::Usage qw( pod2usage );
 
-my ($dbname,			# Database name to use
-    $workdir_default,		# Default working directory
-    $verbose,			# Verbose operations?
-    $no_op,			# No operations?
-    $no_update,			# No updating?
+my ($dbname,                    # Database name to use
+    $workdir_default,           # Default working directory
+    $verbose,                   # Verbose operations?
+    $no_op,                     # No operations?
+    $no_update,                 # No updating?
     );
 GetOptions(
-	   'dbname=s' => \$dbname,
-	   'workdir=s' => \$workdir_default,
-	   'verbose' => \$verbose,
-	   'no-op' => \$no_op,
-	   'no-update' => \$no_update,
+           'dbname=s' => \$dbname,
+           'workdir=s' => \$workdir_default,
+           'verbose' => \$verbose,
+           'no-op' => \$no_op,
+           'no-update' => \$no_update,
 ) or pod2usage( 2 );
 
 pod2usage( -msg => "Required options: --dbname --workdir",
-	   -exitval => 3,
-	   ) unless
+           -exitval => 3,
+           ) unless
     defined $dbname;
 
 $workdir_default = `pwd` unless defined $workdir_default;
 
-my $mdcParser = PS::IPP::Metadata::Config->new;	# Metadata config parser
+my $mdcParser = PS::IPP::Metadata::Config->new; # Metadata config parser
 my $ipprc = PS::IPP::Config->new; # IPP Configuration
 
@@ -44,9 +44,9 @@
 
 # Imfile processing
-my @whole;			# The whole list for processing
+my @whole;                      # The whole list for processing
 {
     my $command = "$chiptool -pendingimfile -dbname $dbname"; # Command to run
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run( command => $command, verbose => 1 );
+        run( command => $command, verbose => 1 );
     die "Unable to get phase 2 imfile list: $error_code\n" if not $success;
     @whole = split /\n/, join( '', @$stdout_buf );
@@ -59,34 +59,35 @@
     push @single, $value;
     if ($value =~ /^\s*END\s*$/) {
-	push @single, "\n";
-	
-	my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or
-	    die "Unable to parse output from chiptool.\n";
-	    
-	foreach my $item (@$list) {
-	    my $chip_id = $item->{chip_id};
-	    my $exp_id = $item->{exp_id};
-	    my $exp_tag = $item->{exp_tag};
-	    my $camera = $item->{camera};
-	    my $class_id = $item->{class_id};
-	    my $uri = $item->{uri};
-	    my $reduction = $item->{reduction};
-	    my $workdir = $item->{workdir};
-	    $workdir = $workdir_default unless (defined $workdir or $workdir ne "NULL");
+        push @single, "\n";
 
-	    my $outroot = caturi( $workdir, $exp_tag, "$exp_tag.ch.$chip_id" );
-	    $ipprc->outroot_prepare( $outroot );
+        my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or
+            die "Unable to parse output from chiptool.\n";
 
-	    my $command = "$chip --chip_id $chip_id --exp_id $exp_id --class_id $class_id --uri $uri --dbname $dbname --camera $camera --outroot $outroot";
-	    $command .= " --reduction $reduction" if defined $reduction;
-	    $command .= " --verbose" if defined $verbose;
-	    $command .= " --no-op" if defined $no_op;
-	    $command .= " --no-update" if defined $no_update;
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		run( command => $command, verbose => 1 );
-	    die "Unable to do phase 2 processing on $chip_id $class_id: $error_code\n" if not $success;
-	}
+        foreach my $item (@$list) {
+            my $chip_id = $item->{chip_id};
+            my $exp_id = $item->{exp_id};
+            my $exp_tag = $item->{exp_tag};
+            my $camera = $item->{camera};
+            my $class_id = $item->{class_id};
+            my $uri = $item->{uri};
+            my $reduction = $item->{reduction};
+            my $state = $item->{state};
+            my $workdir = $item->{workdir};
+            $workdir = $workdir_default unless (defined $workdir or $workdir ne "NULL");
 
-	@single = ();
+            my $outroot = caturi( $workdir, $exp_tag, "$exp_tag.ch.$chip_id" );
+            $ipprc->outroot_prepare( $outroot );
+
+            my $command = "$chip --chip_id $chip_id --exp_id $exp_id --class_id $class_id --uri $uri --dbname $dbname --camera $camera --outroot $outroot --run-state $state";
+            $command .= " --reduction $reduction" if defined $reduction;
+            $command .= " --verbose" if defined $verbose;
+            $command .= " --no-op" if defined $no_op;
+            $command .= " --no-update" if defined $no_update;
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run( command => $command, verbose => 1 );
+            die "Unable to do phase 2 processing on $chip_id $class_id: $error_code\n" if not $success;
+        }
+
+        @single = ();
 
     }
