<%@ LANGUAGE="JSCRIPT" %><% // 13-Apr-09 rbd For John Farrell, after SRO Photometry page // 14-Apr-09 rbd Fix AirmassRange // 04-Oct-09 rbd GEM:178 Custom filter names in photofilts.txt (up to 4 lines) // Custom binning level in photobinning.txt (1 line) // 05-Oct-09 rbd Oops, bug in binning file reading! Oops, forgot number on B // field names. Oops, forgot the Monitor Mode UI! // 18-Oct-09 rbd Fix validation for V-only images. // 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. Add copyright to bottom. // 22-Jan-11 rbd GEM:571 - Make IE fudge manifest constant, change to 18. // 05-Jan-14 rbd Copyright to 2014 // 22-Jan-14 rbd GEM:1083 No more DBRelay hack :-) Also get UserPriorities // from new ACP Scheduler object. // 10-Feb-14 rbd GEM:1094 Comment on the lack of need to remove '+' in field // names for this form to handle filters with spaces in their names. // 17-Jan-19 rbd GEM:1660 Modern DOCTYPE and HTML declarations // 13-Sep-23 rbd No GEM - Copyright to 2023 // // // Enhance String with a trim() method // String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }; var DB = Scheduler.Database; var FSO = new ActiveXObject("Scripting.FileSystemObject"); // // Filter list - Optional file photofilters.txt (up to 4 non-blank lines) // var photoFilts = [ "I", "R", "V", "B" ]; // Standard photometry filters var filtIndex = 0; var filtFn = Server.MapPath("/sc/photofilters.txt"); if(FSO.FileExists(filtFn)) { var filtSt = FSO.OpenTextFile(filtFn, 1); while(!filtSt.AtEndOfStream) { var f = filtSt.ReadLine().trim(); if(f !== "") { photoFilts[filtIndex] = f; if(i >= 3) break; else filtIndex += 1; } } filtSt.Close(); } var fldVar = [ photoFilts[0] + "1", photoFilts[1] + "1", photoFilts[2] + "1", photoFilts[3] + "1", photoFilts[2] + "2", photoFilts[1] + "2", photoFilts[0] + "2" ]; // // Photometry binning - Optional photobinning.txt (1 non-blank line) // var photoBinning = 1; // Standard photometry binning var binFn = Server.MapPath("/sc/photobinning.txt"); if(FSO.FileExists(binFn)) { var binSt = FSO.OpenTextFile(binFn, 1); while(!binSt.AtEndOfStream) { var b = binSt.ReadLine().trim(); try { // Problems? Leave standrd binning if(b != "") { photoBinning = parseInt(b); break; } } catch(ex) { } } binSt.Close(); } // // Project list // function makeProjectList() { var buf = "\r\n"; try { var uID = 0; var eU = new Enumerator(DB.Users); for(; !eU.atEnd(); eU.moveNext()) { var U = eU.item(); if(U.Name == User.Name) { uID = U.ID; break; } } if(uID !== 0) // Get existing projects for this user { DB.CurrentUser = uID; var eR = new Enumerator(DB.Projects); for(; !eR.atEnd(); eR.moveNext()) { var pn = eR.item().Name; buf += "\r\n"; } } } catch(ex) { buf += ""; } finally { DB.CurrentUser = 0; } 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 Photometry Data Request <% if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() == "post") { %> <% } else { %> <% } %> <% if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() != "post") { // === GET === %>

Submit Photometric Survey Request for <%= User.Name %>

1. Destination Project:
Select Project:  (select existing project, or...)
New Project:  (...create new project with this name)
2. Target List:
Targets one per line, tab-delimited: Name RA Dec (J2000)

List File:
3. Images:
<%= photoFilts[0] %>:  images @    seconds
<%= photoFilts[1] %>:  images @    seconds
<%= photoFilts[2] %>:  images @    seconds
<%= photoFilts[3] %>:  images @    seconds
<%= photoFilts[2] %>:  images @    seconds
<%= photoFilts[1] %>:  images @    seconds
<%= photoFilts[0] %>:  images @    seconds
Dither:   (pixels rms -1.0 for auto)
4. Constraints:
Air Mass:   (relative air mass, must be at or below this value)
Air Mass Range:     (max, min - relative air mass, must be within this range)
Hour Angle:     (hours E, W, - east, must be within this range)
Moon Avoid:     (distance degrees, width days, normally 15, 6)
Moon Down:   (Moon must be below horizon, ignore Moon Avoid)
Sky Condition:   (sky must be at least this good)
5. Priority:
Priority:   <% if(Scheduler.UserPriorities) Response.Write("(any range you want, normalized across observers)"); else Response.Write("(priorities are shared across all observers)"); %>
6. Monitor Mode
Monitor interval:   (days) Requeue every n days forever or until "Stop Monitoring at"
Stop monitoring at: (Example: Feb 20, 2010 03:00:00 UTC)
7. Upload Your Request:

 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 FSO = new ActiveXObject("Scripting.FileSystemObject"); 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 = ""; // // A single Schedule object is shared by all targets // var SCH = new ActiveXObject("XML_RTML23.Schedule"); if(Request("pAmLow") !== "" && Request("pAmHigh") !== "") // Validated both there (typ.) { SCH.AirmassRange = new ActiveXObject("XML_RTML23.AirmassRange"); SCH.AirmassRange.Minimum = Request("pAmLow"); SCH.AirmassRange.Maximum = Request("pAmHigh"); } else if(Request("pAirmass") !== "") // Only if no AM Range { SCH.Airmass = Request("pAirmass"); } if(Request("pHaE") !== "" && Request("pHaW") !== "") { SCH.HourAngleRange = new ActiveXObject("XML_RTML23.HourAngleRange"); SCH.HourAngleRange.East = Request("pHaE"); SCH.HourAngleRange.West = Request("pHaW"); } if(Request("pMoonDown")) { SCH.Moon = new ActiveXObject("XML_RTML23.Moon"); SCH.Moon.Down = true; } else if(Request("pMoonAvoid1") !== "" && Request("pMoonAvoid2") !== "") // Only if no Moon Down { SCH.Moon = new ActiveXObject("XML_RTML23.Moon"); SCH.Moon.Distance = Request("pMoonAvoid1"); SCH.Moon.Width = Request("pMoonAvoid2"); } SCH.SkyCondition = Request("pSkyCond"); if(Request("pPriority") !== "") SCH.Priority = Request("pPriority"); // Should always be there, but... if(Request("pMonInt") > 0 && Request.Form("pMonEnd").Item !== "") { var TR = new ActiveXObject("XML_RTML23.TimeRange"); SCH.TimeRange = TR; SCH.TimeRange.Earliest = new Date(new Date().toUTCString().replace(/\s*UTC/, "")).getVarDate(); SCH.TimeRange.Latest = new Date(Request.Form("pMonEnd").Item.replace(/\s*UTC/, "")).getVarDate(); } // // Create a Plan for each target. One Observation. // var tgtStrm = null; try { tgtStrm = FSO.OpenTextFile(Request.Form("FilePath")); var lineNo = 0; while(!tgtStrm.AtEndOfStream) { var line = tgtStrm.ReadLine(); lineNo += 1; if(line.trim() == "") continue; var bits = line.split("\t"); if(bits.length != 3) throw "Bad data at line no. " + lineNo + " \"" + line + "\""; var pName = bits[0].trim(); var REQ = new ActiveXObject("XML_RTML23.Request"); RTML.Requests.Add(REQ); // Creates a Plan in ACPS REQ.ID = pName; // Plan name = object name REQ.UserName = User.Name; // For logged in ACP User if(Request("pProject") !== "") REQ.Project = Request("pProject"); else REQ.Project = Request("pNewProject"); REQ.Description = "Submitted via web photometry form."; if(Request("pMonInt") > 0) // Safe - validated REQ.Reason = "Monitor=" + Request("pMonInt"); // Hack in 3.1 RTML importer REQ.Schedule = SCH; var TGT = new ActiveXObject("XML_RTML23.Target"); REQ.Targets.Add(TGT); TGT.Name = pName; TGT.Coordinates = new ActiveXObject("XML_RTML23.Coordinates"); TGT.Coordinates.RightAscension = 15 * Util.HMS_Hours(bits[1].trim()); // RA In DEGREES for RTML! TGT.Coordinates.Declination = Util.DMS_Degrees(bits[2].trim()); for(var i in fldVar) { // // This form is posted with Content-Type: multipart/form-data // and the field names with spaces are preserved as is. The // spaces are not converted to '+'. // var filt = fldVar[i].substr(0, fldVar[i].length - 1); var cnt = Request("p" + fldVar[i] + "Cnt"); if(cnt !== "") { var PIC = new ActiveXObject("XML_RTML23.Picture"); TGT.Pictures.Add(PIC); PIC.Name = filt + " filter"; PIC.ExposureTime = Request("p" + fldVar[i] + "Exp"); PIC.Filter = filt PIC.Binning = photoBinning; PIC.count = cnt; if(Request("pDither") > 0) PIC.Dither = Request("pDither"); // RTML does not accept 0 if(Request("pDither") < 0) PIC.Dither = 999; // 999 = "auto" } } } } catch(ex) { Response.Write("Submission failed: " + (ex.message ? ex.message : ex) + "\r\n"); if(tgtStrm !== null) tgtStrm.Close(); endResponse(); Response.End(); } tgtStrm.Close(); var RTI; try { var tmpFn = Server.MapPath("/plans/" + User.Username) + "\\last-rtml-from-web.txt"; var tmpSt = FSO.CreateTextFile(tmpFn, true); tmpSt.Write(RTML.XML("", true)); tmpSt.Close(); FSO = null; RTI = new ActiveXObject("DC3.RTML23.Importer"); RTI.DB = DB; RTI.Import(tmpFn); Response.Write("

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

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

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

\r\n"); } catch(ex) { Response.Write("RTML failed: " + (ex.message ? ex.message : ex) + "\r\n"); } finally { DB.CurrentUser = 0; RTML = null; RTI = null; } endResponse(); Response.End(); // NOT INSIDE TRY OR CATCH! FINALLY WILL NOT RUN } %>