Skip to content

Commit 35da2c9

Browse files
committed
Set LatLong in driver properties, calculate SideOfPier in driver
1 parent 30d2270 commit 35da2c9

File tree

8 files changed

+192
-14
lines changed

8 files changed

+192
-14
lines changed

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

Lines changed: 62 additions & 3 deletions
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ Public Class frmMain
2525
If (IsConnected) Then
2626
driver.Connected = False
2727
Timer1.Enabled = False
28+
txtLat.Text = ""
29+
txtLong.Text = ""
30+
lblVersion.Text = ""
31+
txtMountDec.Text = ""
32+
txtMountRA.Text = ""
33+
txtTargetDec.Text = ""
34+
txtTargetRA.Text = ""
35+
2836
Else
2937
driver = New ASCOM.DriverAccess.Telescope(My.Settings.DriverId)
3038
driver.Connected = True
@@ -40,6 +48,9 @@ Public Class frmMain
4048

4149
lblVersion.Text = driver.Action("Telescope:getFirmwareVer","")
4250

51+
txtLat.Text = driver.SiteLatitude.ToString
52+
txtLong.Text = driver.SiteLongitude.ToString
53+
4354
Timer1.Enabled = True
4455
End If
4556
SetUIState()

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/Driver.vb

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,28 @@ Public Class Telescope
6060

6161
Friend Shared comPortProfileName As String = "COM Port" 'Constants used for Profile persistence
6262
Friend Shared traceStateProfileName As String = "Trace Level"
63+
Friend Shared latitudeProfileName As String = "Latitude"
64+
Friend Shared longitudeProfileName As String = "Longitude"
65+
6366
Friend Shared comPortDefault As String = "COM1"
6467
Friend Shared traceStateDefault As String = "False"
68+
Friend Shared latitudeDefault As Double = 39.8283
69+
Friend Shared longitudeDefault As Double = -98.5795
6570

6671
Friend Shared comPort As String ' Variables to hold the currrent device configuration
6772
Friend Shared portNum As String
6873
Friend Shared traceState As Boolean
74+
Friend Shared latitude As Double
75+
Friend Shared longitude As Double
6976

7077
Private connectedState As Boolean ' Private variable to hold the connected state
7178
Private utilities As Util ' Private variable to hold an ASCOM Utilities object
7279
Private astroUtilities As AstroUtils ' Private variable to hold an AstroUtils object to provide the Range method
7380
Private TL As TraceLogger ' Private variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
7481
Private objSerial As ASCOM.Utilities.Serial
7582
Private isParked As Boolean = False
76-
7783
Dim mutexBlind As Mutex, mutexCommand As Mutex
84+
' Dim pierSide As Integer = 1
7885

7986
'
8087
' Constructor - Must be public for COM registration!
@@ -638,17 +645,33 @@ Public Class Telescope
638645

639646
Public Property SideOfPier() As PierSide Implements ITelescopeV3.SideOfPier
640647
Get
641-
TL.LogMessage("SideOfPier Get", "Not implemented")
642-
Throw New ASCOM.PropertyNotImplementedException("SideOfPier", False)
648+
Dim retVal As PierSide
649+
If SiderealTime < 12 Then
650+
If RightAscension >= SiderealTime And RightAscension <= SiderealTime + 12 Then
651+
retVal = PierSide.pierWest
652+
Else
653+
retVal = PierSide.pierEast
654+
End If
655+
Else
656+
If RightAscension <= SiderealTime And RightAscension >= SiderealTime - 12 Then
657+
retVal = PierSide.pierEast
658+
Else
659+
retVal = PierSide.pierWest
660+
End If
661+
End If
662+
TL.LogMessage("SideOfPier Get", retVal.ToString)
663+
Return retVal
643664
End Get
644665
Set(value As PierSide)
645-
TL.LogMessage("SideOfPier Set", "Not implemented")
666+
' TL.LogMessage("SideOfPier Set", value.ToString)
667+
' pierSide = value
668+
TL.LogMessage("SideOfPier Set", "Not Implemented")
646669
Throw New ASCOM.PropertyNotImplementedException("SideOfPier", True)
647670
End Set
648671
End Property
649672

650673
Public ReadOnly Property SiderealTime() As Double Implements ITelescopeV3.SiderealTime
651-
' ToDo - Does this do what I think it does? If so LatLong just became handy for calculating Hour Angle of Polaris
674+
652675
Get
653676
' now using novas 3.1
654677
Dim lst As Double = 0.0
@@ -674,8 +697,10 @@ Public Class Telescope
674697

675698
Public Property SiteElevation() As Double Implements ITelescopeV3.SiteElevation
676699
Get
677-
TL.LogMessage("SiteElevation Get", "Not implemented")
678-
Throw New ASCOM.PropertyNotImplementedException("SiteElevation", False)
700+
TL.LogMessage("SiteElevation Get", "0 - Hardcoded")
701+
' Used by SiderealTIme
702+
' Throw New ASCOM.PropertyNotImplementedException("SiteElevation", False)
703+
Return 0
679704
End Get
680705
Set(value As Double)
681706
TL.LogMessage("SiteElevation Set", "Not implemented")
@@ -686,8 +711,10 @@ Public Class Telescope
686711
Public Property SiteLatitude() As Double Implements ITelescopeV3.SiteLatitude
687712
' ToDo Can we handle this entirely here, wihtout bothering the mount?
688713
Get
689-
TL.LogMessage("SiteLatitude Get", "Not implemented")
690-
Throw New ASCOM.PropertyNotImplementedException("SiteLatitude", False)
714+
' Used by SiderealTime
715+
' Throw New ASCOM.PropertyNotImplementedException("SiteLatitude", False)
716+
TL.LogMessage("SiteLatitude Get", latitude.ToString)
717+
Return latitude
691718
End Get
692719
Set(value As Double)
693720
TL.LogMessage("SiteLatitude Set", "Not implemented")
@@ -698,8 +725,10 @@ Public Class Telescope
698725
Public Property SiteLongitude() As Double Implements ITelescopeV3.SiteLongitude
699726
' ToDo Can we handle this entirely here, wihtout bothering the mount?
700727
Get
701-
TL.LogMessage("SiteLongitude Get", "Not implemented")
702-
Throw New ASCOM.PropertyNotImplementedException("SiteLongitude", False)
728+
' We should be able to not implment this, but SGP (any others?) breaks if we don't. Will confirm and log issue with MSS
729+
' Throw New ASCOM.PropertyNotImplementedException("SiteLongitude", False)
730+
TL.LogMessage("SiteLongitude Get", longitude.ToString)
731+
Return longitude
703732
End Get
704733
Set(value As Double)
705734
TL.LogMessage("SiteLongitude Set", "Not implemented")
@@ -939,6 +968,8 @@ Public Class Telescope
939968
driverProfile.DeviceType = "Telescope"
940969
traceState = Convert.ToBoolean(driverProfile.GetValue(driverID, traceStateProfileName, String.Empty, traceStateDefault))
941970
comPort = driverProfile.GetValue(driverID, comPortProfileName, String.Empty, comPortDefault)
971+
latitude = driverProfile.GetValue(driverID, latitudeProfileName, String.Empty, latitudeDefault)
972+
longitude = driverProfile.GetValue(driverID, longitudeProfileName, String.Empty, longitudeDefault)
942973
End Using
943974
End Sub
944975

@@ -950,6 +981,8 @@ Public Class Telescope
950981
driverProfile.DeviceType = "Telescope"
951982
driverProfile.WriteValue(driverID, traceStateProfileName, traceState.ToString())
952983
driverProfile.WriteValue(driverID, comPortProfileName, comPort.ToString())
984+
driverProfile.WriteValue(driverID, latitudeProfileName, latitude.ToString())
985+
driverProfile.WriteValue(driverID, longitudeProfileName, longitude.ToString())
953986
End Using
954987

955988
End Sub

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

Lines changed: 55 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
@@ -117,4 +117,7 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<metadata name="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121+
<value>17, 17</value>
122+
</metadata>
120123
</root>

Software/OpenAstroTracker ASCOM/OpenAstroTracker ASCOM/SetupDialogForm.vb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Public Class SetupDialogForm
1010
' Persist new values of user settings to the ASCOM profile
1111
Telescope.comPort = ComboBoxComPort.SelectedItem ' Update the state variables with results from the dialogue
1212
Telescope.traceState = chkTrace.Checked
13+
Telescope.latitude = CDbl(txtLat.Text)
14+
Telescope.longitude = CDbl(txtLong.Text)
15+
1316
Me.DialogResult = System.Windows.Forms.DialogResult.OK
1417
Me.Close()
1518
End Sub
@@ -46,6 +49,20 @@ Public Class SetupDialogForm
4649
If ComboBoxComPort.Items.Contains(Telescope.comPort) Then
4750
ComboBoxComPort.SelectedItem = Telescope.comPort
4851
End If
52+
txtLat.Text = Telescope.latitude.ToString
53+
txtLong.Text = Telescope.longitude.ToString
54+
End Sub
55+
56+
Private Sub txtLat_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLat.KeyPress
57+
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not e.KeyChar = "." And Not e.KeyChar = "-" Then
58+
e.Handled = True
59+
End If
60+
End Sub
61+
62+
Private Sub txtLong_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLong.KeyPress
63+
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not e.KeyChar = "." And Not e.KeyChar = "-" Then
64+
e.Handled = True
65+
End If
4966
End Sub
5067

5168
End Class

0 commit comments

Comments
 (0)