Skip to content

Commit 7b73fe1

Browse files
committed
Merge develop into master ready for Platform 7 release.
2 parents 45fcb9c + 97d4610 commit 7b73fe1

12 files changed

Lines changed: 340 additions & 128 deletions

Conform/Conform.vbproj

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,27 +141,15 @@
141141
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
142142
<Private>True</Private>
143143
</Reference>
144-
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
145-
<SpecificVersion>False</SpecificVersion>
146-
<HintPath>..\..\..\..\..\..\..\ASCOM Trunk\ASCOM.DriverAccess\bin\Release\ASCOM.DriverAccess.dll</HintPath>
147-
<Private>True</Private>
148-
</Reference>
149-
<Reference Include="ASCOM.Exceptions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
150-
<SpecificVersion>False</SpecificVersion>
151-
<HintPath>..\..\..\..\..\..\..\ASCOM Trunk\Interfaces\ASCOMExceptions\bin\Release\ASCOM.Exceptions.dll</HintPath>
152-
<Private>True</Private>
153-
</Reference>
144+
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
145+
<Reference Include="ASCOM.Exceptions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
154146
<Reference Include="ASCOM.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
155147
<SpecificVersion>False</SpecificVersion>
156148
<EmbedInteropTypes>False</EmbedInteropTypes>
157149
<HintPath>..\..\..\..\..\..\..\ASCOM Trunk\Interfaces\Master Interfaces\ASCOM.Interfaces.dll</HintPath>
158150
<Private>True</Private>
159151
</Reference>
160-
<Reference Include="ASCOM.Utilities, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
161-
<SpecificVersion>False</SpecificVersion>
162-
<HintPath>..\..\..\..\..\..\..\ASCOM Trunk\ASCOM.Utilities\ASCOM.Utilities\bin\Release\ASCOM.Utilities.dll</HintPath>
163-
<Private>True</Private>
164-
</Reference>
152+
<Reference Include="ASCOM.Utilities, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
165153
<Reference Include="System" />
166154
<Reference Include="System.Core">
167155
<RequiredTargetFramework>3.5</RequiredTargetFramework>

Conform/Devices/CoverCalibrator Tester.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Friend Class CoverCalibratorTester
8484

8585
Public Overrides Sub CheckAccessibility()
8686
Dim deviceInterface As ICoverCalibratorV1
87-
Dim driverAccessDevice As CoverCalibrator
87+
Dim driverAccessDevice As DriverAccess.CoverCalibrator
8888
Dim deviceObject As Object
8989

9090
MyBase.CheckAccessibility(g_CoverCalibratorProgID, DeviceType.CoverCalibrator)

Conform/Devices/DeviceTesterBaseClass.vb

Lines changed: 161 additions & 63 deletions
Large diffs are not rendered by default.

Conform/Devices/RotatorTester.vb

Lines changed: 103 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Friend Class RotatorTester
1010
Const ROTATOR_OK_TOLERANCE As Double = 1.0
1111
Const ROTATOR_INFO_TOLERANCE As Double = 2.0
1212
Const ROTATOR_POSITION_TOLERANCE As Single = 0.001 ' Degrees
13+
Const ROTATOR_POSITION_UNKNOWN As Single = Single.NaN ' Define a constant to represent position unknown. Used when restoring rotator position after testing.
1314

1415
'Rotator variables
1516
Private m_CanReadIsMoving, canReadPosition, m_CanReadTargetPosition, m_CanReadStepSize As Boolean
@@ -18,6 +19,9 @@ Friend Class RotatorTester
1819
Private m_Reverse As Boolean
1920
Private m_LastMoveWasAsync As Boolean
2021
Private canReadMechanicalPosition As Boolean
22+
Private initialPosiiton As Single = ROTATOR_POSITION_UNKNOWN
23+
Private initialMechanicalPosiiton As Single = ROTATOR_POSITION_UNKNOWN
24+
Private initialSyncOffset As Single = ROTATOR_POSITION_UNKNOWN
2125

2226
#If DEBUG Then
2327
Private m_Rotator As ASCOM.DeviceInterface.IRotatorV3
@@ -41,7 +45,7 @@ Friend Class RotatorTester
4145

4246
#Region "New and Dispose"
4347
Sub New()
44-
MyBase.New(True, True, True, True, False, True, False) ' Set flags for this device: HasCanProperties, HasProperties, HasMethods, PreRunCheck, PreConnectCheck, PerformanceCheck, PostRunCheck
48+
MyBase.New(True, True, True, True, False, True, True) ' Set flags for this device: HasCanProperties, HasProperties, HasMethods, PreRunCheck, PreConnectCheck, PerformanceCheck, PostRunCheck
4549
End Sub
4650

4751
' IDisposable
@@ -230,30 +234,122 @@ Friend Class RotatorTester
230234

231235
Public Overrides Sub PreRunCheck()
232236
Dim l_Now As Date
233-
'Get the rotator into a standard state
237+
238+
' Initialise to the unknown position value
239+
initialPosiiton = ROTATOR_POSITION_UNKNOWN
234240
g_Stop = True
235-
LogCallToDriver("PreRunCheck", "About to call Halt method")
241+
242+
' Get the rotator into a standard state
243+
LogCallToDriver("PreRun Check", "About to call Halt method")
236244
Try : m_Rotator.Halt() : Catch : End Try 'Stop any movement
245+
246+
' Confirm that rotator is not moving or wait for it to stop
237247
l_Now = Now
238-
Try 'Confirm that rotator is not moving or wait for it to stop
248+
Try
239249
Status(StatusType.staAction, "Waiting up to " & ROTATOR_WAIT_LIMIT & " seconds for rotator to stop moving")
240-
LogCallToDriver("CanReverse", "About to get IsMoving property repeatedly")
250+
LogCallToDriver("PreRun Check", "About to get IsMoving property repeatedly")
241251
Do
242252
WaitFor(500)
243253
Status(StatusType.staStatus, Now.Subtract(l_Now).TotalSeconds & "/" & ROTATOR_WAIT_LIMIT)
244254
Loop Until (Not m_Rotator.IsMoving) Or (Now.Subtract(l_Now).TotalSeconds > ROTATOR_WAIT_LIMIT)
245255

246256
If Not m_Rotator.IsMoving Then 'Rotator is stopped so OK
247257
g_Stop = False 'Clear stop flag to allow other tests to run
258+
LogMsg("Pre-run Check", MessageLevel.msgOK, "Rotator is stationary")
259+
260+
' Try to record the current position of the rotator so that it can be restored after testing. If this fails the initial position will be set to unknown value.
261+
Try
262+
LogCallToDriver("PreRun Check", "About to get Position property")
263+
initialPosiiton = m_Rotator.Position
264+
LogMsg("Pre-run Check", MessageLevel.msgOK, $"Rotator initial position: {initialPosiiton}")
265+
266+
' Attempt to get the rotator's current mechanical position. If this fails the initial mechanical position will be set to unknown value.
267+
Try
268+
LogCallToDriver("PreRun Check", "About to get MechanicalPosition property")
269+
initialMechanicalPosiiton = m_Rotator.MechanicalPosition
270+
initialSyncOffset = Range(initialPosiiton - initialMechanicalPosiiton, -180.0, True, 180.0, True)
271+
LogMsg("Pre-run Check", MessageLevel.msgOK, $"Rotator initial mechanical position: {initialMechanicalPosiiton}, Initial sync offset: {initialSyncOffset}")
272+
Catch ex As Exception
273+
'Don't report errors at this point
274+
LogMsg("Pre-run Check", MessageLevel.msgInfo, $"Rotator initial mechanical position could not be read: {ex.Message}")
275+
End Try
276+
Catch ex As Exception
277+
'Don't report errors at this point
278+
LogMsg("Pre-run Check", MessageLevel.msgInfo, $"Rotator initial position could not be read: {ex.Message}")
279+
End Try
280+
248281
Else 'Report error message and don't do other tests
249-
LogMsg("Pre-run Check", MessageLevel.msgError, "Rotator still moving after " & ROTATOR_WAIT_LIMIT & "seconds, IsMoving stuck on?")
282+
LogMsg("Pre-run Check", MessageLevel.msgError, "Rotator still moving after " & ROTATOR_WAIT_LIMIT & "seconds, could IsMoving be stuck on?")
250283
End If
251-
LogMsg("Pre-run Check", MessageLevel.msgOK, "Rotator is stationary")
252284
Catch ex As Exception
253285
'Don't report errors at this point
254286
End Try
255287

256288
End Sub
289+
290+
Public Overrides Sub PostRunCheck()
291+
Dim currentPosition, currentMechanicalPosition, relativeMovement, syncPosition As Single
292+
Dim l_Now As Date
293+
294+
' Restore the initial position of the rotator if possible
295+
If initialPosiiton = ROTATOR_POSITION_UNKNOWN Then
296+
' The initial position could not be determined so log a message to this effect.
297+
LogMsg("Post-run Check", MessageLevel.msgNone, "The rotator's initial position could not be determined so it is not possible to restore it's initial position.")
298+
Else
299+
' We have a valid initial position so attempt to reset the rotator to this position.
300+
Try
301+
' Get the current position
302+
LogCallToDriver("Post-run Check", $"About to get Position property")
303+
currentPosition = m_Rotator.Position
304+
LogMsg("Post-run Check", MessageLevel.msgOK, $"Current position: {currentPosition}")
305+
306+
' Restore the original sync offset, if possible
307+
If Not (initialMechanicalPosiiton = ROTATOR_POSITION_UNKNOWN) Then ' We have a valid starting mechanic al position
308+
' Get the current mechanical position
309+
LogCallToDriver("Post-run Check", $"About to get MechanicalPosition property")
310+
currentMechanicalPosition = m_Rotator.MechanicalPosition
311+
LogMsg("Post-run Check", MessageLevel.msgOK, $"Current mechanical position: {currentMechanicalPosition}")
312+
313+
syncPosition = Range(currentMechanicalPosition + initialSyncOffset, 0.0, True, 360.0, False)
314+
LogMsg("Post-run Check", MessageLevel.msgOK, $"New sync position: {syncPosition}")
315+
316+
LogCallToDriver("Post-run Check", $"About to call Sync method. Position: {syncPosition}")
317+
m_Rotator.Sync(syncPosition)
318+
LogMsg("Post-run Check", MessageLevel.msgOK, $"Completed Sync ({initialSyncOffset} degrees) from position: {currentPosition} to {syncPosition}")
319+
End If
320+
321+
' Re-get the current position because the sync will have changed it
322+
LogCallToDriver("Post-run Check", $"About to get Position property")
323+
currentPosition = m_Rotator.Position
324+
LogMsg("Post-run Check", MessageLevel.msgOK, $"New current position: {currentPosition}")
325+
326+
' Calculate the smallest relative movement required to get to the initial position
327+
relativeMovement = Range(initialPosiiton - currentPosition, -180.0, True, 180.0, True)
328+
329+
' Move to the starting position
330+
LogCallToDriver("Post-run Check", $"About to move by {relativeMovement} to {initialPosiiton}")
331+
m_Rotator.Move(relativeMovement)
332+
333+
' Wait for the move to complete
334+
LogCallToDriver("Post-run Check", "About to get IsMoving property repeatedly")
335+
l_Now = Now
336+
Do
337+
WaitFor(500)
338+
Status(StatusType.staStatus, Now.Subtract(l_Now).TotalSeconds & "/" & ROTATOR_WAIT_LIMIT)
339+
Loop Until (Not m_Rotator.IsMoving) Or (Now.Subtract(l_Now).TotalSeconds > ROTATOR_WAIT_LIMIT)
340+
341+
If Not m_Rotator.IsMoving Then 'Rotator is stopped so OK
342+
LogMsg("Post-run Check", MessageLevel.msgOK, $"Rotator starting position successfully restored to {initialPosiiton}")
343+
Else 'Report error message
344+
LogMsg("Post-run Check", MessageLevel.msgError, "Unable to restore rotator starting position, the rotator is still moving after " & ROTATOR_WAIT_LIMIT & "seconds. Could IsMoving be stuck on?")
345+
End If
346+
Catch ex As Exception
347+
LogMsg("Post-run Check", MessageLevel.msgError, $"Exception: {ex}")
348+
349+
End Try
350+
End If
351+
End Sub
352+
257353
Overrides Sub CheckProperties()
258354
'IsMoving - Optional (V1,V2), Mandatory (V3)
259355
Try

Conform/Devices/TelescopeTester.vb

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -395,31 +395,43 @@ Friend Class TelescopeTester
395395
Public Overrides Sub PreRunCheck()
396396
'Get into a consistent state
397397
If g_InterfaceVersion > 1 Then
398-
If g_Settings.DisplayMethodCalls Then LogMsg("Mount Safety", MessageLevel.msgComment, "About to get AtPark property")
399-
If telescopeDevice.AtPark Then
400-
If canUnpark Then
401-
If g_Settings.DisplayMethodCalls Then LogMsg("Mount Safety", MessageLevel.msgComment, "About to call Unpark method")
402-
telescopeDevice.Unpark()
403-
LogMsg("Mount Safety", MessageLevel.msgInfo, "Scope is parked, so it has been unparked for testing")
398+
Try
399+
If g_Settings.DisplayMethodCalls Then LogMsg("Mount Safety", MessageLevel.msgComment, "About to get AtPark property")
400+
If telescopeDevice.AtPark Then
401+
If canUnpark Then
402+
Try
403+
If g_Settings.DisplayMethodCalls Then LogMsg("Mount Safety", MessageLevel.msgComment, "About to call Unpark method")
404+
telescopeDevice.Unpark()
405+
LogMsg("Mount Safety", MessageLevel.msgInfo, "Scope is parked, so it has been unparked for testing")
406+
Catch ex As Exception
407+
HandleException("Mount Safety - Unpark", MemberType.Method, Required.MustBeImplemented, ex, "CanUnpark is true")
408+
End Try
409+
Else
410+
LogMsg("Mount Safety", MessageLevel.msgError, "Scope reports that it is parked but CanUnPark is false - please manually unpark the scope")
411+
g_Stop = True
412+
End If
404413
Else
405-
LogMsg("Mount Safety", MessageLevel.msgError, "Scope reports that it is parked but CanUnPark is false - please manually unpark the scope")
406-
g_Stop = True
414+
LogMsg("Mount Safety", MessageLevel.msgInfo, "Scope is not parked, continuing testing")
407415
End If
408-
Else
409-
LogMsg("Mount Safety", MessageLevel.msgInfo, "Scope is not parked, continuing testing")
410-
End If
416+
Catch ex As Exception
417+
LogMsgError("Mount Safety", $"Exception when trying to access mandatory member Telescope.AtPark: {ex.Message}")
418+
End Try
411419
Else
412420
LogMsg("Mount Safety", MessageLevel.msgInfo, "Skipping AtPark test as this method is not supported in interface V" & g_InterfaceVersion)
413421
Try
414422
If canUnpark Then
415-
If g_Settings.DisplayMethodCalls Then LogMsg("Mount Safety", MessageLevel.msgComment, "About to call Unpark method")
416-
telescopeDevice.Unpark()
417-
LogMsg("Mount Safety", MessageLevel.msgOK, "Scope has been unparked for testing")
423+
Try
424+
If g_Settings.DisplayMethodCalls Then LogMsg("Mount Safety", MessageLevel.msgComment, "About to call Unpark method")
425+
telescopeDevice.Unpark()
426+
LogMsg("Mount Safety", MessageLevel.msgOK, "Scope has been unparked for testing")
427+
Catch ex As Exception
428+
LogMsgError("Mount Safety", $"Exception when trying to unpark the scope: {ex.Message}")
429+
End Try
418430
Else
419431
LogMsg("Mount Safety", MessageLevel.msgOK, "Scope reports that it cannot unpark, unparking skipped")
420432
End If
421433
Catch ex As Exception
422-
LogMsg("Mount Safety", MessageLevel.msgError, "Driver threw an exception while unparking: " & ex.Message)
434+
HandleException("Mount Safety - AtPark", MemberType.Property, Required.Mandatory, ex, "")
423435
End Try
424436
End If
425437

Conform/FrmConformMain.vb

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ Imports System.Reflection
433433
Imports System.Runtime.InteropServices
434434
Imports System.Globalization
435435
Imports Microsoft.Win32
436+
Imports System.Security.Principal
437+
436438
#End Region
437439

438440
Public Class FrmConformMain
@@ -894,9 +896,9 @@ Public Class FrmConformMain
894896
Case DeviceType.Telescope
895897
l_NewProgID = l_Chooser.Choose(g_TelescopeProgID)
896898
If l_NewProgID <> "" Then
897-
g_Settings.DeviceTelescope = l_NewProgID 'Only update settings if OK pressed
898-
g_TelescopeProgID = l_NewProgID
899-
End If
899+
g_Settings.DeviceTelescope = l_NewProgID 'Only update settings if OK pressed
900+
g_TelescopeProgID = l_NewProgID
901+
End If
900902
Case DeviceType.Switch
901903
l_NewProgID = l_Chooser.Choose(g_SwitchProgID)
902904
If l_NewProgID <> "" Then
@@ -1259,6 +1261,25 @@ Public Class FrmConformMain
12591261
My.Computer.FileSystem.DeleteFile("C:\Documents and Settings\All Users\Start Menu\Programs\ASCOM Platform\Tools\Uninstall Conform.lnk")
12601262
Catch ex As Exception
12611263
End Try
1264+
1265+
Using identity As WindowsIdentity = WindowsIdentity.GetCurrent()
1266+
Dim principal As WindowsPrincipal = New WindowsPrincipal(identity)
1267+
1268+
If principal.IsInRole(WindowsBuiltInRole.Administrator) Then
1269+
LogMsg("", MessageLevel.msgAlways, " ")
1270+
LogMsg("", MessageLevel.msgAlways, "***** CONFORM IS RUNNING WITH ADMIN PRIVILEGE!")
1271+
LogMsg("", MessageLevel.msgAlways, " ")
1272+
LogMsg("", MessageLevel.msgAlways, "***** This increases the risk that malicious individuals will target you and cause havoc in your life.")
1273+
LogMsg("", MessageLevel.msgAlways, "***** There is no need to run Conform with Admin privilege, the application is fully functional in normal user mode.")
1274+
LogMsg("", MessageLevel.msgAlways, "***** Please close the Remote Server and re-open it in normal user mode.")
1275+
LogMsg("", MessageLevel.msgAlways, " ")
1276+
Dim choice As DialogResult = MessageBox.Show("Close Conform because it is running as administrator.", "Threat Management", MessageBoxButtons.YesNo, MessageBoxIcon.[Stop], MessageBoxDefaultButton.Button1)
1277+
1278+
If choice = DialogResult.Yes Then
1279+
Close()
1280+
End If
1281+
End If
1282+
End Using
12621283
End Sub
12631284
Private Sub ConformMainForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
12641285
Const l_ButtonIndent As Integer = 115
@@ -1614,7 +1635,7 @@ Public Class FrmConformMain
16141635
End Sub
16151636
Private Function FindDriverExecutable() As String
16161637
FindDriverExecutable = FindDriverInRegistry(Registry.ClassesRoot)
1617-
If ASCOM.Utilities.ApplicationBits = Utilities.Bitness.Bits64 Then ' Check the 32bit registry on a 64bit system if we haven't found an executable yet
1638+
If Utilities.Global.ApplicationBits() = Utilities.Global.Bitness.Bits64 Then ' Check the 32bit registry on a 64bit system if we haven't found an executable yet
16181639
If String.IsNullOrEmpty(FindDriverExecutable) Then ' We are on a 64bit OS and haven't yet found an executable
16191640
LogMsg("FindDriverExecutable", MessageLevel.msgDebug, "We are a 64bit application and an executable has not yet been found, looking in 32bit registry")
16201641
'Using Reg As ASCOM.Utilities.RegistryAccess = New ASCOM.Utilities.RegistryAccess

0 commit comments

Comments
 (0)