r653: *** empty log message ***
[ctsim.git] / cgi-bin / ctsim.cgi.in
index 959d69b5c6fafce2991de45b0fdc823c515c33ef..ae32a901553285ae9a2155f50d36825dc428d58d 100755 (executable)
@@ -9,7 +9,7 @@ use Fcntl ':flock';
 require './ctsim.conf';
 
 my $opt_d = 0;
-$ENV{'PATH'} = "$::bindir:$::lamrundir";
+$ENV{'PATH'} = "$::bindir:$::lamrundir:/bin";
 
 my $fromhost = $ENV{'REMOTE_HOST'};
 
@@ -27,20 +27,32 @@ CGI::ReadParse(\%in);
 
 my $error = "";
 
+if ($::single_process_only > 0) {
+  my @processes = `/bin/ps -A`;
+  my $running = 0;
+  foreach my $p (@processes) {
+    if ($p =~ m/ctsimtext/) {
+      $error .= "Another online simulation is currently running.<br>You may wait a moment and then click your browser's <b>Refresh</b> button to resubmit your simulation<br>";
+      last;
+    }
+  }
+}
+
 my $Phantom_Name = FilterMetaChars($in{'Phantom_Name'});
 my $Phantom_Nx = FilterToNumber($in{'Phantom_Nx'});
 my $Phantom_Ny = FilterToNumber($in{'Phantom_Ny'});
 my $Phantom_NSample = FilterToNumber($in{'Phantom_NSample'});
 $error .= "Phantom name must not be blank<br>" if ($Phantom_Name eq "");
-$error .= "Phantom NX and NY must be between 5 and 1024<br>" if ($Phantom_Nx < 5 || $Phantom_Nx > 1024 || $Phantom_Ny < 5 || $Phantom_Ny > 1024);
-$error .= "Phantom NSample must be between 1 and 10<br>" if ($Phantom_NSample < 1 || $Phantom_NSample > 10);
+$error .= "Phantom NX and NY must be between 5 and 512<br>" if ($Phantom_Nx < 5 || $Phantom_Nx > 512 || $Phantom_Ny < 5 || $Phantom_Ny > 512);
+$error .= "Phantom NSample must be between 1 and 5<br>" if ($Phantom_NSample < 1 || $Phantom_NSample > 5);
 
 my $PJ_NDet = FilterToNumber($in{'PJ_NDet'});
 my $PJ_NRot = FilterToNumber($in{'PJ_NRot'});
 my $PJ_NRay = FilterToNumber($in{'PJ_NRay'});
 my $PJ_RotAngle = FilterToNumber($in{'PJ_RotAngle'});
-$error .= "Projection NDet must be between 5 and 1800<br>" if ($PJ_NDet < 5 || $PJ_NDet > 1800);
-$error .= "Projection NRot must be between 5 and 2048<br>" if ($PJ_NRot < 5 || $PJ_NRot > 2048);
+$error .= "Projection NDet must be between 5 and 1000<br>" if ($PJ_NDet < 5 || $PJ_NDet > 1000);
+$error .= "Projection NRot must be between 5 and 1000<br>" if ($PJ_NRot < 5 || $PJ_NRot > 1000);
+$error .= "Projection NRay must be between 1 and 5<br>" if ($PJ_NRay < 1 || $PJ_NRay > 5);
 $error .= "Projection RotAngle must be between 0.1 and 2<br>" if ($PJ_RotAngle < 0.1 || $PJ_RotAngle > 2);
 
 #my $IR_Nx = FilterToNumber($in{'IR_Nx'});
@@ -96,10 +108,10 @@ my $ir_png_url = "$::url_datadir/ir-$tmpid.png";
 my $pj_png_url = "$::url_datadir/pj-$tmpid.png";
 my $sub_png_url = "$::url_datadir/sub-$tmpid.png";
 
-my $pjrec_ver = "$::bindir/pjrec";
-my $phm2pj_ver = "$::bindir/phm2pj";
-my $phm2if_ver = "$::bindir/phm2if";
-my $diff_ver = "$::bindir/if-2";
+my $pjrec_ver = "$::bindir/ctsimtext pjrec";
+my $phm2pj_ver = "$::bindir/ctsimtext phm2pj";
+my $phm2if_ver = "$::bindir/ctsimtext phm2if";
+my $diff_ver = "$::bindir/ctsimtext if2";
 
 $pjrec_ver = "/opt/lam/bin/mpirun N N $::lamrundir/pjrec-lam" if $MPI;
 $phm2pj_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2pj-lam" if $MPI;
@@ -120,10 +132,10 @@ if ($Disp_Max ne 'auto') {
     $window_options .= " --max $Disp_Max";
 }
 
-my $png1_cmd = "$::bindir/if2img $phantom_fname $phantom_png $window_options --stats --format png";
-my $png2_cmd = "$::bindir/if2img $ir_fname $ir_png $window_options --stats --format png";
-my $png3_cmd = "$::bindir/if2img $pj_if_fname $pj_png --auto $auto_window_pj --stats --format png";
-my $png4_cmd = "$::bindir/if2img $sub_fname $sub_png --auto $auto_window_diff --stats --format png";
+my $png1_cmd = "$::bindir/ifexport $phantom_fname $phantom_png $window_options --stats --format png";
+my $png2_cmd = "$::bindir/ifexport $ir_fname $ir_png $window_options --stats --format png";
+my $png3_cmd = "$::bindir/ifexport $pj_if_fname $pj_png --auto $auto_window_pj --stats --format png";
+my $png4_cmd = "$::bindir/ifexport $sub_fname $sub_png --auto $auto_window_diff --stats --format png";
 
 my $title = "CT Simulation Results";
 
@@ -170,6 +182,12 @@ if ($error ne "") {
       }
     }
   }
+  # Delete image files and projection files
+  unlink($phantom_fname);
+  unlink($ir_fname);
+  unlink($pj_fname);
+  unlink($pj_if_fname);
+  unlink($sub_fname);
 
   $cmdout = "$gp_cmd\n $gp_out $pj_cmd\n $pj_out $pj_if_cmd\n $pj_if_out $pjrec_cmd\n $pjrec_out $diff_cmd\n $diff_out $png1_cmd\n $png_gp_out $png2_cmd\n $png_pjrec_out $png3_cmd\n $png_pj_out $png4_cmd\n $png_sub_out";
   if (open(LOGFILE,">> $logfile")) {
@@ -207,8 +225,7 @@ if ($error ne "") {
 }
 
 $out .= "<HR>\n";
-$out .= "Return to <A HREF=\"/ctsim/index.html\">CT Simulation Designer</a>.<br>\n";
-$out .= "Return to <A HREF=\"www.med-info.com\">Med-Info</a>.\n";
+$out .= "Return to <A HREF=\"http://www.ctsim.org\">CTSim</a>.<br>\n";
 $out .= "</BODY> </HTML>";
 $out .= "\n";