#!/usr/local/bin/perl # Script to take arguments from DiffAG.html, and return an # HTML page to the client. # # The script can be considered as consisting of the following parts: # # (1) Read in arguments passed to script. # (2) Verification of arguments. # (3) Make Calculations. # (4) Generate return HTML page # # J.Brewer, August 1998. ############################################################################## ############################################################################## # (1) Read in arguments passed to script. ############################################################################## # Below is from Gundavaram (Nutshell book) $webmaster = "jbrewer\@eso\.org"; &parse_form_data (*ip); # For compactness, assign array elements to variables... $pier = $ip{'pier'}; $units = $ip{'units'}; $ra_cm = $ip{'ra_cm'}; $dec_cm = $ip{'dec_cm'}; $dec = $ip{'dec'}; ############################################################################## ############################################################################## # (2) Verification of arguments. ############################################################################## # Set the error flag $error = 0; # $pier and $units are not verified as they are defined # via pulldown menus # Check validity of R.A. cross motion rate... if ($ra_cm < -1000 || $ra_cm > 1000){ if (! $error){&first_error;} print "ERROR: R.A. cross motion rate is out of range/invalid\n"; } # Check validity of Dec cross motion rate... if ($dec_cm < -1000 || $dec_cm > 1000){ if (! $error){&first_error;} print "ERROR: Dec cross motion rate is out of range/invalid\n"; } # Bail out if an error occured... if ($error){exit(1);} ############################################################################## ############################################################################## # (3) Make Calculations... ############################################################################## if (!($dec eq "None")){ # Apply 15Cos(Dec) correction to R.A. cross motion rate... $ra_cm = 15*cos((3.142/180)*$dec)*$ra_cm; # Round off... &trun($ra_cm,5); } # Convert RA and Dec cross motion to arcsec/sec. if ($units eq "arcsec/hr"){ $ra_cm = $ra_cm/3600; $dec_cm = $dec_cm/3600; } elsif ($units eq "arcsec/min"){ $ra_cm = $ra_cm/60; $dec_cm = $dec_cm/60; } if ($pier eq "East"){ # Use transformations for East of pier... $RA_CM = 0.6975*($ra_cm - sin((3.142/180)*3)*$dec_cm); $DEC_CM = 1.1154*($dec_cm - sin((3.142/180)*3)*$ra_cm); }else{ # Use transformations for West of pier... $RA_CM = -0.6975*($ra_cm - sin((3.142/180)*3)*$dec_cm); $DEC_CM = -1.1154*($dec_cm - sin((3.142/180)*3)*$ra_cm); } # Round off values... &trun($RA_CM,4); &trun($DEC_CM,4); ############################################################################## ############################################################################## # (4) Generate return HTML page ############################################################################## $dateX = `date`; print < Differential AG Calculation
[2p2 Logo]

Differential AG Calculation

[DK TN]



Entered Parameters

Telescope Pier: $pier
R.A. Cross Motion: $ip{'ra_cm'} $units
Dec. Cross Motion: $ip{'dec_cm'} $units
Object Declination:$dec

Note: 15cos(dec) correction end_of_print1 if ($dec eq "None"){ print"not made to R.A. cross motion rate.

"; }else{ print"made to R.A. cross motion rate.
"; print"Corrected Value is $ra_cm

"; } print <

Results

To start differential autoguiding, first acquire a guide star and start autoguiding. After the autoguider has locked onto the guide star, open an Xterm on the tcs1d5 WS, and issue the command:

cmd pltrack $RA_CM   $DEC_CM

To stop differential autoguiding switch off the autoguider and then enter the command:

cmd nopltrack


This Page Created:
$dateX
Comments:
jbrewer\@eso.org
end_of_print2 ############################################################################## ############################################################################## # sub first error: executed the first time an error occurs... ############################################################################## sub first_error{ print"Content-type: text/plain","\n\n"; print"You have entered invalid data, please return to the form and \n"; print"check your input using the below diagnostics \n\n\n"; $error = 1; } ############################################################################## # sub parse_form_data: decode arguments... ############################################################################## sub parse_form_data { local (*FORM_DATA) = @_; local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value); $request_method = $ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $query_string = $ENV{'QUERY_STRING'}; } elsif ($request_method eq "POST") { read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } else { &return_error (500, "Server Error", "Server uses unsupported method"); } @key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if (defined($FORM_DATA{key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} = $value; } } } ############################################################################## # sub return_error: Error routine for form decoding.... ############################################################################## sub return_error { local($status, $keyword, $message) = @_; print "Content-type: text/html", "\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print <CGI Program -- Unexpected Error

$keyword


$message
Please contact $webmaster for more information. End_of_Error exit(1); } ############################################################################## # Sub to round numbers ############################################################################## sub trun { $_[0]=int($_[0]*10**$_[1]+.5)/10**$_[1]; }