Hello Robin,
Thanks for the information.
Concerning the function list ... OK, I will in future ask you "How to do this ? Which function can be used ?"
Concerning the "script source sharing library" ...
I write a small script for performing a simple GOTO of the mount. I do some experiment and it was necessary to start from a defined position.
Here a script in 2 versions.
- one version usable from the Python console
- one version generating a SharpCap menu (a link has to be inserted in the "SharpCap Settings"-"Startup Scripts")
The script send a GOTO command with RA and DEC coordinates. The user is responsable to give RA and DEC values that not produce a collision.
The mount driver is responsable for any displacement of the mount.
Code: Select all
# *******************************************************************************************
#
# SharpCap script "Test_GOTO.py"
# 2020/08/30 Jean-Francois Pittet
# Version: 1.0
#
# The telescope has to be connected before use of the script and the tracking mode has to be
# activated.
#
# 1. Decimal input: RA limits [0 .. 24]
# DEC limits [-90 .. 90]
# Values outside these limits produce an error
#
# 2. deg/min/sec input: RA ... negative values produce an error
# DEC ... negative values of min and sec are ignored
# Values outside these limits produce an error
#
# *******************************************************************************************
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
clr.AddReference("ASCOM.DriverAccess")
from math import copysign
from System.Windows.Forms import Application, Button, CheckBox, Form, Label, Panel, RadioButton, TextBox
from System.Drawing import Point
from ASCOM.DriverAccess import *
class ChecksAndRadiosForm(Form):
def __init__(self):
self.Text = "Slew the mount to the RA and DEC position"
self.Width = 450
self.Height = 200
self.setupCheckButtons()
self.setupRadioButtons()
def setupCheckButtons(self):
self.label_RA = Label()
self.label_RA.Text = "RA [0.0 ... 24.0]:" # The input values are tested automatically
self.label_RA.Location = Point(25, 50)
self.label_RA.Height = 25
self.label_RA.Width = 100
self.label_DEC = Label()
self.label_DEC.Text = "DEC [-90 ... 90]:" # The input values are tested automatically
self.label_DEC.Location = Point(25, 75)
self.label_DEC.Height = 25
self.label_DEC.Width = 100
self.textbox_RA = TextBox()
self.textbox_RA.Text = ""
self.textbox_RA.Location = Point(125, 45)
self.textbox_RA.Width = 80
self.textbox_DEC = TextBox()
self.textbox_DEC.Text = ""
self.textbox_DEC.Location = Point(125, 70)
self.textbox_DEC.Width = 80
self.textbox_RA_std = TextBox()
self.textbox_RA_min = TextBox()
self.textbox_RA_sec = TextBox()
self.textbox_RA_std.Text = "0"
self.textbox_RA_min.Text = "0"
self.textbox_RA_sec.Text = "0"
self.textbox_RA_std.Location = Point(230, 45)
self.textbox_RA_min.Location = Point(260, 45)
self.textbox_RA_sec.Location = Point(290, 45)
self.textbox_RA_std.Width = 25
self.textbox_RA_min.Width = 25
self.textbox_RA_sec.Width = 40
self.textbox_RA_std.Enabled = False
self.textbox_RA_min.Enabled = False
self.textbox_RA_sec.Enabled = False
self.textbox_DEC_deg = TextBox()
self.textbox_DEC_min = TextBox()
self.textbox_DEC_sec = TextBox()
self.textbox_DEC_deg.Text = "0"
self.textbox_DEC_min.Text = "0"
self.textbox_DEC_sec.Text = "0"
self.textbox_DEC_deg.Location = Point(230, 70)
self.textbox_DEC_min.Location = Point(260, 70)
self.textbox_DEC_sec.Location = Point(290, 70)
self.textbox_DEC_deg.Width = 25
self.textbox_DEC_min.Width = 25
self.textbox_DEC_sec.Width = 40
self.textbox_DEC_deg.Enabled = False
self.textbox_DEC_min.Enabled = False
self.textbox_DEC_sec.Enabled = False
self.button_GOTO = Button()
self.button_GOTO.Text = 'GOTO'
self.button_GOTO.Location = Point(25, 125)
self.button_GOTO.Click += self.goto
self.button_Exit = Button()
self.button_Exit.Text = 'Exit'
self.button_Exit.Location = Point(125, 125)
self.button_Exit.Click += self.exit
self.AcceptButton = self.button_GOTO
self.CancelButton = self.button_Exit
self.Controls.Add(self.label_RA)
self.Controls.Add(self.label_DEC)
self.Controls.Add(self.textbox_RA)
self.Controls.Add(self.textbox_DEC)
self.Controls.Add(self.textbox_RA_std)
self.Controls.Add(self.textbox_RA_min)
self.Controls.Add(self.textbox_RA_sec)
self.Controls.Add(self.textbox_DEC_deg)
self.Controls.Add(self.textbox_DEC_min)
self.Controls.Add(self.textbox_DEC_sec)
self.Controls.Add(self.button_GOTO)
self.Controls.Add(self.button_Exit)
def setupRadioButtons(self):
self.radio1 = RadioButton()
self.radio1.Text = "xx.xxx (deg)"
self.radio1.Location = Point(120, 10)
self.radio1.Checked = True
self.radio1.CheckedChanged += self.checkedChanged
self.radio2 = RadioButton()
self.radio2.Text = "xx (deg) yy (min) zz.zz (sec)"
self.radio2.AutoSize = True
self.radio2.Location = Point(230, 11)
self.radio2.CheckedChanged += self.checkedChanged
self.Controls.Add(self.radio1)
self.Controls.Add(self.radio2)
def checkedChanged(self, sender, args):
if not sender.Checked:
return
if self.radio1.Checked == True:
self.textbox_RA.Enabled = True
self.textbox_DEC.Enabled = True
self.textbox_RA_std.Enabled = False
self.textbox_RA_min.Enabled = False
self.textbox_RA_sec.Enabled = False
self.textbox_DEC_deg.Enabled = False
self.textbox_DEC_min.Enabled = False
self.textbox_DEC_sec.Enabled = False
else:
self.textbox_RA.Enabled = False
self.textbox_DEC.Enabled = False
self.textbox_RA_std.Enabled = True
self.textbox_RA_min.Enabled = True
self.textbox_RA_sec.Enabled = True
self.textbox_DEC_deg.Enabled = True
self.textbox_DEC_min.Enabled = True
self.textbox_DEC_sec.Enabled = True
def goto(self, sender, event):
t = Telescope("ASCOM.Simulator.Telescope")
if self.radio1.Checked == True:
RA = float(self.textbox_RA.Text)
DEC = float(self.textbox_DEC.Text)
else:
RA = float(self.textbox_RA_min.Text) / 60.0 + float(self.textbox_RA_sec.Text) / 3600.0
RA = RA + float(self.textbox_RA_std.Text)
DEC = abs(float(self.textbox_DEC_min.Text)) / 60.0 + abs(float(self.textbox_DEC_sec.Text)) / 3600.0
DEC = DEC + abs(float(self.textbox_DEC_deg.Text))
DEC = DEC * copysign(1, float(self.textbox_DEC_deg.Text))
print("GOTO to RA position : %f" % (RA))
print("GOTO to DEC position: %f" % (DEC))
print
t.SlewToCoordinates(RA, DEC)
def exit(self, sender, event):
print("Stop GOTO script")
self.Close()
form = ChecksAndRadiosForm()
Application.Run(form)
And ...
Code: Select all
# *******************************************************************************************
#
# SharpCap script "Test_GOTO_menu.py"
# 2020/08/30 Jean-Francois Pittet
# Version: 1.0
#
# This script is to be placed in the list of the Startup script list:
# Menu "File", "SharpCap Settings", "Startup Scripts"
# The menu "GOTO" appears on the SharpCap window.
#
# The telescope has to be connected before use of the script and the tracking mode has to be
# activated.
#
# 1. Decimal input: RA limits [0 .. 24]
# DEC limits [-90 .. 90]
# Values outside these limits produce an error
#
# 2. deg/min/sec input: RA ... negative values produce an error
# DEC ... negative values of min and sec are ignored
# Values outside these limits produce an error
#
# *******************************************************************************************
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
clr.AddReference("ASCOM.DriverAccess")
from math import copysign
from System.Windows.Forms import Application, Button, CheckBox, Form, FormStartPosition, Label, Panel, RadioButton, TextBox
from System.Drawing import Point
from ASCOM.DriverAccess import *
class ChecksAndRadiosForm(Form):
def __init__(self):
self.Text = "Slew the mount to the RA and DEC position"
self.Width = 450
self.Height = 200
self.setupCheckButtons()
self.setupRadioButtons()
def setupCheckButtons(self):
self.label_RA = Label()
self.label_RA.Text = "RA [0.0 ... 24.0]:" # The input values are tested automatically
self.label_RA.Location = Point(25, 50)
self.label_RA.Height = 25
self.label_RA.Width = 100
self.label_DEC = Label()
self.label_DEC.Text = "DEC [-90 ... 90]:" # The input values are tested automatically
self.label_DEC.Location = Point(25, 75)
self.label_DEC.Height = 25
self.label_DEC.Width = 100
self.textbox_RA = TextBox()
self.textbox_RA.Text = ""
self.textbox_RA.Location = Point(125, 45)
self.textbox_RA.Width = 80
self.textbox_DEC = TextBox()
self.textbox_DEC.Text = ""
self.textbox_DEC.Location = Point(125, 70)
self.textbox_DEC.Width = 80
self.textbox_RA_std = TextBox()
self.textbox_RA_min = TextBox()
self.textbox_RA_sec = TextBox()
self.textbox_RA_std.Text = "0"
self.textbox_RA_min.Text = "0"
self.textbox_RA_sec.Text = "0"
self.textbox_RA_std.Location = Point(230, 45)
self.textbox_RA_min.Location = Point(260, 45)
self.textbox_RA_sec.Location = Point(290, 45)
self.textbox_RA_std.Width = 25
self.textbox_RA_min.Width = 25
self.textbox_RA_sec.Width = 40
self.textbox_RA_std.Enabled = False
self.textbox_RA_min.Enabled = False
self.textbox_RA_sec.Enabled = False
self.textbox_DEC_deg = TextBox()
self.textbox_DEC_min = TextBox()
self.textbox_DEC_sec = TextBox()
self.textbox_DEC_deg.Text = "0"
self.textbox_DEC_min.Text = "0"
self.textbox_DEC_sec.Text = "0"
self.textbox_DEC_deg.Location = Point(230, 70)
self.textbox_DEC_min.Location = Point(260, 70)
self.textbox_DEC_sec.Location = Point(290, 70)
self.textbox_DEC_deg.Width = 25
self.textbox_DEC_min.Width = 25
self.textbox_DEC_sec.Width = 40
self.textbox_DEC_deg.Enabled = False
self.textbox_DEC_min.Enabled = False
self.textbox_DEC_sec.Enabled = False
self.button_GOTO = Button()
self.button_GOTO.Text = 'GOTO'
self.button_GOTO.Location = Point(25, 125)
self.button_GOTO.Click += self.goto
self.button_Exit = Button()
self.button_Exit.Text = 'Exit'
self.button_Exit.Location = Point(125, 125)
self.button_Exit.Click += self.exit
self.AcceptButton = self.button_GOTO
self.CancelButton = self.button_Exit
self.Controls.Add(self.label_RA)
self.Controls.Add(self.label_DEC)
self.Controls.Add(self.textbox_RA)
self.Controls.Add(self.textbox_DEC)
self.Controls.Add(self.textbox_RA_std)
self.Controls.Add(self.textbox_RA_min)
self.Controls.Add(self.textbox_RA_sec)
self.Controls.Add(self.textbox_DEC_deg)
self.Controls.Add(self.textbox_DEC_min)
self.Controls.Add(self.textbox_DEC_sec)
self.Controls.Add(self.button_GOTO)
self.Controls.Add(self.button_Exit)
def setupRadioButtons(self):
self.radio1 = RadioButton()
self.radio1.Text = "xx.xxx (deg)"
self.radio1.Location = Point(120, 10)
self.radio1.Checked = True
self.radio1.CheckedChanged += self.checkedChanged
self.radio2 = RadioButton()
self.radio2.Text = "xx (deg) yy (min) zz.zz (sec)"
self.radio2.AutoSize = True
self.radio2.Location = Point(230, 11)
self.radio2.CheckedChanged += self.checkedChanged
self.Controls.Add(self.radio1)
self.Controls.Add(self.radio2)
def checkedChanged(self, sender, args):
if not sender.Checked:
return
if self.radio1.Checked == True:
self.textbox_RA.Enabled = True
self.textbox_DEC.Enabled = True
self.textbox_RA_std.Enabled = False
self.textbox_RA_min.Enabled = False
self.textbox_RA_sec.Enabled = False
self.textbox_DEC_deg.Enabled = False
self.textbox_DEC_min.Enabled = False
self.textbox_DEC_sec.Enabled = False
else:
self.textbox_RA.Enabled = False
self.textbox_DEC.Enabled = False
self.textbox_RA_std.Enabled = True
self.textbox_RA_min.Enabled = True
self.textbox_RA_sec.Enabled = True
self.textbox_DEC_deg.Enabled = True
self.textbox_DEC_min.Enabled = True
self.textbox_DEC_sec.Enabled = True
def goto(self, sender, event):
t = Telescope("ASCOM.Simulator.Telescope")
if self.radio1.Checked == True:
RA = float(self.textbox_RA.Text)
DEC = float(self.textbox_DEC.Text)
else:
RA = float(self.textbox_RA_min.Text) / 60.0 + float(self.textbox_RA_sec.Text) / 3600.0
RA = RA + float(self.textbox_RA_std.Text)
DEC = abs(float(self.textbox_DEC_min.Text)) / 60.0 + abs(float(self.textbox_DEC_sec.Text)) / 3600.0
DEC = DEC + abs(float(self.textbox_DEC_deg.Text))
DEC = DEC * copysign(1, float(self.textbox_DEC_deg.Text))
print("GOTO to RA position : %f" % (RA))
print("GOTO to DEC position: %f" % (DEC))
print
t.SlewToCoordinates(RA, DEC)
def exit(self, sender, event):
print("Stop GOTO script")
self.Close()
def launch_form():
form = ChecksAndRadiosForm()
form.StartPosition = FormStartPosition.CenterScreen
form.Show()
GOTO_Custom_Button = SharpCap.AddCustomButton("GOTO", None, "GOTO", launch_form)
Any comments are welcome.
Regards,
Jean-Francois