Skip to content

Commit 7d048ee

Browse files
committed
Fix TrackingRates issue
Old template, fixed per discussion at https://ascomtalk.groups.io/g/Developer/topic/28488950#148
1 parent 35da2c9 commit 7d048ee

File tree

6 files changed

+69
-28
lines changed

6 files changed

+69
-28
lines changed

Software/OpenAstroTracker ASCOM/OAT PC Control/frmMain.Designer.vb

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Software/OpenAstroTracker ASCOM/OAT PC Control/frmMain.vb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,10 @@ Public Class frmMain
174174
btnHalt.Enabled = True
175175
End If
176176
End Sub
177+
178+
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
179+
180+
MsgBox(driver.TrackingRates.Count)
181+
182+
End Sub
177183
End Class

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/Driver.vb

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Public Class Telescope
8181
Private objSerial As ASCOM.Utilities.Serial
8282
Private isParked As Boolean = False
8383
Dim mutexBlind As Mutex, mutexCommand As Mutex
84-
' Dim pierSide As Integer = 1
84+
Private m_TrackingRates(-1) As DriveRates
8585

8686
'
8787
' Constructor - Must be public for COM registration!
@@ -313,8 +313,13 @@ Public Class Telescope
313313

314314
#Region "ITelescope Implementation"
315315
Public Sub AbortSlew() Implements ITelescopeV3.AbortSlew
316-
CommandBlind(":Q")
317-
TL.LogMessage("AbortSlew", ":Q# Issued")
316+
If Not AtPark Then
317+
CommandBlind(":Q")
318+
TL.LogMessage("AbortSlew", ":Q# Issued")
319+
Else
320+
Throw New ASCOM.ParkedException("AbortSlew")
321+
End If
322+
318323
End Sub
319324

320325
Public ReadOnly Property AlignmentMode() As AlignmentModes Implements ITelescopeV3.AlignmentMode
@@ -758,31 +763,34 @@ Public Class Telescope
758763
End Sub
759764

760765
Public Sub SlewToCoordinates(RightAscension As Double, Declination As Double) Implements ITelescopeV3.SlewToCoordinates
761-
762-
If Not AtPark Then
763-
TL.LogMessage("SlewToCoordinates", "RA " + RightAscension.ToString + ", Dec " + Declination.ToString)
764-
Dim strRAcmd = ":Sr" + utilities.HoursToHMS(RightAscension, ":", ":")
765-
Dim strDeccmd = utilities.DegreesToDMS(Declination, "*", ":", "")
766-
If Declination < 0 Then
767-
strDeccmd = "-" + strDeccmd
768-
Else
769-
strDeccmd = "+" + strDeccmd
770-
End If
771-
strDeccmd = ":Sd" + strDeccmd
772-
TL.LogMessage("SlewToCoordinatesRACmd", strRAcmd)
773-
TL.LogMessage("SlewToCoordinatesDecCmd", strDeccmd)
774-
If CommandString(strRAcmd) = "1" Then
775-
If CommandString(strDeccmd) = "1" Then
776-
CommandString(":MS")
766+
If RightAscension <= 24 And RightAscension >= 0 And Declination >= -90 And Declination <= 90 Then
767+
768+
If Not AtPark Then
769+
TL.LogMessage("SlewToCoordinates", "RA " + RightAscension.ToString + ", Dec " + Declination.ToString)
770+
Dim strRAcmd = ":Sr" + utilities.HoursToHMS(RightAscension, ":", ":")
771+
Dim strDeccmd = utilities.DegreesToDMS(Declination, "*", ":", "")
772+
If Declination < 0 Then
773+
strDeccmd = "-" + strDeccmd
774+
Else
775+
strDeccmd = "+" + strDeccmd
777776
End If
777+
strDeccmd = ":Sd" + strDeccmd
778+
TL.LogMessage("SlewToCoordinatesRACmd", strRAcmd)
779+
TL.LogMessage("SlewToCoordinatesDecCmd", strDeccmd)
780+
If CommandString(strRAcmd) = "1" Then
781+
If CommandString(strDeccmd) = "1" Then
782+
CommandString(":MS")
783+
End If
778784

785+
End If
786+
Else
787+
TL.LogMessage("SlewToCoordinates", "Parked")
788+
Throw New ASCOM.ParkedException("SlewToCoordinates")
779789
End If
780790
Else
781-
TL.LogMessage("SlewToCoordinates", "Parked")
782-
Throw New ASCOM.ParkedException("SlewToCoordinates")
791+
TL.LogMessage("SlewToCoordinates", "Invalid coordinates RA: " + RightAscension.ToString + ", Dec: " + Declination.ToString)
792+
Throw New ASCOM.InvalidValueException("SlewToCoordinates")
783793
End If
784-
785-
786794
End Sub
787795

788796
Public Sub SlewToCoordinatesAsync(RightAscension As Double, Declination As Double) Implements ITelescopeV3.SlewToCoordinatesAsync
@@ -797,7 +805,7 @@ Public Class Telescope
797805
End Sub
798806

799807
Public Sub SlewToTargetAsync() Implements ITelescopeV3.SlewToTargetAsync
800-
TL.LogMessage(" Public Sub SlewToTargetAsync() Implements ITelescopeV3.SlewToTargetAsync", "Not implemented")
808+
TL.LogMessage("SlewToTargetAsync", "Not implemented")
801809
Throw New ASCOM.MethodNotImplementedException("SlewToTargetAsync")
802810
End Sub
803811

@@ -867,8 +875,9 @@ Public Class Telescope
867875

868876
Public Property TrackingRate() As DriveRates Implements ITelescopeV3.TrackingRate
869877
Get
870-
TL.LogMessage("TrackingRate Get", "Not implemented")
871-
Throw New ASCOM.PropertyNotImplementedException("TrackingRate", False)
878+
TL.LogMessage("TrackingRate Get", DriveRates.driveSidereal.ToString)
879+
Return DriveRates.driveSidereal
880+
' Throw New ASCOM.PropertyNotImplementedException("TrackingRate", False)
872881
End Get
873882
Set(value As DriveRates)
874883
TL.LogMessage("TrackingRate Set", "Not implemented")

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/Rates.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Public Class TrackingRates
157157

158158
Private m_TrackingRates(-1) As DriveRates ' Empty array, but an array nonetheless
159159
' This should make the enumerator thread safe.
160-
Private ReadOnly pos As Threading.ThreadLocal(Of Integer)
160+
Private ReadOnly pos As Threading.ThreadLocal(Of Integer) = New Threading.ThreadLocal(Of Integer)(Function() -1)
161161
Private ReadOnly lockObj As Object = New Object
162162

163163
'

0 commit comments

Comments
 (0)