temma logo

cocoaTemma AppleScripts

Kok Chen [w7ay (at) arrl (dot) net]
Last updated: November 27, 2006


Introduction

cocoaTemma has AppleScript support for a separate application to control a Takahashi telescope without having to incorporate cocoaTemma's code into that application.

From the Script Editor, you access cocoaTemma the usual way, i.e.,


tell application “cocoaTemma”
end tell


A boolean ready allows you to check if cocoaTemma has finished initializations of its objects and is ready to accept commands. For example, a script can do the following to wait until cocoaTemma is ready:


tell application “cocoaTemma”
repeat
if ready then exit repeat
delay 1
end repeat
end tell


cocoaTemma has another boolean connected for checking if the app is already connect to a telescope.

Setting connected to true will attempt to open the most recently opened serial port and connect to a Temma controller. You need to run cocoaTemma at least once before and have made a manual (non-AppleScript) connection. That would have saved the name of your serial port in your plist file. For system security reasons, cocoaTemma does not allow you to connect to an arbitrary serial port that is not in your plist.

The latitude and longitude of the telescope is also assumed to have been previously set and saved in the plist file.

Setting connected to false will close a connection.

The following is an example of checking connection before actually asking cocoaTemma to connect to the telescope.


tell application “cocoaTemma”
repeat
if ready then exit repeat
delay 1
end repeat
if not connected then
set connected to true
repeat
if connected then exit repeat
delay 1
end repeat
end if
-- connection sequence should be done at this point.
if connected then
-- perform telescope operations here...
end if
end tell


To test an AppleScript connection without a telescope connected, you can use connectToEmulator to connect to the built-in emulator in cocoaTemma, instead of using the set connected command to connect to a real telescope, e.g.,


tell application “cocoaTemma”
repeat
if ready then exit repeat
delay 1
end repeat
if not connected then
connectToEmulator
repeat
if connected then exit repeat
delay 1
end repeat
end if
-- connection sequence should be done at this point.
if connected then
-- perform emulator operations here...
end if
end tell


Once connected, you can start sending commands and reading status from cocoaTemma.

otaSide is a boolean for the current location of the OTA relative to the polar axis. A true value is West and a false value indicates East. For example, the following checks which side the OTA is, and if it is on the East, sets it to the West:


if not otaSide then
set otaSide to true
end if


syncToZenith will command cocoaTemma to send a zenith sync command to the Temma controller.


syncToZenith


syncToLocation will command cocoaTemma to send a sync command to the Temma controller with the current (see below) AppleScript coordinates.


syncToLocation


syncToLocation will return a false if for some reason (e.g., coordinates are blow the horizon) it failed to sync.

The AppleScript portion of cocoaTemma maintains its own private coordinates. The Remote tab in cocoaTemma's Main window displays the "current" Remote location. Note that, just like the coordinates for stars and Deep Sky objects, the location indicated by the remote coordinates is not the location the telescope is pointed at, until you ask the telescope to perform a goto action.

remote

Just like the coordinates from stars and other objects, cocoaTemma computes if the current location is above the horizon.

fetchLocation will read the telescope's current location and store it into the Remote coordinates.

You can read and set the Remote coordinates by going through the following integer variables

raHours
raMinutes
rsSeconds
decSign
decDegrees
decMinutes
decSeconds

Right Ascension is in hours, minutes and seconds of time and Declination is in degrees, arc minutes and arc seconds. The Declination's sign is carried separately in the decSign variable (+1 for positive Declinations and -1 for negative Declinations).

For example, you can set the RA of the Remote coordinates by


set raHours to 12
set raMinutes to 34
set raSeconds to 56



The boolean aboveHorizon indicates if the Remote coordinates is above the horizon.

Finally, you can use the current Remote coordinates to sync the telescope or to perform a goto by using the following two commands

syncToLocation
gotoLocation

Both of these commands will return a true if the command was successfully executed, or a false if it is not (for example if the coordinates are below the horizon, or an attempt to perform a goto when the telescope has been paused).

The following with sync the scope to zenith (i.e., assume that the OTA is poined to zenith) and then set Vega's position and attempt to slew to it.


syncToZenith
set raHours to 18
set raMinutes to 36
set raSeconds to 56
set decSign to 1
set decDegrees to 38
set decMinutes to 47
set decSeconds to 3
if gotoLocation then
say "telescope is now pointed at Vega"
end if