From df7dfb7c04e09b6eb1913686e3742dba18c59c26 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sat, 11 Dec 2021 19:10:18 +0000 Subject: [PATCH] Modified the implementation of side of pier support detection. Hopefully will now, Added extra checking to ensure that a slew cannot be started whilst a slew is in progress. --- .../FocuserUnitTests.cs | 6 - .../TelescopeUnitTests.cs | 70 +++- Meade.net.Telescope/Telescope.cs | 305 +++++++++--------- Meade.net.focuser/Focuser.cs | 39 ++- Meade.net/TelescopeList.cs | 1 + Meade.net/Wrapper/SharedResourcesWrapper.cs | 15 +- 6 files changed, 221 insertions(+), 215 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index e96a219..a898637 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -42,8 +42,6 @@ namespace Meade.net.Focuser.UnitTests _sharedResourcesWrapperMock = new Mock(); - _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); }); - _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties); _focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object); @@ -422,8 +420,6 @@ namespace Meade.net.Focuser.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once); } - _sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny()), Times.Once); - _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once()); @@ -455,8 +451,6 @@ namespace Meade.net.Focuser.UnitTests _utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2)); } - - _sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny()), Times.Once); } [Test] diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 0e65afb..8fcf673 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -95,9 +95,6 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.SendString("GZ", false)).Returns("DDD*MM’SS"); _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties); - _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); }); - _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>( func => func()); - _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny>())).Returns>(func => func()); _connectionInfo = new ConnectionInfo { @@ -1930,11 +1927,12 @@ namespace Meade.net.Telescope.UnitTests Assert.That(excpetion.Method, Is.EqualTo("SetPark")); } - [Test] - public void SideOfPier_Get_WhenMeridianFlipNotSupported_ThenThrowsException() + [TestCase(TelescopeList.LX200CLASSIC, null)] + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_31Ee)] + [TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42F)] + public void SideOfPier_Get_WhenMeridianFlipNotSupported_ThenThrowsException(string model, string firmware) { - // LX200 classic is a fork mounted scope so it does not support meridian flips - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(TelescopeList.LX200CLASSIC); + ConnectTelescope(model, firmware); var excpetion = Assert.Throws(() => { @@ -1946,6 +1944,41 @@ namespace Meade.net.Telescope.UnitTests Assert.That(excpetion.AccessorSet, Is.False); } + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)] + [TestCase(TelescopeList.LX200GPS, TelescopeList.LX200GPS_42G)] + public void SideOfPier_Get_WhenMeridianFlipSupported_ThenReturnsResult(string model, string firmware) + { + ConnectTelescope(model, firmware); + + Assert.DoesNotThrow(() => { var result = _telescope.SideOfPier; }); + } + + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algAltAz, 'A')] + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algPolar, 'P')] + public void SideOfPier_Get_WhenMeridianFlipNotSupportedByAlignementMode_ThenThrowsException(string model, string firmware, AlignmentModes alignmode, char alignmentStatus) + { + ConnectTelescope(model, firmware); + _testProperties.AlignmentStatus = new[] { alignmentStatus, 'T', '1' }; + + var excpetion = Assert.Throws(() => + { + var result = _telescope.SideOfPier; + Assert.Fail($"{result} should not have returned"); + }); + + Assert.That(excpetion.Property, Is.EqualTo("SideOfPier")); + Assert.That(excpetion.AccessorSet, Is.False); + } + + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, AlignmentModes.algGermanPolar, 'G')] + public void SideOfPier_Get_WhenMeridianFlipSupportedByAlignementMode_ThenDoesNotThrow(string model, string firmware, AlignmentModes alignmode, char alignmentStatus) + { + ConnectTelescope(model, firmware); + _testProperties.AlignmentStatus = new[] { alignmentStatus, 'T', '1' }; + + Assert.DoesNotThrow(() => { var result = _telescope.SideOfPier; }); + } + [Test] public void SideOfPier_Set_ThenThrowsException() { @@ -2119,7 +2152,7 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendString("Gg", false), Times.Exactly(3)); _sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Exactly(2)); - _sharedResourcesWrapperMock.Verify(x => x.SendString("D", false), Times.Exactly(3)); + _sharedResourcesWrapperMock.Verify(x => x.SendString("D", false), Times.AtLeast(3)); } [Test] @@ -3272,12 +3305,15 @@ namespace Meade.net.Telescope.UnitTests { _sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0"); + var preTestItterations = 1; var slewCounter = 0; var iterations = 10; _sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() => { slewCounter++; - if (slewCounter <= iterations) + if (slewCounter <= preTestItterations) + return ""; + else if (slewCounter <= iterations) return "|"; return ""; }); @@ -3289,7 +3325,7 @@ namespace Meade.net.Telescope.UnitTests _telescope.SlewToTarget(); - _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations)); + _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations - preTestItterations)); } [Test] @@ -3366,12 +3402,15 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0"); + var preTestItterations = 1; var slewCounter = 0; var iterations = 10; _sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() => { slewCounter++; - if (slewCounter <= iterations) + if (slewCounter <= preTestItterations) + return ""; + else if (slewCounter <= iterations) return "|"; return ""; }); @@ -3383,7 +3422,7 @@ namespace Meade.net.Telescope.UnitTests Assert.That(_telescope.TargetDeclination, Is.EqualTo(dmsResult)); _sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once); - _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations)); + _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations - preTestItterations)); } [Test] @@ -3486,12 +3525,15 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Setup(x => x.SendChar("MS", false)).Returns("0"); + var preTestItterations = 1; var slewCounter = 0; var iterations = 10; _sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns(() => { slewCounter++; - if (slewCounter <= iterations) + if (slewCounter <= preTestItterations) + return ""; + else if (slewCounter <= iterations) return "|"; return ""; }); @@ -3503,7 +3545,7 @@ 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("MS", false), Times.Once); - _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations)); + _utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny()), Times.Exactly(iterations - preTestItterations)); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 261d9b3..d9d220d 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -649,7 +649,7 @@ namespace ASCOM.Meade.net // According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so // we assume that for any telescope that supports the GW command and is not in Alt-Az mode then // meridian flip on slew is supported - private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode != AlignmentModes.algAltAz; + private bool IsMeridianFlipOnSlewSupported() => IsGwCommandSupported() && AlignmentMode == AlignmentModes.algGermanPolar; private bool FirmwareIsGreaterThan(string minVersion) { @@ -734,39 +734,36 @@ namespace ASCOM.Meade.net { LogMessage("SetLongFormat", "Long coordinate format not supported for this mount"); - SharedResourcesWrapper.Lock(() => SharedResourcesWrapper.IsLongFormat = false); + SharedResourcesWrapper.IsLongFormat = false; return; } - SharedResourcesWrapper.Lock(() => + var result = SharedResourcesWrapper.SendString("GZ"); + LogMessage("SetLongFormat", $"Get - Azimuth {result}"); + //:GZ# Get telescope azimuth + //Returns: DDD*MM.T or DDD*MM'SS# + //The current telescope Azimuth depending on the selected precision. + + SharedResourcesWrapper.IsLongFormat = result.Length > 6; + + if (SharedResourcesWrapper.IsLongFormat != setLongFormat) { - var result = SharedResourcesWrapper.SendString("GZ"); - LogMessage("SetLongFormat", $"Get - Azimuth {result}"); - //:GZ# Get telescope azimuth - //Returns: DDD*MM.T or DDD*MM'SS# - //The current telescope Azimuth depending on the selected precision. - + _utilities.WaitForMilliseconds(500); + SharedResourcesWrapper.SendBlind("U"); + //:U# Toggle between low/hi precision positions + //Low - RA displays and messages HH:MM.T sDD*MM + //High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS + // Returns Nothing + result = SharedResourcesWrapper.SendString("GZ"); SharedResourcesWrapper.IsLongFormat = result.Length > 6; - - if (SharedResourcesWrapper.IsLongFormat != setLongFormat) - { - _utilities.WaitForMilliseconds(500); - SharedResourcesWrapper.SendBlind("U"); - //:U# Toggle between low/hi precision positions - //Low - RA displays and messages HH:MM.T sDD*MM - //High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS - // Returns Nothing - result = SharedResourcesWrapper.SendString("GZ"); - SharedResourcesWrapper.IsLongFormat = result.Length > 6; - LogMessage("SetLongFormat", $"Get - Azimuth {result}"); - if (SharedResourcesWrapper.IsLongFormat == setLongFormat) - LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} "); - } - else - { + LogMessage("SetLongFormat", $"Get - Azimuth {result}"); + if (SharedResourcesWrapper.IsLongFormat == setLongFormat) LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} "); - } - }); + } + else + { + LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} "); + } LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} "); } @@ -1001,8 +998,8 @@ namespace ASCOM.Meade.net alignmentMode = AlignmentModes.algPolar; break; //case "G": - // alignmentMode = AlignmentModes.algGermanPolar; - // break; + //alignmentMode = AlignmentModes.algGermanPolar; + //break; default: throw new InvalidValueException( $"unknown alignment returned from telescope: {alignmentString}"); @@ -1135,13 +1132,13 @@ namespace ASCOM.Meade.net private HorizonCoordinates CalcAltAzFromTelescopeEqData() { - var altitudeData = SharedResourcesWrapper.Lock(() => new AltitudeData + var altitudeData = new AltitudeData { UtcDateTime = UTCDate, SiteLongitude = SiteLongitude, SiteLatitude = SiteLatitude, EquatorialCoordinates = GetTelescopeRaAndDec() - }); + }; double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime, altitudeData.SiteLongitude, @@ -2175,98 +2172,94 @@ namespace ASCOM.Meade.net LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}"); - HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude}; + HorizonCoordinates altAz = new HorizonCoordinates { Azimuth = azimuth, Altitude = altitude }; var utcDateTime = UTCDate; var latitude = SiteLatitude; var longitude = SiteLongitude; - SharedResourcesWrapper.Lock(() => - { - var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz); + var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, altAz); - TargetRightAscension = raDec.RightAscension; - TargetDeclination = raDec.Declination; + TargetRightAscension = raDec.RightAscension; + TargetDeclination = raDec.Declination; - DoSlewAsync(true); - - //TargetAltitude = altitude; - //TargetAzimuth = azimuth; - - //DoSlewAsync(false); - }); + DoSlewAsync(true); } private void DoSlewAsync(bool polar) { CheckConnected("DoSlewAsync"); CheckParked(); - - SharedResourcesWrapper.Lock(() => + if (Slewing) { - switch (polar) - { - case true: - var response = SharedResourcesWrapper.SendChar("MS"); - //:MS# Slew to Target Object - //Returns: - //0 Slew is Possible - //1# Object Below Horizon w/string message - //2# Object Below Higher w/string message + 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 (response) - { - case "0": - //We're slewing everything should be working just fine. - LogMessage("DoSlewAsync", "Slewing to target"); + switch (polar) + { + case true: + var response = SharedResourcesWrapper.SendChar("MS"); + //:MS# Slew to Target Object + //Returns: + //0 Slew is Possible + //1# Object Below Horizon w/string message + //2# Object Below Higher w/string message - if (IsMeridianFlipOnSlewSupported()) - { - // Update side of pier to destination side of pier - // Assumption: Mount will do meridian flip if required - SharedResourcesWrapper.SideOfPier = DestinationSideOfPier(TargetRightAscension, TargetDeclination); - } + switch (response) + { + case "0": + //We're slewing everything should be working just fine. + LogMessage("DoSlewAsync", "Slewing to target"); - SetSlewingMinEndTime(); - break; - case "1": - //Below Horizon - string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated(); - LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\""); - throw new InvalidOperationException(belowHorizonMessage); - case "2": - //Below minimum elevation - string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated(); - LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\""); - throw new InvalidOperationException(belowMinimumElevationMessage); - case "3": - //Telescope can hit the mount - string canHitMountMessage = SharedResourcesWrapper.ReadTerminated(); - LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\""); - throw new InvalidOperationException(canHitMountMessage); - default: - LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\""); - throw new DriverException("This error should not happen"); + if (IsMeridianFlipOnSlewSupported()) + { + // Update side of pier to destination side of pier + // Assumption: Mount will do meridian flip if required + SharedResourcesWrapper.SideOfPier = + DestinationSideOfPier(TargetRightAscension, TargetDeclination); + } - } + SetSlewingMinEndTime(); + break; + case "1": + //Below Horizon + string belowHorizonMessage = SharedResourcesWrapper.ReadTerminated(); + LogMessage("DoSlewAsync", $"Slew failed \"{belowHorizonMessage}\""); + throw new InvalidOperationException(belowHorizonMessage); + case "2": + //Below minimum elevation + string belowMinimumElevationMessage = SharedResourcesWrapper.ReadTerminated(); + LogMessage("DoSlewAsync", $"Slew failed \"{belowMinimumElevationMessage}\""); + throw new InvalidOperationException(belowMinimumElevationMessage); + case "3": + //Telescope can hit the mount + string canHitMountMessage = SharedResourcesWrapper.ReadTerminated(); + LogMessage("DoSlewAsync", $"Slew failed \"{canHitMountMessage}\""); + throw new InvalidOperationException(canHitMountMessage); + default: + LogMessage("DoSlewAsync", $"Slew failed - unknown response \"{response}\""); + throw new DriverException("This error should not happen"); - break; - case false: - var maResponse = SharedResourcesWrapper.SendChar("MA"); - //:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az - //Returns: - //0 - No fault - //1 - Fault - //LX200 - Not supported + } - if (maResponse == "1") - { - throw new InvalidOperationException("fault"); - } - SetSlewingMinEndTime(); - break; - } - }); + break; + case false: + var maResponse = SharedResourcesWrapper.SendChar("MA"); + //:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az + //Returns: + //0 - No fault + //1 - Fault + //LX200 - Not supported + + if (maResponse == "1") + { + throw new InvalidOperationException("fault"); + } + + SetSlewingMinEndTime(); + break; + } } public void SlewToCoordinates(double rightAscension, double declination) @@ -2450,17 +2443,15 @@ namespace ASCOM.Meade.net public void SyncToCoordinates(double rightAscension, double declination) { LogMessage("SyncToCoordinates", $"RA={rightAscension} Dec={declination}"); - LogMessage("SyncToCoordinates", $"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}"); + LogMessage("SyncToCoordinates", + $"RA={_utilitiesExtra.HoursToHMS(rightAscension)} Dec={_utilitiesExtra.HoursToHMS(declination)}"); CheckConnected("SyncToCoordinates"); CheckParked(); - SharedResourcesWrapper.Lock(() => - { - TargetRightAscension = rightAscension; - TargetDeclination = declination; + TargetRightAscension = rightAscension; + TargetDeclination = declination; - SyncToTarget(); - }); + SyncToTarget(); } public void SyncToTarget() @@ -2612,13 +2603,15 @@ namespace ASCOM.Meade.net get { LogMessage("Tracking", "Get"); + bool isTracking = true; if (IsGwCommandSupported()) { var alignmentStatus = GetScopeAlignmentStatus(); - return alignmentStatus.Tracking; + isTracking = alignmentStatus.Tracking; } - return true; + LogMessage("Tracking", $"Get = {isTracking}"); + return isTracking; } set { @@ -2731,23 +2724,18 @@ namespace ASCOM.Meade.net { CheckParked(); - var telescopeDateDetails = SharedResourcesWrapper.Lock(() => + var telescopeDateDetails = new TelescopeDateDetails { - var tdd = new TelescopeDateDetails - { - TelescopeDate = SharedResourcesWrapper.SendString("GC"), - //:GC# Get current date. - //Returns: MM/DD/YY# - //The current local calendar date for the telescope. - TelescopeTime = SharedResourcesWrapper.SendString("GL"), - //:GL# Get Local Time in 24 hour format - //Returns: HH:MM:SS# - //The Local Time in 24 - hour Format - UtcCorrection = GetUtcCorrection() - }; - - return tdd; - }); + TelescopeDate = SharedResourcesWrapper.SendString("GC"), + //:GC# Get current date. + //Returns: MM/DD/YY# + //The current local calendar date for the telescope. + TelescopeTime = SharedResourcesWrapper.SendString("GL"), + //:GL# Get Local Time in 24 hour format + //Returns: HH:MM:SS# + //The Local Time in 24 - hour Format + UtcCorrection = GetUtcCorrection() + }; int month = telescopeDateDetails.TelescopeDate.Substring(0, 2).ToInteger(); int day = telescopeDateDetails.TelescopeDate.Substring(3, 2).ToInteger(); @@ -2783,40 +2771,37 @@ namespace ASCOM.Meade.net CheckConnected("UTCDate Set"); - SharedResourcesWrapper.Lock(() => + var utcCorrection = GetUtcCorrection(); + var localDateTime = value - utcCorrection; + + string localStingCommand = $"SL{localDateTime:HH:mm:ss}"; + var timeResult = SharedResourcesWrapper.SendChar(localStingCommand); + //:SLHH:MM:SS# + //Set the local Time + //Returns: + //0 - Invalid + //1 - Valid + if (timeResult != "1") { - var utcCorrection = GetUtcCorrection(); - var localDateTime = value - utcCorrection; + throw new InvalidOperationException("Failed to set local time"); + } - string localStingCommand = $"SL{localDateTime:HH:mm:ss}"; - var timeResult = SharedResourcesWrapper.SendChar(localStingCommand); - //:SLHH:MM:SS# - //Set the local Time - //Returns: - //0 - Invalid - //1 - Valid - if (timeResult != "1") - { - throw new InvalidOperationException("Failed to set local time"); - } + string localDateCommand = $"SC{localDateTime:MM/dd/yy}"; + var dateResult = SharedResourcesWrapper.SendChar(localDateCommand); + //:SCMM/DD/YY# + //Change Handbox Date to MM/DD/YY + //Returns: + //D = '0' if the date is invalid. The string is the null string. + //D = '1' for valid dates and the string is "Updating Planetary Data# #" + //Note: For Autostar II this is the UTC data! + if (dateResult != "1") + { + throw new InvalidOperationException("Failed to set local date"); + } - string localDateCommand = $"SC{localDateTime:MM/dd/yy}"; - var dateResult = SharedResourcesWrapper.SendChar(localDateCommand); - //:SCMM/DD/YY# - //Change Handbox Date to MM/DD/YY - //Returns: - //D = '0' if the date is invalid. The string is the null string. - //D = '1' for valid dates and the string is "Updating Planetary Data# #" - //Note: For Autostar II this is the UTC data! - if (dateResult != "1") - { - throw new InvalidOperationException("Failed to set local date"); - } - - //throwing away these two strings which represent - SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data# - SharedResourcesWrapper.ReadTerminated(); // # - }); + //throwing away these two strings which represent + SharedResourcesWrapper.ReadTerminated(); //Updating Planetary Data# + SharedResourcesWrapper.ReadTerminated(); // # } } diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 8d3ac6c..d547177 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -297,30 +297,27 @@ namespace ASCOM.Meade.net var direction = position > 0; if (ReverseFocusDirection) direction = !direction; + + //backlash compensation. + var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0; - SharedResourcesWrapper.Lock(() => + var steps = Math.Abs(position) + backlashCompensationSteps; + + + MoveFocuser(direction, steps); + + + //todo refactor the backlash compensation to combine the commands into as few moves as practicle. + //ApplyBacklashCompensation(direction); + if (direction & backlashCompensationSteps != 0) { - //backlash compensation. - var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0; + Tl.LogMessage("Move", "Applying backlash compensation"); + MoveFocuser(!direction, backlashCompensationSteps); + } - var steps = Math.Abs(position) + backlashCompensationSteps; - - - MoveFocuser(direction, steps); - - - //todo refactor the backlash compensation to combine the commands into as few moves as practicle. - //ApplyBacklashCompensation(direction); - if (direction & backlashCompensationSteps != 0) - { - Tl.LogMessage("Move", "Applying backlash compensation"); - MoveFocuser(!direction, backlashCompensationSteps); - } - - DynamicBreaking(direction); - //todo implement dynamic braking - //dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop. - }); + DynamicBreaking(direction); + //todo implement dynamic braking + //dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop. } private void DynamicBreaking(bool directionOut) diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index e41f2e9..42f92d0 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -23,6 +23,7 @@ // ReSharper disable once InconsistentNaming public const string LX200GPS = "LX2001"; + public const string LX200GPS_42F = "4.2F"; // ReSharper disable once InconsistentNaming public const string LX200GPS_42G = "4.2G"; #endregion diff --git a/Meade.net/Wrapper/SharedResourcesWrapper.cs b/Meade.net/Wrapper/SharedResourcesWrapper.cs index 754f341..4499fd4 100644 --- a/Meade.net/Wrapper/SharedResourcesWrapper.cs +++ b/Meade.net/Wrapper/SharedResourcesWrapper.cs @@ -12,10 +12,7 @@ namespace ASCOM.Meade.net.Wrapper string ProductName { get; } string FirmwareVersion { get; } - - void Lock(Action action); - T Lock(Func func); - + string SendString(string message, bool raw = false); void SendBlind(string message, bool raw = false); bool SendBool(string command, bool raw = false); @@ -69,16 +66,6 @@ namespace ASCOM.Meade.net.Wrapper public string FirmwareVersion => SharedResources.FirmwareVersion; - public void Lock(Action action) - { - SharedResources.Lock(action); - } - - public T Lock(Func func) - { - return SharedResources.Lock(func); - } - public string SendString(string message, bool raw = false) { return SharedResources.SendString(message, raw);