APSF,0,RPEHLM_Prefix //****************************************************************** // Name : RAS_Gen // Purpose : Generate 'Browser Astronomy' compatible scripts // Requires: AP v1.5.1b3 or later // Author : Robin Lauryssen-Mitchell // Date : 29th July 2006 // Version : 0.7 // Status : Beta // History : 0.1 - Initial beta release // 0.2 - LOGOUT handling added // 0.3 - Initial version of PREFIX handling added // Improved code for ScriptDetails // 0.4 - Auto-increment filter during ExposureSet replication (crude) // 0.5 - Implemented the multi-column SetExposure dialogue // Added 'persistent' values to the SetExpsoure dialogue // Replaced local support routines with those provided in v1.5.1b2 // 0.6 - Replaced varient arrays with class arrays // 0.7 - Added filtering to SelectList to only display sensible options // Added RPEHLM_Prefix script // Replace SelectPlan with the more capable ChoosePlan // Added MinimumSlewSort feature // Notes : Filter handling is a bit (actually a lot) horrible // Some routines have now been included in APv1.5.1a10 and b1 // Code style and documentation is patchy in places (mostly actually) // This version is configured for Rent-A-Scope equipment // To Do : Next up will be the Mosaic option // : See the manual //****************************************************************** //================================================================== // Declarations //================================================================== //------------------------------------------------------------------ // Const declarations //------------------------------------------------------------------ //General const cNoObject = 0 //No plan objects count //Plan constants const cNoPlan = 0 const cMinPlan = 1 //List processing selections const cNoList = -1 //No list to processed flag const cAllList = 0 //Process all plan objects const cHighlightedList = 1 //Process only highlighted plan objects const cSelectedList = 2 //Process only selected plan object //Imaging script selections const cAllInOneScript = 0 //All objects in one imaging script const cOnePerScript = 1 //One object per imaging script //Exposure type selections const cAllSameExp = 0 //All objects have same exposure parameters const cSetPerObjectExp = 1 //Each object has different exposure parameters //Scope identifiers const cNoScope = 0 //No scope selected const cAre01 = 1 //Are01 - Takahasi Mewlon 300 / FLI Dream Machine const cAre02 = 2 //Are02 const cAre03 = 3 //Are03 - Takahasi Sky90 const cAre04 = 4 //Are04 - Takahasi Epsilon 250 const cAre05 = 5 //Are05 const cAre06 = 6 //Are06 - (Australia) //Exposure sets (parameters per filter) const cExposureSet1 = 0 const cExposureSet2 = 1 const cExposureSet3 = 2 const cExposureSet4 = 3 //Exposure set array indices (ExposureSets) const cMinute = 0 const cSecond = 1 const cDelay = 2 const cBinMode = 3 const cFilter = 4 const cActive = 5 const cImages = 6 const cCopy = 7 const cAutodark = 8 //Script Details array indices (ScriptSet) const cScriptType = 0 //Which type of imaging script to create (0=AllInOne, 1=OnePerObject) const cExposureType = 1 //Exposure parameters for objects (0=All the same, 1=Set per object) const cFilterSet = 2 // const cAutoGuideFlag = 3 //Autoguiding (True=On, False=Off) const cPrefixFlag = 4 //Generate PREFIX command flag (True=yes, False=no) const cLogoutFlag = 5 //Generate LOGOUT command flag (True=yes, False=no) const cMSS = 6 //Arrange target list in Minimum Slew Sort (True=yes, False=no) //-------------------------------------------------------------------------------- // Class declarations //-------------------------------------------------------------------------------- class ExposureSetType dim Minute as integer dim Second as integer dim Delay as integer dim BinMode as integer dim Filter as integer dim Images as integer dim Autodark as boolean dim Active as boolean end class class ScriptDetailsType dim ScriptType as integer //Which type of imaging script to create (0=AllInOne, 1=OnePerObject) dim ExposureType as integer //Exposure parameters for objects (0=All the same, 1=Set per object) dim FilterSet as integer // dim AutoGuideFlag as boolean //Autoguiding (True=On, False=Off) dim PrefixFlag as boolean //Generate PREFIX command flag (True=yes, False=no) dim LogoutFlag as boolean //Generate LOGOUT command flag (True=yes, False=no) dim MSSFlag as boolean //Arrange target list in Minimum Slew Sort (True=yes, False=no) end class //------------------------------------------------------------------ // Var declarations //------------------------------------------------------------------ dim i as integer //General loop counter dim doit as boolean //General flag dim multi(-1) as string // dim WhichList as integer //Which object list to process (0=All, 1=Highlighted, 2=Selected) dim TargetCount as integer //Number of targets to be processed (also used as an error flag) dim ErrorText as string //Holder for error message text dim PlanID as integer //ID of currently selected plan dim PlanName as string //Name of currently selected plan dim ScopeID as integer //Which scope is the script fo //Script details dim ScriptSet as ScriptDetailsType //Script details //ExposureSet/s dim ExposureSets (cExposureSet4) as ExposureSetType dim CopyExposureSet as boolean dim HaveExposureSets as boolean dim AutoGuideFlag as boolean //Autoguiding (True=On, False=Off) dim AutoguideStatus as boolean dim AutoguideMin as integer //File dim TextOutput as APTextFile //Output script file handle dim ScratchPlanID as integer //================================================================== // Subs and Functions //================================================================== //------------------------------------------------------------------ // Name: SelectList // Purpose: Choose an object list to process (must have a selected plan) // Returns: ListID - Type of object list selected (0=No list selected) // CancelFlag - True=User cancelled, False=List selected //------------------------------------------------------------------ function SelectList (byref ListID as integer) as boolean dim multi(-1) as string //Choice text dim ErrorText as string //Error message to be displayed dim CancelFlag as boolean //Did user click 'Cancel'? dim OptionSelect as string CancelFlag = false //Initialise the Cancel flag //Build the choice strings multi.append "All "+str(nObj)+" objects" //The complete plan object list OptionSelect = "0" if nHighlighted > cNoObject then multi.append str(nHighlighted)+" highlighted objects only" //Only the highlighted objects OptionSelect = OptionSelect + "1" end if if SelectedObject > cNoObject then multi.append "Selected object only ("+Obj(SelectedObject).ID+")" //Only the selected objects OptionSelect = OptionSelect + "2" end if SetChoiceParameter("Target list?", ListID, multi) //Setup the dialogue //Show the Target List selection dialogue if EditParameters ("Current plan: " + PlanName) then //ListID = GetChoiceParameter("Target list?") //Process the user response ListID = val(mid(OptionSelect, GetChoiceParameter("Target list?")+1, 1)) select case ListID case cAllList //Process all objects if nObj = cNoObject then //...if the plan has any ListID = cNoList ErrorText = "ERROR: Plan contains no objects" end if case cHighlightedList //Process highlighted objects if nHighlighted = cNoObject then //...if there are any ListID = cNoList ErrorText = "ERROR: No highlighted object/s" end if case cSelectedList //Process the selected object if SelectedObject < 1 then //...if there is one ListID = cNoList ErrorText = "ERROR: No selected object" end if end select else //User clicked Cancel button ListID = cNoList CancelFlag = true ErrorText = "INFO: User cancel" end if //Abandon the script if the seleceted list contains no objects //or the user selected Cancel if ListID = cNoList then print ErrorText CancelFlag = true end if return CancelFlag end function //------------------------------------------------------------------ // Name : ScriptDetails // Purpose : Get script and exposure type details // Requires: None // Returns : Script type, Exposure set type, Autoguide and Logout command flags // Notes : Some of these parameters should be 'permanetly' stored //------------------------------------------------------------------ function GetScriptSet (byref ScriptSet as ScriptDetailsType, ListID as integer) as boolean const Title = "Script Details" const cDefaultScript = 0 const cDefaultExposure = 0 const cDefaultAutoguiding = false const cDefaultPrefix = false const cDefaultLogout = true const cDefaultMSS = false dim Flag as boolean = false ScriptSet = new ScriptDetailsType SetChoiceParameter("Script Generation:", cDefaultScript, _ "One script for all objects", _ "One script per object") SetChoiceParameter("Exposure Sets:", cDefaultExposure, _ "Same for all objects", _ "Different for each object") SetCaptionParameter ("Miscellaneous:") SetBooleanParameter(false, "Autoguiding", cDefaultAutoguiding) SetBooleanParameter(false, "Prefix command", cDefaultPrefix) SetBooleanParameter(false, "Logout command", cDefaultLogout) if ((ListID = cAllList) and (nObjects > 2)) or ((ListID = cHighlightedList) and (nHighlighted > 2)) then //if not((ListID = 2) or (nHighlighted < 3)) then //needs a check for nObjects < 3 SetBooleanParameter(false, "Minimum Slew Sort", cDefaultMSS) end if if EditParameters(Title) then ScriptSet.ScriptType = GetChoiceParameter("Script Generation:") ScriptSet.ExposureType = GetChoiceParameter("Exposure Sets:") ScriptSet.AutoGuideFlag = GetBooleanParameter("Autoguiding") ScriptSet.PrefixFlag = GetBooleanParameter("Prefix command") ScriptSet.LogoutFlag = GetBooleanParameter("Logout command") ScriptSet.MSSFlag = GetBooleanParameter("Minimum Slew Sort") Flag = true else //User clicked Cancel Flag = false end if return Flag end function //------------------------------------------------------------------ // Name : SelectScope // Purpose: Allows the user to select which scope the script is intended for // What the user is actually doing is selecting a set of filters // Each RAS scope has a unique set of filters and wheel positions! //------------------------------------------------------------------ function SelectScope (byval ScriptID as integer, byref ScopeID as integer) as boolean dim ChangeScope as boolean // dim multi(-1) as string //Choice text dim Flag as boolean multi.append "ARE01" //Set up the choice text multi.append "ARE02" multi.append "ARE03" multi.append "ARE04" multi.append "ARE05" multi.append "ARE06" SetChoiceParameter("Which scope?", ScopeID, multi) //Setup the dialogue if ScriptID = cOnePerScript then SetBooleanParameter ("Change scope per script", ChangeScope) end if if EditParameters ("Telescope selection") then //Process the dialogue ScopeID = GetChoiceParameter("Which scope?") + 1 //Return scope ID ChangeScope = GetBooleanParameter("Change scope per script") Flag=true else ScopeID = cNoScope //Return cNoScope on Cancel Flag = false end if return Flag end function //------------------------------------------------------------------ // Name : PopulateExposureSet // Purpose: Fill the indexed ExposureSet with the passed parameters //------------------------------------------------------------------ sub PopulateExposureSet (SetID as integer, _ Minute as integer, Second as integer, Delay as integer, _ BinMode as integer, Filter as integer, Images as integer, _ Autodark as boolean, Active as boolean) ExposureSets(SetID).Minute = Minute ExposureSets(SetID).Second = Second ExposureSets(SetID).Delay = Delay ExposureSets(SetID).BinMode = BinMode + 1 ExposureSets(SetID).Filter = Filter ExposureSets(SetID).Active = Active ExposureSets(SetID).Images = Images ExposureSets(SetID).Autodark = Autodark end sub //------------------------------------------------------------------ // Setup exposure parameters // NOTE: This does too much // Need to separate out data capture and data storage // Possibly should return captured data as a parameter array // It's done this way mostly because I have not found how to_ // create user defined data types yet (or even if its possible) //------------------------------------------------------------------ function GetExposureSets (SetTitle as string, ScopeRef as integer) as boolean const cMinMinutes = 0 const cMaxMinutes = 60 const cMinSeconds = 0 const cMaxSeconds = 60 const cMinDelay = 0 const cMaxDelay = 15 const cMinBin = 0 const cMaxBin = 2 const cMinSeries = 0 const cMaxSeries = 99 const cDefSeries = 1 const cAutodarkOff = false const cAutodarkOn = true const cActiveOff = false const cActiveOn = true const cReuseOn = true const cReuseOff = false const cMinuteField = 0 const cSecondField = 1 const cDelayField = 2 const cBinField = 3 const cFilterField = 4 const cSeriesField = 5 const cAutodarkField = 7 const cActiveField = 8 const cMaxField = cActiveField dim Fields(cMaxField) as string dim CancelFlag as boolean = false //Cancel button flag dim ExpMinutes as integer = cMinMinutes dim ExpSeconds as integer = cMinSeconds dim Delay as integer = cMinSeconds dim BinMode as integer dim BinList(-1) as string dim Filter as integer dim FilterList(-1) as string dim Active as boolean dim Series as integer dim AutoDark as boolean dim Reuse as boolean dim Flist as string dim FilterID as integer dim FieldCount as integer dim ColCount as integer dim Field as string Fields(cMinuteField) = "Minutes" Fields(cSecondField) = "Seconds" Fields(cDelayField) = "Delay" Fields(cBinField) = "BinMode" Fields(cFilterField) = "Filter" Fields(cSeriesField) = "Series" Fields(cAutodarkField) = "Autodark" Fields(cActiveField) = "Active" //Init dialgoue parameter ExpMinutes = cMinMinutes ExpSeconds = cMinSeconds Delay = cMinSeconds BinMode = cMinBin Active = cActiveOn Series = cDefSeries Autodark = cAutodarkOff //Build Bin Mode selection list BinList.append "1x1" BinList.append "2x2" BinList.append "3x3" select case ScopeRef case cAre01 FilterList.append "B-Blue" FilterList.append "B-V-Green" FilterList.append "B-Red" FilterList.append "B-IR" FilterList.append "Clear" Filter = 4 Flist = "4210" case cAre02 FilterList.append "Bes-Ultr" FilterList.append "Bes-Blue" FilterList.append "Bes-Green" FilterList.append "Bes-Red" FilterList.append "Bes-Infra" FilterList.append "Lum" FilterList.append "Ha" FilterList.append "SII" FilterList.append "OIII" FilterList.append "Blue" Filter = 5 Flist = "5321" case cAre03 FilterList.append "Lum" FilterList.append "Red" FilterList.append "Green" FilterList.append "Blue" FilterList.append "Clr" FilterList.append "Ha" FilterList.append "SII" FilterList.append "OII" FilterList.append "Blank1" FilterList.append "Blank2" Filter = 0 Flist = "0123" case cAre04 FilterList.append "Red (R)" FilterList.append "Green (V)" FilterList.append "Blue (B)" FilterList.append "Clear" FilterList.append "Ha" FilterList.append "SII" FilterList.append "OIII" FilterList.append "Infra" Filter = 3 Flist = "3012" case cAre05 FilterList.append "Red" FilterList.append "Green" FilterList.append "Blue" FilterList.append "Clear" FilterList.append "Ha" FilterList.append "SII" FilterList.append "OIII" FilterList.append "Infrared" Filter = 3 Flist = "3012" case cAre06 //Unfinished - holding values FilterList.append "Lum?" FilterList.append "Red?" FilterList.append "Green?" FilterList.append "Blue?" FilterList.append "Ha?" FilterList.append "SII?" FilterList.append "OIII?" FilterList.append "Clear?" Filter = 0 Flist = "0123" else //Whoops! Shouldn't be here, but do something sensible anyway FilterList.append "Lum?" FilterList.append "Red?" FilterList.append "Green?" FilterList.append "Blue?" Filter = 0 Flist = "0123" end select //Build choice strings SetCaptionParameter (false, "Filter 1 (normally Clear)") SetCaptionParameter (true, "Filter 2 (normally Red)") SetCaptionParameter (true, "Filter 3 (normally Green)") SetCaptionParameter (true, "Filter 4 (normally Blue)") for FieldCount = 0 to cMaxField for ColCount = 0 to 3 select case FieldCount case cMinuteField Field=Fields(cMinuteField)+"."+str(ColCount) SetIntegerParameter (ColCount>0, Field, RestoreIntegerValue(Field, cMinMinutes), cMinMinutes, cMaxMinutes) case cSecondField Field=Fields(cSecondField)+"."+str(ColCount) SetIntegerParameter (ColCount>0, Field, RestoreIntegerValue(Field, cMinSeconds), cMinSeconds, cMaxSeconds) case cDelayField Field=Fields(cDelayField)+"."+str(ColCount) SetIntegerParameter (ColCount>0, Field, RestoreIntegerValue(Field, cMinDelay), cMinDelay, cMaxDelay) case cBinField Field=Fields(cBinField)+"."+str(ColCount) SetPopupParameter (ColCount>0, Field, RestoreIntegerValue(Field, cMinBin), BinList) case cFilterField Field=Fields(cFilterField)+"."+str(ColCount) SetPopupParameter (ColCount>0, Field, RestoreIntegerValue(Field, val(mid(Flist, ColCount+1, 1))), FilterList) case cSeriesField Field=Fields(cSeriesField)+"."+str(ColCount) SetIntegerParameter (ColCount>0, Field, RestoreIntegerValue(Field, cDefSeries), cMinSeries, cMaxSeries) case cAutodarkField Field=Fields(cAutodarkField)+"."+str(ColCount) SetBooleanParameter (ColCount>0, Field, RestoreBooleanValue(Field, cAutodarkOff)) case cActiveField Field=Fields(cActiveField)+"."+str(ColCount) SetBooleanParameter (ColCount>0, Field, RestoreBooleanValue(Field, cActiveOn)) end select next next //Display dialogue if EditParameters ("Set Exposure for: " + SetTitle, false) then //Store exposure parameters in holding array for ColCount = cExposureSet1 to cExposureSet4 PopulateExposureSet (ColCount, _ GetIntegerParameter (Fields(cMinuteField)+"."+str(ColCount)), _ GetIntegerParameter (Fields(cSecondField)+"."+str(ColCount)), _ GetIntegerParameter (Fields(cDelayField)+"."+str(ColCount)), _ GetPopupParameter (Fields(cBinField)+"."+str(ColCount)), _ GetPopupParameter (Fields(cFilterField)+"."+str(ColCount)), _ GetIntegerParameter (Fields(cSeriesField)+"."+str(ColCount)), _ GetBooleanParameter (Fields(cAutodarkField)+"."+str(ColCount)), _ GetBooleanParameter (Fields(cActiveField)+"."+str(ColCount))) next for ColCount = cExposureSet1 to cExposureSet4 Field = Fields(cMinuteField)+"."+str(ColCount) SaveIntegerValue (Field, GetIntegerParameter(Field)) Field = Fields(cSecondField)+"."+str(ColCount) SaveIntegerValue (Field, GetIntegerParameter(Field)) Field = Fields(cDelayField)+"."+str(ColCount) SaveIntegerValue (Field, GetIntegerParameter(Field)) Field = Fields(cBinField)+"."+str(ColCount) SaveIntegerValue (Field, GetPopupParameter(Field)) Field = Fields(cFilterField)+"."+str(ColCount) SaveIntegerValue (Field, GetPopupParameter(Field)) Field = Fields(cSeriesField)+"."+str(ColCount) SaveIntegerValue (Field, GetIntegerParameter(Field)) Field = Fields(cAutodarkField)+"."+str(ColCount) SaveBooleanValue (Field, GetBooleanParameter(Field)) Field = Fields(cActiveField)+"."+str(ColCount) SaveBooleanValue (Field, GetBooleanParameter(Field)) next SaveBooleanValue ("Reuse", GetBooleanParameter("Reuse")) CancelFlag = false else CancelFlag = true //User cancelled the dialogue end if return CancelFlag end function //------------------------------------------------------------------ //Get Autoguide parameters //------------------------------------------------------------------ function Autoguide(byref Status as boolean, byref GuideMin as integer) as boolean const cMinGuideMin = 500 const cMaxGuideMin = 9999 dim CancelFlag as boolean if ScriptSet.AutoguideFlag then Status = false GuideMin = cMinGuideMin SetBooleanParameter ("State (ticked=on)", Status) SetIntegerParameter ("GuideMin", GuideMin, cMinGuideMin, cMaxGuideMin) if EditParameters ("Autoguiding") then CancelFlag=False Status = GetBooleanParameter ("State (ticked=on)") GuideMin = GetIntegerParameter ("GuideMin") else CancelFlag = True end if else CancelFlag = False end if return CancelFlag end function //------------------------------------------------------------------ //Name : ScopeIDToName //Purpose: For a given ID return the scope name //Returns: Scope name as a text string //------------------------------------------------------------------ function ScopeIDToName (ScopeID as integer) as string dim ScopeName as string select case ScopeID case cAre01 ScopeName = "ARE01" case cAre02 ScopeName = "ARE02" case cAre03 ScopeName = "ARE03" case cAre04 ScopeName = "ARE04" case cAre05 ScopeName = "ARE05" case cAre06 ScopeName = "ARE06" else ScopeName = "Undefined" end select return ScopeName end function //------------------------------------------------------------------ //Name : GetPrefix //Purpose : If the object has a name, return it to use as a prefix //Requires: //Returns : Dialogue cancel flag //Notes : //------------------------------------------------------------------ function GetPrefix (ObjectID as double, byref Prefix as string) as boolean const delim = "," dim Flag as boolean dim NameText as string dim SelList(-1) as string NameText = Obj(ObjectID).Name if NameText <> "" then if Instr(NameText, delim) >0 then SelList=split(NameText, delim) SetPopupParameter ("Prefix", 0, SelList) if EditParameters ("Select Prefix for " + Obj(ObjectID).ID) then Prefix = SelList(GetPopupParameter("Prefix")) Flag = true else Prefix = "" Flag = false end if else Prefix = NameText Flag = true end if else Prefix = Obj(ObjectID).ID Flag = true end if return Flag end function //------------------------------------------------------------------ //Name : WriteFileEntry //Purpose : Format object/exposure data and write to file //Requires: FileHandle, Object index //Returns : None //Notes : This routine is doing too much (and not enough 8-) // Data formatting needs to be elsewhere // File creation or appending needs to be here (I think, maybe) //------------------------------------------------------------------ sub WriteFileEntry (File as APTextFile, Oid as integer) dim SetIndex as integer dim ExpTime as string dim PrefixText as string File.WriteLine "#Object:_" + Obj(Oid).ID File.WriteLine "#Selected_scope:_" + ScopeIDToName(ScopeID) if ScriptSet.PrefixFlag then if GetPrefix(Oid, PrefixText) then File.WriteLine "PREFIX " + PrefixText else exit end if end if File.WriteLine "SLEW " + FormatRA(Obj(Oid).RA, false, "hmsa") + "," + FormatDec(Obj(Oid).Dec, false, "+dmsa") if AutoGuideStatus then File.WriteLine "AUTOGUIDE start" File.WriteLine "GUIDEMIN " + str(AutoGuideMin) end if for SetIndex = cExposureSet1 to cExposureSet4 if ExposureSets(SetIndex).Active then File.WriteLine "BIN " + str(ExposureSets(SetIndex).BinMode) File.WriteLine "FILTER " + str(ExposureSets(SetIndex).Filter) if ExposureSets(SetIndex).Delay > 0 then File.WriteLine "DELAY " + str(ExposureSets(SetIndex).Delay) end if File.WriteLine "SERIES " + str(ExposureSets(SetIndex).Images) if ExposureSets(SetIndex).Autodark then File.WriteLine "AUTODARK on" end if ExpTime = str(((ExposureSets(SetIndex).Minute)*60) + (ExposureSets(SetIndex).Second mod 1200)) if AutoGuideStatus then File.WriteLine "IMAGEX " + ExpTime else File.WriteLine "IMAGE " + ExpTime end if if ExposureSets(SetIndex).Autodark then File.WriteLine "AUTODARK off" end if end if // active exposure set next SetIndex if AutoGuideStatus then File.WriteLine "AUTOGUIDE stop" end if end sub //================================================================== // Main code // This list of IF statements should probably be nested // On the other hand this code layout works so don't fix it! //================================================================== //Before doing anything else, make sure the Class stuff is set up! //Why on Earth each element of ExposureSets needs to be created individually beats me!!! ExposureSets(0) = New ExposureSetType ExposureSets(1) = New ExposureSetType ExposureSets(2) = New ExposureSetType ExposureSets(3) = New ExposureSetType //------------------------------------------------------------------ // Check we have a plan to work with //------------------------------------------------------------------ PlanID=ChoosePlan(PlanName) select case PlanID case cUserCanceled print "Info: User cancel" exit case cNoPlan print "ERROR: There are no plans available for processing" exit else end select //------------------------------------------------------------------ // Check to make sure the plan has some objects to work with //------------------------------------------------------------------ if nObj = cNoObject then //If no objects then print "ERROR: " + PlanName + " contains no objects!" //...output error exit //...and abort script end if //otherwise continue script //------------------------------------------------------------------ //Assume there is one object selected //*** Might be a bad assumption!!! *** //------------------------------------------------------------------ //------------------------------------------------------------------ //Find out which object list (All, Highlighted or Selected) the _ //user wants to process //Note: All errors are handled internally to SelectList //------------------------------------------------------------------ if SelectList(WhichList) then exit end if //------------------------------------------------------------------ //Note: //------------------------------------------------------------------ if not(GetScriptSet(ScriptSet, WhichList)) then //If the user selection has no objects to process print "INFO: User cancel" //...display error text exit end if //------------------------------------------------------------------ //Get the scope to be used //------------------------------------------------------------------ if not(SelectScope(ScriptSet.ScriptType, ScopeID)) then print "INFO: User cancel" //...display error text exit end if //------------------------------------------------------------------ //If ScriptType is 'AllInOne' then we need to create a file to append to //------------------------------------------------------------------ if ScriptSet.ScriptType = cAllInOneScript then TextOutput=WriteTextFile if TextOutput=nil then print "INFO: User cancel" exit end if end if //------------------------------------------------------------------ // Process the plan object/s // Note: Need to change the loop structure to make aborting easier //------------------------------------------------------------------ HaveExposureSets = false //No ExposureSet data - yet //Do the Minimum Slew Sort? if ScriptSet.MSSFlag then ScratchPlanID=LoadScratchPlan(true) CopyPlanToPlan (PlanID, ScratchPlanID, WhichList) MinimumSlewSort //Do the sort that all this 'orrible stuff is here for PlanID=ScratchPlanID //Scratch plan now has all the objects we want SelectPlan(PlanID) //Make sure it's currently selected WhichList=cAllList //Kludge because IsHighlighted property is NOT copied end if for i=1 to nObj //Scan plan list doit = false //reset process object flag select case WhichList //What sort of list is being processed? case cAllList // All objects doit = true // set the process flag every time case cHighlightedList // Highlighted objects doit = Obj(i).IsHighlighted // set the process flag only if indexed object is highlighted case cSelectedList // Selected doit = Obj(i).Selected // set the process flag only if indexed object is selected end select if doit then // Indexed object to be processed select case ScriptSet.ExposureType // Same ExposureSets for all objects case cAllSameExp if not(HaveExposureSets) then if GetExposureSets("All Objects", ScopeID)then print "INFO: User cancel" exit //THIS WILL NOT TERMINATE THE SCRIPT end if HaveExposureSets = true if AutoGuide(AutoGuideStatus, AutoGuideMin) then print "INFO: User cancel" exit end if end if case cSetPerObjectExp //Different ExposureSets per object if GetExposureSets(Obj(i).ID, ScopeID) then print "INFO: User cancel" exit //THIS WILL NOT TERMINATE THE SCRIPT end if if AutoGuide(AutoGuideStatus, AutoGuideMin) then print "INFO: User cancel" exit end if end select select case ScriptSet.ScriptType case cAllInOneScript //Format object/exposure data for output WriteFileEntry (TextOutput, i) //Append formatted data to file case cOnePerScript //Create new file (where?) //Perhaps after the first time extract the path for use next time round. Append the Obj.ID? TextOutput=WriteTextFile if TextOutput=nil then print "INFO: User cancel" exit //THIS WILL NOT TERMINATE THE SCRIPT else //Write to file WriteFileEntry (TextOutput, i) if ScriptSet.LogoutFlag then TextOutput.WriteLine "LOGOUT" end if end if TextOutput.close end select end if //end 'doit' processing next //------------------------------------------------------------------ //If ScriptType is 'AllInOne' then we need to close the file //------------------------------------------------------------------ if ScriptSet.ScriptType = cAllInOneScript then if ScriptSet.LogoutFlag then TextOutput.WriteLine "LOGOUT" end if TextOutput.close end if //------------------------------------------------------------------ //If MinimumSlewSort was used then we need to close the scratch plan //------------------------------------------------------------------ if ScriptSet.MSSFlag then PlanID=DumpScratchPlan() end if //------------------------------------------------------------------ //We're done! //------------------------------------------------------------------ print "INFO: END" exit