From 129fc23d838c0795095c990cfff2d491b91c5f2e Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Thu, 10 Nov 2022 15:30:16 +0000 Subject: [PATCH] Added an attempt to use the short format to set the TargetRightAscension if the long format fails. --- Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs | 1 + Meade.net.Telescope/Telescope.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index a844bb6..c05c0e2 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -2518,6 +2518,7 @@ namespace Meade.net.Telescope.UnitTests { _sharedResourcesWrapperMock.Setup(x => x.SendChar(_traceLoggerMock.Object, It.IsAny(), false)).Returns("0"); _utilMock.Setup(x => x.HoursToHMS(It.IsAny(), ":", ":", ":", It.IsAny())).Returns("00:00:00.00"); + _utilMock.Setup(x => x.HoursToHM(It.IsAny(), ":", "", It.IsAny())).Returns("00:00:00.00"); ConnectTelescope(); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index e74f794..35c386d 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -3496,7 +3496,15 @@ namespace ASCOM.Meade.net if (value >= 24) throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59"); - var hms = SetTargetRightAscension(value, SharedResourcesWrapper.IsLongFormat); + string hms; + try + { + hms = SetTargetRightAscension(value, SharedResourcesWrapper.IsLongFormat); + } + catch (InvalidOperationException) + { + hms = SetTargetRightAscension(value, !SharedResourcesWrapper.IsLongFormat); + } SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms); }