Added support for AtPark and Park
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO.Ports;
|
||||
using ASCOM;
|
||||
using ASCOM.DeviceInterface;
|
||||
@@ -33,6 +34,8 @@ namespace MeadeAutostar497.UnitTests
|
||||
serialMock.Setup(x => x.CommandTerminated(It.IsAny<string>(), It.IsAny<string>())).Returns(() => _stringToRecieve);
|
||||
serialMock.Setup(x => x.IsOpen).Returns(() => _isConnected);
|
||||
|
||||
//Todo inject the serialMock instead of using a singleton to increase code stability.
|
||||
|
||||
_telescopeController = TelescopeController.Instance;
|
||||
_telescopeController.Connected = false;
|
||||
_telescopeController.SerialPort = serialMock.Object;
|
||||
@@ -474,5 +477,50 @@ namespace MeadeAutostar497.UnitTests
|
||||
|
||||
serialMock.Verify( x => x.Command(command), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AtParkIsFalseByDefault()
|
||||
{
|
||||
_isConnected = true;
|
||||
|
||||
_telescopeController.Connected = true;
|
||||
|
||||
Assert.That( _telescopeController.AtPark, Is.False );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AtParkIsTrueAfterParkingScope()
|
||||
{
|
||||
_isConnected = true;
|
||||
|
||||
_telescopeController.Connected = true;
|
||||
_telescopeController.Park();
|
||||
|
||||
Assert.That(_telescopeController.AtPark, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Park_CallingParkSendsTheParkCommand()
|
||||
{
|
||||
_isConnected = true;
|
||||
|
||||
_telescopeController.Connected = true;
|
||||
_telescopeController.Park();
|
||||
|
||||
serialMock.Verify( x => x.Command(":hP#"), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Park_ParkingSecondTimeDoesNothing()
|
||||
{
|
||||
_isConnected = true;
|
||||
|
||||
_telescopeController.Connected = true;
|
||||
_telescopeController.Park();
|
||||
|
||||
_telescopeController.Park();
|
||||
|
||||
serialMock.Verify(x => x.Command(":hP#"), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,8 +342,9 @@ namespace ASCOM.MeadeAutostar497
|
||||
{
|
||||
get
|
||||
{
|
||||
tl.LogMessage("AtPark", "Get - " + false.ToString());
|
||||
return false;
|
||||
var atPatk = _telescopeController.AtPark;
|
||||
tl.LogMessage("AtPark", "Get - " + atPatk.ToString());
|
||||
return atPatk;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,8 +635,8 @@ namespace ASCOM.MeadeAutostar497
|
||||
|
||||
public void Park()
|
||||
{
|
||||
tl.LogMessage("Park", "Not implemented");
|
||||
throw new ASCOM.MethodNotImplementedException("Park");
|
||||
tl.LogMessage("Park", "Parking telescope");
|
||||
_telescopeController.Park();
|
||||
}
|
||||
|
||||
public void PulseGuide(GuideDirections Direction, int Duration)
|
||||
|
||||
@@ -13,7 +13,9 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
double SiteLatitude { get; set; }
|
||||
double SiteLongitude { get; set; }
|
||||
AlignmentModes AlignmentMode { get; set; }
|
||||
bool AtPark { get; }
|
||||
void AbortSlew();
|
||||
void PulseGuide(GuideDirections direction, int duration);
|
||||
void Park();
|
||||
}
|
||||
}
|
||||
@@ -293,6 +293,10 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
}
|
||||
}
|
||||
|
||||
private bool _parked = false;
|
||||
|
||||
public bool AtPark => _parked;
|
||||
|
||||
public void AbortSlew()
|
||||
{
|
||||
SerialPort.Command("#:Q#");
|
||||
@@ -335,6 +339,15 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
}
|
||||
}
|
||||
|
||||
public void Park()
|
||||
{
|
||||
if (_parked)
|
||||
return;
|
||||
|
||||
_parked = true;
|
||||
_serialPort.Command(":hP#");
|
||||
}
|
||||
|
||||
public bool UserNewerPulseGuiding { get; set; } = true; //todo make this a device setting
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user