<%@ LANGUAGE="JSCRIPT" %><% // 23-Dec-08 rbd New DB caching hack // 18-Feb-09 rbd New RTML importer requires Contact.Organization. Catch case // where exposure interval longer than total time. Move final // EndResponse outside try/catch/finally so all three will run. // Fix several problems with empty form fields! Make note on // Priority follow normalization setting in Scheduler. // 22-Mar-09 rbd Fix bug in finally part of post code // 05-Nov-09 rbd GEM:284 - Add dithering support // 06-Nov-09 rbd GEM:285 - Change Dither to input box // 12-Aug-10 rbd GEM:423 - Add [ACP loginusername] to Contact User so Acquire // Scheduler can substitute that into file path and put logs // into that user's web logs folder. // 20-Jan-11 rbd GEM:571 - Set our parent iframe's height dynamically. // 22-Jan-11 rbd GEM:571 - Make IE fudge manifest constant, change to 18. // // // Enhance String with a trim() method // String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }; var DB = Session("SDB"); if(DB == undefined) { var DBR = new ActiveXObject("ACP.DBRelay"); DB = DBR.GetDB(Session); DBR = null; } var Conf = new ActiveXObject("DC3.Scheduler.SchedulerConfig"); var UserPriorities = Conf.UserPriorities; Conf = null; var FSO = new ActiveXObject("Scripting.FileSystemObject"); function makeFilterList() { var buf = ""; try { var filtFn = Server.MapPath("/sc/" + "filters.txt"); if(!FSO.FileExists(filtFn)) return; // No file, no filters var filtSt = FSO.OpenTextFile(filtFn, 1); while(!filtSt.AtEndOfStream) { var f = filtSt.ReadLine().trim(); if(f !== "") buf += "\r\n"; } filtSt.Close(); } catch(ex) { buf = "\r\n"; } return buf; } function makeBinningList() { var buf = ""; try { var binFn = Server.MapPath("/sc/" + "binning.txt"); if(!FSO.FileExists(binFn)) return "(??)"; // Must have binning file! var binSt = FSO.OpenTextFile(binFn, 1); while(!binSt.AtEndOfStream) { var b = binSt.ReadLine().trim(); if(b !== "") buf += "\r\n"; } binSt.Close(); } catch(ex) { buf = "\r\n"; } return buf; } function endResponse() { Response.Write("

The browser will be refreshed in a few seconds...
\r\n"); Response.Write("... or click here to refresh now.

\r\n"); Response.Write("\r\n"); } Response.ExpiresAbsolute = new Date("Jan 1, 2000").getVarDate(); // Expire even with clock offsets Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); %> Submit Astro-Imaging Request <% if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() == "post") { %> <% } else { %> <% } %> <% if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() != "post") { // === GET === %>

Submit Astro-Imaging Request for <%= User.Name %>

1. Object and Coordinates:
Object Name:   (same name for all colors of same object)
Right Ascension:   (hours, J2000, flexible format)
Declination:   (degrees, J2000, flexible format)
Position Angle:   (degrees, required if rotator used)
2. Images: (request each color separately)
Total time:   (hours, may extend over multiple nights)
Exposure time:   (seconds, for each individual exposure)
Filter:
Binning:
Dither:   (pixels rms -1.0 for auto)
3. Priority and Constraints: (advanced, click to reveal)
4. Upload Your Request

Your images will be grouped into a project with the name given in Object Name above.

 Submit Request

<% } else { Response.Write("\r\n"); // === POST === if(!User.CanUpload) { Response.Write("

No permission to upload.

\r\n"); endResponse(); Response.End(); } if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() != "post") { Response.Write("

This URL allows only uploaded content.

\r\n"); endResponse(); Response.End(); } var RTML = new ActiveXObject("XML_RTML23.RTML"); RTML.Version = 2.3; // Required! RTML.Contact = new ActiveXObject("XML_RTML23.Contact"); RTML.Contact.User = User.Name if (User.Username != "localweb") RTML.Contact.User += " [ACP " + User.Username + "]"; // Insert special tag for real web RTML.Contact.Email = "your@email.here"; RTML.Contact.Organization = ""; var name = Request("pName"); var filter = Request("pFilter"); var eachExp = Request("pEachExp"); // Requested sub exposure interval var reqTotExp = Request("pTotExp") * 3600; // Total seconds requested var haE = Request("pHaE"); var haW = Request("pHaW"); var totExp = 0; // Total seconds in images so far if(eachExp > reqTotExp) { DB.CurrentUser = 0; RTML = null; Response.Write("

Request failed: exposure interval (" + eachExp + " sec.) longer than total
\r\n"); Response.Write(" time requested (" + reqTotExp + " sec)

"); endResponse(); Response.End(); } // // 1 hour (max) groups, but allow a 1-image "group" with longer exposure. // grpTime = Math.min(1, Request("pTotExp")); // 1hr max or tot requested time (short group) var maxInGrp = Math.max(1, Math.floor(grpTime * 3600 / eachExp)); // Max number of images in each group if(haW !== "" && haE !== "" && (eachExp > ((haW - haE) * 2400))) // Sub exposure too long for HA constraint? { DB.CurrentUser = 0; RTML = null; Response.Write("

Request failed: exposure interval (" + eachExp + " sec.) too large for hour angle constraint
\r\n"); Response.Write(" Exposures must fit into 2/3 of the hour angle range (" + grpTime * 3600 + " sec)

"); endResponse(); Response.End(); } // // Be careful, there are many boundary conditions here. // var expNum = 1; while(totExp < reqTotExp) // Make plans for each exposure till needed { var grpCount = Math.min(maxInGrp, Math.floor((reqTotExp - totExp) / eachExp)); // Number in this group if(grpCount === 0) break; // Avoid short block grpTime = grpCount * eachExp; // Final group time for this group var REQ = new ActiveXObject("XML_RTML23.Request"); RTML.Requests.Add(REQ); // Creates a Plan in ACPS REQ.Project = name; // Plan belongs to project named after object REQ.Description = Util.FormatVar((grpTime / 3600.0), "0.00") + " hr block of " + Util.FormatVar((1.0 * Request("pTotExp")), "0.00") + " hr (total) request for " + Request("pFilter") + " images."; REQ.UserName = User.Name; // For logged in ACP user //see below REQ.ID = name + "-" + filter + "-" + expNum; // Plan name is object-filter-index // expNum += 1; // Separate for lint var SCH = new ActiveXObject("XML_RTML23.Schedule"); REQ.Schedule = SCH; if(Request("pSkyCond") !== "") SCH.SkyCondition = Request("pSkyCond"); if(Request("pPriority") !== "") SCH.Priority = Request("pPriority"); else SCH.Priority = 0; if(haE !== "" && haW !== "") // Validated both there { SCH.HourAngleRange = new ActiveXObject("XML_RTML23.HourAngleRange"); SCH.HourAngleRange.East = haE; SCH.HourAngleRange.West = haW; } if(Request("pHorizon") !== "") SCH.Horizon = Request("pHorizon"); if(Request("pMoonDown")) { SCH.Moon = new ActiveXObject("XML_RTML23.Moon"); SCH.Moon.Down = true; } else if(Request("pMoonAvoid1") !== "" && Request("pMoonAvoid2") !== "") { SCH.Moon = new ActiveXObject("XML_RTML23.Moon"); SCH.Moon.Distance = Request("pMoonAvoid1"); SCH.Moon.Width = Request("pMoonAvoid2"); } var TGT = new ActiveXObject("XML_RTML23.Target"); REQ.Targets.Add(TGT); TGT.Coordinates = new ActiveXObject("XML_RTML23.Coordinates"); TGT.Coordinates.RightAscension = 15 * Util.HMS_Hours(Request("pRA")); // RA In DEGREES for RTML! TGT.Coordinates.Declination = Util.DMS_Degrees(Request("pDE")); if(Request("pPA") !== "") TGT.PositionAngle = Request("pPA"); TGT.Name = name; TGT.Description = ""; // (not "RTML Target") var PIC = new ActiveXObject("XML_RTML23.Picture"); TGT.Pictures.Add(PIC); PIC.Name = filter + " filter"; PIC.ExposureTime = eachExp; PIC.Filter = filter; PIC.Binning = Request("pBinning"); PIC.count = grpCount; // Never 0 (see above) if(Request("pDither") > 0) PIC.Dither = Request("pDither"); // RTML does not accept 0 if(Request("pDither") < 0) PIC.Dither = 999; // 999 = "auto" totExp += PIC.ExposureTime * grpCount; if(grpCount > 1) REQ.ID = name + "-" + filter + " (" + expNum + "-" + (expNum + grpCount - 1) + ")"; else REQ.ID = name + "-" + filter + "-" + expNum; expNum += grpCount; } var RTI; var tmpSt = null; try { var tmpFn = Server.MapPath("/plans/" + User.Username) + "\\last-rtml-from-web.txt"; tmpSt = FSO.CreateTextFile(tmpFn, true); tmpSt.Write(RTML.XML("", true)); tmpSt.Close(); tmpSt = null; // [sentinel] for finally RTI = new ActiveXObject("DC3.RTML23.Importer"); RTI.DB = DB; RTI.Import(tmpFn); var R = RTI.Projects.Item(0); if(R.Description == "Project created from imported RTML.") { R.Description = ""; R.Update(); } Response.Write("

Request has been entered successfully by ACP user " + User.Name + " (" + User.Username + ").

\r\n"); Response.Write("

Enable the project when you want it to become eligible to run!

\r\n"); } catch(ex) { Response.Write("

Request failed: " + (ex.message ? ex.message : ex) + "

\r\n"); } finally { if(tmpSt !== null) tmpSt.Close(); DB.CurrentUser = 0; RTML = null; RTI = null; } endResponse(); Response.End(); // NOT INSIDE TRY OR CATCH! FINALLY WILL NOT RUN } %>