APSF //################################################################################################################################## // Name : DSLRShoot // Purpose : Photograph one or more selected targets // Requires: AP v1.5.9a15 (or higher) // Author : Robin Lauryssen-Mitchell // Date : 30th October 2007 // Version : 1.3 // Status : Production // History : 0.1 - Initial beta release // 0.2 - Removed confirmation box from Slew failure processing - caused shoot-list processing to be halted // Had a session of slew failures so improved the error reporting (possibly due to my hardware) // Fixed 'out-by-one' error with com port selector // 0.3 - Removed reference to lib_RPEHLM_Library (causing 'overloaded' errors) // 1.0 - Mostly documentation changes. Really needs a rewrite - oh well one day! // 1.1 - Added Exposure Repeat feature (Thanks Ken) // Added Observation Logging feature // Added Save Plan feature // Fixed major bug in extracting exposure time from shootlist (Thanks Paul) // Fixed bug in MSS detection when AllObjects selected // Fixed bug in canceling setting exposure time for SelectedObjectOnly // 1.2 - Fixed a horribley stupid bug in the telescope slewing routine // Added ASCOM support // Removed the 'Scope not connected' check // 1.3 - Fixed missing library files (rats!) // Notes : IMPORTANT *** ONLY TESTED WITH MY HARDWARE - MEADE LX90 (CLASSIC), CANON EOS300D (Rebel to colonial friends) // The camera will require a serial shutter release cable // Images are stored on the camera CF card // No testing is done to see if the camera is functioning correctly or even exists // Default Com port is 4 (that's what my system uses) // ToDo : - Add imaging sequence abort // - Add shoot-list save/load? // - Disable ASCOM support on non-Windows platforms //################################################################################################################################## //----- Start of included Library Scripts //----- Library Script: lib_AP //################################################################################################################################## // Name : AP_Library // Purpose : Library to support AP scripts. // The use of this library (particularly the constants) is intended to improve the readability of AP scripts. // For example, instead of: // if ObjectIndex = -1 then ... // you could write // if ObjectIndex = cNoSelectedObject then ... // Requires: AP v1.5.1b3 or later // Author : Robin Lauryssen-Mitchell // Date : 14th September 2006 // Version : 1.2 // Status : Production // History : 08Aug06 - 0.1 - Initial beta release // 21Aug06 - 0.2 - Changed name from AP_Constants to AP_Declarations // 22Aug06 - 0.3 - Added prefixes to declarations // 27Aug06 - 0.4 - Changed name to AP_Library - and changed it back again when the routines stopped working!!! // 11Sep06 - 1.1 - Added Double-Click constants for SetListParameter etc // 14Sep06 - 1.2 - Added WindowStatus, // Notes : - Must get approval from Paul before posting this. Might be thought of as an 'official' part of AP due to the filename // Perhaps get some of these (constants) included in the APCallable module // - References to the Scripting Manual are correct as of v1.5.1b3 (I hope) // - Some of the constant name prefixes are a little clumsy (e.g. APTF for APTextFile), however, they are added in an // attempt to avoid conflicting with another script writers declarations. Occasionally it got too much, even for me. // For example, what should have been the prefix cAPAAVSO got abbreviated to cAPA. The whole Prefix question, // including the leading 'c' is up for debate, censure, veto, whatever. BTW, the leading 'c' is a left-over from a // Microsoft program documentation standard - not sure if even they still use it!!! // - Prefixes // Format = AP?? where AP=AstroPlanner and ??=1 or a 2-letter section designator // Section Title Prefix Notes // ------- --------------------------- ------ ------------------------------------ // 2.2 General Properties APGP // 2.3 General Methods APGM Constellation constants not prefixed // 2.3.24 EditParameters APEP // 2.4 APPlanObject APO // 2.5 APObservation APOB // 2.6 APAAVSO APA // 2.7 APCatalogObject APCO // 2.8 APCatalog APC // 2.9 APTextFile APTF // 2.10 APSearch APS // 2.11 Canvas APCV // 2.11.4 CanvasFOV APCF // 2.11.5 Creating and drawing tables APCT // 2.12 Table APT // 2.13 Resources APR // 2.13.2 SiteResource APSR // 2.13.3 TelescopeResource APTR // 2.13.4 EyepieceResource APER // 2.13.5 VisualAidResource APVR // 2.14 Serial port support APSP // - Still not convinced that the Prefixes are a good idea - feels a little clumsy to me // - Have abandoned, for the time being, the idea of including 'standard' variable declarations in this library. // For the time being this file will only contain Constants and a few routines. //################################################################################################################################## //================================================================================================================================== // Declarations //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Scripting constants //---------------------------------------------------------------------------------------------------------------------------------- //.................................................................................................................................. // 2.2 General Properties (APGP) //.................................................................................................................................. //General purpose const cAPGP_CancelledYes = true //User clicked a 'Cancel' button const cAPGP_CancelledNo = false //User did not click a 'Cancel' button //Object const cAPGP_NoSelectedObject = -1 //Plan does not contain a selected object const cAPGP_NoObject = 0 //Plan contains no objects const cAPGP_MinObject = 1 //Base object ID //Plan const cAPGP_MissingPlan = -1 //No plan (usually with given name) was loadable const cAPGP_NoPlan = 0 //No plan (usually with given name) is loaded const cAPGP_MinPlan = 1 //Base plan ID const cAPGP_PlanFileExt = ".apd" //AP plan file extension //Catalogue const cAPGP_MinCatalog = 1 //Base catalogue ID //Telescope const cAPGP_CurrentRAOffline = -999 //RA value returned if scope is offline const cAPGP_CurrentDecOffline = -999 //Dec value returned if scope is offline const cAPGP_ScopeIsOffline = false //Value return by IsOnline if scope is offline const cAPGP_ScopeIsOnline = true //Value return by IsOnline if scope is online //User Heading const cAPGP_UserColumn1 = 1 //Index for User column 1 const cAPGP_UserColumn2 = 2 //Index for User column 2 const cAPGP_UserColumn3 = 3 //Index for User column 3 const cAPGP_UserColumn4 = 4 //Index for User column 4 //User Abort const cAPGP_AbortNo = false //Operation was not cancelled by user const cAPGP_AbortYes = true //Operation was cancelled by user //PlanLocalDateTime const cAPGP_UseComputerTime = 0 //Set the local date/time to the computer date/time //Plan Dates const cAPGP_MinPlanTime = 0.0 //Minimum GMT/GMTST/LST time const cAPGP_MaxPlanTime = 23.999999 //Maximum GMT/GMTST/LST time //.................................................................................................................................. // 2.3 General Methods (APGM) //.................................................................................................................................. //List const cAPGM_MinList = 1 //Base list ID const cAPGM_MinListRow = 1 //Base list row ID const cAPGM_MinListCol = 1 //Base list column ID const cAPGM_ListHeadingDef = 0 //Heading justification is Default const cAPGM_ListHeadingLeft = 1 //Heading justification is Left const cAPGM_ListHeadingCentre = 2 //Heading justification is Centre const cAPGM_ListHeadingRight = 3 //Heading justification is Right //SlewTo const cAPGM_SlewToNotConnected = -1 //Telescope is not connected or not GoTo capable const cAPGM_SlewToOK = 0 //Slew successful const cAPGM_SlewToBelowHorizon = 1 //Below horizon const cAPGM_SlewToOutsideLimits = 2 //Outside slewing limits const cAPGM_SlewToBlocked = 3 //Blocked by user-defined horizon //CatalogFindID const cAPGM_CatalogNotFound = 0 //Catalogue search was not successful const cAPGM_MinCatalogFound = 1 //Minimum catalogue find ID //GetCatalog const cAPGM_GetCatalogFailed = nil //Catalogue ID or Name could not be found //2.3.9 Choice const cAPGM_MinChoice = 1 //Base Choice ID const cAPGM_ChoiceCancelled = -1 //User clicked 'Cancel' //2.3.10 Options const cAPGM_MinOption = 1 //Base Option ID const cAPGM_OptionCancelled = -1 //User clicked 'Cancel' //TextFile const cAPGM_TextFileFailed = nil //Operation failed or user clicked 'Cancel' const cAPGM_ScriptFileExt = ".txt" //Script filename extension //Launch const cAPGM_AppForeground = true //Try to put the application in the foreground when launched //Shell const cAPGM_ShellMinTimeout = 0 //When would this ever be used!? const cAPGM_ShellDefTimeout = 2000 //Default timeout - 2000ms or 2 seconds //FindObject const cAPGM_FindObjectFailed = nil //FindObject search failed //EditParameters (see section 2.3.24 below) //UserColumnNumeric const cAPGM_UserDecPlaces0 = 0 //Display 0 decimal places const cAPGM_UserDecPlaces1 = 1 //Display 1 decimal place const cAPGM_UserDecPlaces2 = 2 //Display 2 decimal places const cAPGM_UserDecPlaces3 = 3 //Display 3 decimal places const cAPGM_UserDecPlaces4 = 4 //Display 4 decimal places const cAPGM_UserDecPlacesAuto = -1 //Automatically select number of decimal places //[Get|Set]ExternalCoords const cAPGM_ExternalCoordsOK = true //External application returned a set of coordinates const cAPGM_ExternalCoordsFailed = false //External application could not return coordinates for some reason //GetURL const cAPGM_URLTimeoutNever = 0 //Sets the function to never timeout const cAPGM_URLTimeoutDef = 30 //Default timeout const cAPGM_URLEmpty = "" //Returned if error occurrs //SortObservingList const cAPGM_AscendingOrder = true //Sort into ascending order const cAPGM_DescendingOrder = false //Sort into descending order //GetPlanName, PlanChanged, SavePlan, ClosePlan const cAPGM_CurrentlySelectedPlan = -1 //Get the currently selected plan name //GetPlanNumber const cAPGM_PlanNumberNotFound = 0 //The named plan is not currently loaded //PlanChanged const cAPGM_PlanHasChanged = true //Plan has been changed since last save const cAPGM_PlanNotChanged = false //Plan has not been changed since last save //ClosePlan const cAPGM_PlanSilentCloseOff = true //Avoid the user alert if the plan is 'dirty' const cAPGM_PlanSilentCloseOn = false //Raise the user alert if the plan is 'dirty' //NewPlan const cAPGM_NewPlanOverwriteAlertOff = true //Do not raise a file overwrite alert const cAPGM_NewPlanOverwriteAlertOn = false //Raise a file overwrite alert if needed const cAPGM_NewPlanUniqueOn = true //Auto-generate unique file name suffix if needed const cAPGM_NewPlanUniqueOff = false //Do not generate a unique file name suffix if file name already exists const cAPGM_NewPlanCancelled = 0 //User cancelled the operation const cAPGM_NewPlanBadFileName = -1 //Specified path does not make sense for some reason const cAPGM_NewPlanPathIsFolder = -2 //Specified path is a folder const cAPGM_NewPlanProtectedFile = -3 //Plan file could not be deleted const cAPGM_NewPlanFileIsOpen = -4 //Plan with same name is already open const cAPGM_NewPlanCreationFailed = -5 //Plan could not be created //OpenPlan const cAPGM_OpenPlanFailed = -1 //Plan file could not be opened for some reason (usually a bad path specification) //StartProgress const cAPGM_StartProgressCancelOn = true //Display a cancel button const cAPGM_StartProgressCancelOff = false //Do not display a cancel button //UpdateProgress const cAPGM_UpdateProgressCancelled = true //Cancel button was clicked const cAPGM_UpdateProgressRunning = false //Cancel button not clicked //Format[RA|Dec] const cAPGM_FormatExtendedOn = true //Enable decimal second representation const cAPGM_FormatExtendedOff = false //Disable decimal second representation //FormatRA const cAPGM_RAMin = 0.0 //Minimum RA value const cAPGM_RAMax = 23.9999 //Maximum RA value const cAPGM_RADefault = "hms:" //The default RA format const cAPGM_RALong = "hmsa" //The longest RA format available const cAPGM_RAShort = "hms" //The shortest RA format available const cAPGM_RADecimal = "h" //Express the RA value as a decimal //FormatDec const cAPGM_DecMin = -90.0 //Minimum Dec value const cAPGM_DecMax = 90.0 //Maximum Dec value const cAPGM_DecDefault = "+dmsx" //The default Dec format const cAPGM_DecLong = "+dmsa" //Longest format (could have been '+dmsx', but I chose this version to match the long RA format) const cAPGM_DecShort = "dms" //Shortest Dec format available const cAPGM_DecDecimal = "d" //Express the Dec value as a decimal //OKCancel const cAPGM_DefaultOKButton = true //OK button is the default const cAPGM_DefaultCancelButton = false //Cancel button is the default const cAPGM_OKButtonClicked = true //The OK button was clicked const cAPGM_CancelButtonClicked = false //The Cancel button was clicked //YesNo const cAPGM_DefaultYesButton = true //Yes button is the default const cAPGM_DefaultNoButton = false //No button is the default const cAPGM_YesButtonClicked = true //Yes button was clicked const cAPGM_NoButtonClicked = false //No button was clicked //Confirmation const cAPGM_DefaultButton1 = true //Button 1 is the default const cAPGM_DefaultButton2 = false //Button 2 is the default const cAPGM_Button1Clicked = true //Button 1 was clicked const cAPGM_Button2Clicked = false //Button 2 was clicked //Constellations const cAnd = 0 const cAnt = 1 const cAps = 2 const cAql = 3 const cAqr = 4 const cAra = 5 const cAri = 6 const cAur = 7 const cBoo = 8 const cCae = 9 const cCam = 10 const cCap = 11 const cCar = 12 const cCas = 13 const cCen = 14 const cCep = 15 const cCet = 16 const cCha = 17 const cCir = 18 const cCMa = 19 const cCMi = 20 const cCnc = 21 const cCol = 22 const cCom = 23 const cCrA = 24 const cCrB = 25 const cCrt = 26 const cCru = 27 const cCrv = 28 const cCVn = 29 const cCyg = 30 const cDel = 31 const cDor = 32 const cDra = 33 const cEqu = 34 const cEri = 35 const cFor = 36 const cGem = 37 const cGru = 38 const cHer = 39 const cHor = 40 const cHya = 41 const cHyi = 42 const cInd = 43 const cLac = 44 const cLeo = 45 const cLep = 46 const cLib = 47 const cLMi = 48 const cLup = 49 const cLyn = 50 const cLyr = 51 const cMen = 52 const cMic = 53 const cMon = 54 const cMus = 55 const cNor = 56 const cOct = 57 const cOph = 58 const cOri = 59 const cPav = 60 const cPeg = 61 const cPer = 62 const cPhe = 63 const cPic = 64 const cPsA = 65 const cPsc = 66 const cPup = 67 const cPyx = 68 const cRet = 69 const cScl = 70 const cSco = 71 const cSct = 72 const cSer = 73 const cSex = 74 const cSge = 75 const cSgr = 76 const cTau = 77 const cTel = 78 const cTrA = 79 const cTri = 80 const cTuc = 81 const cUMa = 82 const cUMi = 83 const cVel = 84 const cVir = 85 const cVol = 86 const cVul = 87 const cAndromeda = 0 const cAntlia = 1 const cApus = 2 const cAquila = 3 const cAquarius = 4 const cAra = 5 const cAries = 6 const cAuriga = 7 const cBootes = 8 const cCaelum = 9 const cCamelopardis = 10 const cCapricornus = 11 const cCarina = 12 const cCassiopeia = 13 const cCentaurus = 14 const cCepheus = 15 const cCetus = 16 const cChamaeleon = 17 const cCircinus = 18 const cCanisMajor = 19 const cCanisMinor = 20 const cCancer = 21 const cColumba = 22 const cComaBerenices = 23 const cCoronaAustralis = 24 const cCoronaBorealis = 25 const cCrater = 26 const cCrux = 27 const cCorvus = 28 const cCanesVenatici = 29 const cCygnus = 30 const cDelphinus = 31 const cDorado = 32 const cDraco = 33 const cEquuleus = 34 const cEridanus = 35 const cFornax = 36 const cGemini = 37 const cGrus = 38 const cHercules = 39 const cHorologium = 40 const cHydra = 41 const cHydrus = 42 const cIndus = 43 const cLacerta = 44 const cLeo = 45 const cLepus = 46 const cLibra = 47 const cLeoMinor = 48 const cLupus = 49 const cLynx = 50 const cLyra = 51 const cMensa = 52 const cMicroscopium = 53 const cMonoceros = 54 const cMusca = 55 const cNorma = 56 const cOctans = 57 const cOphiuchus = 58 const cOrion = 59 const cPavo = 60 const cPegasus = 61 const cPerseus = 62 const cPhoenix = 63 const cPictor = 64 const cPiscesAustrinus = 65 const cPisces = 66 const cPuppis = 67 const cPyxis = 68 const cReticulum = 69 const cSculptor = 70 const cScorpius = 71 const cScutum = 72 const cSerpens = 73 const cSextans = 74 const cSagitta = 75 const cSagittarius = 76 const cTaurus = 77 const cTelescopium = 78 const cTriangulumAustrale = 79 const cTriangulum = 80 const cTucana = 81 const cUrsaMajor = 82 const cUrsaMinor = 83 const cVela = 84 const cVirgo = 85 const cVolans = 86 const cVulpecula = 87 const cConstellationNone = -1 const cConstellationMin = 0 const cConstellationMax = 87 //Additional non-ScriptingManual declarations const cConstellationSep = " - " const cConstellationShortName = 1 const cConstellationLongName = 2 //2.3.70 ScreenSize const cAPGM_PhysicalScreen = true //Real screen size const cAPGM_AvailableScreen = false //Takeing into account screen menus, docks etc //2.3.71-74 Main Window States (Windows only) const cAPGM_MainWindowMinimized = -1 const cAPGM_MainWindowNormal = 0 const cAPGM_MainWindowMaximized = 1 //.................................................................................................................................. // 2.3.24 EditParameters (APEP) //.................................................................................................................................. const cAPEP_UserCancelled = -1 //User cancel flag value (should replace this - darn! can't remember why!!!) const cAPEP_ShowFieldIndices = true //Reveal the field ID and Tab numbers const cAPEP_HideFieldIndices = false //Hide the field ID and Tab numbers // [Get|Set]XXXParameter //General const cAPEP_FieldAppendOn = true //Put field in next column to right const cAPEP_FieldAppendOff = false //Put field in next row down const cAPEP_FieldIndexSep = "." //Field label format Index separator const cAPEP_FieldTabSep = ":" //Field label format Tab separator //String const cAPEP_StringMultilineOn = true const cAPEP_StringMultilineOff = false //Choice const cAPEP_ChoiceDisablePrefix = "!" //PopUp, ListChoice const cAPEP_ListSortedOff = false //Display list in 'loaded' order const cAPEP_ListSortedOn = true //Display list in alpha sorted order const cAPEP_ListMaxVisibleDef = 6 //Default number of list entries visible const cAPEP_DblClickOn = true //Allow double-click = OK const cAPEP_DblClickOff = false //Disable double-click = OK //CheckList const cAPEP_CheckListBoxOn = 1 const cAPEP_CheckListBoxOff = 0 //Caption const cAPEP_CaptionGreyOff = false const cAPEP_CaptionGreyOn = true const cAPEP_CaptionBoldOff = false const cAPEP_CaptionBoldOn = true const cAPEP_CaptionItalicOff = false const cAPEP_CaptionItalicOn = true const cAPEP_CaptionSmallOff = false const cAPEP_CaptionSmallOn = true const cAPEP_CaptionFullWidthOff = false const cAPEP_CaptionFullWidthOn = true const cAPEP_CaptionLineDefault = 1 // 2.3.68 Object Type Methods // There are no declarations for these methods as the values returned may change in future releases of AP. //.................................................................................................................................. // 2.4 APPlanObject (APO) //.................................................................................................................................. //Altitude (in degrees) const cAPO_MinAltitude = 0.0 const cAPO_MaxAltitude = 90.0 //Apparent Magnitude const cAPO_ApparentMagnitudeError = 99.0 //Object is below the horizon //Azimuth (in degrees) const cAPO_MinAzimuth = 0.0 const cAPO_MaxAzimuth = 360.0 //Dec (in degrees) const cAPO_MinDec = -90.0 const cAPO_MaxDec = 90.0 //Difficulty Index const cAPO_MinDifficultyIndex = 0.0 const cAPO_MaxDifficultyIndex = 100.0 //Extinction const cAPO_ExtinctionError = 99.0 //ForceHighlight const cAPO_ObjectHighlightOn = true const cAPO_ObjectHighlightOff = false //HourAngle const cAPO_MinHourAngle = -12.0 const cAPO_MaxHourAngle = 12.0 //IsHighlighted const cAPO_ObjectHighlightedOn = true const cAPO_ObjectHighlightedOff = false //IsVisible const cAPO_ObjectVisibleOn = true const cAPO_ObjectVisibleOff = false //Magnitude const cAPO_MinMagnitude = -30.0 const cAPO_MaxMagnitude = 30.0 const cAPO_DefMagnitude = 9.0 //Default object magnitude (I like this value - so there) const cAPO_MagnitudeError = 99.0 //or greater indicate a possible error condition //nObservations, nObs const cAPO_MinObservations = 1 const cAPO_MinGlobalObservations = 1 //PosAngle const cAPO_MinPosAngle = 0 const cAPO_MaxPosAngle = 360 //RA const cAPO_MinRA = 0.0 const cAPO_MaxRA = 23.99999 //Rise const cAPO_MinRise = 0.0 const cAPO_MaxRise = 23.9999 const cAPO_CircumpolarRise = -1 const cAPO_NeverRise = -2 //Selected const cAPO_ObjectSelectedOn = true //Object selected const cAPO_ObjectSelectedOff = false //Object not selected //Set const cAPO_MinSet = 0.0 const cAPO_MaxSet = 23.9999 const cAPO_CircumpolarSet = -1 const cAPO_NeverSet = -2 //Transit const cAPO_MinTransit = 0.0 const cAPO_MaxTransit = 23.9999 //NewObservation const cAPO_NoDateTime = 0.0 //.................................................................................................................................. // 2.5 APObservation (APOB) //.................................................................................................................................. //DateTime const cAPOB_NoDateTime = 0.0 //Same as NewObservation? (see 2.4) //IsAAVSO const cAPOB_IsAAVSOOn = true const cAPOB_IsAAVSOOff = false //.................................................................................................................................. // 2.6 APAAVSO (APA) //.................................................................................................................................. //MagDecPt const cAPA_MagDecPt1 = 1 const cAPA_MagDecPt2 = 2 const cAPA_MagDecPt3 = 3 //FainterThen const cAPA_FainterThanOn = true const cAPA_FainterThanOff = false //Uncertain const cAPA_UncertainOn = true const cAPA_UncertainOff = false //StepMagnitude const cAPA_StepMagnitudeOn = true const cAPA_StepMagnitudeOff = false //DoAirMass const cAPA_DoAirMassOn = true const cAPA_DoAirMassOff = false //ComputeAirMass const cAPA_ComputeAirMassOn = true const cAPA_ComputeAirMassOff = false //DoError const cAPA_DoErrorOn = true const cAPA_DoErrorOff = false //.................................................................................................................................. // 2.7 APCatalogObject (APCO) //.................................................................................................................................. //ID const cAPCO_MinID = 1 const cAPCO_NoID = "" //GetTypes //Need to play around with this to see if there is anything worth adding //.................................................................................................................................. // 2.8 APCatalog (APC) //.................................................................................................................................. //GetObject const cAPC_GetObjectMin = 1 const cAPC_GetObjectNone = nil //.................................................................................................................................. // 2.9 APTextFile (APTF) //.................................................................................................................................. //EOF const cAPTF_EOFYes = true //File is at EOF const cAPTF_EOFNo = false //File is not at EOF //ReadLine, ReadAll const cAPTF_ReadError = "" //Returned if ReadLine failed for some reason (e.g. File is not open) //.................................................................................................................................. // 2.10 APSearch (APS) //.................................................................................................................................. //See section 2.10.1 for an extenisive list of constants //MaxResults const cAPS_MaxResultsDef = 100 //Default maximum results //.................................................................................................................................. // 2.11 Canvas (APCV) //.................................................................................................................................. //Canvas Constructor const cAPCV_PageSetupOn = true //Call the page setup dialogue const cAPCV_PageSetupOff = false //Do not call the page setup dialogue //.................................................................................................................................. // 2.11.4 CanvasFOV (APCF) //.................................................................................................................................. //DrawFOV const cAPCF_BlackOnWhite = true //Do blank on white display const cAPCF_WhiteOnBlack = false //Do white on black display //FOVsize const cAPCF_FOVSizeMin = 0.1 const cAPCF_FOVSizeMax = 60.0 //FOVOption const cAPCF_FOVOptionOn = true const cAPCF_FOVOptionOff = false const cAPCF_FOVOptionAltAzRotation = "Alt/Az Rotation" const cAPCF_FOVOptionCustomReticles = "Custom Reticles" const cAPCF_FOVOptionConstellations = "Constellations" const cAPCF_FOVOptionExtMagRange = "Extended Magnitude Range" const cAPCF_FOVOptionFlipHorizontal = "Flip Horizontal" const cAPCF_FOVOptionFlipVertical = "Flip Vertical" //FOVCatalogue const cAPCF_NoCatalog = "" //Perform operation on all catalogues const cAPCF_CatalogOn = true //Select catalogue const cAPCF_CatalogOff = false //Deselect catalogue const cAPCF_CatalogLabelOn = true //Select catalogue labels const cAPCF_CatalogLabelOff = false //Deselect catalogue labels //FOVStarLimits const cAPCF_StarLimitMin = 0.0 //Minimum magnitude limit const cAPCF_StarLimitMax = 12.0 //Maximum magnitude limit const cAPCF_StarLimitExt = 30.0 //Extended magnitude limit //FOVApeture const cAPCF_FOVApetureOn = true //Draw the FOV circle and crosshair const cAPCF_FOVApetureOff = false //Do not draw the FOV circle and crosshair //SkyOption const cAPCF_OptionStateOn = true //Select the required option const cAPCF_OptionStateOff = false //Deselect the required option //Text constants for the options have not been added. //These options may change in future versions of AP. //I might just add these if I really feel the need!!! //DrawImage const cAPCF_TitleOn = true const cAPCF_TitleOff = false const cAPCF_InvertedOn = true const cAPCF_InvertedOff = false const cAPCF_GreyScaleOn = true const cAPCF_GreyScaleOff = false const cAPCF_ScaledOn = true const cAPCF_ScaledOff = false //IsUserImage const cAPCF_UserImage = true const cAPCF_DSSImage = false //.................................................................................................................................. // 2.11.5 Creating and drawing tables (APCT) //.................................................................................................................................. //DrawTable (These constants already exist, without the prefix of course) const cAPCT_GridNone = 0 const cAPCT_GridThin = 1 const cAPCT_GridThick = 2 //.................................................................................................................................. // 2.12 Table (APT) //.................................................................................................................................. //LoadFromText //const cAPT_DelimeterDef = chr(9) //REALbasic does not allow this - darn it!!! const cAPT_DelimiterDef = 9 //Default delimiter is Tab const cAPT_HasTitlesYes = true const cAPT_HasTitlesNo = false // 2.12.14 Formatting a table // This section details a bunch of formatting constants. // Not much point replicating them here. //.................................................................................................................................. // 2.13 Resources (APR) //.................................................................................................................................. const cAPR_SiteResourceMin = 1 const cAPR_SiteResourceNone = nil const cAPR_TelescopeResourceMin = 1 const cAPR_TelescopeResourceNone = nil const cAPR_EyepieceResourceMin = 1 const cAPR_EyepieceResourceNone = nil const cAPR_VisualAidResourceMin = 1 const cAPR_VisualAidResourceNone = nil //SiteResource, TelescopeResource, EyepieceResource //These can be used as general replacements for the equivalent declarations given below const cAPR_DefaultResourceYes = true const cAPR_DefaultResourceNo = false //.................................................................................................................................. // 2.13.2 SiteResource (APSR) //.................................................................................................................................. const cAPSR_DefaultSiteYes = true const cAPSR_DefaultSiteNo = false const cAPSR_USDSTYes = true const cAPSR_USDSTNo = false const cAPSR_EUDSTYes = true const cAPSR_EUDSTNo = false //.................................................................................................................................. // 2.13.3 TelescopeResource (APTR) //.................................................................................................................................. const cAPTR_DefaultTelescopeYes = true const cAPTR_DefaultTelescopeNo = false const cAPTR_IsTelescopeYes = true const cAPTR_IsTelescopeNo = false const cAPTR_IsBinocularYes = true const cAPTR_IsBinocularNo = false const cAPTR_FlipFinderHorizontalYes = true const cAPTR_FlipFinderHorizontalNo = false const cAPTR_FlipFinderVerticalYes = true const cAPTR_FlipFinderVerticalNo = false //.................................................................................................................................. // 2.13.4 EyepieceResource (APER) //.................................................................................................................................. const cAPER_DefaultEyepieceYes = true const cAPER_DefaultEyepieceNo = false //.................................................................................................................................. // 2.13.5 VisualAidResource (APVR) //.................................................................................................................................. const cAPVR_InvertsHorizontallyYes = true const cAPVR_InvertsHorizontallyNo = false const cAPVR_InvertsVerticallyYes = true const cAPVR_InvertsVerticallyNo = false //.................................................................................................................................. // 2.14 Serial port support (APSP) //.................................................................................................................................. const cAPSP_SerialPort1 = 1 const cAPSP_SerialPort2 = 2 const cAPSP_SerialPort3 = 3 const cAPSP_SerialPort4 = 4 //APSerialPort const cAPSP_BitRateDefault = 9600 const cAPSP_DataBitsDefault = 8 const cAPSP_StopBitsDefault = 1 const cAPSP_ParityEven = "Even" const cAPSP_ParityOdd = "Odd" const cAPSP_ParityNone = "None" const cAPSP_ParityDefault = "None" const cAPSP_FlowControlReset = "" const cAPSP_FlowControlOff = "" const cAPSP_FlowControlXON = "XON" const cAPSP_FlowControlCTS = "CTS" const cAPSP_FlowControlDTS = "DTS" const cAPSP_FlowControlDefault = "" const cAPSP_ReceiveDefault = "" const cAPSP_ReceiveTimeoutDefault = 5 //----- Library Script: lib_ASCII //################################################################################################################################## // Name : ASCII // Purpose : Standard library of ASCII constants // Requires: AP v1.5.1b3 or later // Author : Robin Lauryssen-Mitchell // Date : 05th September 2006 // Version : 1.0 // Status : Production // History : 0.1 - Initial 'in-house' release // 1.0 - First public release // Notes : This is a 'library' file. It is not intended to be run as a script, but to be 'linked' to other scripts. //################################################################################################################################## //================================================================================================================================== // Declarations //================================================================================================================================== //Non-printable const cNUL = 0 //Null const cSOH = 1 //Start of heading const cSTX = 2 //Start of text const cETX = 3 //End of text const cEOT = 4 //End of transmission const cENQ = 5 //Enquiry const cACK = 6 //Acknowledge const cBEL = 7 //Bell const cBS = 8 //Backspace const cHT = 9 //Horizontal tab const cLF = 10 //Line feed const cVT = 11 //Vertical tab const cFF = 12 //Form feed const cCR = 13 //Carriage return const cSO = 14 //Shift out const cSI = 15 //Shift in const cDLE = 16 //Data link escape const cDC1 = 17 //Device control 1 const cDC2 = 18 //Device control 2 const cDC3 = 19 //Device control 3 const cDC4 = 20 //Device control 4 const cNAK = 21 //Negative acknowledgement const cSYN = 22 //Synchronous idle const cETB = 23 //End of transmission block const cCAN = 24 //Cancel const cEM = 25 //End of medium const cSUB = 26 //Substitute const cESC = 27 //Escape const cFS = 28 //File separator const cGS = 29 //Group separator const cRS = 30 //Record separator const cUS = 31 //Unit separator const cDEL = 127 //Delete //Printable non-alphanumeric const cSpace = " " //32 const cBang = "!" //33 const cDblQuote = """" //34 const cHash = "#" //35 const cDollar = "$" //36 const cPercent = "%" //37 const cAmpersand = "&" //38 const cSngQuote = "'" //39 const cOpenBracket = "(" //40 const cCloseBracket = ")" //41 const cMult = "*" //42 const cPlus = "+" //43 const cComma = "," //44 const cMinus = "-" //45 const cPoint = "." //46 const cDivide = "/" //47 const cColon = ":" //58 const cSemicolon = ";" //59 const cLT = "<" //60 const cEqual = "=" //61 const cGT = ">" //62 const cQuery = "?" //63 const cAT = "@" //64 const cOpenSquare = "[" //91 const cSlash = "\" //92 const cCloseSquare = "]" //93 const cCaret = "^" //94 const cUnderscore = "_" //95 const cAccent = "`" //96 const cOpenBrace = "{" //123 const cBar = "|" //124 const cCloseBrace = "}" //125 const cTilde = "~" //126 ??? //Misc const cMinASCII = 0 //Lower character limit const cMaxASCII = 127 //Standard ASCII upper character limit const cExtASCII = 255 //Extended ASCII upper character limit //----- Library Script: lib_RPEHLM_Declarations //################################################################################################################################## // Name : RPEHLM_Declarations // Purpose: Standard library of declarations to support RPEHLM authored scripts //################################################################################################################################## //================================================================================================================================== // Declarations //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Constant declarations //---------------------------------------------------------------------------------------------------------------------------------- //Scratch Plan const cScratchPlan = "_RPEHLM.apd" //Temporary data holding plan const cRPEHLMPlanPrefix = "_RPEHLM" //ALL RPEHLM temporary plans will have this prefix (usually ignored by ChoosePlan) const cScratchCleanOn = true //Erase contents of temp plan const cScratchCleanOff = false //Do not erase contents of temp plan //Object copy operation flags (Might be AP_Declaration material) const cObjNoCopy = -1 //No list to be processed flag const cObjCopyAll = 0 //Process all plan objects const cObjCopyHighlighted = 1 //Process only highlighted plan objects const cObjCopySelected = 2 //Process only selected plan object //Misc. constants const cBaseIndex = 0 //Counting base, normally used with arrays const cDelim = "," //General string delimeter const cNewline = 13 //Newline chr, normally used with dialogues (no longer needed really) //File constants const cEmptyFilePath = "" //Nul file path const cWinPathSeparator = "\" //Windows file path separator //Message constants const cMsgUserCancelled = "INFO: User cancelled" const cMsgScriptComplete = "INFO: Script completed" const cMsgScriptException = "ERROR: An exception occurred!" const cMsgNoObjectSelected = "ERROR: No object selected" //Boolean constants const cFlagOff = False //Boolean off flag const cFlagOn = True //Boolean on flag const cTrueText = "True" //True text const cFalseText = "False" //False text //---------------------------------------------------------------------------------------------------------------------------------- //Script Save/Restore labels // Declared here because I may wish to use the same labels in other scripts // Combined with the SaveRestoreTag function this can be used to ensure global use of SaveRestore labels //---------------------------------------------------------------------------------------------------------------------------------- //SaveRestoreTag const cSaveRestoreTag = "RLM" //Used to enable common Save/Restore labels across multiple plans //Used by SimbadQuery const cSearchArea = "RLM_SearchArea" //Search area (object only, area around, wildcard, catalogue) const cSearchBib = "RLM_SearchBib" //Search bibliography const cSearchRadius = "RLM_SearchRadius" //Search radius const cSearchRadiusType = "RLM_SearchRadiusType" //Search radius type (deg, arcmin, arcsec) const cSearchType = "RLM_SearchType" //Search type (Selected Name, All Names, RA/Dec) //---------------------------------------------------------------------------------------------------------------------------------- // Dim declarations //---------------------------------------------------------------------------------------------------------------------------------- //General purpose dim CancelFlag as boolean = cAPGP_CancelledNo //Process cancel flag (normally user clicking a dialogue Cancel button) dim Index as integer = cBaseIndex //Loop counter (normally used to index arrays) //Plans dim MainPlanID as integer = cAPGP_NoPlan //ID of the main working plan dim MainPlanName as string = cEmptyFilePath //Name of the main working plan dim ScratchPlanID as integer = cAPGP_NoPlan //ID used for temporary data holding plan (usually _RPEHLM_Blank.apd) //----- End of included Library Scripts //================================================================================================================================== // Declarations //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Const declarations //---------------------------------------------------------------------------------------------------------------------------------- //Debugging stuff const TESTSCRIPT = false //True if script is being tested (no need for scope to be connected) const EXPOSURECORRECTION = 1 //Temp fix for suspected 'out-by-one' error in Delay //Application const cMajorVersion = "1" const cMinorVersion = "3" //Misc. stuff const cBaseIndex = 0 //Used for things like array and loop counting const cDelim = "," //General string delimeter const cModifierKey = 42 // '\' const cNoSelectedObject = -1 //No selected object in current plan //Default application values const cDefExpTime = 10.0 //Default image exposure time (seconds) const cDefExpRepeat = 1 //Default exposure repeat count const cDefSlewTime = 60.0 //Default scope slewing time (seconds) const cDefScopeDelay = 5 //Default wait time before processing further commands (seconds) const cDefCamDelay = 5 //Default wait time before processing further commands (seconds) const cDefScopeName = "SerialPort" //Default scope name (espically if ASCOM flag is false) //ShootList window columns const cSLID = 1 //Object ID const cSLRA = 2 //Object RA const cSLDec = 3 //Object Dec const cSLExp = 4 //Exposure duration const cSLRepeat = 5 //Exposure repeat count const cSLdRA = 6 //Object RA (decimal) const cSLdDec = 7 //Object Dec (decimal) //Console list window columns const cConID = 1 //Object ID const cConScope = 2 //Scope status const cConCam = 3 //Camera status const cConRepeat = 4 //Exposure repeat const cConTime = 5 //Exposure times (local) //Application 'run' modes (see AppStateType) const cAppSimpleMode = 0 //Simple mode (no dialogue box) const cAppDialogMode = 1 //Display dialogue mode //-------------------------------------- //Application data Save & Restore labels //-------------------------------------- //SaveRestoreTag const cSaveRestoreTag = "RLM" //Used to enable common Save/Restore labels across multiple plans //This stuff is used to save/restore the DSLRShoot configuration using the current plan const cSR_SortFlag = "RLM_DSLRS_Sort" const cSR_CamPort = "RLM_DSLRS_CamPort" const cSR_ExpFlag = "RLM_DSLRS_ExpFlag" const cSR_ExpTime = "RLM_DSLRS_ExpTime" const cSR_ExpRepeat = "RLM_DSLRS_ExpRepeat" const cSR_ObsFlag = "RLM_DSLRS_ObsFlag" const cSR_ObsTimeFlag = "RLM_DSLRS_ObsTimeFlag" const cSR_SlewTime = "RLM_DSLRS_SlewTime" const cSR_ScopeDelay = "RLM_DSLRS_ScopeDelay" const cSR_CameraDelay = "RLM_DSLRS_CameraDelay" const cSR_MSSMethod = "RLM_DSLRS_MSSMethod" const cSR_MSSWeight = "RLM_DSLRS_MSSWeight" const cSR_ScopeFlag = "RLM_DSLRS_ScopeFlag" const cSR_ScopeName = "RLM_DSLRS_ScopeName" const cSR_BleepFlag = "RLM_DSLRS_Bleep" const cSR_SaveFlag = "RLM_DSLRS_Save" //Application state Save & Restore labels const cSR_SplashFlag = "RLM_DSLRS_SplashFlag" //---------------------------------------------------------------------------------------------------------------------------------- // Class declarations //---------------------------------------------------------------------------------------------------------------------------------- class AppStateType dim DoIt as boolean //Do some processing flag (often returned from a sub or function) dim ExitFlag as boolean //Application exit state (T=exit, F=keep running) dim SplashFlag as boolean //Splash display flag dim ErrNum as integer //General purpose error number (0=OK) dim ErrText as string //General purpose error text end class class AppDataType dim ObjList as integer //Which 'list' of objects to process (0=None, 1=Highlighted, 2=Selected) dim SortFlag as boolean //Do minimum slew sort (only with >3 highlighted objects) dim CamPort as integer //Camera com port dim ExpFlag as boolean //Flag to set ExpTime for all images dim ExpTime as double //Common exposure time for all images dim ExpRepeat as integer //Exposure repeat count dim ObsFlag as boolean //Create observation record for each image dim ObsTimeFlag as integer //Record start, mid or end of exposure time dim ObsNote as string //Observation note dim SlewTime as double //Timeout for scope slewing dim ScopeDelay as double //Delay after scope slew (and before image exposure) dim CameraDelay as double //Delay after image exposure dim MSSMethod as integer //MinimumSlewSort method flag dim MSSWeight as integer //MinimumSlewSort weight flag dim ScopeFlag as boolean //Scope driver selection (T=Ascom, F=AP) dim ScopeName as string //Ascom selected telescope dim BleepFlag as boolean //Make a noise when done dim SaveFlag as boolean //Save plan at sequence end end class //---------------------------------------------------------------------------------------------------------------------------------- // Var declarations //---------------------------------------------------------------------------------------------------------------------------------- dim Ascom as OLEObject //ASCOM object dim AppState as AppStateType //Application state (supposed to be) dim AppData as AppDataType //Application data //================================================================================================================================== // Subs and Functions //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- //Name : IconApp //Purpose : Initialise data structures used by this script //Requires: None //Returns : None //Notes : None //---------------------------------------------------------------------------------------------------------------------------------- sub IconApp() dim KeyState as boolean //Get key-modifier state as early in the code as possible (helps avoid user confusion) KeyState = KeyDown(cModifierKey) //Initialise Application Type structures AppState = new AppStateType AppData = new AppDataType //Initialise with data stored from last use of dialogue mode (or defaults) SaveRestoreTag(cSaveRestoreTag) //Setup SaveRestoreTag to use RLM Library Tags AppState = RestoreAppState() AppData = RestoreAppData() //Icon application state AppState.DoIt = cFlagOff AppState.ExitFlag = cFlagOff //Don't exit the application //Initialise Ascom object Ascom = new OLEObject("DriverHelper.Chooser") end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : Splash //Purpose : Display a splash screen at application start //Requires: - //Returns : CancelFlag //Notes : None //---------------------------------------------------------------------------------------------------------------------------------- function Splash() as boolean const cAppTitle = "DSLRShoot" const cAppBlurb = "Image selected plan objects" const cAppBlurbLines = 2 const cDialogueTitle = "Splash" //Dialogue box labels const cHideSplashLabel = "Hide splash?" const cMinimizeLabel = "Minimize AP?" dim CancelFlag as boolean //Build the splash dialogue if AppState.SplashFlag = cFlagOn then //Display application title and blurb SetCaptionParameter(cAPEP_FieldAppendOff, cAppTitle + " v" + cMajorVersion + "." + cMinorVersion, cAPEP_CaptionLineDefault, _ cAPEP_CaptionGreyOff, cAPEP_CaptionBoldOn, cAPEP_CaptionItalicOff, cAPEP_CaptionSmallOff, _ cAPEP_CaptionFullWidthOn) SetCaptionParameter(cAPEP_FieldAppendOff, cAppBlurb, cAppBlurbLines, _ cAPEP_CaptionGreyOff, cAPEP_CaptionBoldOff, cAPEP_CaptionItalicOff, cAPEP_CaptionSmallOff, _ cAPEP_CaptionFullWidthOn) //Display dialogue? SetBooleanParameter (cAPEP_FieldAppendOff, cHideSplashLabel, cFlagOff) //Hide splash? if Platform() = platform_Windows then //Windows only option SetBooleanParameter (cAPEP_FieldAppendOff, cMinimizeLabel, cFlagOff) end if //Find out what the user did if EditParameters (cDialogueTitle, cAPEP_ShowFieldIndices) then if GetBooleanParameter(cMinimizeLabel) then MinimizeMainWindow() end if AppState.SplashFlag = not(GetBooleanParameter(cHideSplashLabel)) CancelFlag = cAPGP_CancelledNo else //User clicked Cancel button CancelFlag = cAPGP_CancelledYes end if else CancelFlag = cAPGP_CancelledNo //Splash wasn't displayed so user couldn't click cancel - could they!!! end if return CancelFlag end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : DoDialogMode // Purpose: Choose an object list to process (must have a selected plan) // Returns: None //---------------------------------------------------------------------------------------------------------------------------------- sub DoDialogMode () //Local declarations const cMinSortObjects = 3 //Minimum # objects for which Slew sorting makes sense const cObsTimeStamps = "Start,Middle,End" //Observation time stamp dim MinSortFlag as boolean = false //Enough objects to make MinimumSlewSorting worthwhile? dim ObjList as integer //Which list of objects to process dim DialogTitle as string //Title to add to dialogue box //Dialog box labels const cCamPortLabel = "Camera port" const cExpFlagLabel = "Exposure for all objects" const cExpTimeLabel = "(seconds)" const cExpRepeatLabel = "Repeat exposure" const cObsFlagLabel = "Create observations" const cObsTimeLabel = "Observation time" const cObsNoteLabel = "Observation note" const cSlewTimeLabel = "Slew timeout (secs)" const cScopeDelayLabel = "Scope settle time (secs)" const cCameraDelayLabel = "Camera delay time (secs)" const cMSSLabel = "Do minimum slew sort" const cMSSMethodLabel = "MSS Method" const cMSSWeightLabel = "MSS Weight" const cScopeFlagLabel = "Change scope driver?" //Display labels dim MSS_Method(-1) as string dim MSS_Weight(-1) as string //Misc. labels const cBleepLabel = "Bleep" const cDialogTitle = "Session Setup: " const cMiscLabel = "Misc. settings:" const cSaveLabel = "Save plan" //Setup the dialogue AppData = RestoreAppData() //Recover default field data MSS_Method = split("Default,RADec,AltAz", cDelim) MSS_Weight = split("None,Low,High", cDelim) if ChooseTargetList(ObjList) then print cMsgNoObjectSelected //exit else AppData.ObjList = ObjList //Camera port SetPopupParameter (cAPEP_FieldAppendOff, cCamPortLabel, AppData.CamPort, SerialPortNames()) //Scope selection stuff SetBooleanParameter(cAPEP_FieldAppendOff, cScopeFlagLabel, AppData.ScopeFlag) SetCaptionParameter(cAPEP_FieldAppendOff, "Selected Scope: " + AppData.ScopeName, 1, False, True, False, False, True) //***Setup application fields here MinSortFlag = false select case AppData.ObjList case cObjCopyAll if nObjects >= cMinSortObjects then MinSortFlag = true DialogTitle = "All "+str(nObj)+" objects" case cObjCopyHighlighted if nHighlighted >= cMinSortObjects then MinSortFlag = true DialogTitle = "All "+str(nHighlighted)+" highlighted objects" case cObjCopySelected MinSortFlag = false DialogTitle = Obj(SelectedObject).ID case else MinSortFlag = false DialogTitle = "" end select //if (nHighlighted >= cMinSortObjects) and (AppData.ObjList = cObjCopyHighlighted) then if MinSortFlag then SetBooleanParameter(cAPEP_FieldAppendOff, cMSSLabel, AppData.SortFlag) SetPopupParameter (cAPEP_FieldAppendOff, cMSSMethodLabel, AppData.MSSMethod, MSS_Method) SetPopupParameter (cAPEP_FieldAppendOff, cMSSWeightLabel, AppData.MSSWeight, MSS_Weight) ParameterDependency(cMSSMethodLabel, cMSSLabel) ParameterDependency(cMSSWeightLabel, cMSSLabel) end if //Exposure data SetBooleanParameter(cAPEP_FieldAppendOff, cExpFlagLabel, AppData.ExpFlag) SetDoubleParameter (cAPEP_FieldAppendOff, cExpTimeLabel, AppData.ExpTime) SetIntegerParameter(cAPEP_FieldAppendOff, cExpRepeatLabel, AppData.ExpRepeat) ParameterDependency(cExpTimeLabel, cExpFlagLabel) ParameterDependency(cExpRepeatLabel, cExpFlagLabel) //Observation records SetBooleanParameter(cAPEP_FieldAppendOff, cObsFlagLabel, AppData.ObsFlag) SetChoiceParameter(cAPEP_FieldAppendOff, cObsTimeLabel, AppData.ObsTimeFlag, split(cObsTimeStamps, cDelim)) SetStringParameter (cAPEP_FieldAppendOff, cObsNoteLabel, AppData.ObsNote, true) ParameterDependency(cObsTimeLabel, cObsFlagLabel) ParameterDependency(cObsNoteLabel, cObsFlagLabel) //Timeouts (mount and camera) SetDoubleParameter(cAPEP_FieldAppendOff, cSlewTimeLabel, AppData.SlewTime, 0) SetDoubleParameter(cAPEP_FieldAppendOff, cScopeDelayLabel, AppData.ScopeDelay, 0) SetDoubleParameter(cAPEP_FieldAppendOff, cCameraDelayLabel, AppData.CameraDelay, 0) //Misc. SetCaptionParameter(cAPEP_FieldAppendOff, cMiscLabel, 1, False, True, False, False, True) SetBooleanParameter(cAPEP_FieldAppendOff, cBleepLabel, AppData.BleepFlag) SetBooleanParameter(cAPEP_FieldAppendOff, cSaveLabel, AppData.SaveFlag) //Show the dialogue if EditParameters (cDialogTitle+DialogTitle) then //Retrieve field data and store in AppData.[key] //if (nHighlighted >= cMinSortObjects) and (AppData.ObjList = cObjCopyHighlighted) then if MinSortFlag then AppData.SortFlag = GetBooleanParameter(cMSSLabel) AppData.MSSMethod = GetPopupParameter (cMSSMethodLabel) AppData.MSSWeight = GetPopupParameter (cMSSWeightLabel) else AppData.SortFlag = false AppData.MSSMethod = 0 AppData.MSSWeight = 0 end if AppData.CamPort = GetPopupParameter (cCamPortLabel) AppData.ExpFlag = GetBooleanParameter(cExpFlagLabel) AppData.ExpTime = GetDoubleParameter (cExpTimeLabel) AppData.ExpRepeat = GetIntegerParameter(cExpRepeatLabel) AppData.ObsFlag = GetBooleanParameter(cObsFlagLabel) AppData.ObsTimeFlag = GetChoiceParameter (cObsTimeLabel) AppData.ObsNote = GetStringParameter (cObsNoteLabel) AppData.SlewTime = GetDoubleParameter (cSlewTimeLabel) AppData.ScopeDelay = GetDoubleParameter (cScopeDelayLabel) AppData.CameraDelay = GetDoubleParameter (cCameraDelayLabel) AppData.ScopeFlag = GetBooleanParameter(cScopeFlagLabel) //Retrieve misc. data AppData.BleepFlag = GetBooleanParameter(cBleepLabel) AppData.SaveFlag = GetBooleanParameter(cSaveLabel) if AppData.ScopeFlag then Ascom.Value("DeviceType") = "sTelescope" AppData.ScopeName = mid(Ascom.Invoke("Choose", "s"+AppData.ScopeName), 2) if AppData.ScopeName = "" then AppData.ScopeName = cDefScopeName AppData.ScopeFlag = false end if end if SaveAppData(AppData) //Save values for use as defaults next time around AppState.DoIt = cFlagOn else //User clicked Cancel button AppState.DoIt = cFlagOff //so don't "doit" AppState.ExitFlag = cFlagOn //and exit the application (after cleaning up) end if end if end sub //---------------------------------------------------------------------------------------------------------------------------------- // Name : ChooseTargetList // Purpose: Choose an object list to process (must have a selected plan) // Returns: ListID - Type of object list selected (-1=No list selected, 0=entire list, 1=highlighted only, 2=selected only) // CancelFlag - True=User cancelled, False=List selected //---------------------------------------------------------------------------------------------------------------------------------- function ChooseTargetList (byref ListID as integer) as boolean const cDialogTitle = "Current plan: " const cTargetLabel = "Target list?" dim multi(-1) as string //Choice text //dim ErrorText as string //Error message to be displayed dim OptionSelect as string CancelFlag = cAPGP_CancelledNo //Initialise the Cancel flag //Build the choice strings multi.append "All "+str(nObj)+" objects" //The complete plan object list OptionSelect = "0" if nHighlighted > cAPGP_NoObject then multi.append str(nHighlighted)+" highlighted objects only" //Only the highlighted objects OptionSelect = OptionSelect + "1" end if if SelectedObject > cAPGP_NoObject then multi.append "Selected object only ("+Obj(SelectedObject).ID+")" //Only the selected objects OptionSelect = OptionSelect + "2" end if SetChoiceParameter(cAPEP_FieldAppendOff, cTargetLabel, ListID, multi) //Setup the dialogue //Show the Target List selection dialogue MainPlanName = GetPlanName(CurrentPlanNumber) if EditParameters (cDialogTitle + MainPlanName) then ListID = val(mid(OptionSelect, GetChoiceParameter(cTargetLabel)+1, 1)) select case ListID case cObjCopyAll //Process all objects if nObj = cAPGP_NoObject then //...if the plan has any ListID = cObjNoCopy //ErrorText = "ERROR: Plan contains no objects" end if case cObjCopyHighlighted //Process highlighted objects if nHighlighted = cAPGP_NoObject then //...if there are any ListID = cObjNoCopy //ErrorText = "ERROR: No highlighted object/s" end if case cObjCopySelected //Process the selected object if SelectedObject < cAPGP_MinObject then //...if there is one ListID = cObjNoCopy //ErrorText = "ERROR: No selected object" end if end select else //User clicked Cancel button ListID = cObjNoCopy CancelFlag = cAPGP_CancelledYes //ErrorText = cMsgUserCancelled end if return CancelFlag end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : GetComNames // Purpose: Return an array of com port names // Returns: Array of string containg the com port names //---------------------------------------------------------------------------------------------------------------------------------- function SerialPortNames() as string() dim Names(-1) as string for Index = 1 to nSerialPorts Names.Append SerialPort(Index).Name next return Names end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : GetExposureTime // Purpose: Get exposure time from user // Returns: Boolean flag (true=cancelled, false=ok) //---------------------------------------------------------------------------------------------------------------------------------- function GetExposureTime(Name as string, byref Exposure as double, byref Repeat as integer) as boolean //Local declarations const cDialogTitle = "Object: " const cExposureLabel = "Exposure (secs)" const cRepeatLabel = "Exposure repeat" SetDoubleParameter (cAPEP_FieldAppendOff, cExposureLabel, AppData.ExpTime) SetIntegerParameter(cAPEP_FieldAppendOff, cRepeatLabel, AppData.ExpRepeat) if EditParameters (cDialogTitle+Name) then Exposure = GetDoubleParameter (cExposureLabel) Repeat = GetIntegerParameter(cRepeatLabel) CancelFlag = cFlagOff else //User clicked Cancel button Exposure = cDefExpTime Repeat = cDefExpRepeat CancelFlag = cFlagOn end if return CancelFlag end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : CopyAlltoLW //Purpose : Copy plan objects to shoot-list window //Requires: //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub CopyAlltoLW (List as ListWindow) dim ListIndex as double dim ExpTime as double dim ExpRepeat as integer //Prep locals ListIndex = 1 ExpTime = AppData.ExpTime for Index = 1 to nObjects //copy object to list List.Cell(ListIndex, cSLID) = Obj(Index).ID List.Cell(ListIndex, cSLRA, "RA") = Obj(Index).RA List.Cell(ListIndex, cSLDec, "Dec") = Obj(Index).Dec if not(AppData.ExpFlag) then //Get exposure time for this object if GetExposureTime(Obj(Index).ID, ExpTime, ExpRepeat) then exit //ABORT THE LOOP!!! end if end if List.Cell(ListIndex, cSLExp, "-00.00") = ExpTime List.Cell(ListIndex, cSLRepeat, "00") = ExpRepeat ListIndex = ListIndex + 1 next List.Refresh end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : CopyHighlightedtoLW //Purpose : Copy plan highlighted objects to shoot-list window //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub CopyHighlightedtoLW (List as ListWindow) dim ListIndex as double = 1 dim ExpTime as double dim ExpRepeat as integer dim LWobj(-1) as APPlanObject //Prep locals ExpTime = AppData.ExpTime ExpRepeat = AppData.ExpRepeat redim LWobj(nHighlighted) LWobj() = HighlightedObjects() if AppData.SortFlag then MinimumSlewSort(LWobj(), AppData.MSSMethod, AppData.MSSWeight) end if for Index = 0 to ubound(LWObj()) //copy object to list List.Cell(ListIndex, cSLID) = LWObj(Index).ID List.Cell(ListIndex, cSLRA, "RA") = LWObj(Index).RA List.Cell(ListIndex, cSLDec, "Dec") = LWObj(Index).Dec List.Cell(ListIndex, cSLdRA, "-0.000000") = LWObj(Index).RA List.Cell(ListIndex, cSLdDec, "-0.000000") = LWObj(Index).Dec if not(AppData.ExpFlag) then //Get exposure time for this object if GetExposureTime(LWObj(Index).ID, ExpTime, ExpRepeat) then exit //ABORT THE LOOP!!! end if end if List.Cell(ListIndex, cSLExp, "-00.00") = ExpTime List.Cell(ListIndex, cSLRepeat, "00") = ExpRepeat ListIndex = ListIndex + 1 next List.Refresh end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : CopySelectedtoLW //Purpose : Copy plan selected object to shoot-list window //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub CopySelectedToLW (List as ListWindow, LWObject as APPlanObject) const cListIndex = 1 dim ExpTime as double dim ExpRepeat as integer ExpTime = AppData.ExpTime ExpRepeat = AppData.ExpRepeat List.Cell(cListIndex, cSLID) = LWObject.ID List.Cell(cListIndex, cSLRA, "RA") = LWObject.RA List.Cell(cListIndex, cSLDec, "Dec") = LWObject.Dec List.Cell(cListIndex, cSLdRA, "-0.000000") = LWObject.RA List.Cell(cListIndex, cSLdDec, "-0.000000") = LWObject.Dec if not(AppData.ExpFlag) then //Get exposure time for this object if GetExposureTime(LWObject.ID, ExpTime, ExpRepeat) then //Delete list entry? List.Clear end if end if if List.Rows > 0 then List.Cell(cListIndex, cSLExp, "-00.00") = ExpTime List.Cell(cListIndex, cSLRepeat, "00") = ExpRepeat end if List.Refresh end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : DelayAlt //Purpose : Alternate Delay //Requires: Seconds - double: Duration of wait // Caption - string: Optional text for progress bar //Returns : - //Notes : If Caption is blank or not present no progress bar is displayed //---------------------------------------------------------------------------------------------------------------------------------- sub DelayAlt(Seconds as double, Caption as string = "") dim StartTime as double dim Elapsed as double if Caption<>"" then StartProgress(Caption, false, Seconds) StartTime = Microseconds do Elapsed = (MicroSeconds-StartTime)*1E-6 if Caption<>"" then call UpdateProgress(Elapsed) //if KeyDown(32) then debug "KeyDown" Yield loop until Elapsed >= Seconds if Caption<>"" then StopProgress end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : WaitForScope //Purpose : Wait for scope to slew and settle //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- function WaitForScope (TimeOut as double, Delay as double, byref AppState as AppStateType) as boolean const cSlewOK = 0 const cSlewTimeout = -1 const cSlewAbort = -2 const cSlewUnknown = -3 const cSlewDone = "Done" const cTimeOutText = "TimeOut" const cAbortText = "Aborted" const cUnknownText = "Unknown" const cDelayText = "Settling scope..." dim SlewStatus as integer = cSlewOK dim StartTime as double dim Elapsed as double if AppData.ScopeName = cDefScopeName then SlewStatus = SlewWait(TimeOut) else //TODO: ASCOM Telescope.Slewing StartProgress("Slewing ...", false, TimeOut) StartTime = Microseconds SlewStatus = cSlewTimeout do Elapsed = (MicroSeconds-StartTime)*1E-6 call UpdateProgress(Elapsed) if Ascom.Value("Slewing")="b0" then SlewStatus = cSlewOK exit end if Yield loop until Elapsed >= TimeOut StopProgress end if select case SlewStatus //SlewWait(TimeOut) case cSlewOK AppState.ErrNum = cSlewOK AppState.ErrText = cSlewDone if Delay > 0 then //Do scope delay DelayAlt(Delay, cDelayText) end if case cSlewTimeout AppState.ErrNum = cSlewTimeout AppState.ErrText = cTimeOutText case cSlewAbort AppState.ErrNum = cSlewAbort AppState.ErrText = cAbortText else AppState.ErrNum = cSlewUnknown AppState.ErrText = cUnknownText end select return AppState.ErrNum = cSlewOK end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : DoCamera //Purpose : Connect to camera and operate shutter //Requires: CameraPort, ExposureTime and SettleTime //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub DoCamera (CamPort as integer, ExposureTime as double, SettleTime as double, byref StartTime as double) dim port as APSerialPort port=SerialPort(CamPort+1) port.BitRate=9600 // 9,600 bps (default) port.DataBits=8 // 8 databits (default) port.StopBits=1 // 1 stopbit (default) port.Parity="None" // No parity bit (default) port.FlowControl="" // Hardware flow control off port.RequestToSend=false port.Open port.RequestToSend=true StartTime = CurrentDate() DelayAlt(ExposureTime+EXPOSURECORRECTION, "Exposing...") port.RequestToSend=false port.Close DelayAlt(SettleTime, "Camera settling...") end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : NewConsole //Purpose : Modify a line in the 'console' ListWindow //Requires: Headings - Column headings as delimited string // Sep - Separator used in Headings //Returns : ListWindow object //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- function NewConsole (Headings as string, Sep as string) as ListWindow dim lw as ListWindow dim Header(-1) as string dim Index as integer Header = split(Headings, Sep) lw = new ListWindow(Header(0)) for Index = 1 to ubound(Header) lw.Heading(Index, 1) = Header(Index) next lw.Refresh return lw end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : ConsoleUpdate //Purpose : Modify a line in the 'console' ListWindow //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub ConsoleUpdate (Console as ListWindow, Line as integer, LineContent as string, Sep as string) dim Col(-1) as string dim Index as integer Col = split(LineContent, Sep) for Index = 0 to ubound(Col) if Col(Index) > "" then Console.Cell(Line, Index+1) = Col(Index) end if next Console.Cell(Line, cConTime) = DoubleToTime(CurrentDate(),true) Console.Refresh end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : ObservationUpdate //Purpose : Add an observation record to the plan object being imaged //Requires: ID - plan object name // StartTime - start time of the exposure // Exposure - exposure duration //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub ObservationUpdate (ID as string, StartTime as double, Exposure as double) dim pObject as APPlanObject dim pObservation as APObservation dim ObsTime as double pObject = FindObject(ID) if pObject <> Nil then select case AppData.ObsTimeFlag case 0 //Exposure start time ObsTime = StartTime case 1 //Exposure mid-point time ObsTime = StartTime + (Exposure / 2.0) case 2 //Exposure end time ObsTime = StartTime + Exposure case else //Something went wrong!!! ObsTime = 0.0 end select pObservation = pObject.NewObservation(StartTime) if pObservation <> Nil then pObservation.Notes = AppData.ObsNote end if end if end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : SlewScope //Purpose : Move the scope to given RA,Dec coordinates using either ASCOM or serial port //Requires: RA and Dec //Returns : Integer: Error code (0=OK) //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- function SlewScope (RA as string, Dec as string) as integer dim Result as integer = 0 if AppData.ScopeName = cDefScopeName then Result = SlewTo(val(RA), val(Dec)) else if Ascom.Value("CanSlewAsync")="b1" then call Ascom.Invoke("SlewToCoordinatesAsync", "d"+format(val(RA),"0.000000"), "d"+format(val(Dec), "-0.000000")) else call Ascom.Invoke("SlewToCoordinates", "d"+format(val(RA),"0.000000"), "d"+format(val(Dec), "-0.000000")) end if if Ascom.LastError <> "" then Result = -1 end if return Result end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : ShootTheList //Purpose : Process the shoot list (move scope, take image) //Requires: ListWindow (ShootList) //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub ShootTheList(ShootList as ListWindow) dim Console as ListWindow //Shoot-list progress window dim ExpDuration as double //Exposure duration dim ExpRepeat as integer //Exposure repeat counter dim StartTime as double //Date/Time exposure started //Set up shoot-list progress monitor Console = NewConsole ("Console|ID|Scope|Camera|Repeat|Time", "|") //Process the shoot-list for Index = 1 to ShootList.Rows ConsoleUpdate(Console, Index, ShootList.Cell(Index, cConID), "|") ExpDuration = val(ShootList.Cell(Index, cSLExp)) if ExpDuration > 0 then //If we have valid exposure time ... ConsoleUpdate(Console, Index, "|Slewing|Waiting", "|") //if (SlewTo(val(ShootList.Cell(Index,2)), val(ShootList.Cell(Index,3))) = 0) or TESTSCRIPT then //... slew the scope ... if SlewScope (ShootList.Cell(Index,cSLdRA), ShootList.Cell(Index,cSLdDec)) = 0 then if WaitForScope(AppData.SlewTime, AppData.ScopeDelay, AppState) then //... wait for scope to slew and settle ... ConsoleUpdate(Console, Index, "|Done|Exposing", "|") for ExpRepeat = 1 to val(ShootList.Cell(Index, cSLRepeat)) ConsoleUpdate(Console, Index, "|||"+str(ExpRepeat)+"/"+ShootList.Cell(Index, cSLRepeat), "|") DoCamera(AppData.CamPort, ExpDuration, AppData.CameraDelay, StartTime) //... do the imaging if AppData.ObsFlag then ObservationUpdate(ShootList.Cell(Index,1), StartTime, ExpDuration) next ConsoleUpdate(Console, Index, "||Done", "|") else //Scope did not reach target object ConsoleUpdate(Console, Index, "|"+AppState.ErrText+"|Not done", "|") end if else //Scope did not start slew ConsoleUpdate(Console, Index, "|SlewTo failed|Not done", "|") end if else //Exposure time = 0 so skip the entry ConsoleUpdate(Console, Index, "|Skipped|Skipped", "|") end if next end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : DoApp //Purpose : Main application routine //Requires: AppData - contains all the application data, either default or user-defined //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub DoApp (AppData as AppDataType) //Local declarations //dim DoIt as boolean dim lw as ListWindow Ascom = new OLEObject(AppData.ScopeName, true) Ascom.Value("Connected")="b1" if Ascom.LastError <> "" then print "ASCOM Error: " + Ascom.LastError return end if if Ascom.Value("CanSlewAsync")="b0" and Ascom.Value("Canslew")="b0" then print "ASCOM Error: Scope cannot slew" return end if if Ascom.Value("CanPark")="b1" then call Ascom.Invoke("UnPark") if Ascom.LastError <> "" then print "ASCOM Error: " + Ascom.LastError return end if if Ascom.Value("CanSetTracking")="b1" then Ascom.Value("Tracking")="b1" if Ascom.LastError <> "" then print "ASCOM Error: " + Ascom.LastError return end if //Setup the list window lw = new ListWindow("Imaging List") // The parameter is optional lw.Heading(cSLID, 1) = "ID" lw.Heading(cSLRA, 2) = "RA" lw.Heading(cSLDec, 2) = "Dec" lw.Heading(cSLExp, 2) = "Exp" lw.Heading(cSLRepeat, 2) = "Rpt" lw.Heading(cSLdRA, 2) = "dRA" lw.Heading(cSLdDec, 2) = "dDec" select case AppData.ObjList case cObjCopyAll // All objects CopyAlltoLW(lw) case cObjCopyHighlighted // Highlighted objects CopyHighlightedtoLW(lw) case cObjCopySelected // Selected CopySelectedToLW(lw, Obj(SelectedObject)) end select if lw.Rows > 0 then if YesNo ("Shoot object list?"+EndOfLine+str(lw.Rows)+" to shoot", false) then ShootTheList(lw) if AppData.SaveFlag then SavePlan() else //Debug "Abort" end if else //Nothing to shoot? end if end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : RestoreAppData //Purpose : Retrive saved values stored in the Plan file //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- function RestoreAppData () as AppDataType dim RestoreData as AppDataType RestoreData = new AppDataType //Application data RestoreData.SortFlag = RestoreBooleanValue (cSR_SortFlag, cFlagOff) RestoreData.CamPort = RestoreIntegerValue (cSR_CamPort, 0) RestoreData.ExpFlag = RestoreBooleanValue (cSR_ExpFlag, cFlagOff) RestoreData.ExpTime = RestoreDoubleValue (cSR_ExpTime, cDefExpTime) RestoreData.ExpRepeat = RestoreDoubleValue (cSR_ExpRepeat, cDefExpRepeat) RestoreData.ObsFlag = RestoreBooleanValue (cSR_ObsFlag, false) RestoreData.ObsTimeFlag = RestoreIntegerValue (cSR_ObsTimeFlag, 0) RestoreData.SlewTime = RestoreDoubleValue (cSR_SlewTime, cDefSlewTime) RestoreData.ScopeDelay = RestoreDoubleValue (cSR_ScopeDelay, cDefScopeDelay) RestoreData.CameraDelay = RestoreDoubleValue (cSR_CameraDelay, cDefCamDelay) 'RestoreData.ScopeFlag = RestoreBooleanValue (cSR_ScopeFlag, false) RestoreData.ScopeName = RestoreStringValue (cSR_ScopeName, cDefScopeName) RestoreData.MSSMethod = RestoreIntegerValue (cSR_MSSMethod, 0) RestoreData.MSSWeight = RestoreIntegerValue (cSR_MSSWeight, 0) //Misc. RestoreData.BleepFlag = RestoreBooleanValue(cSR_BleepFlag, cFlagOff) RestoreData.SaveFlag = RestoreBooleanValue(cSR_SaveFlag, cFlagOff) return RestoreData end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : SaveAppData //Purpose : Save values to the Plan file //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub SaveAppData (SaveData as AppDataType) //Application data SaveBooleanValue (cSR_SortFlag, SaveData.SortFlag) SaveIntegerValue (cSR_CamPort, SaveData.CamPort) SaveBooleanValue (cSR_ExpFlag, SaveData.ExpFlag) SaveDoubleValue (cSR_ExpTime, SaveData.ExpTime) SaveIntegerValue (cSR_ExpRepeat, SaveData.ExpRepeat) SaveBooleanValue (cSR_ObsFlag, SaveData.ObsFlag) SaveIntegerValue (cSR_ObsTimeFlag, SaveData.ObsTimeFlag) SaveDoubleValue (cSR_SlewTime, SaveData.SlewTime) SaveDoubleValue (cSR_ScopeDelay, SaveData.ScopeDelay) SaveDoubleValue (cSR_CameraDelay, SaveData.CameraDelay) 'SaveBooleanValue (cSR_ScopeFlag, SaveData.ScopeFlag) SaveStringValue (cSR_ScopeName, SaveData.ScopeName) SaveIntegerValue (cSR_MSSMethod, SaveData.MSSMethod) SaveIntegerValue (cSR_MSSWeight, SaveData.MSSWeight) //Misc. SaveBooleanValue (cSR_BleepFlag, SaveData.BleepFlag) SaveBooleanValue (cSR_SaveFlag, SaveData.SaveFlag) end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : RestoreAppState //Purpose : Retrive saved application state values stored in the Plan file //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- function RestoreAppState () as AppStateType dim RestoreState as AppStateType RestoreState = new AppStateType //Application state RestoreState.SplashFlag = RestoreBooleanValue(cSR_SplashFlag, cFlagOn) return RestoreState end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : SaveAppState //Purpose : Save application state values to the Plan file //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub SaveAppState (SaveState as AppStateType) //Application data SaveBooleanValue(cSR_SplashFlag, SaveState.SplashFlag) end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : TerminateApp //Purpose : Gracefully close the script //Requires: Message - Text to display to the user at close-out //Returns : None //Notes : None //---------------------------------------------------------------------------------------------------------------------------------- sub TerminateApp(Message as string) SaveAppState(AppState) //Stash application state for next time if AppData.ScopeName <> cDefScopeName then Ascom.Value("Connected")="b0" Ascom = NIL end if if Message > "" then print Message end if if MainWindowStatus() = cAPGM_MainWindowMinimized then RestoreMainWindow() end if end sub //================================================================================================================================== // Main Code //================================================================================================================================== //dim WhichList as integer IconApp() if Splash() then TerminateApp(cMsgUserCancelled) else DoDialogMode() if AppState.DoIt then DoApp (AppData) end if end if TerminateApp(cMsgScriptComplete)