Modified the precision toggle to only use the first letter of the response rather than try to detect the entire string

This commit is contained in:
2019-08-18 22:43:38 +01:00
parent f10936a9e8
commit f6556716a5
2 changed files with 8 additions and 7 deletions
@@ -752,23 +752,23 @@ namespace Meade.net.Telescope.UnitTests
_profileProperties.Precision = desiredPresision; _profileProperties.Precision = desiredPresision;
var currentPrecision = telescopePrecision; var currentPrecision = telescopePrecision;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":P#")).Returns(() => _sharedResourcesWrapperMock.Setup(x => x.SendChar(":P#")).Returns(() =>
{ {
currentPrecision = !currentPrecision; currentPrecision = !currentPrecision;
switch (currentPrecision) switch (currentPrecision)
{ {
case true: case true:
return "HIGH PRECISION"; return "H";
default: default:
return "LOW PRECISION"; return "L";
} }
}); });
_telescope.Connected = true; _telescope.Connected = true;
Assert.That(currentPrecision, Is.EqualTo(finalPrecision)); Assert.That(currentPrecision, Is.EqualTo(finalPrecision));
_sharedResourcesWrapperMock.Verify(x => x.SendString(":P#"), Times.AtLeastOnce); _sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.AtLeastOnce);
} }
[Test] [Test]
+4 -3
View File
@@ -489,17 +489,18 @@ namespace ASCOM.Meade.net
private bool TogglePrecision() private bool TogglePrecision()
{ {
var result = _sharedResourcesWrapper.SendString(":P#"); LogMessage("TogglePrecision", $"Toggling slewing precision");
var result = _sharedResourcesWrapper.SendChar(":P#");
//:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target. //:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target.
//Returns: <string> //Returns: <string>
//“HIGH PRECISION” Current setting after this command. //“HIGH PRECISION” Current setting after this command.
//“LOW PRECISION” Current setting after this command. //“LOW PRECISION” Current setting after this command.
LogMessage("TogglePrecision", $"Result: {result}");
bool highPrecision = false; bool highPrecision = false;
switch (result) switch (result)
{ {
case "HIGH PRECISION": case "H":
highPrecision = true; highPrecision = true;
break; break;
} }