@@ -508,7 +508,6 @@ Public Class Telescope
508
508
End Property
509
509
510
510
Public ReadOnly Property CanSlewAsync() As Boolean Implements ITelescopeV3.CanSlewAsync
511
- ' TODO - Async Slewing
512
511
Get
513
512
TL.LogMessage( "CanSlewAsync" , "Get - " & True .ToString())
514
513
Return True
@@ -517,8 +516,8 @@ Public Class Telescope
517
516
518
517
Public ReadOnly Property CanSync() As Boolean Implements ITelescopeV3.CanSync
519
518
Get
520
- TL.LogMessage( "CanSync" , "Get - " & False .ToString())
521
- Return False
519
+ TL.LogMessage( "CanSync" , "Get - " & True .ToString())
520
+ Return True
522
521
End Get
523
522
End Property
524
523
@@ -635,14 +634,10 @@ Public Class Telescope
635
634
TL.LogMessage( "Park" , "Err : Mount already parked" )
636
635
Throw New ASCOM.ParkedException( "Park" )
637
636
Else
638
- Dim prkRet As String = CommandString( ":hP" , False )
639
- If prkRet = "1" Then
640
- isParked = True
641
- Else
642
- isParked = False
643
- Throw New ASCOM.DriverException( "Park failed" )
644
- End If
645
- TL.LogMessage( "Park" , "Park requested : " + prkRet)
637
+ CommandString( ":hP" , False )
638
+ PollUntilZero( ":GIS" )
639
+ isParked = True
640
+ TL.LogMessage( "Park" , "Parked mount" )
646
641
End If
647
642
648
643
End Sub
@@ -789,6 +784,7 @@ Public Class Telescope
789
784
End Sub
790
785
791
786
Public Sub SlewToCoordinates(RightAscension As Double , Declination As Double ) Implements ITelescopeV3.SlewToCoordinates
787
+ ' Synchronous slew to given coordinates. Uses PollUntilZero to wait for slew to finish
792
788
If RightAscension <= 24 And RightAscension >= 0 And Declination >= - 90 And Declination <= 90 Then
793
789
794
790
If Not AtPark Then
@@ -804,6 +800,7 @@ Public Class Telescope
804
800
If CommandString(strRAcmd) = "1" Then
805
801
If CommandString(strDeccmd) = "1" Then
806
802
CommandString( ":MS" )
803
+ PollUntilZero( ":GIS" )
807
804
End If
808
805
809
806
End If
@@ -818,25 +815,51 @@ Public Class Telescope
818
815
End Sub
819
816
820
817
Public Sub SlewToCoordinatesAsync(RightAscension As Double , Declination As Double ) Implements ITelescopeV3.SlewToCoordinatesAsync
821
- TL.LogMessage( "SlewToCoordinatesAsync" , RightAscension.ToString + ", " + Declination.ToString)
822
- SlewToCoordinates( RightAscension, Declination)
818
+ ' ASynchronous slew to coordinates. Returns immediately after receiving response from :MS that command was accepted
819
+ If RightAscension <= 24 And RightAscension >= 0 And Declination >= - 90 And Declination <= 90 Then
823
820
821
+ If Not AtPark Then
822
+ TL.LogMessage( "SlewToCoordinatesAsync" , "RA " + RightAscension.ToString + ", Dec " + Declination.ToString)
823
+ Dim strRAcmd = ":Sr" + utilities.HoursToHMS(RightAscension, ":" , ":" )
824
+ Dim strDeccmd = utilities.DegreesToDMS(Declination, "*" , ":" , "" )
825
+ If Declination >= 0 Then
826
+ strDeccmd = "+" + strDeccmd
827
+ End If
828
+ strDeccmd = ":Sd" + strDeccmd
829
+ TL.LogMessage( "SlewToCoordinatesAsyncRACmd" , strRAcmd)
830
+ TL.LogMessage( "SlewToCoordinatesAsyncDecCmd" , strDeccmd)
831
+ If CommandString(strRAcmd) = "1" Then
832
+ If CommandString(strDeccmd) = "1" Then
833
+ CommandString( ":MS" )
834
+ End If
835
+
836
+ End If
837
+ Else
838
+ TL.LogMessage( "SlewToCoordinatesAsync" , "Parked" )
839
+ Throw New ASCOM.ParkedException( "SlewToCoordinatesAsync" )
840
+ End If
841
+ Else
842
+ TL.LogMessage( "SlewToCoordinatesAsync" , "Invalid coordinates RA: " + RightAscension.ToString + ", Dec: " + Declination.ToString)
843
+ Throw New ASCOM.InvalidValueException( "SlewToCoordinatesAsync" )
844
+ End If
824
845
825
846
End Sub
826
847
827
848
Public Sub SlewToTarget() Implements ITelescopeV3.SlewToTarget
849
+ TL.LogMessage( "SlewToTarget" , TargetRightAscension.ToString + ", " + TargetDeclination.ToString)
828
850
SlewToCoordinates(TargetRightAscension, TargetDeclination)
829
851
End Sub
830
852
831
853
Public Sub SlewToTargetAsync() Implements ITelescopeV3.SlewToTargetAsync
832
854
TL.LogMessage( "SlewToTargetAsync" , TargetRightAscension.ToString + ", " + TargetDeclination.ToString)
833
- SlewToCoordinates (TargetRightAscension, TargetDeclination)
855
+ SlewToCoordinatesAsync (TargetRightAscension, TargetDeclination)
834
856
End Sub
835
857
836
858
Public ReadOnly Property Slewing() As Boolean Implements ITelescopeV3.Slewing
837
859
Get
838
- TL.LogMessage( "Slewing Get" , "Not implemented" )
839
- Throw New ASCOM.PropertyNotImplementedException( "Slewing" , False )
860
+ Dim retVal As Boolean = Convert.ToBoolean( CInt (CommandString( ":GIS" )))
861
+ TL.LogMessage( "Slewing Get" , retVal.ToString)
862
+ Return retVal
840
863
End Get
841
864
End Property
842
865
@@ -846,13 +869,53 @@ Public Class Telescope
846
869
End Sub
847
870
848
871
Public Sub SyncToCoordinates(RightAscension As Double , Declination As Double ) Implements ITelescopeV3.SyncToCoordinates
849
- TL.LogMessage( "SyncToCoordinates" , "Not implemented" )
850
- Throw New ASCOM.MethodNotImplementedException( "SyncToCoordinates" )
872
+ If RightAscension <= 24 And RightAscension >= 0 And Declination >= - 90 And Declination <= 90 Then
873
+ Dim sign As String = String .Empty
874
+ If Declination >= 0 Then
875
+ sign = "+"
876
+ End If
877
+ Dim success As String = CommandString( ":SY" + sign + utilities.DegreesToDMS(Declination, "*" , ":" , String .Empty) + "." + utilities.HoursToHMS(RightAscension, ":" , ":" ), False )
878
+ If success = "1" Then
879
+ TL.LogMessage( "SyncToCoordinates" , "Synced to " + utilities.DegreesToDMS(Declination) + ", " + utilities.HoursToHMS(RightAscension))
880
+ Else
881
+ TL.LogMessage( "SyncToCoordinates" , "Failed to sync to " + utilities.DegreesToDMS(Declination) + ", " + utilities.HoursToHMS(RightAscension))
882
+ Throw New ASCOM.DriverException( "SyncToCoordinates" )
883
+ End If
884
+ Else
885
+ TL.LogMessage( "SyncToCoordinates" , "Invalid coordinates RA: " + RightAscension.ToString + ", Dec: " + Declination.ToString)
886
+ Throw New ASCOM.InvalidValueException( "SyncToCoordinates" )
887
+ End If
851
888
End Sub
852
889
853
890
Public Sub SyncToTarget() Implements ITelescopeV3.SyncToTarget
854
- TL.LogMessage( "SyncToTarget" , "Not implemented" )
855
- Throw New ASCOM.MethodNotImplementedException( "SyncToTarget" )
891
+ If targetDecSet Then
892
+
893
+ If targetRASet Then
894
+
895
+ Dim sign As String = String .Empty
896
+ If TargetDeclination >= 0 Then
897
+ sign = "+"
898
+ End If
899
+ Dim success As String = CommandString( ":SY" + sign + utilities.DegreesToDMS(TargetDeclination, "*" , ":" , String .Empty) + "." + utilities.HoursToHMS(TargetRightAscension, ":" , ":" ), False )
900
+ If success = "1" Then
901
+ TL.LogMessage( "SyncToTarget" , "Synced to " + utilities.DegreesToDMS(TargetDeclination) + ", " + utilities.HoursToHMS(TargetRightAscension))
902
+ Else
903
+ TL.LogMessage( "SyncToTarget" , "Failed to sync to " + utilities.DegreesToDMS(TargetDeclination) + ", " + utilities.HoursToHMS(TargetRightAscension))
904
+ Throw New ASCOM.DriverException( "SyncToTarget" )
905
+ End If
906
+
907
+ Else
908
+
909
+ Throw New ASCOM.ValueNotSetException( "TargetRightAscension" )
910
+
911
+ End If
912
+
913
+ Else
914
+
915
+ Throw New ASCOM.ValueNotSetException( "TargetDeclination" )
916
+
917
+ End If
918
+
856
919
End Sub
857
920
858
921
Public Property TargetDeclination() As Double Implements ITelescopeV3.TargetDeclination
@@ -1062,4 +1125,18 @@ Public Class Telescope
1062
1125
1063
1126
# End Region
1064
1127
1128
+ # Region "Helper Functions"
1129
+
1130
+ Private Function PollUntilZero( ByVal command As String ) As Integer
1131
+ ' Takes a command to be sent via CommandString, and resends every 1000ms until a 0 is returned. Returns 0 only when complete.
1132
+ Dim retVal As String = ""
1133
+ Do Until retVal = "0"
1134
+ retVal = CommandString(command, False )
1135
+ Thread.Sleep( 1000 )
1136
+ Loop
1137
+ Return CInt (retVal)
1138
+ End Function
1139
+
1140
+ # End Region
1141
+
1065
1142
End Class
0 commit comments