Running JavaScript Scripts

JavaScript can be used to access TheSky’s extensive automation model to give almost unlimited possibilities for controlling TheSky to accomplish almost any task. 

 

For example, one of the JavaScripts included with TheSky is named MessierMarathon.js.  When run, this relatively simple script automatically slews to each Messier object in the list and takes a photo.  As described in the script’s comments, the script can be adapted to use any list of objects you like.

To view this sample script, click Tools > Run JavaScript, then click the Open button.  Select MessierMarathon.js and click Open.

 

Text Description automatically generated

Figure 162: Example Messier Marathon JavaScript.

 

The Script window shows a series of command buttons at the top, an editable multi-line text box beneath, and a read-only Script Output text box that shows the results of the last script run. 

Open a JavaScript (Open button)

Click the Open button to view scripts that are located in TheSky’s Resources/Common/User/Java Scripts folder.

Save a JavaScript (Save button)

Click the Save button to save the current script.

Save JavaScript Under a New Name (Save As)

Click the Save As button to save the current script with a different name.

Create a New Script (New button)

Click the New button to clear the existing script text and create a new script.  Click Yes when prompted to confirm that you really want to erase the current script text.

Run the Script (Run button)

Click the Run button to execute the current script.

Turn on Debugging (Enable Debugger Checkbox)

Turn this checkbox on to enable the JavaScript debugger.  The debugger can be used to step through your script to isolate errors and appears automatically when an execution exception in the script is encountered.

 

Graphical user interface Description automatically generated

Figure 163: The Script Debugger listing an error in a script (see red text).

Clear the Script Output (Clear button)

Click the Clear button at the bottom of the Script window to remove Script Output text.

TheSky Scripting URL

Click this URL to visit the Software Bisque web page that contains TheSky’s scripting documentation.  The URL is:

 

https://www.bisque.com/wp-content/scriptthesky

 

JavaScript Debugger

The Script Debugger window contains standard controls for debugging source code. 

Debugger Tool Bar

The tool bar (by default at the top of the Script Debugger window), provides commands used to start, stop, step through, run to the cursor, or find text the script’s source code.

Loaded Scripts

This window shows the path to the currently running script.

Breakpoints

This window lists the lines in the script where a break point has been defined and execution is stopped here.

 

·       Click the New graphic to create a new break point.

·       Click the Delete graphic to remove an existing break point.

Stack window

This window lists the current source code stack information.

Locals window

This window lists the local variables in the scripts and their current values.

Console Tab

Shows the debugger messages.

Debug Output Tab

Shows output from debugger messages in the source code.

Error Log Tab

Shows a time stamped event log while the script is run.

 

Sample Java Scripts

The table below lists the JavaScripts that are included with TheSky.  Refer to the comments in each script for additional information.

 

JavaScript Name (.js)

Description

Actions

Manipulate the Sky Chart using TheSky’s Actions.

AtFocus3

Run @Focus3 from a script.

AutomatedImageLinkSettings

Access the current automated Image Link settings.

Camera

For daytime testing, this script simulates photo acquisition by connecting to the current camera and acquires the photos from Digitized Sky Survey rather than a photo of the actual sky.  

CameraDependentSettings

Produces a list of camera-dependent settings.

ClickFind

Simulates a mouse click at a given pixel position on the Sky Chart (100, 100) and outputs that object(s) located nearby.

ClosedLoopSlew

Performs a closed loop slew to an object (the planet Uranus by default).

DomeGetAzEl

Retrieves the azimuth and elevation of the dome’s slit.

FilterFocusOffset

Determines the focus position offset for each filters in a filter wheel.

Find

Finds an object by name (the planet Saturn by default) and lists the object’s properties.

GetTargetRA

Retrieves and displays a target object’s right ascension coordinates (the planet Venus by default).

GetTargetRA2

Retrieves and displays a target object’s right ascension coordinates (the planet Venus by default) indirectly by calling a function named targetRADec(targetName).

ImageLink

Given the path to a FITS file on the local computer, performs an ImageLink and lists the resulting ImageLink properties.

MessierMarathon

Slew to and photograph every object in the Messier Catalog.

MountBPT

Determine if the mount is beyond the pole.

MountFindHome

Issues a Find Home command to the mount.

MountGetRADec

Retrieves the RA and Dec of the mount.

MountGoto

Slews the mount based on an input RA and Dec.

MountIsSlewing

Reports if the mount is currently slewing.

MountStartOpenLoopMove

Performs an open-loop move in an input direction and slew rate.

MountTrackingOff

Sets the mounts RA tracking rate to 0.

Park

Parks the mount using TheSky’s telescope parking implementation.

PowerControl

Turns the remote power switches power on or off.

RunQuery

Runs an Advanced Database Query.

SetImageLinkToUseAllSky

Configures Image Link to use the All Sky Image Link database.

ShowInventory

Provides the list of light sources detected in a FITs photo.

SlewDomeToTelescope

Keeps the dome aligned with the position of the telescope.

TextFileExample

Demonstrates how to access information in a text file from a JavaScript.

TheSky

 

TheSkyXGrabScreen

Captures the current TheSky window.

TheSkyXMisc

Demonstrates how to call many of TheSky miscellaneous methods and properties.

UnguidedDitherOSC

Performs dithering while taking unguided photos.

UnguideDitherWFilters

Performs dithering while taking unguided photos and changes the filters in the filter wheel.