Made sure that the alignment mode is preserved when parked, across sessions.

This commit is contained in:
2022-05-08 15:15:30 +01:00
parent 2b5205d9c5
commit ebca231d9a
3 changed files with 18 additions and 23 deletions
@@ -131,6 +131,7 @@ namespace Meade.net.Telescope.UnitTests
_testProperties.AlignmentStatus = alignmentStatus.ToCharArray();
_sharedResourcesWrapperMock.Setup(x => x.SendChars("GW", false, 3)).Returns(() => new string(_testProperties.AlignmentStatus));
_sharedResourcesWrapperMock.Setup(x => x.SendString("GW", false)).Returns(() => new string(_testProperties.AlignmentStatus));
_sharedResourcesWrapperMock.Setup(x => x.SendBlind("AP", false)).Callback(() => _testProperties.AlignmentStatus[1] = 'T');
_sharedResourcesWrapperMock.Setup(x => x.SendBlind("AL", false)).Callback(() => _testProperties.AlignmentStatus[1] = 'N');
@@ -808,9 +809,10 @@ namespace Meade.net.Telescope.UnitTests
[Test]
public void AlignmentMode_Get_WhenUnknownAlignmentMode_ThrowsException()
{
_testProperties.AlignmentMode = "";
ConnectTelescope();
_testProperties.AlignmentMode = "";
Assert.Throws<InvalidValueException>(() =>
{
var actualResult = _telescope.AlignmentMode;
+6 -4
View File
@@ -488,6 +488,8 @@ namespace ASCOM.Meade.net
SendCurrentDateTime("Connect");
}
}
SharedResources.AlignmentMode = AlignmentMode;
}
else
{
@@ -1050,6 +1052,8 @@ namespace ASCOM.Meade.net
//:AL# Sets telescope to Land alignment mode
//Returns: nothing
SharedResources.AlignmentMode = AlignmentMode;
}
}
@@ -2805,8 +2809,6 @@ namespace ASCOM.Meade.net
}
}
private AlignmentModes _savedAlignmode;
public bool Tracking
{
get
@@ -2833,12 +2835,12 @@ namespace ASCOM.Meade.net
if (!value)
{
_savedAlignmode = AlignmentMode;
SharedResources.AlignmentMode = AlignmentMode;
SharedResourcesWrapper.SendBlind("AL");
}
else
{
AlignmentMode = _savedAlignmode;
AlignmentMode = SharedResources.AlignmentMode;
}
}
}
+7 -16
View File
@@ -568,22 +568,6 @@ namespace ASCOM.Meade.net
#endregion
public static void Lock(Action action)
{
lock (LockObject)
{
action();
}
}
public static T Lock<T>(Func<T> func)
{
lock (LockObject)
{
return func();
}
}
/// <summary>
/// Skeleton of a hardware class, all this does is hold a count of the connections,
/// in reality extra code will be needed to handle the hardware in some way
@@ -626,6 +610,13 @@ namespace ASCOM.Meade.net
private set => _isParked.Set(value);
}
private static readonly ThreadSafeValue<AlignmentModes> _alignmentMode = AlignmentModes.algAltAz;
public static AlignmentModes AlignmentMode
{
get => _alignmentMode;
set => _alignmentMode.Set(value);
}
private static readonly ThreadSafeValue<PierSide> _sideOfPier = PierSide.pierUnknown;
/// <summary>
/// Start with <see cref="PierSide.pierUnknown"/>.