Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a18577552 | |||
| c7f1a4272f | |||
| 6601fa6205 | |||
| e2abda2d14 | |||
| 97810b5575 | |||
| 1185770a94 | |||
| 25d88b0609 | |||
| 85c77787ce |
@@ -215,6 +215,17 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
|
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Action_Site_Count_WhenCalling_ThenReturnsFour()
|
||||||
|
{
|
||||||
|
ConnectTelescope();
|
||||||
|
|
||||||
|
string parameters = "Count";
|
||||||
|
var result = _telescope.Action("site", parameters);
|
||||||
|
|
||||||
|
Assert.That(result, Is.EqualTo("4"));
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase("1", "#:SMHome#", "Home")]
|
[TestCase("1", "#:SMHome#", "Home")]
|
||||||
[TestCase("2", "#:SNClub#", "Club")]
|
[TestCase("2", "#:SNClub#", "Club")]
|
||||||
[TestCase("3", "#:SOGPS Site#", "GPS Site")]
|
[TestCase("3", "#:SOGPS Site#", "GPS Site")]
|
||||||
@@ -1311,6 +1322,63 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once);
|
_utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(GuideDirections.guideEast)]
|
||||||
|
[TestCase(GuideDirections.guideWest)]
|
||||||
|
[TestCase(GuideDirections.guideNorth)]
|
||||||
|
[TestCase(GuideDirections.guideSouth)]
|
||||||
|
public void PulseGuide_WhenSlewingAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction)
|
||||||
|
{
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("|");
|
||||||
|
|
||||||
|
var duration = 0;
|
||||||
|
ConnectTelescope();
|
||||||
|
|
||||||
|
var exception = Assert.Throws<InvalidOperationException>(() => { _telescope.PulseGuide(direction, duration); });
|
||||||
|
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide whilst slewing to target."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(GuideDirections.guideEast, TelescopeAxes.axisPrimary)]
|
||||||
|
[TestCase(GuideDirections.guideWest, TelescopeAxes.axisPrimary)]
|
||||||
|
[TestCase(GuideDirections.guideNorth, TelescopeAxes.axisSecondary)]
|
||||||
|
[TestCase(GuideDirections.guideSouth, TelescopeAxes.axisSecondary)]
|
||||||
|
public void PulseGuide_WhenMovingAxisAndPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction, TelescopeAxes axes)
|
||||||
|
{
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("#:D#")).Returns("");
|
||||||
|
|
||||||
|
var duration = 0;
|
||||||
|
ConnectTelescope();
|
||||||
|
|
||||||
|
_telescope.MoveAxis(axes, 1);
|
||||||
|
|
||||||
|
var exception = Assert.Throws<InvalidOperationException>(() => { _telescope.PulseGuide(direction, duration); });
|
||||||
|
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide while moving same axis."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(GuideDirections.guideEast)]
|
||||||
|
[TestCase(GuideDirections.guideWest)]
|
||||||
|
[TestCase(GuideDirections.guideNorth)]
|
||||||
|
[TestCase(GuideDirections.guideSouth)]
|
||||||
|
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenIsSlewingRespondsFalse(GuideDirections direction)
|
||||||
|
{
|
||||||
|
var duration = 0;
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
|
||||||
|
|
||||||
|
var isSlewing = true;
|
||||||
|
_utilMock.Setup(x => x.WaitForMilliseconds(duration)).Callback(() =>
|
||||||
|
{
|
||||||
|
isSlewing = _telescope.Slewing;
|
||||||
|
});
|
||||||
|
|
||||||
|
_telescope.Connected = true;
|
||||||
|
|
||||||
|
_telescope.PulseGuide(direction, duration);
|
||||||
|
|
||||||
|
Assert.That(isSlewing, Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase(GuideDirections.guideEast)]
|
[TestCase(GuideDirections.guideEast)]
|
||||||
[TestCase(GuideDirections.guideWest)]
|
[TestCase(GuideDirections.guideWest)]
|
||||||
[TestCase(GuideDirections.guideNorth)]
|
[TestCase(GuideDirections.guideNorth)]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using System.Runtime.InteropServices;
|
|||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
[assembly: ComVisible(true)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
[assembly: Guid("8b9fccb9-87ae-42f7-90af-079e13de6efb")]
|
[assembly: Guid("8b9fccb9-87ae-42f7-90af-079e13de6efb")]
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ using System.Collections;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
using ASCOM.Astrometry;
|
using ASCOM.Astrometry;
|
||||||
using ASCOM.Astrometry.AstroUtils;
|
using ASCOM.Astrometry.AstroUtils;
|
||||||
using ASCOM.Astrometry.NOVAS;
|
using ASCOM.Astrometry.NOVAS;
|
||||||
@@ -35,6 +37,7 @@ namespace ASCOM.Meade.net
|
|||||||
[ProgId("ASCOM.MeadeGeneric.Telescope")]
|
[ProgId("ASCOM.MeadeGeneric.Telescope")]
|
||||||
[ServedClassName("Meade Generic")]
|
[ServedClassName("Meade Generic")]
|
||||||
[ClassInterface(ClassInterfaceType.None)]
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
|
[ComVisible(true)]
|
||||||
public class Telescope : ReferenceCountedObjectBase, ITelescopeV3
|
public class Telescope : ReferenceCountedObjectBase, ITelescopeV3
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -78,15 +81,45 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Telescope()
|
public Telescope()
|
||||||
{
|
{
|
||||||
//todo move this out to IOC
|
try
|
||||||
var util = new Util(); //Initialise util object
|
{
|
||||||
_utilities = util;
|
//todo move this out to IOC
|
||||||
_utilitiesExtra = util; //Initialise util object
|
var util = new Util(); //Initialise util object
|
||||||
_astroUtilities = new AstroUtils(); // Initialise astro utilities object
|
_utilities = util;
|
||||||
_sharedResourcesWrapper = new SharedResourcesWrapper();
|
_utilitiesExtra = util; //Initialise util object
|
||||||
_astroMaths = new AstroMaths.AstroMaths();
|
_astroUtilities = new AstroUtils(); // Initialise astro utilities object
|
||||||
|
_sharedResourcesWrapper = new SharedResourcesWrapper();
|
||||||
|
_astroMaths = new AstroMaths.AstroMaths();
|
||||||
|
|
||||||
Initialise();
|
Initialise();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
var currentException = e;
|
||||||
|
|
||||||
|
while (currentException != null)
|
||||||
|
{
|
||||||
|
AppendException(sb, currentException);
|
||||||
|
|
||||||
|
currentException = currentException.InnerException;
|
||||||
|
|
||||||
|
if (currentException != null)
|
||||||
|
sb.AppendLine("-----");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show(sb.ToString());
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AppendException(StringBuilder sb, Exception currentException)
|
||||||
|
{
|
||||||
|
sb.AppendLine(currentException.Message);
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine(currentException.StackTrace);
|
||||||
|
sb.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths)
|
public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths)
|
||||||
@@ -101,6 +134,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double _guideRate;
|
private double _guideRate;
|
||||||
|
private bool _isGuiding = false;
|
||||||
|
|
||||||
private void Initialise()
|
private void Initialise()
|
||||||
{
|
{
|
||||||
@@ -1382,6 +1416,15 @@ namespace ASCOM.Meade.net
|
|||||||
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
|
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
|
||||||
CheckConnected("PulseGuide");
|
CheckConnected("PulseGuide");
|
||||||
|
|
||||||
|
if (IsSlewingToTarget())
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
||||||
|
|
||||||
|
if (_movingPrimary && (direction == GuideDirections.guideEast || direction == GuideDirections.guideWest))
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
||||||
|
|
||||||
|
if (_movingSecondary && (direction == GuideDirections.guideNorth || direction == GuideDirections.guideSouth))
|
||||||
|
throw new InvalidOperationException("Unable to PulseGuide while moving same axis.");
|
||||||
|
|
||||||
var coordinatesBeforeMove = GetTelescopeRaAndDec();
|
var coordinatesBeforeMove = GetTelescopeRaAndDec();
|
||||||
|
|
||||||
if (_userNewerPulseGuiding && duration < 10000)
|
if (_userNewerPulseGuiding && duration < 10000)
|
||||||
@@ -1417,28 +1460,36 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (direction)
|
_isGuiding = true;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
case GuideDirections.guideEast:
|
switch (direction)
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, 1);
|
{
|
||||||
_utilities.WaitForMilliseconds(duration);
|
case GuideDirections.guideEast:
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
MoveAxis(TelescopeAxes.axisPrimary, 1);
|
||||||
break;
|
_utilities.WaitForMilliseconds(duration);
|
||||||
case GuideDirections.guideNorth:
|
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, 1);
|
break;
|
||||||
_utilities.WaitForMilliseconds(duration);
|
case GuideDirections.guideNorth:
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
MoveAxis(TelescopeAxes.axisSecondary, 1);
|
||||||
break;
|
_utilities.WaitForMilliseconds(duration);
|
||||||
case GuideDirections.guideSouth:
|
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, -1);
|
break;
|
||||||
_utilities.WaitForMilliseconds(duration);
|
case GuideDirections.guideSouth:
|
||||||
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
MoveAxis(TelescopeAxes.axisSecondary, -1);
|
||||||
break;
|
_utilities.WaitForMilliseconds(duration);
|
||||||
case GuideDirections.guideWest:
|
MoveAxis(TelescopeAxes.axisSecondary, 0);
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, -1);
|
break;
|
||||||
_utilities.WaitForMilliseconds(duration);
|
case GuideDirections.guideWest:
|
||||||
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
MoveAxis(TelescopeAxes.axisPrimary, -1);
|
||||||
break;
|
_utilities.WaitForMilliseconds(duration);
|
||||||
|
MoveAxis(TelescopeAxes.axisPrimary, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isGuiding = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1882,6 +1933,9 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private bool MovingAxis()
|
private bool MovingAxis()
|
||||||
{
|
{
|
||||||
|
if (_isGuiding)
|
||||||
|
return false;
|
||||||
|
|
||||||
return _movingPrimary || _movingSecondary;
|
return _movingPrimary || _movingSecondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1895,26 +1949,34 @@ namespace ASCOM.Meade.net
|
|||||||
if (MovingAxis())
|
if (MovingAxis())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CheckConnected("Slewing Get");
|
return IsSlewingToTarget();
|
||||||
|
|
||||||
var result = _sharedResourcesWrapper.SendString("#:D#");
|
|
||||||
//:D# Requests a string of bars indicating the distance to the current target location.
|
|
||||||
//Returns:
|
|
||||||
//LX200's – a string of bar characters indicating the distance.
|
|
||||||
//Autostars and Autostar II – a string containing one bar until a slew is complete, then a null string is returned.
|
|
||||||
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSlewing = result != string.Empty;
|
|
||||||
|
|
||||||
LogMessage("Slewing Get", $"Result = {isSlewing}");
|
|
||||||
return isSlewing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsSlewingToTarget()
|
||||||
|
{
|
||||||
|
CheckConnected("Slewing Get");
|
||||||
|
|
||||||
|
if (_isGuiding)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var result = _sharedResourcesWrapper.SendString("#:D#");
|
||||||
|
//:D# Requests a string of bars indicating the distance to the current target location.
|
||||||
|
//Returns:
|
||||||
|
//LX200's – a string of bar characters indicating the distance.
|
||||||
|
//Autostars and Autostar II – a string containing one bar until a slew is complete, then a null string is returned.
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSlewing = result != string.Empty;
|
||||||
|
|
||||||
|
LogMessage("Slewing Get", $"Result = {isSlewing}");
|
||||||
|
return isSlewing;
|
||||||
|
}
|
||||||
|
|
||||||
public void SyncToAltAz(double azimuth, double altitude)
|
public void SyncToAltAz(double azimuth, double altitude)
|
||||||
{
|
{
|
||||||
LogMessage("SyncToAltAz", "Not implemented");
|
LogMessage("SyncToAltAz", "Not implemented");
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace ASCOM.Meade.net
|
|||||||
[ProgId("ASCOM.MeadeGeneric.focuser")]
|
[ProgId("ASCOM.MeadeGeneric.focuser")]
|
||||||
[ServedClassName("Meade Generic")]
|
[ServedClassName("Meade Generic")]
|
||||||
[ClassInterface(ClassInterfaceType.None)]
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
|
[ComVisible(true)]
|
||||||
public class Focuser : ReferenceCountedObjectBase, IFocuserV3
|
public class Focuser : ReferenceCountedObjectBase, IFocuserV3
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using System.Runtime.InteropServices;
|
|||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
[assembly: ComVisible(true)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
[assembly: Guid("4ad7a6d4-6d54-4a9a-bbf3-895353e318f8")]
|
[assembly: Guid("4ad7a6d4-6d54-4a9a-bbf3-895353e318f8")]
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace ASCOM.Meade.net
|
|||||||
driverProfile.DeviceType = "Telescope";
|
driverProfile.DeviceType = "Telescope";
|
||||||
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
||||||
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
||||||
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture));
|
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture));
|
||||||
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
|
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ namespace ASCOM.Meade.net
|
|||||||
driverProfile.DeviceType = "Telescope";
|
driverProfile.DeviceType = "Telescope";
|
||||||
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
|
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
|
||||||
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
|
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
|
||||||
profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault));
|
profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault), NumberFormatInfo.InvariantInfo);
|
||||||
profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
|
profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user