From 7554c1e213d16d2dfff448bdc9dda06ec7f1f136 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Mon, 18 Nov 2024 20:21:10 +0000 Subject: [PATCH 01/11] Added an extra test to Slewing so that if connected will check with the mount to see if it's actually slewing, which is should have been doing --- .../TelescopeUnitTests.cs | 40 +++++++++++++++---- Meade.net.Telescope/Telescope.cs | 6 ++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 9648436..eb56508 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Reflection; using ASCOM; using ASCOM.Astrometry.AstroUtils; @@ -2940,13 +2942,15 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Slewing_WhenConnectedAndTelescopeFails_ThenReturnsFalse() { + _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(""); + ConnectTelescope(); var result = _telescope.Slewing; Assert.That(result, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(2)); } [Test] @@ -3033,7 +3037,24 @@ namespace Meade.net.Telescope.UnitTests [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)] public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing) { - _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(response); + List slewingResponses = new List(); + + if (isSlewing) + slewingResponses.Add("|"); + + slewingResponses.Add(response); + + var callCounter = 0; + + _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns( () => { + var slewingResult = slewingResponses[callCounter]; + callCounter++; + if (callCounter > slewingResponses.Count - 1) + { + callCounter = slewingResponses.Count - 1; + } + return slewingResult; + }); ConnectTelescope(productName, firmwareVersion); @@ -3041,7 +3062,10 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.EqualTo(isSlewing)); - _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Once); + if (isSlewing) + { + _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(1)); + } } [TestCase(1, TelescopeAxes.axisPrimary)] @@ -3267,7 +3291,7 @@ namespace Meade.net.Telescope.UnitTests { _sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, "MS", false)).Returns("0"); - var preTestItterations = 1; + var preTestItterations = 2; var slewCounter = 0; var iterations = 10; @@ -3359,7 +3383,7 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, "MS", false)).Returns("0"); - var preTestItterations = 1; + var preTestItterations = 2; var slewCounter = 0; var iterations = 10; _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(() => @@ -3482,7 +3506,7 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, "MS", false)).Returns("0"); - var preTestItterations = 1; + var preTestItterations = 2; var slewCounter = 0; var iterations = 10; _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(() => @@ -3583,6 +3607,8 @@ namespace Meade.net.Telescope.UnitTests [Test] public void AbortSlew_WhenConnected_ThenSendsStopSlewingToTelescope() { + _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, "D", false)).Returns(""); + ConnectTelescope(); _telescope.AbortSlew(); @@ -3592,7 +3618,7 @@ namespace Meade.net.Telescope.UnitTests var isSloSlewing = _telescope.Slewing; Assert.That(isSloSlewing, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(2)); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 988cd2f..ba9f9aa 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -2998,6 +2998,8 @@ namespace ASCOM.Meade.net throw new ASCOM.InvalidOperationException("Cannot start a slew whilst slew is in progress."); } + + switch (polar) { case true: @@ -3212,8 +3214,8 @@ namespace ASCOM.Meade.net { try { - var isSlewing = GetSlewing(); - + var isSlewing = GetSlewing() || (IsConnected && IsSlewingToTarget()); + if (isSlewing) SetSlewingMinEndTime(); else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime) From c2bc2cfc7ee7abbb193327aff42ffcbf3054fe86 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 26 Nov 2024 16:01:07 +0000 Subject: [PATCH 02/11] Added extra check to ensure that slewing is return true whilst executing one of the ascom slew commands. --- .../TelescopeUnitTests.cs | 12 +- Meade.net.Telescope/Telescope.cs | 167 ++++++++++-------- 2 files changed, 100 insertions(+), 79 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index eb56508..b19dda8 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -2950,7 +2950,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(2)); + _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(1)); } [Test] @@ -3317,8 +3317,6 @@ namespace Meade.net.Telescope.UnitTests _telescope.TargetDeclination = 1; _telescope.SlewToTarget(); - - _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations - preTestItterations)); } [Test] @@ -3402,8 +3400,6 @@ namespace Meade.net.Telescope.UnitTests Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.RightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult)); _sharedResourcesWrapperMock.Verify(x => x.SendChar(_traceLoggerMock.Object, "MS", false), Times.Once); - - _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations - preTestItterations)); } [Test] @@ -3526,7 +3522,6 @@ namespace Meade.net.Telescope.UnitTests Assert.That(_telescope.TargetRightAscension, Is.EqualTo(_testProperties.RightAscension)); Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.Declination)); _sharedResourcesWrapperMock.Verify(x => x.SendChar(_traceLoggerMock.Object, "MS", false), Times.Once); - _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations - preTestItterations)); } [Test] @@ -3615,10 +3610,9 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "Q", false), Times.Once); - var isSloSlewing = _telescope.Slewing; + var isSlewing = _telescope.Slewing; - Assert.That(isSloSlewing, Is.False); - _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, "D", false), Times.Exactly(2)); + Assert.That(isSlewing, Is.False); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index ba9f9aa..ba1ffcc 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -23,7 +23,7 @@ namespace ASCOM.Meade.net // Your driver's DeviceID is ASCOM.Meade.net.Telescope // // The Guid attribute sets the CLSID for ASCOM.Meade.net.Telescope - // The ClassInterface/None addribute prevents an empty interface called + // The ClassInterface/None attribute prevents an empty interface called // _Meade.net from being created and used as the [default] interface // // Replace the not implemented exceptions with code to implement the function or @@ -78,6 +78,11 @@ namespace ASCOM.Meade.net /// private int _digitsDe = 2; + /// + /// Used to make sure that the slewing property returns true when in the middle of an ascom slew command, anything above 0 means that we are inside slewing commands. + /// + private int _forceSlewingCount = 0; + /// /// Initializes a new instance of the class. /// Must be public for COM registration. @@ -2861,49 +2866,57 @@ namespace ASCOM.Meade.net public void SlewToAltAzAsync(double azimuth, double altitude, bool polar) { + _forceSlewingCount++; try { - CheckConnected("SlewToAltAzAsync"); - CheckParked(); - - if (altitude > 90) - throw new InvalidValueException("Altitude cannot be greater than 90."); - - if (altitude < 0) - throw new InvalidValueException("Altitude cannot be less than 0."); - - if (azimuth >= 360) - throw new InvalidValueException("Azimuth cannot be 360 or higher."); - - if (azimuth < 0) - throw new InvalidValueException("Azimuth cannot be less than 0."); - - LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude} polar={polar}"); - - if (polar) + try { - HorizonCoordinates altAz = new HorizonCoordinates { Azimuth = azimuth, Altitude = altitude }; + CheckConnected("SlewToAltAzAsync"); + CheckParked(); - var utcDateTime = UTCDate; - var latitude = SiteLatitude; - var longitude = SiteLongitude; - var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz); + if (altitude > 90) + throw new InvalidValueException("Altitude cannot be greater than 90."); - TargetRightAscension = raDec.RightAscension; - TargetDeclination = raDec.Declination; + if (altitude < 0) + throw new InvalidValueException("Altitude cannot be less than 0."); + + if (azimuth >= 360) + throw new InvalidValueException("Azimuth cannot be 360 or higher."); + + if (azimuth < 0) + throw new InvalidValueException("Azimuth cannot be less than 0."); + + LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude} polar={polar}"); + + if (polar) + { + HorizonCoordinates altAz = new HorizonCoordinates { Azimuth = azimuth, Altitude = altitude }; + + var utcDateTime = UTCDate; + var latitude = SiteLatitude; + var longitude = SiteLongitude; + var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz); + + TargetRightAscension = raDec.RightAscension; + TargetDeclination = raDec.Declination; + } + else + { + TargetAltitude = altitude; + TargetAzimuth = azimuth; + } + + DoSlewAsync(polar); } - else + catch (Exception ex) { - TargetAltitude = altitude; - TargetAzimuth = azimuth; + LogMessage("SlewToAltAzAsync", $"Error: {ex.Message}"); + throw; } - - DoSlewAsync(polar); } - catch (Exception ex) + finally { - LogMessage("SlewToAltAzAsync", $"Error: {ex.Message}"); - throw; + _forceSlewingCount--; } } @@ -2992,14 +3005,12 @@ namespace ASCOM.Meade.net LogMessage("DoSlewAsync", "Beginning slew sequence"); CheckConnected("DoSlewAsync"); CheckParked(); - if (Slewing) + if (GetSlewing(true)) { LogMessage("DoSlewAsync", "Cannot start a slew whilst slew is in progress."); throw new ASCOM.InvalidOperationException("Cannot start a slew whilst slew is in progress."); } - - switch (polar) { case true: @@ -3133,22 +3144,30 @@ namespace ASCOM.Meade.net public void SlewToCoordinatesAsync(double rightAscension, double declination) { + _forceSlewingCount++; try { - LogMessage("SlewToCoordinatesAsync", $"Ra={rightAscension}, Dec={declination}"); - CheckConnected("SlewToCoordinatesAsync"); - CheckParked(); + try + { + LogMessage("SlewToCoordinatesAsync", $"Ra={rightAscension}, Dec={declination}"); + CheckConnected("SlewToCoordinatesAsync"); + CheckParked(); - TargetRightAscension = rightAscension; - TargetDeclination = declination; - DoSlewAsync(true); + TargetRightAscension = rightAscension; + TargetDeclination = declination; + DoSlewAsync(true); - LogMessage("SlewToCoordinatesAsync", $"Completed Ra={rightAscension}, Dec={declination}"); + LogMessage("SlewToCoordinatesAsync", $"Completed Ra={rightAscension}, Dec={declination}"); + } + catch (Exception ex) + { + LogMessage("SlewToCoordinatesAsync", $"Error: {ex.Message}"); + throw; + } } - catch (Exception ex) + finally { - LogMessage("SlewToCoordinatesAsync", $"Error: {ex.Message}"); - throw; + _forceSlewingCount--; } } @@ -3177,20 +3196,28 @@ namespace ASCOM.Meade.net public void SlewToTargetAsync() { + _forceSlewingCount++; try { - CheckConnected("SlewToTargetAsync"); - CheckParked(); + try + { + CheckConnected("SlewToTargetAsync"); + CheckParked(); - if (TargetDeclination.Equals(InvalidParameter) || TargetRightAscension.Equals(InvalidParameter)) - throw new InvalidOperationException("No target selected to slew to."); + if (TargetDeclination.Equals(InvalidParameter) || TargetRightAscension.Equals(InvalidParameter)) + throw new InvalidOperationException("No target selected to slew to."); - DoSlewAsync(true); + DoSlewAsync(true); + } + catch (Exception ex) + { + LogMessage("SlewToTargetAsync", $"Error: {ex.Message}"); + throw; + } } - catch (Exception ex) + finally { - LogMessage("SlewToTargetAsync", $"Error: {ex.Message}"); - throw; + _forceSlewingCount--; } } @@ -3214,12 +3241,7 @@ namespace ASCOM.Meade.net { try { - var isSlewing = GetSlewing() || (IsConnected && IsSlewingToTarget()); - - if (isSlewing) - SetSlewingMinEndTime(); - else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime) - isSlewing = true; + var isSlewing = GetSlewing(false); LogMessage("Slewing", $"Result = {isSlewing}"); return isSlewing; @@ -3242,19 +3264,24 @@ namespace ASCOM.Meade.net return TimeSpan.FromSeconds( SlewSettleTime + _profileProperties.SettleTime ); } - private bool GetSlewing() + private bool GetSlewing(bool isInternalCall) { var result = false; try { if (Connected) - result = MovingAxis() || IsSlewingToTarget(); + result = (!isInternalCall && _forceSlewingCount > 0) || MovingAxis() || IsSlewingToTarget(); } finally { LogMessage("GetSlewing", $"Result = {result}"); } + if (result) + SetSlewingMinEndTime(); + else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime) + result = true; + return result; } @@ -3809,18 +3836,18 @@ namespace ASCOM.Meade.net UtcCorrection = GetUtcCorrection() }; - int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger(); - int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger(); - int year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger(); + var month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger(); + var day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger(); + var year = telescopeDateDetails.TelescopeDate.Substring(6, 2).ToInteger(); if (year < 2000) //todo fix this hack that will create a Y2K100 bug { - year = year + 2000; + year += 2000; } - int hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger(); - int minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger(); - int second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger(); + var hour = telescopeDateDetails.TelescopeTime.Substring(0, 2).ToInteger(); + var minute = telescopeDateDetails.TelescopeTime.Substring(3, 2).ToInteger(); + var second = telescopeDateDetails.TelescopeTime.Substring(6, 2).ToInteger(); var utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc) + telescopeDateDetails.UtcCorrection; From cd6e72eb0a82270655995d3ce6a94cd4475d66c5 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Wed, 27 Nov 2024 22:12:27 +0000 Subject: [PATCH 03/11] Tweaked the GetSlewing command hopefully this makes the logic function correctly. Also upgraded the logging to expose whether it's an internal call or not. --- Meade.net.Telescope/Telescope.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index ba1ffcc..0c1b6ce 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -3270,11 +3270,18 @@ namespace ASCOM.Meade.net try { if (Connected) - result = (!isInternalCall && _forceSlewingCount > 0) || MovingAxis() || IsSlewingToTarget(); + { + if (!isInternalCall) + { + result = _forceSlewingCount > 0; + } + + result = result || MovingAxis() || IsSlewingToTarget(); + } } finally { - LogMessage("GetSlewing", $"Result = {result}"); + LogMessage("GetSlewing", $"Result = {result} (isInternalCall = {isInternalCall}"); } if (result) From 4ef80b448eab26dd284e8e74e5048b35bda33082 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sat, 30 Nov 2024 18:18:16 +0000 Subject: [PATCH 04/11] Another slight tweak to the GetSlewing internal call code. --- Meade.net.Telescope/Telescope.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 0c1b6ce..af45199 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -3281,13 +3281,16 @@ namespace ASCOM.Meade.net } finally { - LogMessage("GetSlewing", $"Result = {result} (isInternalCall = {isInternalCall}"); + LogMessage("GetSlewing", $"Result = {result} (isInternalCall = {isInternalCall})"); } if (result) SetSlewingMinEndTime(); - else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime) + else if (_clock.UtcNow < SharedResourcesWrapper.EarliestNonSlewingTime && !isInternalCall) + { + LogMessage("GetSlewing", $"Last slewing operation has not yet completed. You need to wait for another {(_clock.UtcNow - SharedResourcesWrapper.EarliestNonSlewingTime).TotalMilliseconds} Milliseconds"); result = true; + } return result; } From 0afb80bd706e2d10174ad8b3b10033c2952c33a0 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sun, 1 Dec 2024 22:42:19 +0000 Subject: [PATCH 05/11] Fixed problem where the telescope area was in mm when it should be mm squared. And the driver was incorrect by a factor of 1000. --- Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs | 4 +++- Meade.net.Telescope/Telescope.cs | 2 +- Meade.net/SetupDialogForm.cs | 5 +++++ Meade.net/SetupDialogForm.designer.cs | 1 + Meade.net/SetupDialogForm.resx | 6 +++--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index b19dda8..5da6cd2 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -845,9 +845,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void ApertureArea_Get_ReturnsExpectedResult() { + _profileProperties.ApertureArea = 130674; + var result = _telescope.ApertureArea; - Assert.That(result, Is.EqualTo(_profileProperties.ApertureArea / 1000)); + Assert.That(result, Is.EqualTo(_profileProperties.ApertureArea / (1000*1000))); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index af45199..ae71f22 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1355,7 +1355,7 @@ namespace ASCOM.Meade.net { get { - var apertureArea = _profileProperties.ApertureArea / 1000; + var apertureArea = _profileProperties.ApertureArea / (1000*1000); LogMessage("ApertureArea Get", $"{apertureArea}"); return apertureArea; } diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index d41d3f9..cee869f 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -388,6 +388,11 @@ namespace ASCOM.Meade.net Verb = "open" }); } + + private void label29_Click(object sender, EventArgs e) + { + + } } } diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index 182c198..b41ea01 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -434,6 +434,7 @@ namespace ASCOM.Meade.net // resources.ApplyResources(this.label29, "label29"); this.label29.Name = "label29"; + this.label29.Click += new System.EventHandler(this.label29_Click); // // txtApertureArea // diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index c64acf9..d432837 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -1579,13 +1579,13 @@ 494, 139 - 23, 13 + 26, 13 56 - mm + mm² label29 @@ -1678,7 +1678,7 @@ True - 25 + 232 6, 13 From 431776cfdf343693b364450a4b36120c36a3e99e Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sun, 15 Dec 2024 21:45:19 +0000 Subject: [PATCH 06/11] Adding more information to the tracelog for get slewing --- Meade.net.Telescope/Telescope.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index ae71f22..656ea43 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -3281,7 +3281,7 @@ namespace ASCOM.Meade.net } finally { - LogMessage("GetSlewing", $"Result = {result} (isInternalCall = {isInternalCall})"); + LogMessage("GetSlewing", $"Result = {result} (isInternalCall = {isInternalCall} _forceSlewingCount= {_forceSlewingCount})"); } if (result) From 6aa19b869bbb18d24b78aa0c2e490b814df469f8 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 24 Dec 2024 17:00:03 +0000 Subject: [PATCH 07/11] Tweaked the code so that the _forceInternal variable doesn't care about if the scope is connected or not. --- Meade.net.Telescope/Telescope.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 656ea43..427a1bd 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -3267,15 +3267,16 @@ namespace ASCOM.Meade.net private bool GetSlewing(bool isInternalCall) { var result = false; + + if (!isInternalCall) + { + result = _forceSlewingCount > 0; + } + try { if (Connected) { - if (!isInternalCall) - { - result = _forceSlewingCount > 0; - } - result = result || MovingAxis() || IsSlewingToTarget(); } } From 056484bce95e725fdfc4f3018c388f70081c5289 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 24 Dec 2024 17:25:18 +0000 Subject: [PATCH 08/11] Modified the code again, so that the _forceSlewingCount is done last, so that it's at up to date as possible. --- Meade.net.Telescope/Telescope.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 427a1bd..d3b849b 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -3267,17 +3267,16 @@ namespace ASCOM.Meade.net private bool GetSlewing(bool isInternalCall) { var result = false; - - if (!isInternalCall) - { - result = _forceSlewingCount > 0; - } - + try { if (Connected) { - result = result || MovingAxis() || IsSlewingToTarget(); + result = MovingAxis() || IsSlewingToTarget(); + if (!isInternalCall && !result) + { + result = _forceSlewingCount > 0; + } } } finally From e7e216597aa8c4258ec868c1bc90b27504268d97 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Wed, 1 Jan 2025 17:19:34 +0000 Subject: [PATCH 09/11] Changing the recieve timeout to 30 seconds, as a test --- Meade.net.Telescope/Telescope.cs | 4 ++++ Meade.net/SharedResources.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index d3b849b..6d5442e 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -4043,7 +4043,9 @@ namespace ASCOM.Meade.net /// This technique should mean that it is never necessary to manually register a driver with ASCOM. /// [ComRegisterFunction] +#pragma warning disable IDE0060 // Remove unused parameter public static void RegisterAscom(Type t) +#pragma warning restore IDE0060 // Remove unused parameter { RegUnregAscom(true); } @@ -4066,7 +4068,9 @@ namespace ASCOM.Meade.net /// This technique should mean that it is never necessary to manually unregister a driver from ASCOM. /// [ComUnregisterFunction] +#pragma warning disable IDE0060 // Remove unused parameter public static void UnregisterAscom(Type t) +#pragma warning restore IDE0060 // Remove unused parameter { RegUnregAscom(false); } diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 03fcf3d..38467a9 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -8,7 +8,7 @@ // // NOTES: // -// * ALL DECLARATIONS MUST BE STATIC HERE!! INSTANCES OF THIS CLASS MUST NEVER BE CREATED! +// * ALL DECLARATIONS MUST BE STATIC HERE!! INSTANCES OF THIS CLASS MUST NEVER BE CREATEDReceiveTimeout // // Written by: Bob Denny 29-May-2007 // Modified by Chris Rowland and Peter Simpson to hamdle multiple hardware devices March 2011 @@ -401,7 +401,7 @@ namespace ASCOM.Meade.net SharedSerial.StopBits = (SerialStopBits)Enum.Parse(typeof(SerialStopBits), profileProperties.StopBits); SharedSerial.Parity = (SerialParity)Enum.Parse(typeof(SerialParity), profileProperties.Parity); SharedSerial.Handshake = (SerialHandshake)Enum.Parse(typeof(SerialHandshake), profileProperties.Handshake); - SharedSerial.ReceiveTimeout = 5; //5 second timeout; + SharedSerial.ReceiveTimeout = 30; //30 second timeout; SharedSerial.Speed = SerialSpeed.ps9600; var wantedSpeed = (SerialSpeed)profileProperties.Speed; From a81318f4b5cd93afedabe840e2deb39e96356c1b Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 7 Jan 2025 15:49:51 +0000 Subject: [PATCH 10/11] Adding error trap so that the display prompts can be bypassed if it doesn't work, will still try to set the date and time. --- Meade.net.Telescope/Telescope.cs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 6d5442e..6ab350c 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -686,19 +686,26 @@ namespace ASCOM.Meade.net } default: { - var i = 10; - while (i > 0) + try { - var displayText = Action("Handbox", "readdisplay"); - if (displayText.Contains("Align:")) + var i = 10; + while (i > 0) { - i = 0; - continue; - } + var displayText = Action("Handbox", "readdisplay"); + if (displayText.Contains("Align:")) + { + i = 0; + continue; + } - Action("Handbox", "mode"); - _utilities.WaitForMilliseconds(500); - i--; + Action("Handbox", "mode"); + _utilities.WaitForMilliseconds(500); + i--; + } + } + catch (TimeoutException e) + { + LogMessage("ApplySkipAutoStarPrompts","Timed out bypassing the date time prompts. Skipping."); } break; From 8521b3e2d2eb23c41414bcd7367210ae2532d480 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Wed, 8 Jan 2025 16:13:46 +0000 Subject: [PATCH 11/11] Added ability to override the 5 second serial timeout with your own value. --- Meade.net/ProfileProperties.cs | 1 + Meade.net/SetupDialogForm.cs | 10 + Meade.net/SetupDialogForm.designer.cs | 24 + Meade.net/SetupDialogForm.resx | 624 ++++++++++++++++++-------- Meade.net/SharedResources.cs | 6 +- 5 files changed, 484 insertions(+), 181 deletions(-) diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 6a3833d..48b6ade 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -26,5 +26,6 @@ namespace ASCOM.Meade.net public double FocalLength { get; set; } public double ApertureArea { get; set; } public double ApertureDiameter { get; set; } + public int TimeoutMs { get; set; } } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index cee869f..f06d4bc 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -232,6 +232,15 @@ namespace ASCOM.Meade.net txtApertureDiameter.Text = "203"; } + try + { + txtTimeout.Text = profileProperties.TimeoutMs.ToString(CultureInfo.CurrentCulture); + } + catch (Exception) + { + txtTimeout.Text = "5000"; + } + UpdateParkedItemsEnabled(); } @@ -241,6 +250,7 @@ namespace ASCOM.Meade.net { TraceLogger = chkTrace.Checked, ComPort = comboBoxComPort.SelectedItem.ToString(), + TimeoutMs = Convert.ToInt32(txtTimeout.Text), RtsDtrEnabled = cbxRtsDtr.Checked, DataBits = Convert.ToInt32(numDatabits.Value), StopBits = cboStopBits.SelectedItem.ToString(), diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index b41ea01..8cb72ce 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -92,6 +92,9 @@ namespace ASCOM.Meade.net this.txtApertureArea = new System.Windows.Forms.TextBox(); this.label30 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); + this.txtTimeout = new System.Windows.Forms.TextBox(); + this.label31 = new System.Windows.Forms.Label(); + this.label32 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); @@ -453,10 +456,28 @@ namespace ASCOM.Meade.net this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // + // txtTimeout + // + resources.ApplyResources(this.txtTimeout, "txtTimeout"); + this.txtTimeout.Name = "txtTimeout"; + // + // label31 + // + resources.ApplyResources(this.label31, "label31"); + this.label31.Name = "label31"; + // + // label32 + // + resources.ApplyResources(this.label32, "label32"); + this.label32.Name = "label32"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label32); + this.Controls.Add(this.label31); + this.Controls.Add(this.txtTimeout); this.Controls.Add(this.button1); this.Controls.Add(this.label29); this.Controls.Add(this.txtApertureArea); @@ -591,5 +612,8 @@ namespace ASCOM.Meade.net private TextBox txtApertureArea; private Label label30; private Button button1; + private TextBox txtTimeout; + private Label label31; + private Label label32; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index d432837..7de4d69 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -123,10 +123,13 @@ - 765, 391 + 1148, 602 + + + 4, 5, 4, 5 - 59, 24 + 88, 37 @@ -145,16 +148,19 @@ $this - 57 + 60 Bottom, Right - 765, 421 + 1148, 648 + + + 4, 5, 4, 5 - 59, 25 + 88, 38 1 @@ -172,13 +178,16 @@ $this - 56 + 59 - 12, 9 + 18, 14 + + + 4, 0, 4, 0 - 274, 31 + 411, 48 2 @@ -196,13 +205,16 @@ $this - 55 + 58 Top, Right - 776, 9 + 1164, 14 + + + 4, 5, 4, 5 48, 56 @@ -223,16 +235,19 @@ $this - 54 + 57 True - 12, 90 + 18, 138 + + + 4, 0, 4, 0 - 58, 13 + 88, 20 5 @@ -250,16 +265,19 @@ $this - 53 + 56 True - 97, 380 + 146, 585 + + + 4, 5, 4, 5 - 90, 17 + 128, 24 2 @@ -277,13 +295,16 @@ $this - 52 + 55 - 97, 87 + 146, 134 + + + 4, 5, 4, 5 - 90, 21 + 133, 28 0 @@ -298,16 +319,19 @@ $this - 51 + 54 True - 290, 262 + 435, 403 + + + 4, 0, 4, 0 - 61, 13 + 91, 20 8 @@ -325,16 +349,16 @@ $this - 50 + 53 - - 17, 17 - - 388, 259 + 582, 398 + + + 4, 5, 4, 5 - 46, 20 + 67, 26 3 @@ -342,6 +366,9 @@ 10.0 + + 17, 17 + LX-200GPS only @@ -355,16 +382,19 @@ $this - 49 + 52 True - 440, 262 + 660, 403 + + + 4, 0, 4, 0 - 122, 13 + 180, 20 10 @@ -382,16 +412,19 @@ $this - 48 + 51 True - 440, 275 + 660, 423 + + + 4, 0, 4, 0 - 105, 13 + 160, 20 11 @@ -409,16 +442,19 @@ $this - 47 + 50 True - 290, 294 + 435, 452 + + + 4, 0, 4, 0 - 50, 13 + 73, 20 12 @@ -436,7 +472,7 @@ $this - 46 + 49 Unchanged @@ -448,10 +484,13 @@ High - 388, 291 + 582, 448 + + + 4, 5, 4, 5 - 90, 21 + 133, 28 4 @@ -466,7 +505,7 @@ $this - 45 + 48 True @@ -475,10 +514,13 @@ NoControl - 290, 321 + 435, 494 + + + 4, 0, 4, 0 - 67, 13 + 100, 20 14 @@ -496,7 +538,7 @@ $this - 44 + 47 Auto @@ -508,10 +550,13 @@ Pulse guiding - 388, 318 + 582, 489 + + + 4, 5, 4, 5 - 90, 21 + 133, 28 5 @@ -526,7 +571,7 @@ $this - 43 + 46 True @@ -535,10 +580,13 @@ Microsoft Sans Serif, 8.25pt, style=Bold - 290, 67 + 435, 103 + + + 4, 0, 4, 0 - 66, 13 + 95, 20 16 @@ -556,7 +604,7 @@ $this - 42 + 45 True @@ -568,10 +616,13 @@ NoControl - 290, 359 + 435, 552 + + + 4, 0, 4, 0 - 52, 13 + 77, 20 17 @@ -589,13 +640,16 @@ $this - 41 + 44 - 388, 377 + 582, 580 + + + 4, 5, 4, 5 - 46, 20 + 67, 26 6 @@ -613,7 +667,7 @@ $this - 39 + 42 True @@ -622,10 +676,13 @@ NoControl - 290, 380 + 435, 585 + + + 4, 0, 4, 0 - 79, 13 + 117, 20 18 @@ -643,7 +700,7 @@ $this - 40 + 43 True @@ -652,10 +709,13 @@ NoControl - 440, 380 + 660, 585 + + + 4, 0, 4, 0 - 20, 13 + 30, 20 20 @@ -673,7 +733,7 @@ $this - 38 + 41 True @@ -685,10 +745,13 @@ NoControl - 12, 67 + 18, 103 + + + 4, 0, 4, 0 - 71, 13 + 103, 20 21 @@ -706,16 +769,19 @@ $this - 37 + 40 True - 388, 403 + 582, 620 + + + 4, 5, 4, 5 - 109, 17 + 158, 24 7 @@ -733,16 +799,19 @@ $this - 36 + 39 True - 388, 426 + 582, 655 + + + 4, 5, 4, 5 - 112, 17 + 163, 24 8 @@ -760,7 +829,7 @@ $this - 35 + 38 True @@ -769,10 +838,13 @@ NoControl - 97, 114 + 146, 175 + + + 4, 5, 4, 5 - 112, 17 + 158, 24 1 @@ -793,11 +865,8 @@ $this - 34 + 37 - - 17, 17 - True @@ -805,10 +874,13 @@ NoControl - 671, 96 + 1006, 148 + + + 4, 5, 4, 5 - 145, 17 + 215, 24 41 @@ -829,16 +901,19 @@ $this - 16 + 19 True - 290, 189 + 435, 291 + + + 4, 0, 4, 0 - 72, 13 + 106, 20 22 @@ -856,13 +931,16 @@ $this - 33 + 36 - 388, 186 + 582, 286 + + + 4, 5, 4, 5 - 100, 20 + 148, 26 23 @@ -877,16 +955,19 @@ $this - 32 + 35 True - 494, 189 + 741, 291 + + + 4, 0, 4, 0 - 38, 13 + 58, 20 24 @@ -904,16 +985,19 @@ $this - 31 + 34 True - 290, 220 + 435, 338 + + + 4, 0, 4, 0 - 56, 13 + 85, 20 25 @@ -931,13 +1015,16 @@ $this - 30 + 33 - 388, 218 + 582, 335 + + + 4, 5, 4, 5 - 120, 20 + 180, 26 26 @@ -952,16 +1039,19 @@ $this - 29 + 32 True - 514, 220 + 771, 338 + + + 4, 0, 4, 0 - 47, 13 + 69, 20 27 @@ -979,16 +1069,19 @@ $this - 28 + 31 True - 15, 139 + 22, 214 + + + 4, 0, 4, 0 - 49, 13 + 73, 20 29 @@ -1006,13 +1099,16 @@ $this - 27 + 30 - 97, 163 + 146, 251 + + + 4, 5, 4, 5 - 119, 21 + 176, 28 30 @@ -1027,13 +1123,16 @@ $this - 26 + 29 - 97, 137 + 146, 211 + + + 4, 5, 4, 5 - 120, 20 + 180, 26 31 @@ -1048,13 +1147,16 @@ $this - 25 + 28 - 97, 190 + 146, 292 + + + 4, 5, 4, 5 - 119, 21 + 176, 28 32 @@ -1069,13 +1171,16 @@ $this - 24 + 27 - 97, 217 + 146, 334 + + + 4, 5, 4, 5 - 119, 21 + 176, 28 33 @@ -1090,13 +1195,16 @@ $this - 23 + 26 - 97, 244 + 146, 375 + + + 4, 5, 4, 5 - 121, 21 + 180, 28 34 @@ -1111,16 +1219,19 @@ $this - 22 + 25 True - 15, 166 + 22, 255 + + + 4, 0, 4, 0 - 49, 13 + 74, 20 35 @@ -1138,16 +1249,19 @@ $this - 21 + 24 True - 15, 193 + 22, 297 + + + 4, 0, 4, 0 - 33, 13 + 48, 20 36 @@ -1165,16 +1279,19 @@ $this - 20 + 23 True - 15, 220 + 22, 338 + + + 4, 0, 4, 0 - 38, 13 + 56, 20 37 @@ -1192,16 +1309,19 @@ $this - 19 + 22 True - 15, 247 + 22, 380 + + + 4, 0, 4, 0 - 62, 13 + 91, 20 38 @@ -1219,7 +1339,7 @@ $this - 18 + 21 True @@ -1231,10 +1351,13 @@ NoControl - 15, 359 + 22, 552 + + + 4, 0, 4, 0 - 73, 13 + 109, 20 39 @@ -1252,7 +1375,7 @@ $this - 17 + 20 No Coordinates @@ -1264,10 +1387,13 @@ Report coordinates as - 671, 124 + 1006, 191 + + + 4, 5, 4, 5 - 126, 21 + 187, 28 42 @@ -1282,16 +1408,19 @@ $this - 15 + 18 True - 574, 127 + 861, 195 + + + 4, 0, 4, 0 - 91, 13 + 132, 20 43 @@ -1309,16 +1438,19 @@ $this - 14 + 17 True - 668, 154 + 1002, 237 + + + 4, 0, 4, 0 - 19, 13 + 28, 20 44 @@ -1336,16 +1468,19 @@ $this - 13 + 16 True - 668, 180 + 1002, 277 + + + 4, 0, 4, 0 - 19, 13 + 28, 20 45 @@ -1363,13 +1498,16 @@ $this - 12 + 15 - 697, 151 + 1046, 232 + + + 4, 5, 4, 5 - 100, 20 + 148, 26 46 @@ -1384,13 +1522,16 @@ $this - 11 + 14 - 697, 177 + 1046, 272 + + + 4, 5, 4, 5 - 100, 20 + 148, 26 47 @@ -1405,7 +1546,7 @@ $this - 10 + 13 True @@ -1414,10 +1555,13 @@ NoControl - 290, 90 + 435, 138 + + + 4, 0, 4, 0 - 69, 13 + 102, 20 48 @@ -1435,13 +1579,16 @@ $this - 9 + 12 - 388, 87 + 582, 134 + + + 4, 5, 4, 5 - 100, 20 + 148, 26 49 @@ -1456,7 +1603,7 @@ $this - 8 + 11 True @@ -1465,10 +1612,13 @@ NoControl - 494, 90 + 741, 138 + + + 4, 0, 4, 0 - 23, 13 + 35, 20 50 @@ -1486,7 +1636,7 @@ $this - 7 + 10 True @@ -1495,10 +1645,13 @@ NoControl - 494, 114 + 741, 175 + + + 4, 0, 4, 0 - 23, 13 + 35, 20 53 @@ -1516,13 +1669,16 @@ $this - 4 + 7 - 388, 111 + 582, 171 + + + 4, 5, 4, 5 - 100, 20 + 148, 26 52 @@ -1537,7 +1693,7 @@ $this - 5 + 8 True @@ -1546,10 +1702,13 @@ NoControl - 290, 114 + 435, 175 + + + 4, 0, 4, 0 - 92, 13 + 140, 20 51 @@ -1567,7 +1726,7 @@ $this - 6 + 9 True @@ -1576,10 +1735,13 @@ NoControl - 494, 139 + 741, 214 + + + 4, 0, 4, 0 - 26, 13 + 40, 20 56 @@ -1597,13 +1759,16 @@ $this - 1 + 4 - 388, 136 + 582, 209 + + + 4, 5, 4, 5 - 100, 20 + 148, 26 55 @@ -1618,7 +1783,7 @@ $this - 2 + 5 True @@ -1627,10 +1792,13 @@ NoControl - 290, 139 + 435, 214 + + + 4, 0, 4, 0 - 72, 13 + 109, 20 54 @@ -1648,13 +1816,16 @@ $this - 3 + 6 - 112, 399 + 168, 614 + + + 4, 5, 4, 5 - 75, 23 + 112, 35 57 @@ -1672,6 +1843,96 @@ $this + 3 + + + 146, 423 + + + 4, 5, 4, 5 + + + 148, 26 + + + 35 + + + txtTimeout + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + NoControl + + + 22, 423 + + + 4, 0, 4, 0 + + + 110, 20 + + + 58 + + + Serial Timeout + + + label31 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + NoControl + + + 302, 426 + + + 4, 0, 4, 0 + + + 30, 20 + + + 59 + + + ms + + + label32 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -1681,10 +1942,13 @@ 232 - 6, 13 + 9, 20 - 834, 454 + 1251, 698 + + + 4, 5, 4, 5 CenterScreen diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 38467a9..6a403e1 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -189,6 +189,7 @@ namespace ASCOM.Meade.net // Constants used for Profile persistence private const string ComPortProfileName = "COM Port"; + private const string TimeoutMsName = "Serial Timeout (MS)"; private const string RtsDtrProfileName = "Rts / Dtr"; private const string TraceStateProfileName = "Trace Level"; private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; @@ -222,6 +223,7 @@ namespace ASCOM.Meade.net driverProfile.DeviceType = "Telescope"; driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); + driverProfile.WriteValue(DriverId, TimeoutMsName, profileProperties.TimeoutMs.ToString()); driverProfile.WriteValue(DriverId, RtsDtrProfileName, profileProperties.RtsDtrEnabled.ToString()); driverProfile.WriteValue(DriverId, SpeedName, profileProperties.Speed.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, DataBitsName, profileProperties.DataBits.ToString(CultureInfo.InvariantCulture)); @@ -248,6 +250,7 @@ namespace ASCOM.Meade.net } private const string ComPortDefault = "COM1"; + private const string TimeoutMsDefault = "5000"; private const string RtsDtrDefault = "false"; private const string TraceStateDefault = "false"; private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate @@ -280,6 +283,7 @@ namespace ASCOM.Meade.net { driverProfile.DeviceType = "Telescope"; profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault); + profileProperties.TimeoutMs = Convert.ToInt32(driverProfile.GetValue(DriverId, TimeoutMsName, string.Empty, TimeoutMsDefault)); profileProperties.RtsDtrEnabled = Convert.ToBoolean(driverProfile.GetValue(DriverId, RtsDtrProfileName, string.Empty, RtsDtrDefault)); profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault)); profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault), NumberFormatInfo.InvariantInfo); @@ -401,7 +405,7 @@ namespace ASCOM.Meade.net SharedSerial.StopBits = (SerialStopBits)Enum.Parse(typeof(SerialStopBits), profileProperties.StopBits); SharedSerial.Parity = (SerialParity)Enum.Parse(typeof(SerialParity), profileProperties.Parity); SharedSerial.Handshake = (SerialHandshake)Enum.Parse(typeof(SerialHandshake), profileProperties.Handshake); - SharedSerial.ReceiveTimeout = 30; //30 second timeout; + SharedSerial.ReceiveTimeoutMs = profileProperties.TimeoutMs; SharedSerial.Speed = SerialSpeed.ps9600; var wantedSpeed = (SerialSpeed)profileProperties.Speed;