From 56642267b0bb7e3d7fb18b879913954638605188 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Mon, 17 Feb 2025 15:37:40 +0000 Subject: [PATCH 1/6] Altered the profile read exception handling a little. --- Meade.net/Meade.net.csproj | 1 + Meade.net/SharedResources.cs | 34 ++++++------- Meade.net/Wrapper/GetValueException.cs | 28 +++++++++++ Meade.net/Wrapper/IProfileWrapper.cs | 68 +++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 Meade.net/Wrapper/GetValueException.cs diff --git a/Meade.net/Meade.net.csproj b/Meade.net/Meade.net.csproj index 25ad3a8..fca6d92 100644 --- a/Meade.net/Meade.net.csproj +++ b/Meade.net/Meade.net.csproj @@ -148,6 +148,7 @@ + diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 6a403e1..3544a53 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -283,30 +283,30 @@ 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); + profileProperties.TimeoutMs = driverProfile.GetValueInt(DriverId, TimeoutMsName, string.Empty, TimeoutMsDefault); + profileProperties.RtsDtrEnabled = driverProfile.GetValueBool(DriverId, RtsDtrProfileName, string.Empty, RtsDtrDefault); + profileProperties.TraceLogger = driverProfile.GetValueBool(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault); + profileProperties.GuideRateArcSecondsPerSecond = driverProfile.GetValueDouble(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault); profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault); profileProperties.GuidingStyle = driverProfile.GetValue(DriverId, GuidingStyleProfileName, string.Empty, GuidingStyleDefault); - profileProperties.BacklashCompensation = Convert.ToInt32(driverProfile.GetValue(DriverId, BacklashCompensationName, string.Empty, BacklashCompensationDefault)); - profileProperties.ReverseFocusDirection = Convert.ToBoolean(driverProfile.GetValue(DriverId, ReverseFocusDirectionName, string.Empty, ReverseFocuserDiectionDefault)); - profileProperties.DynamicBreaking = Convert.ToBoolean(driverProfile.GetValue(DriverId, DynamicBreakingName, string.Empty, DynamicBreakingDefault)); - profileProperties.SiteElevation = Convert.ToInt32(driverProfile.GetValue(DriverId, SiteElevationName, string.Empty, SiteElevationDefault)); - profileProperties.SettleTime = Convert.ToInt16(driverProfile.GetValue(DriverId, SettleTimeName, string.Empty, SettleTimeDefault)); + profileProperties.BacklashCompensation = driverProfile.GetValueInt(DriverId, BacklashCompensationName, string.Empty, BacklashCompensationDefault); + profileProperties.ReverseFocusDirection = driverProfile.GetValueBool(DriverId, ReverseFocusDirectionName, string.Empty, ReverseFocuserDiectionDefault); + profileProperties.DynamicBreaking = driverProfile.GetValueBool(DriverId, DynamicBreakingName, string.Empty, DynamicBreakingDefault); + profileProperties.SiteElevation = driverProfile.GetValueInt(DriverId, SiteElevationName, string.Empty, SiteElevationDefault); + profileProperties.SettleTime = driverProfile.GetValueShort(DriverId, SettleTimeName, string.Empty, SettleTimeDefault); profileProperties.StopBits = driverProfile.GetValue(DriverId, StopBitsName, string.Empty, StopBitsDefault); - profileProperties.DataBits = Convert.ToInt32(driverProfile.GetValue(DriverId, DataBitsName, string.Empty, DataBitsDefault)); + profileProperties.DataBits = driverProfile.GetValueInt(DriverId, DataBitsName, string.Empty, DataBitsDefault); profileProperties.Handshake = driverProfile.GetValue(DriverId, HandShakeName, string.Empty, HandShakeDefault); - profileProperties.Speed = Convert.ToInt32(driverProfile.GetValue(DriverId, SpeedName, string.Empty, SpeedDefault)); + profileProperties.Speed = driverProfile.GetValueInt(DriverId, SpeedName, string.Empty, SpeedDefault); profileProperties.Parity = driverProfile.GetValue(DriverId, ParityName, string.Empty, ParityDefault); - profileProperties.SendDateTime = Convert.ToBoolean(driverProfile.GetValue(DriverId, SendDateTimeName, string.Empty, SendDateTimeDefault)); + profileProperties.SendDateTime = driverProfile.GetValueBool(DriverId, SendDateTimeName, string.Empty, SendDateTimeDefault); profileProperties.ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription(driverProfile.GetValue(DriverId, ParkedBehaviourName, string.Empty, ParkedBehaviourDefault)); - profileProperties.ParkedAlt = double.Parse(driverProfile.GetValue(DriverId, ParkedAltName, string.Empty, ParkedAltDefault), NumberFormatInfo.InvariantInfo); - profileProperties.ParkedAz = double.Parse(driverProfile.GetValue(DriverId, ParkedAzimuthName, string.Empty, ParkedAzimuthDefault), NumberFormatInfo.InvariantInfo); - profileProperties.FocalLength = double.Parse(driverProfile.GetValue(DriverId, FocalLengthName, string.Empty, FocalLengthDefault), NumberFormatInfo.InvariantInfo); - profileProperties.ApertureArea = double.Parse(driverProfile.GetValue(DriverId, ApertureAreaName, string.Empty, ApertureAreaDefault), NumberFormatInfo.InvariantInfo); - profileProperties.ApertureDiameter = double.Parse(driverProfile.GetValue(DriverId, ApertureDiameterName, string.Empty, ApertureDiameterDefault), NumberFormatInfo.InvariantInfo); + profileProperties.ParkedAlt = driverProfile.GetValueDouble(DriverId, ParkedAltName, string.Empty, ParkedAltDefault); + profileProperties.ParkedAz = driverProfile.GetValueDouble(DriverId, ParkedAzimuthName, string.Empty, ParkedAzimuthDefault); + profileProperties.FocalLength = driverProfile.GetValueDouble(DriverId, FocalLengthName, string.Empty, FocalLengthDefault); + profileProperties.ApertureArea = driverProfile.GetValueDouble(DriverId, ApertureAreaName, string.Empty, ApertureAreaDefault); + profileProperties.ApertureDiameter = driverProfile.GetValueDouble(DriverId, ApertureDiameterName, string.Empty, ApertureDiameterDefault); } return profileProperties; diff --git a/Meade.net/Wrapper/GetValueException.cs b/Meade.net/Wrapper/GetValueException.cs new file mode 100644 index 0000000..ea1175c --- /dev/null +++ b/Meade.net/Wrapper/GetValueException.cs @@ -0,0 +1,28 @@ +using System; + +namespace ASCOM.Meade.net.Wrapper +{ + public class GetValueException : Exception + { + public GetValueException( + string driverId, + string name, + string subKey, + string defaultValue, + Exception innerException + ) : base ( $"Error getting value {name} from driver {driverId} in {subKey} and default value {defaultValue} cannot be used.", innerException) + { + } + + public GetValueException( + string driverId, + string name, + string subKey, + string defaultValue, + string value, + Exception innerException): + base($"Error converting value {name} from {value}", innerException) + { + } + } +} \ No newline at end of file diff --git a/Meade.net/Wrapper/IProfileWrapper.cs b/Meade.net/Wrapper/IProfileWrapper.cs index ae9d434..5682ff6 100644 --- a/Meade.net/Wrapper/IProfileWrapper.cs +++ b/Meade.net/Wrapper/IProfileWrapper.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Globalization; using ASCOM.Utilities; using ASCOM.Utilities.Interfaces; @@ -7,7 +8,11 @@ namespace ASCOM.Meade.net.Wrapper { public interface IProfileWrapper : IProfile, IProfileExtra, IDisposable { + int GetValueInt(string driverId, string name, string subKey, string defaultValue); + short GetValueShort(string driverId, string name, string subKey, string defaultValue); + bool GetValueBool(string driverId, string name, string subKey, string defaultValue); + double GetValueDouble(string driverId, string name, string subKey, string defaultValue); } public class ProfileWrapper : IProfileWrapper @@ -36,7 +41,68 @@ namespace ASCOM.Meade.net.Wrapper public string GetValue(string driverId, string name, string subKey, string defaultValue) { - return _profile.GetValue(driverId, name, subKey, defaultValue); + try + { + return _profile.GetValue(driverId, name, subKey, defaultValue); + } + catch (Exception e) + { + throw new GetValueException(driverId, name, subKey, defaultValue, e); + } + + } + + public int GetValueInt(string driverId, string name, string subKey, string defaultValue) + { + var value = _profile.GetValue(driverId, name, subKey, defaultValue); + try + { + return int.Parse(value, CultureInfo.InvariantCulture); + } + catch (Exception e) + { + throw new GetValueException(driverId, name, subKey, defaultValue, value, e); + } + + } + + public short GetValueShort(string driverId, string name, string subKey, string defaultValue) + { + var value = _profile.GetValue(driverId, name, subKey, defaultValue); + try + { + return short.Parse(value, CultureInfo.InvariantCulture); + } + catch (Exception e) + { + throw new GetValueException(driverId, name, subKey, defaultValue, value, e); + } + } + + public bool GetValueBool(string driverId, string name, string subKey, string defaultValue) + { + var value = _profile.GetValue(driverId, name, subKey, defaultValue); + try + { + return bool.Parse(value); + } + catch (Exception e) + { + throw new GetValueException(driverId, name, subKey, defaultValue, value, e); + } + } + + public double GetValueDouble(string driverId, string name, string subKey, string defaultValue) + { + var value = _profile.GetValue(driverId, name, subKey, defaultValue); + try + { + return double.Parse(value, CultureInfo.InvariantCulture); + } + catch (Exception e) + { + throw new GetValueException(driverId, name, subKey, defaultValue, value, e); + } } public void WriteValue(string driverId, string name, string value, string subKey) From ea07c7b625bc95cfbad1b22f204298a558d9ee37 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Mon, 17 Feb 2025 15:56:34 +0000 Subject: [PATCH 2/6] Fixed unit tests --- .../SharedResourcesUnitTests.cs | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 8ca906c..740f652 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -151,21 +151,21 @@ namespace Meade.net.UnitTests string TraceStateDefault = "false"; string ComPortDefault = "COM1"; - string SpeedDefault = "9600"; - string DataBitsDefault = "8"; + int SpeedDefault = 9600; + int DataBitsDefault = 8; string StopBitsDefault = "One"; string HandshakeDefault = "None"; string ParityDefault = "None"; - string RtsDtrEnabledDefault = "true"; + bool RtsDtrEnabledDefault = true; - string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate + double GuideRateProfileNameDefault = 10.077939; //67% of sidereal rate string PrecisionDefault = "Unchanged"; string GuidingStyleDefault = "Auto"; - string BacklashCompensationDefault = "3000"; - string ReverseFocuserDiectionDefault = "true"; + int BacklashCompensationDefault = 3000; + bool ReverseFocuserDiectionDefault = true; - string SendDateTimeDefault = "true"; + bool SendDateTimeDefault = true; string SkipPromptsDefault = "true"; string ParkedBehaviourDefault = "No Coordinates"; @@ -184,23 +184,23 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); profileWrapperMock - .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, - GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); + .Setup(x => x.GetValueDouble(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + GuideRateProfileNameDefault.ToString())).Returns(GuideRateProfileNameDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault)) .Returns(GuidingStyleDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault)) + x.GetValueInt(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault.ToString())) .Returns(BacklashCompensationDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, "true")) + x.GetValueBool(DriverId, "Reverse Focuser Direction", string.Empty, "true")) .Returns(() => ReverseFocuserDiectionDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + x.GetValueInt(DriverId, "Speed", string.Empty, SpeedDefault.ToString())) .Returns(() => SpeedDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + x.GetValueInt(DriverId, "Data Bits", string.Empty, DataBitsDefault.ToString())) .Returns(() => DataBitsDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) @@ -212,7 +212,7 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) .Returns(() => ParityDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Rts / Dtr", string.Empty, "false")) + x.GetValueBool(DriverId, "Rts / Dtr", string.Empty, "false")) .Returns(() => RtsDtrEnabledDefault); profileWrapperMock.Setup(x => @@ -239,7 +239,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false")) + x.GetValueBool(DriverId, "Send Date and time on connect", string.Empty, "false")) .Returns(() => SendDateTimeDefault); profileWrapperMock.Setup(x => @@ -264,21 +264,21 @@ namespace Meade.net.UnitTests Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault)); Assert.That(profileProperties.GuideRateArcSecondsPerSecond, - Is.EqualTo(double.Parse(GuideRateProfileNameDefault))); + Is.EqualTo(GuideRateProfileNameDefault)); Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault)); - Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(int.Parse(BacklashCompensationDefault))); - Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(bool.Parse(ReverseFocuserDiectionDefault))); + Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(BacklashCompensationDefault)); + Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(ReverseFocuserDiectionDefault)); - Assert.That(profileProperties.Speed, Is.EqualTo(int.Parse(SpeedDefault))); - Assert.That(profileProperties.DataBits, Is.EqualTo(int.Parse(DataBitsDefault))); + Assert.That(profileProperties.Speed, Is.EqualTo(SpeedDefault)); + Assert.That(profileProperties.DataBits, Is.EqualTo(DataBitsDefault)); Assert.That(profileProperties.StopBits, Is.EqualTo(StopBitsDefault)); Assert.That(profileProperties.Handshake, Is.EqualTo(HandshakeDefault)); Assert.That(profileProperties.Parity, Is.EqualTo(ParityDefault)); - Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(bool.Parse(RtsDtrEnabledDefault))); + Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(RtsDtrEnabledDefault)); - Assert.That(profileProperties.SendDateTime, Is.EqualTo(bool.Parse(SendDateTimeDefault))); + Assert.That(profileProperties.SendDateTime, Is.EqualTo(SendDateTimeDefault)); } [TestCase("TCP")] @@ -692,15 +692,15 @@ namespace Meade.net.UnitTests } } - [TestCase("57600")] - [TestCase("38400")] - [TestCase("28800")] - [TestCase("19200")] - [TestCase("14400")] - [TestCase("4800")] - [TestCase("2400")] - [TestCase("1200")] - public void Connect_WhenSpeedIsFastAndAutostarAtDefault_ThenConnectsAutoStarSpeedChanged(string WantedSpeed) + [TestCase(57600)] + [TestCase(38400)] + [TestCase(28800)] + [TestCase(19200)] + [TestCase(14400)] + [TestCase(4800)] + [TestCase(2400)] + [TestCase(1200)] + public void Connect_WhenSpeedIsFastAndAutostarAtDefault_ThenConnectsAutoStarSpeedChanged(int WantedSpeed) { string deviceId = "Serial"; @@ -739,7 +739,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + x.GetValueInt(DriverId, "Speed", string.Empty, SpeedDefault)) .Returns(() => WantedSpeed); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) @@ -812,15 +812,15 @@ namespace Meade.net.UnitTests } } - [TestCase("57600")] - [TestCase("38400")] - [TestCase("28800")] - [TestCase("19200")] - [TestCase("14400")] - [TestCase("4800")] - [TestCase("2400")] - [TestCase("1200")] - public void Connect_WhenAutostarReportsFailedToChangeSpeec_ThenConnectsAutoStarAtDefaultSpeed(string WantedSpeed) + [TestCase(57600)] + [TestCase(38400)] + [TestCase(28800)] + [TestCase(19200)] + [TestCase(14400)] + [TestCase(4800)] + [TestCase(2400)] + [TestCase(1200)] + public void Connect_WhenAutostarReportsFailedToChangeSpeec_ThenConnectsAutoStarAtDefaultSpeed(int WantedSpeed) { string deviceId = "Serial"; @@ -859,7 +859,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + x.GetValueInt(DriverId, "Speed", string.Empty, SpeedDefault)) .Returns(() => WantedSpeed); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) From d1ed5558b2ca173af9bca293e08719e037a77da2 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 18 Feb 2025 14:45:12 +0000 Subject: [PATCH 3/6] Changes the code a little more --- Meade.net/Wrapper/IProfileWrapper.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Meade.net/Wrapper/IProfileWrapper.cs b/Meade.net/Wrapper/IProfileWrapper.cs index 5682ff6..fcc62ff 100644 --- a/Meade.net/Wrapper/IProfileWrapper.cs +++ b/Meade.net/Wrapper/IProfileWrapper.cs @@ -54,7 +54,7 @@ namespace ASCOM.Meade.net.Wrapper public int GetValueInt(string driverId, string name, string subKey, string defaultValue) { - var value = _profile.GetValue(driverId, name, subKey, defaultValue); + var value = GetValue(driverId, name, subKey, defaultValue); try { return int.Parse(value, CultureInfo.InvariantCulture); @@ -68,7 +68,7 @@ namespace ASCOM.Meade.net.Wrapper public short GetValueShort(string driverId, string name, string subKey, string defaultValue) { - var value = _profile.GetValue(driverId, name, subKey, defaultValue); + var value = GetValue(driverId, name, subKey, defaultValue); try { return short.Parse(value, CultureInfo.InvariantCulture); @@ -81,7 +81,7 @@ namespace ASCOM.Meade.net.Wrapper public bool GetValueBool(string driverId, string name, string subKey, string defaultValue) { - var value = _profile.GetValue(driverId, name, subKey, defaultValue); + var value = GetValue(driverId, name, subKey, defaultValue); try { return bool.Parse(value); @@ -94,7 +94,7 @@ namespace ASCOM.Meade.net.Wrapper public double GetValueDouble(string driverId, string name, string subKey, string defaultValue) { - var value = _profile.GetValue(driverId, name, subKey, defaultValue); + var value = GetValue(driverId, name, subKey, defaultValue); try { return double.Parse(value, CultureInfo.InvariantCulture); From a89b1c8fa62a961f170519461d887d58fadc3dda Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Fri, 19 Sep 2025 18:32:16 +0100 Subject: [PATCH 4/6] Added Nunit3 test adapter nuget package to the test projects to improve testing for people without NCrunch. --- .../AstroMath.UnitTests.csproj | 65 ++++++++++++++++++ AstroMath.UnitTests/packages.config | 15 +++++ .../Meade.net.Focuser.UnitTests.csproj | 65 ++++++++++++++++++ Meade.net.Focuser.UnitTests/packages.config | 15 +++++ .../Meade.net.Telescope.UnitTests.csproj | 66 +++++++++++++++++++ Meade.net.Telescope.UnitTests/packages.config | 15 +++++ .../Meade.net.UnitTests.csproj | 65 ++++++++++++++++++ Meade.net.UnitTests/packages.config | 15 +++++ 8 files changed, 321 insertions(+) diff --git a/AstroMath.UnitTests/AstroMath.UnitTests.csproj b/AstroMath.UnitTests/AstroMath.UnitTests.csproj index 243721d..a4d9ee5 100644 --- a/AstroMath.UnitTests/AstroMath.UnitTests.csproj +++ b/AstroMath.UnitTests/AstroMath.UnitTests.csproj @@ -1,5 +1,9 @@  + + + + @@ -59,6 +63,36 @@ ..\packages\JetBrains.Annotations.2022.3.1\lib\net20\JetBrains.Annotations.dll + + ..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll + + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll + + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + + ..\packages\Microsoft.Testing.Platform.1.7.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.TestPlatform.AdapterUtilities.17.13.0\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + ..\packages\Moq.4.18.2\lib\net462\Moq.dll @@ -66,11 +100,32 @@ ..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.7.0.0-preview.2.22152.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll @@ -105,5 +160,15 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/AstroMath.UnitTests/packages.config b/AstroMath.UnitTests/packages.config index 0e509b4..05c5263 100644 --- a/AstroMath.UnitTests/packages.config +++ b/AstroMath.UnitTests/packages.config @@ -2,8 +2,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj b/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj index fbc940d..4f276c3 100644 --- a/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj +++ b/Meade.net.Focuser.UnitTests/Meade.net.Focuser.UnitTests.csproj @@ -1,5 +1,9 @@  + + + + @@ -74,6 +78,36 @@ ..\packages\JetBrains.Annotations.2022.3.1\lib\net20\JetBrains.Annotations.dll + + ..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll + + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll + + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + + ..\packages\Microsoft.Testing.Platform.1.7.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.TestPlatform.AdapterUtilities.17.13.0\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + ..\packages\Moq.4.18.2\lib\net462\Moq.dll @@ -81,11 +115,32 @@ ..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.7.0.0-preview.2.22152.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll @@ -120,5 +175,15 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/Meade.net.Focuser.UnitTests/packages.config b/Meade.net.Focuser.UnitTests/packages.config index 7765007..91027d2 100644 --- a/Meade.net.Focuser.UnitTests/packages.config +++ b/Meade.net.Focuser.UnitTests/packages.config @@ -3,8 +3,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj b/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj index 0770dd6..673bdcc 100644 --- a/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj +++ b/Meade.net.Telescope.UnitTests/Meade.net.Telescope.UnitTests.csproj @@ -1,5 +1,9 @@  + + + + @@ -95,6 +99,36 @@ ..\packages\JetBrains.Annotations.2022.3.1\lib\net20\JetBrains.Annotations.dll + + ..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll + + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll + + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + + ..\packages\Microsoft.Testing.Platform.1.7.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.TestPlatform.AdapterUtilities.17.13.0\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + ..\packages\Moq.4.18.2\lib\net462\Moq.dll @@ -102,11 +136,33 @@ ..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.7.0.0-preview.2.22152.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll @@ -140,5 +196,15 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/Meade.net.Telescope.UnitTests/packages.config b/Meade.net.Telescope.UnitTests/packages.config index 7765007..91027d2 100644 --- a/Meade.net.Telescope.UnitTests/packages.config +++ b/Meade.net.Telescope.UnitTests/packages.config @@ -3,8 +3,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meade.net.UnitTests/Meade.net.UnitTests.csproj b/Meade.net.UnitTests/Meade.net.UnitTests.csproj index 3093ac2..f1ff094 100644 --- a/Meade.net.UnitTests/Meade.net.UnitTests.csproj +++ b/Meade.net.UnitTests/Meade.net.UnitTests.csproj @@ -1,5 +1,9 @@  + + + + @@ -73,6 +77,36 @@ ..\packages\JetBrains.Annotations.2022.3.1\lib\net20\JetBrains.Annotations.dll + + ..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll + + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll + + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.7.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + + ..\packages\Microsoft.Testing.Platform.1.7.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.TestPlatform.AdapterUtilities.17.13.0\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.13.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + ..\packages\Moq.4.18.2\lib\net462\Moq.dll @@ -80,11 +114,32 @@ ..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.7.0.0-preview.2.22152.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll @@ -119,5 +174,15 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/Meade.net.UnitTests/packages.config b/Meade.net.UnitTests/packages.config index 8d0b71a..42d813c 100644 --- a/Meade.net.UnitTests/packages.config +++ b/Meade.net.UnitTests/packages.config @@ -3,9 +3,24 @@ + + + + + + + + + + + + + + + \ No newline at end of file From c24b4c116129779d22c5d93ee4efe94eaf41f43e Mon Sep 17 00:00:00 2001 From: Olivier Balitch Date: Sat, 27 Sep 2025 11:46:00 +0200 Subject: [PATCH 5/6] Initial support of LXD600 mount: no StarPatch, no long format, no park support for this mount. --- .../TelescopeUnitTests.cs | 1 + Meade.net.Telescope/Telescope.cs | 52 +++++---- .../SharedResourcesUnitTests.cs | 103 ++++++++++++++++++ Meade.net/SharedResources.cs | 13 ++- Meade.net/TelescopeList.cs | 7 ++ 5 files changed, 152 insertions(+), 24 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 5da6cd2..c1bbbf3 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -917,6 +917,7 @@ namespace Meade.net.Telescope.UnitTests [TestCase("Autostar", "43Eg", true)] [TestCase("LX200 Classic", "", false)] + [TestCase("LXD600", TelescopeList.LXD600_6_12S, false)] public void CanPark_Get_ReturnsTrue(string productName, string firmware, bool canPark) { ConnectTelescope(productName, firmware, $"{_testProperties.AlignmentMode}N0"); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 6ab350c..19bc187 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -632,22 +632,26 @@ namespace ASCOM.Meade.net { var isStarPatch = false; - var firmwareVersionArray = SharedResourcesWrapper.FirmwareVersion.ToCharArray(); - if (firmwareVersionArray.Length > 1) + //LXD600 is based on LX-200 classic Meade and does not support StarPatch + if (SharedResourcesWrapper.ProductName != TelescopeList.LXD600) { - //If last character is a number - var lastChr = firmwareVersionArray[firmwareVersionArray.Length - 1]; - if (char.IsNumber(lastChr)) + var firmwareVersionArray = SharedResourcesWrapper.FirmwareVersion.ToCharArray(); + if (firmwareVersionArray.Length > 1) { - // Get case of second to last character - var secondLastChar = firmwareVersionArray[firmwareVersionArray.Length - 2]; - // lower case = StarPatch, upper case = Meade - isStarPatch = char.IsLower(secondLastChar); - } - else - { - // lower case = Meade, upper case = StarPatch - isStarPatch = char.IsUpper(lastChr); + //If last character is a number + var lastChr = firmwareVersionArray[firmwareVersionArray.Length - 1]; + if (char.IsNumber(lastChr)) + { + // Get case of second to last character + var secondLastChar = firmwareVersionArray[firmwareVersionArray.Length - 2]; + // lower case = StarPatch, upper case = Meade + isStarPatch = char.IsLower(secondLastChar); + } + else + { + // lower case = Meade, upper case = StarPatch + isStarPatch = char.IsUpper(lastChr); + } } } @@ -765,7 +769,8 @@ namespace ASCOM.Meade.net private bool IsLongFormatSupported() { - if (SharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC) + if ((SharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC) || + (SharedResourcesWrapper.ProductName == TelescopeList.LXD600)) { return false; } @@ -1532,7 +1537,8 @@ namespace ASCOM.Meade.net { try { - var canPark = SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC; + var canPark = ((SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC) && + (SharedResourcesWrapper.ProductName != TelescopeList.LXD600)); LogMessage("CanPark", "Get - " + canPark); return canPark; } @@ -1810,7 +1816,8 @@ namespace ASCOM.Meade.net TelescopeList.LX200GPS, TelescopeList.RCX400, TelescopeList.LX200CLASSIC, - TelescopeList.LX800 + TelescopeList.LX800, + TelescopeList.LXD600 }; return unParkableScopes.Contains(SharedResourcesWrapper.ProductName); @@ -2294,7 +2301,8 @@ namespace ASCOM.Meade.net var isTracking = Tracking; - if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC) + if ((SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC) && + (SharedResourcesWrapper.ProductName != TelescopeList.LXD600)) { SharedResourcesWrapper.SendBlind(Tl, "hP"); //:hP# Autostar, Autostar II and LX 16" Slew to Park Position @@ -2302,7 +2310,7 @@ namespace ASCOM.Meade.net } else { - LogMessage("Park", $"LX200 Classic does not support parking"); + LogMessage("Park", $"LX200 Classic or LXD600 do not support parking"); throw new NotImplementedException("Park"); } @@ -2953,7 +2961,7 @@ namespace ASCOM.Meade.net LogMessage("TargetAltitude Set", $"{command}"); var response = SharedResourcesWrapper.SendBool(Tl, command); //:SasDD*MM# - // Set target object altitude to sDD*MM# or sDD*MM’SS# [LX 16”, Autostar, Autostar II] + // Set target object altitude to sDD*MM# or sDD*MM�SS# [LX 16�, Autostar, Autostar II] // Returns: // 1 Object within slew range // 0 Object out of slew range @@ -2990,9 +2998,9 @@ namespace ASCOM.Meade.net LogMessage("TargetAzimuth Set", $"{command}"); var response = SharedResourcesWrapper.SendBool(Tl, command); //:SzDDD*MM# - // Sets the target Object Azimuth[LX 16” and Autostar II only] + // Sets the target Object Azimuth[LX 16� and Autostar II only] // Returns: - // 0 – Invalid + // 0 � Invalid // 1 - Valid if (!response) throw new InvalidOperationException("Target Azimuth out of slew range."); diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 740f652..5649700 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -488,6 +488,109 @@ namespace Meade.net.UnitTests } } + [Test] + public void Connect_WhenDeviceIdIsSerialGVPGVTPartiallySupported_ThenConnectsAndSetsProductToLXD600() + { + string deviceId = "Serial"; + string DriverId = "ASCOM.MeadeGeneric.Telescope"; + + string TraceStateDefault = "false"; + + string ComPortDefault = "COM1"; + string SpeedDefault = "9600"; + string DataBitsDefault = "8"; + string StopBitsDefault = "One"; + string HandshakeDefault = "None"; + string ParityDefault = "None"; + string RtsDtrEnabledDefault = "false"; + + string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate + string PrecisionDefault = "Unchanged"; + + string ParkedBehaviourDefault = "No Coordinates"; + string ParkedAltDefault = "0"; + string ParkedAzimuthDefault = "180"; + string FocalLengthDefault = "2000"; + string ApertureAreaDefault = "32685"; + string ApertureDiameterDefault = "203"; + + Mock profileWrapperMock = new Mock(); + profileWrapperMock.SetupAllProperties(); + + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) + .Returns(TraceStateDefault); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) + .Returns(ComPortDefault); + profileWrapperMock + .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) + .Returns(PrecisionDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + .Returns(() => SpeedDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + .Returns(() => DataBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) + .Returns(() => StopBitsDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault)) + .Returns(() => HandshakeDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault)) + .Returns(() => RtsDtrEnabledDefault); + + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault)) + .Returns(() => ParityDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault)) + .Returns(() => ParkedAltDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) + .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) + .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault)) + .Returns(() => ApertureAreaDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault)) + .Returns(() => ApertureDiameterDefault); + + Mock profileFactoryMock = new Mock(); + profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); + + SharedResources.ProfileFactory = profileFactoryMock.Object; + + string serialPortReturn = string.Empty; + string productNameAndFirmwareVersion = TelescopeList.LXD600_6_12S; + + _serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = productNameAndFirmwareVersion; }); + _serialMock.Setup(x => x.Transmit("#:GVN#")).Callback(() => { serialPortReturn = productNameAndFirmwareVersion; }); + + _serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; }); + _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn); + + var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); + try + { + Assert.That(connectionResult.SameDevice, Is.EqualTo(1)); + Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LXD600)); + Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(productNameAndFirmwareVersion)); + } + finally + { + SharedResources.Disconnect(deviceId, String.Empty); + } + } + [Test] public void Connect_WhenDeviceIdIsSerialButGVPIsAutostar_ThenConnectsAndSetsProductToAutostarAndFirmware() { diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 3544a53..2651c52 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -211,7 +211,7 @@ namespace ASCOM.Meade.net private const string ParkedAltName = "Parked Altitude"; private const string ParkedAzimuthName = "Parked Azimuth"; private const string FocalLengthName = "Focal Length (mm)"; - private const string ApertureAreaName = "Aperture Area (mm²)"; + private const string ApertureAreaName = "Aperture Area (mm�)"; private const string ApertureDiameterName = "Aperture Diameter (mm)"; public static void WriteProfile(ProfileProperties profileProperties) @@ -470,11 +470,20 @@ namespace ASCOM.Meade.net } } SharedSerial.Connected = true; - + try { ProductName = SendString(traceLogger, "GVP"); FirmwareVersion = SendString(traceLogger, "GVN"); + + //LXD600 mount uses LX-200 based firmware. When both above commands are sent to the scope, + //they both return the "6.12S" string. + //There may be other values of the string applicable to LXD600 mount or other values of the string + //may allow identify LXD650/LXD700 or other scopes. May require further adjustments. + if (String.Equals(ProductName, FirmwareVersion) && String.Equals(ProductName, TelescopeList.LXD600_6_12S)) + { + ProductName = TelescopeList.LXD600; + } } catch (Exception ex) { diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 15c8307..2a410fb 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -45,6 +45,13 @@ public const string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported! #endregion + #region LXD600 + public const string LXD600 = "LXD600"; + + public const string LXD600_6_12S = "6.12S"; + + #endregion + #region RCX400 // ReSharper disable once InconsistentNaming public const string RCX400 = "RCX400"; From a0d5eec2679073f61742bb99bb6b9300bfd4c9f1 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sun, 28 Dec 2025 21:13:45 +0000 Subject: [PATCH 6/6] code tidyup --- 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 6ab350c..bcfbda6 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -703,7 +703,7 @@ namespace ASCOM.Meade.net i--; } } - catch (TimeoutException e) + catch (TimeoutException) { LogMessage("ApplySkipAutoStarPrompts","Timed out bypassing the date time prompts. Skipping."); }