Added support for AlignmentMode
This commit is contained in:
@@ -444,5 +444,35 @@ namespace MeadeAutostar497.UnitTests
|
||||
|
||||
serialMock.Verify(x => x.Command(":Mgs1024#"), Times.Once);
|
||||
}
|
||||
|
||||
[TestCase("AT0", AlignmentModes.algAltAz)]
|
||||
[TestCase("PT0", AlignmentModes.algPolar)]
|
||||
[TestCase("GT0", AlignmentModes.algGermanPolar)]
|
||||
public void AlignmentMode_Get_ReturnsExpectedValue(string commandResponse, AlignmentModes mode)
|
||||
{
|
||||
serialMock.Setup(x => x.CommandTerminated(":GW#", "#")).Returns(commandResponse);
|
||||
|
||||
_isConnected = true;
|
||||
|
||||
_telescopeController.Connected = true;
|
||||
|
||||
var result = _telescopeController.AlignmentMode;
|
||||
|
||||
Assert.That(result, Is.EqualTo(mode));
|
||||
}
|
||||
|
||||
[TestCase(AlignmentModes.algAltAz, ":AA#")]
|
||||
[TestCase(AlignmentModes.algPolar, ":AP#")]
|
||||
[TestCase(AlignmentModes.algGermanPolar, ":AP#")]
|
||||
public void AligmentMode_Set_WorksAsExpected(AlignmentModes mode, string command)
|
||||
{
|
||||
_isConnected = true;
|
||||
|
||||
_telescopeController.Connected = true;
|
||||
|
||||
_telescopeController.AlignmentMode = mode;
|
||||
|
||||
serialMock.Verify( x => x.Command(command), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace ASCOM.MeadeAutostar497
|
||||
get
|
||||
{
|
||||
tl.LogMessage("AlignmentMode Get", "Not implemented");
|
||||
throw new ASCOM.PropertyNotImplementedException("AlignmentMode", false);
|
||||
return _telescopeController.AlignmentMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
DateTime utcDate { get; set; }
|
||||
double SiteLatitude { get; set; }
|
||||
double SiteLongitude { get; set; }
|
||||
AlignmentModes AlignmentMode { get; set; }
|
||||
void AbortSlew();
|
||||
void PulseGuide(GuideDirections direction, int duration);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using ASCOM.DeviceInterface;
|
||||
|
||||
namespace ASCOM.MeadeAutostar497.Controller
|
||||
{
|
||||
//todo stop this being a singleton, and instead use a server to make only a single instance.
|
||||
public sealed class TelescopeController : ITelescopeController
|
||||
{
|
||||
private static readonly Lazy<TelescopeController> lazy = new Lazy<TelescopeController>();
|
||||
@@ -248,6 +249,50 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
|
||||
}
|
||||
|
||||
public AlignmentModes AlignmentMode
|
||||
{
|
||||
get
|
||||
{
|
||||
var alignmentString = SerialPort.CommandTerminated(":GW#", "#");
|
||||
|
||||
switch (alignmentString[0])
|
||||
{
|
||||
case 'A': return AlignmentModes.algAltAz;
|
||||
case 'P': return AlignmentModes.algPolar;
|
||||
case 'G': return AlignmentModes.algGermanPolar;
|
||||
default:
|
||||
throw new ASCOM.InvalidValueException($"unknown alignment returned from telescope: {alignmentString[0]}");
|
||||
}
|
||||
//:GW# Get Scope Alignment Status
|
||||
//Returns: <mount><tracking><alignment>#
|
||||
// where:
|
||||
//mount: A - AzEl mounted, P - Equatorially mounted, G - german mounted equatorial
|
||||
//tracking: T - tracking, N - not tracking
|
||||
//alignment: 0 - needs alignment, 1 - one star aligned, 2 - two star aligned, 3 - three star aligned.
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case AlignmentModes.algAltAz: SerialPort.Command(":AA#");
|
||||
break;
|
||||
case AlignmentModes.algPolar:
|
||||
case AlignmentModes.algGermanPolar:
|
||||
SerialPort.Command(":AP#");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, null);
|
||||
}
|
||||
|
||||
//:AL# Sets telescope to Land alignment mode
|
||||
//Returns: nothing
|
||||
//:AP# Sets telescope to Polar alignment mode
|
||||
//Returns: nothing
|
||||
//:AA# Sets telescope the AltAz alignment mode
|
||||
//Returns: nothing
|
||||
}
|
||||
}
|
||||
|
||||
public void AbortSlew()
|
||||
{
|
||||
SerialPort.Command("#:Q#");
|
||||
|
||||
Reference in New Issue
Block a user