Skip to content

Commit 79f67c8

Browse files
committed
Resolve target set and slew to target ASCOM errors
Oh..and fuck git
1 parent 7d048ee commit 79f67c8

File tree

6 files changed

+95
-25
lines changed

6 files changed

+95
-25
lines changed

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/Driver.vb

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,30 @@ Public Class Telescope
6262
Friend Shared traceStateProfileName As String = "Trace Level"
6363
Friend Shared latitudeProfileName As String = "Latitude"
6464
Friend Shared longitudeProfileName As String = "Longitude"
65+
Friend Shared elevationProfileName As String = "Elevation"
6566

6667
Friend Shared comPortDefault As String = "COM1"
6768
Friend Shared traceStateDefault As String = "False"
6869
Friend Shared latitudeDefault As Double = 39.8283
6970
Friend Shared longitudeDefault As Double = -98.5795
71+
Friend Shared elevationDefault As Integer = 1
7072

7173
Friend Shared comPort As String ' Variables to hold the currrent device configuration
7274
Friend Shared portNum As String
7375
Friend Shared traceState As Boolean
7476
Friend Shared latitude As Double
7577
Friend Shared longitude As Double
78+
Friend Shared elevation As Integer
7679

7780
Private connectedState As Boolean ' Private variable to hold the connected state
7881
Private utilities As Util ' Private variable to hold an ASCOM Utilities object
7982
Private astroUtilities As AstroUtils ' Private variable to hold an AstroUtils object to provide the Range method
8083
Private TL As TraceLogger ' Private variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
8184
Private objSerial As ASCOM.Utilities.Serial
8285
Private isParked As Boolean = False
86+
Private targetRA As Double, targetDec As Double, targetRASet As Boolean = False, targetDecSet As Boolean = False
8387
Dim mutexBlind As Mutex, mutexCommand As Mutex
84-
Private m_TrackingRates(-1) As DriveRates
88+
' Private m_TrackingRates(-1) As DriveRates
8589

8690
'
8791
' Constructor - Must be public for COM registration!
@@ -702,14 +706,16 @@ Public Class Telescope
702706

703707
Public Property SiteElevation() As Double Implements ITelescopeV3.SiteElevation
704708
Get
705-
TL.LogMessage("SiteElevation Get", "0 - Hardcoded")
706-
' Used by SiderealTIme
707-
' Throw New ASCOM.PropertyNotImplementedException("SiteElevation", False)
708-
Return 0
709+
TL.LogMessage("SiteElevation Get", elevation.ToString)
710+
Return elevation
709711
End Get
710712
Set(value As Double)
711-
TL.LogMessage("SiteElevation Set", "Not implemented")
712-
Throw New ASCOM.PropertyNotImplementedException("SiteElevation", True)
713+
If value >= -300 And value <= 10000 Then
714+
TL.LogMessage("SiteElevation Set", value.ToString)
715+
elevation = value
716+
Else
717+
Throw New ASCOM.InvalidValueException("SiteElevation")
718+
End If
713719
End Set
714720
End Property
715721

@@ -799,9 +805,7 @@ Public Class Telescope
799805
End Sub
800806

801807
Public Sub SlewToTarget() Implements ITelescopeV3.SlewToTarget
802-
' When do we want to use slew to target?
803-
TL.LogMessage("SlewToTarget", "Not implemented")
804-
Throw New ASCOM.MethodNotImplementedException("SlewToTarget")
808+
SlewToCoordinates(TargetRightAscension, TargetDeclination)
805809
End Sub
806810

807811
Public Sub SlewToTargetAsync() Implements ITelescopeV3.SlewToTargetAsync
@@ -834,29 +838,59 @@ Public Class Telescope
834838

835839
Public Property TargetDeclination() As Double Implements ITelescopeV3.TargetDeclination
836840
Get
837-
Dim declination__t As Double = 0.0
838-
Dim targetDec As String = CommandString(":Gd")
839-
TL.LogMessage("TargetDeclination", "Get - " & targetDec)
840-
declination__t = utilities.DMSToDegrees(targetDec)
841-
Return declination__t
841+
If targetDecSet Then
842+
TL.LogMessage("TargetDeclination Get", targetDec.ToString)
843+
Return targetDec
844+
Else
845+
TL.LogMessage("TargetDeclination Get", "Value not set")
846+
Throw New ASCOM.ValueNotSetException("TargetDeclination")
847+
End If
848+
'Dim declination__t As Double = 0.0
849+
'Dim targetDec As String = CommandString(":Gd")
850+
'TL.LogMessage("TargetDeclination", "Get - " & targetDec)
851+
'declination__t = utilities.DMSToDegrees(targetDec)
852+
'Return declination__t
842853
End Get
843854
Set(value As Double)
844-
TL.LogMessage("TargetDeclination Set", "Not implemented")
845-
Throw New ASCOM.PropertyNotImplementedException("TargetDeclination", True)
855+
If value >= -90 And value <= 90 Then
856+
TL.LogMessage("TargetDeclination Set", value.ToString)
857+
targetDec = value
858+
targetDecSet = True
859+
Else
860+
TL.LogMessage("TargetDeclination Set", "Invalid Value " + value.ToString)
861+
Throw New ASCOM.InvalidValueException("TargetDeclination")
862+
End If
863+
'TL.LogMessage("TargetDeclination Set", "Not implemented")
864+
'Throw New ASCOM.PropertyNotImplementedException("TargetDeclination", True)
846865
End Set
847866
End Property
848867

849868
Public Property TargetRightAscension() As Double Implements ITelescopeV3.TargetRightAscension
850869
Get
851-
Dim rightAscension__t As Double = 0.0
852-
Dim targetRA As String = CommandString(":Gr")
853-
TL.LogMessage("TargetRightAscension", "Get - " + targetRA)
854-
rightAscension__t = utilities.HMSToHours(targetRA)
855-
Return rightAscension__t
870+
If targetRASet Then
871+
TL.LogMessage("TargetRightAscension Get", targetRA.ToString)
872+
Return targetRA
873+
Else
874+
TL.LogMessage("TargetRightAscension Get", "Value not set")
875+
Throw New ASCOM.ValueNotSetException("TargetRightAscension")
876+
End If
877+
'Dim rightAscension__t As Double = 0.0
878+
'Dim targetRA As String = CommandString(":Gr")
879+
'TL.LogMessage("TargetRightAscension", "Get - " + targetRA)
880+
'rightAscension__t = utilities.HMSToHours(targetRA)
881+
'Return rightAscension__t
856882
End Get
857883
Set(value As Double)
858-
TL.LogMessage("TargetRightAscension Set", "Not implemented")
859-
Throw New ASCOM.PropertyNotImplementedException("TargetRightAscension", True)
884+
If value >= 0 And value <= 24 Then
885+
TL.LogMessage("TargetRightAscension Set", value.ToString)
886+
targetRA = value
887+
targetRASet = True
888+
Else
889+
TL.LogMessage("TargetRightAscension Set", "Invalid Value " + value.ToString)
890+
Throw New ASCOM.InvalidValueException("TargetRightAscension")
891+
End If
892+
'TL.LogMessage("TargetRightAscension Set", "Not implemented")
893+
'Throw New ASCOM.PropertyNotImplementedException("TargetRightAscension", True)
860894
End Set
861895
End Property
862896

@@ -979,6 +1013,7 @@ Public Class Telescope
9791013
comPort = driverProfile.GetValue(driverID, comPortProfileName, String.Empty, comPortDefault)
9801014
latitude = driverProfile.GetValue(driverID, latitudeProfileName, String.Empty, latitudeDefault)
9811015
longitude = driverProfile.GetValue(driverID, longitudeProfileName, String.Empty, longitudeDefault)
1016+
elevation = driverProfile.GetValue(driverID, elevationProfileName, String.Empty, elevationDefault)
9821017
End Using
9831018
End Sub
9841019

@@ -992,6 +1027,7 @@ Public Class Telescope
9921027
driverProfile.WriteValue(driverID, comPortProfileName, comPort.ToString())
9931028
driverProfile.WriteValue(driverID, latitudeProfileName, latitude.ToString())
9941029
driverProfile.WriteValue(driverID, longitudeProfileName, longitude.ToString())
1030+
driverProfile.WriteValue(driverID, elevationProfileName, elevation.ToString)
9951031
End Using
9961032

9971033
End Sub

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/SetupDialogForm.Designer.vb

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/SetupDialogForm.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,7 @@
120120
<metadata name="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123+
<metadata name="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124+
<value>17, 17</value>
125+
</metadata>
123126
</root>

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/SetupDialogForm.vb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Public Class SetupDialogForm
1212
Telescope.traceState = chkTrace.Checked
1313
Telescope.latitude = CDbl(txtLat.Text)
1414
Telescope.longitude = CDbl(txtLong.Text)
15-
15+
Telescope.elevation = CInt(txtElevation.Text)
1616
Me.DialogResult = System.Windows.Forms.DialogResult.OK
1717
Me.Close()
1818
End Sub
@@ -51,6 +51,7 @@ Public Class SetupDialogForm
5151
End If
5252
txtLat.Text = Telescope.latitude.ToString
5353
txtLong.Text = Telescope.longitude.ToString
54+
txtElevation.Text = Telescope.elevation.ToString
5455
End Sub
5556

5657
Private Sub txtLat_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLat.KeyPress
@@ -65,4 +66,11 @@ Public Class SetupDialogForm
6566
End If
6667
End Sub
6768

69+
Private Sub txtElevation_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtElevation.KeyPress
70+
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
71+
e.Handled = True
72+
End If
73+
End Sub
74+
75+
6876
End Class

0 commit comments

Comments
 (0)