Author Topic: SkyRoof Tips  (Read 3954 times)

Wes

  • Low Earth orbit
  • Administrator
  • Newbie
  • *****
  • Posts: 12
    • View Profile
    • astrobytes
SkyRoof Tips
« on: January 11, 2015, 01:19:28 PM »
 You can add custom scripts to SkyRoof to control various operations of your observatory. Scripts that are set to run when the roof "Open" command is issued will run as soon as the "Open" button is clicked while scripts that are set to run when the roof "Close" button is clicked will run before the roof closes. The roof will not close until the roof closure script has completed. This can be beneficial to users to park mounts that are not ASCOM compliant or for custom control of other devices. The following sample scripts are shown as examples of the type of operations that scripting can perform with SkyRoof. Remember that no matter how the roof is controlled, there must be a means to park the telescope before the roof can close. This can be done by either connecting to the mount through the ASCOM interface in the SkyRoof program or through a custom script that is run when the roof "Close" command is issued.


'************************************Start up Script--runs when roof is opened******************************

Set myCamera = CreateObject("MaxIm.CCDCamera") 'The camera and guide camera object
Set myActiveHome = CreateObject("x10.ActiveHome") 'The X-10 object for controlling X-10 power modules
Set myScope = CreateObject("POTH.Telescope") 'The telescope hub object
Set MyMaximScope = CreateObject("Maxim.Application") 'Maxim Telescope Object
Set WshShell = WScript.CreateObject("WScript.Shell") 'Shell object to execute other applications
Set Speech = CreateObject("SAPI.SpVoice") 'Speech API Object
Set FSO = CreateObject("Scripting.FileSystemObject") 'Scripting Object

'*******************************************Speech Subroutines****************************************

Dim sText 'Set the variable sText
Sub Talk 'Speech subroutine 1 invokes subroutine 2   
       SpeakText sText
End Sub

Sub SpeakText(sText) 'Speech subroutine 2
   On Error Resume Next
   Speech.Speak sText, SVSFlagsAsync + SVSFPurgeBeforeSpeak
   Do
      Sleep 100
   Loop Until Speech.WaitUntilDone(10)
End Sub

'*******************************************Script Starts Here********************************************

sText="Initializing observatory systems"
Talk
wscript.Sleep 500
sText="Powering mount on"
Talk
myActiveHome.SendAction "sendplc", "a3,on" 'Turn mount on
wscript.Sleep 4000
sText="Observatory lamp on"
Talk
myActiveHome.SendAction "sendplc", "a1,on" 'Turn observatory light On
wscript.Sleep 4000
sText="Radio on"
Talk
myActiveHome.SendAction "sendplc", "a8,on" 'Turn radio On
wscript.Sleep 4000
sText="Scope fans on"
Talk
myActiveHome.SendAction "sendplc", "a6,on" 'Turn scope fans on
wscript.Sleep 4000
sText="Focuser on"
Talk
myActiveHome.SendAction "sendplc", "a5,on" 'Turn Optec focuser on
wscript.Sleep 4000
sText="Camera on"
Talk
myActiveHome.SendAction "sendplc", "a4,on" 'Turn Camera on
wscript.Sleep 4000
sText="Guide camera on"
Talk
myActiveHome.SendAction "sendplc", "a7,on" 'Turn Guide camera on
wscript.Sleep 10000 ' 31 seconds mount boot up time

sText="Initializing mount"
Talk
If myScope.Connected = False Then 'Connect to scope through POTH
myScope.Connected = True
End If
wscript.Sleep 20000 'wait for POTH to set Autostar2 date and time 24 seconds

sText="Linking to cameras"
Talk
myCamera.DisableAutoShutdown = True 'Keep camera from unlinking automatically
myCamera.LinkEnabled = True 'Connect to camera in Maxim

wscript.Sleep 4000
sText="Camera cooler on"
Talk
myCamera.CoolerOn = True

wscript.Sleep 4000
sText="Linking computer to mount"
Talk
MyMaximScope.LockApp = True
wscript.Sleep 3000
If MyMaximScope.TelescopeConnected = False Then 'Connect telescope to Maxim
MyMaximScope.TelescopeConnected = True
End If
wscript.Sleep 3000
WshShell.Exec "C:\Users\Public\Documents\Setup Files\GPS2.exe "
wscript.Sleep 2000
myActiveHome.SendAction "sendplc", "k1,off" 'Turn dew lamp off
myActiveHome.SendAction "sendplc", "a1,off" 'Turn observatory light Off
sText="Observatory start up complete"
Talk





'*******************************Shut Down Script--runs when roof closure is issued before roof closes*************************

' The first 4 lines initialize the OLE objects

Set myCamera = CreateObject("MaxIm.CCDCamera")       'The CCD camera object (and guider) in Maxim
Set myActiveHome = CreateObject("x10.ActiveHome")    'The X-10 object
Set myScope = CreateObject("POTH.Telescope")         'The telescope hub object ASCOM POTH
Set myMaximScope = CreateObject("Maxim.Application") 'Maxim Telescope Object
Set Speech = CreateObject("SAPI.SpVoice")
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim sText

Sub Talk       
       SpeakText sText
End Sub

Sub SpeakText(sText)
   On Error Resume Next
   Speech.Speak sText, SVSFlagsAsync + SVSFPurgeBeforeSpeak
   Do
      Sleep 100
   Loop Until Speech.WaitUntilDone(10)
End Sub
'****************************Script starts here****************************************

myCamera.LinkEnabled() = True    'Link CCD camera to Maxim

sText="Initializing observatory shutdown"
Talk

myActiveHome.SendAction "sendplc", "a6,off"    'Turn Scope Fans off
wscript.Sleep 3000

myActiveHome.SendAction "sendplc", "a1,on"    'Turn observatory light on
wscript.Sleep 3000

sText="Halting guider"
Talk
If myCamera.LinkEnabled Then
myCamera.GuiderStop()        'Stop the guider
wscript.Sleep 5000           'wait 5 seconds
sText="Camera cooler off"
Talk
myCamera.CoolerOn = False    'Turn the cooler off
End If

wscript.Sleep 3000

sText="Unlinking cameras"
Talk
If myCamera.LinkEnabled Then
MyCamera.LinkEnabled = False    'Disconnect the camera from Maxim (if connected)
End If

wscript.Sleep 3000

sText="Unlinking mount"
Talk
If myMaximScope.TelescopeConnected = True Then    'Disconnect telescope from Maxim (if connected)
myMaximScope.TelescopeConnected = False
End If

wscript.Sleep 3000

sText="parking telescope, please wait"
Talk
If myscope.Connected Then
myscope.Park()    'Park the telescope using ASCOM POTH
End If

wscript.Sleep 60000 'wait for scope to park

sText="telescope parked"
Talk
wscript.Sleep 1000

sText="Powering systems down"
Talk
myActiveHome.SendAction "sendplc", "a5,off"    'Turn Focuser off
wscript.Sleep 3000
myActiveHome.SendAction "sendplc", "a7,off"    'Turn Guide Camera off
wscript.Sleep 3000
myActiveHome.SendAction "sendplc", "a3,off"    'Turn Mount off
wscript.Sleep 3000

myMaximScope.LockApp = False
wscript.Sleep 2000
myScope.Connected = False    'Disconnect the scope from ASCOM POTH
sText="waiting for roof closure"
Talk
Set myCamera = Nothing
Set MyMaximScope = Nothing
Set MyScope = Nothing
wscript.Sleep 180000
myActiveHome.SendAction "sendplc", "a4,off"    'Turn Camera off
wscript.Sleep 3000
myActiveHome.SendAction "sendplc", "k1,on"     'Turn Dew Lamp on
wscript.Sleep 3000   
myActiveHome.SendAction "sendplc", "a1,off"    'Turn Observatory Lamp off
wscript.Sleep 1000
myActiveHome.SendAction "sendplc", "a8,off" 'Turn radio Off
sText="shutdown routine complete, good night"
Talk
« Last Edit: April 08, 2015, 03:41:36 PM by Wes »