#!/usr/bin/perl # Ed Sternin July.2001 $|=1; $dir = "/var/www/htdocs/tmp"; $fname = "$^T$$"; $host = $ENV{'REMOTE_ADDR'}; ##print "Content-type: text/plain\n\n"; sub translatevalue { local($value) = @_; $value =~ tr/+/ /; $value =~ s/%(..)/pack("c",hex($1))/ge; $value =~ s/\r/ /ge; return $value; } if ($ENV{'REQUEST_METHOD'} eq "GET") { $INPUT = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { while ($t = <>) { $INPUT .= $t; } } @temp = split("&", $INPUT); foreach $t (@temp) { ($key, $value) = split("=", $t); $key =~ tr/A-Z/a-z/; $key = translatevalue($key); $value = translatevalue($value); ${$key} = $value; $FIELDS{$key} = $value; if ($key =~ /^ch(.+)$/) { $CHANNELS{$1} = $value; } ## print "$key = $value\n"; } if ($action eq " Go ") { ## print "Content-type: text/plain\n\n"; print "Content-type: text/html\n\n"; print "\n"; $cmd = "/usr/local/bin/lpf"; $NP = 1; # defaults of lpf are Npts = 1 $DW = 1; # and DWell = 1s if (defined($debug)) { $cmd = join("", $cmd, " -vv"); } if (defined($ip) & !($ip eq "") ) { $cmd = join("", $cmd, " -i $ip"); } else { $cmd = join("", $cmd, " -i $host"); } if (defined($port)) { $cmd = join("", $cmd, " -p $port"); } if (defined($npts)) { $cmd = join("", $cmd, " -n $npts"); $NP = $npts; } if (defined($dwell)) { $cmd = join("", $cmd, " -d $dwell"); $DW = $dwell; } if (defined(%CHANNELS)) { $cmd = join("", $cmd, " -c "); foreach $ch (keys %CHANNELS) { $cmd = join ("", $cmd, "$ch,"); } $cmd =~ s/,*$//; # remove trailing ',' } if (defined($demo)) { $cmd = join("", $cmd, " -s"); } $ttime = $DW * $NP; print "
\n";
  print "Executing\n  $cmd\n";
  print "This will take $ttime seconds, please be patient... \n";
  print "When done, select the data returned and Copy/Paste it\n";
  print "into the \"x y [dy [dx]]\" window below:\n\n"; 
  if (defined($demo)) {
    print "\nThis DEMO data was acquired earlier, your settings are ignored\n";
     foreach $ch (keys %CHANNELS) {
       if ($ch eq "1") {
         print "Ch.1: try fitting to (A+D)*(x<C)+(A*exp(-(x-C)*B)+D)*(x>=C)\n";
	 print "      and set initial B=3 or so\n";
         }
      else {
        if ($ch eq "11") {
          print "Ch.11: try fitting to A*sin(x*B+C)+D\n";
          }
        else {
          print "There is no data for Ch. $ch, try Ch.1 or 11\n";
          }
        }
      }
    }
  print "
\n"; print "
\n"; print "\n"; print "
\n"; ## system("$cmd 2>&1 | tee $dir/$fname"); ## print `cat $dir/$fname`; ## unlink "$dir/$fname"; } else { print "Content-type: text/html\n\n"; print "\n"; print " \n"; print "\n"; } exit;