Merged in feature/GWSupport-update (pull request #35)
Feature/GWSupport update
This commit is contained in:
@@ -18,20 +18,23 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
{
|
{
|
||||||
public class TestProperties
|
public class TestProperties
|
||||||
{
|
{
|
||||||
internal string telescopeRaResult = "HH:MM:SS";
|
internal string telescopeRaResult { get; set; } = "HH:MM:SS";
|
||||||
internal double rightAscension = 1.2; //todo rename to declination;
|
internal double rightAscension { get; set; } = 1.2; //todo rename to declination;
|
||||||
internal double declination = 45;
|
internal double declination { get; set; } = 45;
|
||||||
|
|
||||||
internal string SiteLatitudeString = "testLatString";
|
internal string SiteLatitudeString { get; set; } = "testLatString";
|
||||||
internal double SiteLatitudeValue = 123.45;
|
internal double SiteLatitudeValue { get; set; } = 123.45;
|
||||||
|
|
||||||
internal string telescopeDate = "10/15/20";
|
internal string telescopeDate { get; set; } = "10/15/20";
|
||||||
internal string telescopeTime = "20:15:10";
|
internal string telescopeTime { get; set; } = "20:15:10";
|
||||||
internal string telescopeUtcCorrection = "-1.0";
|
internal string telescopeUtcCorrection { get; set; } = "-1.0";
|
||||||
|
|
||||||
internal double hourAngle;
|
internal double hourAngle { get; set; }
|
||||||
internal int telescopeAltitude = 45;
|
internal int telescopeAltitude { get; set; } = 45;
|
||||||
internal int telescopeAzimuth = 200;
|
internal int telescopeAzimuth { get; set; } = 200;
|
||||||
|
|
||||||
|
internal char[] AlignmentStatus { get; set; }
|
||||||
|
internal string TrackingRate { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -121,8 +124,14 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Object, _astroMathsMock.Object, _clockMock.Object, _novasMock.Object);
|
_sharedResourcesWrapperMock.Object, _astroMathsMock.Object, _clockMock.Object, _novasMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectTelescope(string productName = TelescopeList.Autostar497, string firmwareVersion = TelescopeList.Autostar497_31Ee)
|
private void ConnectTelescope(string productName = TelescopeList.Autostar497, string firmwareVersion = TelescopeList.Autostar497_31Ee, string alignmentStatus = "GT0")
|
||||||
{
|
{
|
||||||
|
_testProperties.AlignmentStatus = alignmentStatus.ToCharArray();
|
||||||
|
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendChars("GW", false, 3)).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');
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("Gt", false)).Returns( () => _testProperties.SiteLatitudeString);
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("Gt", false)).Returns( () => _testProperties.SiteLatitudeString);
|
||||||
_utilMock.Setup(x => x.DMSToDegrees(_testProperties.SiteLatitudeString)).Returns( () => _testProperties.SiteLatitudeValue);
|
_utilMock.Setup(x => x.DMSToDegrees(_testProperties.SiteLatitudeString)).Returns( () => _testProperties.SiteLatitudeValue);
|
||||||
|
|
||||||
@@ -133,6 +142,12 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("GL", false)).Returns(() => _testProperties.telescopeTime);
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("GL", false)).Returns(() => _testProperties.telescopeTime);
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("GG", false)).Returns(() => _testProperties.telescopeUtcCorrection);
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("GG", false)).Returns(() => _testProperties.telescopeUtcCorrection);
|
||||||
|
|
||||||
|
const string siderealTrackingRate = "+60.1";
|
||||||
|
_testProperties.TrackingRate = siderealTrackingRate;
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendString("GT", false)).Returns(() => _testProperties.TrackingRate);
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendBlind("TL", false)).Callback(() => _testProperties.TrackingRate = "lunar");
|
||||||
|
_sharedResourcesWrapperMock.Setup(x => x.SendBlind("TQ", false)).Callback(() => _testProperties.TrackingRate = siderealTrackingRate);
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName);
|
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName);
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion);
|
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion);
|
||||||
|
|
||||||
@@ -144,6 +159,8 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.SetupGet(x => x.IsParked).Returns(() => _isParked);
|
_sharedResourcesWrapperMock.SetupGet(x => x.IsParked).Returns(() => _isParked);
|
||||||
_sharedResourcesWrapperMock.SetupGet(x => x.ParkedPosition).Returns(() => _parkedPosition);
|
_sharedResourcesWrapperMock.SetupGet(x => x.ParkedPosition).Returns(() => _parkedPosition);
|
||||||
|
|
||||||
|
_sharedResourcesWrapperMock.SetupProperty(x => x.IsGuiding);
|
||||||
|
|
||||||
_astroMathsMock
|
_astroMathsMock
|
||||||
.Setup(x => x.ConvertHozToEq(It.IsAny<DateTime>(), It.IsAny<double>(), It.IsAny<double>(),
|
.Setup(x => x.ConvertHozToEq(It.IsAny<DateTime>(), It.IsAny<double>(), It.IsAny<double>(),
|
||||||
It.IsAny<HorizonCoordinates>())).Returns(() => new EquatorialCoordinates { Declination = _testProperties.declination, RightAscension = _testProperties.rightAscension });
|
It.IsAny<HorizonCoordinates>())).Returns(() => new EquatorialCoordinates { Declination = _testProperties.declination, RightAscension = _testProperties.rightAscension });
|
||||||
@@ -769,15 +786,17 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestCase("A", AlignmentModes.algAltAz)]
|
[TestCase("A", AlignmentModes.algAltAz, TelescopeList.Autostar497, TelescopeList.Autostar497_31Ee)]
|
||||||
[TestCase("P", AlignmentModes.algPolar)]
|
[TestCase("P", AlignmentModes.algPolar, TelescopeList.Autostar497, TelescopeList.Autostar497_31Ee)]
|
||||||
[TestCase("G", AlignmentModes.algGermanPolar)]
|
[TestCase("A", AlignmentModes.algAltAz, TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)]
|
||||||
public void AlignmentMode_Get_WhenScopeInAltAz_ReturnsAltAz(string telescopeMode, AlignmentModes alignmentMode)
|
[TestCase("P", AlignmentModes.algPolar, TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)]
|
||||||
|
[TestCase("G", AlignmentModes.algGermanPolar, TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)]
|
||||||
|
public void AlignmentMode_Get_WhenScopeInAltAz_ReturnsAltAz(string telescopeMode, AlignmentModes alignmentMode, string productName, string firmware)
|
||||||
{
|
{
|
||||||
const char ack = (char)6;
|
const char ack = (char)6;
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar(ack.ToString(), true)).Returns(telescopeMode);
|
_sharedResourcesWrapperMock.Setup(x => x.SendChar(ack.ToString(), false)).Returns(telescopeMode);
|
||||||
|
|
||||||
ConnectTelescope();
|
ConnectTelescope(productName, firmware, $"{telescopeMode}N0");
|
||||||
|
|
||||||
var actualResult = _telescope.AlignmentMode;
|
var actualResult = _telescope.AlignmentMode;
|
||||||
|
|
||||||
@@ -1109,12 +1128,15 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(result, Is.False);
|
Assert.That(result, Is.False);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[TestCase(TelescopeList.Autostar497_30Ee, false)]
|
||||||
public void CanSetTracking_Get_ReturnsTrue()
|
[TestCase(TelescopeList.Autostar497_43Eg, true)]
|
||||||
|
public void CanSetTracking_Get_ReturnsTrueIffGWCommandIsSupported(string firmware, bool supported)
|
||||||
{
|
{
|
||||||
|
ConnectTelescope(firmwareVersion: firmware);
|
||||||
|
|
||||||
var result = _telescope.CanSetTracking;
|
var result = _telescope.CanSetTracking;
|
||||||
|
|
||||||
Assert.That(result, Is.True);
|
Assert.That(result, Is.EqualTo(supported));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -1939,7 +1961,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_astroUtilsMock.Setup(x => x.ConditionHA(It.IsAny<double>())).Returns<double>(pHA => pHA < -12 ? pHA + 12 : pHA > 12 ? pHA - 12 : pHA);
|
_astroUtilsMock.Setup(x => x.ConditionHA(It.IsAny<double>())).Returns<double>(pHA => pHA < -12 ? pHA + 12 : pHA > 12 ? pHA - 12 : pHA);
|
||||||
_astroUtilsMock.Setup(x => x.ConditionRA(It.IsAny<double>())).Returns<double>(pRA => pRA < 0 ? pRA + 24 : pRA >= 24 ? pRA - 24 : pRA);
|
_astroUtilsMock.Setup(x => x.ConditionRA(It.IsAny<double>())).Returns<double>(pRA => pRA < 0 ? pRA + 24 : pRA >= 24 ? pRA - 24 : pRA);
|
||||||
|
|
||||||
ConnectTelescope();
|
ConnectTelescope(firmwareVersion: TelescopeList.Autostar497_43Eg);
|
||||||
Assert.That(_connectionInfo.SameDevice, Is.EqualTo(1));
|
Assert.That(_connectionInfo.SameDevice, Is.EqualTo(1));
|
||||||
|
|
||||||
_telescope.SlewToCoordinates(ra, dec);
|
_telescope.SlewToCoordinates(ra, dec);
|
||||||
@@ -2053,7 +2075,8 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
// Setup DestinationSideOfPier
|
// Setup DestinationSideOfPier
|
||||||
_astroUtilsMock.Setup(x => x.ConditionHA(It.IsAny<double>())).Returns<double>(pHA => pHA < -12 ? pHA + 12 : pHA > 12 ? pHA - 12 : pHA);
|
_astroUtilsMock.Setup(x => x.ConditionHA(It.IsAny<double>())).Returns<double>(pHA => pHA < -12 ? pHA + 12 : pHA > 12 ? pHA - 12 : pHA);
|
||||||
|
|
||||||
ConnectTelescope();
|
// Use firmware that supports GW
|
||||||
|
ConnectTelescope(firmwareVersion: TelescopeList.Autostar497_43Eg);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
_telescope.SlewToCoordinatesAsync(ra, dec);
|
_telescope.SlewToCoordinatesAsync(ra, dec);
|
||||||
@@ -2646,11 +2669,26 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
public void Tracking_SetAndGet_WhenValueSet_ThenCanGetNewValue(bool tracking)
|
public void Tracking_Set_WhenCanSetTrackingIsFalse_ThenThrowsNotImplementedException(bool tracking)
|
||||||
{
|
{
|
||||||
|
// GW is not supported, so CanSetTracking is false
|
||||||
|
ConnectTelescope(firmwareVersion: TelescopeList.Autostar497_30Ee);
|
||||||
|
|
||||||
|
Assert.Throws<ASCOM.NotImplementedException>( () => { _telescope.Tracking = tracking; } );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(true, "AP")]
|
||||||
|
[TestCase(false, "AL")]
|
||||||
|
public void Tracking_Set_WhenCanSetTrackingIsTrue_ThenValueIsUpdated(bool tracking, string alignmentCommand)
|
||||||
|
{
|
||||||
|
// GW is supported, so CanSetTracking is true
|
||||||
|
ConnectTelescope(firmwareVersion: TelescopeList.Autostar497_43Eg);
|
||||||
|
|
||||||
_telescope.Tracking = tracking;
|
_telescope.Tracking = tracking;
|
||||||
|
|
||||||
Assert.That(_telescope.Tracking, Is.EqualTo(tracking));
|
Assert.That(_telescope.Tracking, Is.EqualTo(tracking));
|
||||||
|
|
||||||
|
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(alignmentCommand, false), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -2668,7 +2706,10 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
_telescope.TrackingRate = rate;
|
_telescope.TrackingRate = rate;
|
||||||
|
|
||||||
|
Assert.That(_telescope.TrackingRate, Is.EqualTo(rate));
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(commandString, false), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(commandString, false), Times.Once);
|
||||||
|
_sharedResourcesWrapperMock.Verify(x => x.SendString("GT", false), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -2972,7 +3013,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
[TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] //The test case below is this same string encoded to return exactly what the telescope will return.
|
[TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] //The test case below is this same string encoded to return exactly what the telescope will return.
|
||||||
[TestCase(TelescopeList.LX200CLASSIC, "", "\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff \x00ff\x00ff\x00ff\x00ff\x00ff\x00ff", false)]
|
[TestCase(TelescopeList.LX200CLASSIC, "", "\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff\x00ff \x00ff\x00ff\x00ff\x00ff\x00ff\x00ff", false)]
|
||||||
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)]
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)]
|
||||||
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "\u007f", true)]
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "\x007f", true)]
|
||||||
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)]
|
[TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)]
|
||||||
public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing)
|
public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing)
|
||||||
{
|
{
|
||||||
@@ -3202,7 +3243,6 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_telescope.SlewToTarget();
|
_telescope.SlewToTarget();
|
||||||
|
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
||||||
_astroUtilsMock.Verify(x => x.ConditionHA(It.IsAny<double>()), Times.Once);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -3297,7 +3337,6 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
||||||
|
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
||||||
_astroUtilsMock.Verify(x => x.ConditionHA(It.IsAny<double>()), Times.Once);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -3418,7 +3457,6 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.declination));
|
Assert.That(_telescope.TargetDeclination, Is.EqualTo(_testProperties.declination));
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar("MS", false), Times.Once);
|
||||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Exactly(iterations));
|
||||||
_astroUtilsMock.Verify(x => x.ConditionHA(It.IsAny<double>()), Times.Once);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace ASCOM.Meade.net
|
||||||
|
{
|
||||||
|
public enum Alignment
|
||||||
|
{
|
||||||
|
NeedsAlignment,
|
||||||
|
OneStarAligned,
|
||||||
|
TwoStarAligned,
|
||||||
|
ThreeStarAligned,
|
||||||
|
AlignedOnHome,
|
||||||
|
ScopeWasParked,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using ASCOM.DeviceInterface;
|
||||||
|
|
||||||
|
namespace ASCOM.Meade.net
|
||||||
|
{
|
||||||
|
public class AlignmentStatus
|
||||||
|
{
|
||||||
|
public AlignmentModes AlignmentMode { get; set; }
|
||||||
|
public bool Tracking { get; set; }
|
||||||
|
public Alignment Status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<OutputPath>..\bin\Release\</OutputPath>
|
<OutputPath>..\bin\Release\</OutputPath>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<OutputPath>..\bin\Debug\</OutputPath>
|
<OutputPath>..\bin\Debug\</OutputPath>
|
||||||
@@ -118,6 +118,8 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Alignment.cs" />
|
||||||
|
<Compile Include="AlignmentStatus.cs" />
|
||||||
<Compile Include="AstroMaths\AltitudeData.cs" />
|
<Compile Include="AstroMaths\AltitudeData.cs" />
|
||||||
<Compile Include="AstroMaths\AstroMathExtensions.cs" />
|
<Compile Include="AstroMaths\AstroMathExtensions.cs" />
|
||||||
<Compile Include="AstroMaths\AstroMaths.cs" />
|
<Compile Include="AstroMaths\AstroMaths.cs" />
|
||||||
@@ -190,7 +192,7 @@
|
|||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
</Target>
|
</Target>
|
||||||
|
|||||||
+172
-137
@@ -140,9 +140,6 @@ namespace ASCOM.Meade.net
|
|||||||
Initialise(nameof(Telescope));
|
Initialise(nameof(Telescope));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isGuiding;
|
|
||||||
|
|
||||||
private bool _isTargetCoordinateInitRequired = true;
|
|
||||||
//
|
//
|
||||||
// PUBLIC COM INTERFACE ITelescopeV3 IMPLEMENTATION
|
// PUBLIC COM INTERFACE ITelescopeV3 IMPLEMENTATION
|
||||||
//
|
//
|
||||||
@@ -360,9 +357,6 @@ namespace ASCOM.Meade.net
|
|||||||
var result = SharedResourcesWrapper.SendBool(command, raw);
|
var result = SharedResourcesWrapper.SendBool(command, raw);
|
||||||
LogMessage("CommandBool", "Completed: {0}", result);
|
LogMessage("CommandBool", "Completed: {0}", result);
|
||||||
return result;
|
return result;
|
||||||
// or
|
|
||||||
//throw new MethodNotImplementedException("CommandBool");
|
|
||||||
// DO NOT have both these sections! One or the other
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CommandString(string command, bool raw)
|
public string CommandString(string command, bool raw)
|
||||||
@@ -372,10 +366,19 @@ namespace ASCOM.Meade.net
|
|||||||
// it's a good idea to put all the low level communication with the device here,
|
// it's a good idea to put all the low level communication with the device here,
|
||||||
// then all communication calls this function
|
// then all communication calls this function
|
||||||
// you need something to ensure that only one command is in progress at a time
|
// you need something to ensure that only one command is in progress at a time
|
||||||
var result = SharedResourcesWrapper.SendString(command, raw);
|
string result;
|
||||||
LogMessage("CommandBool", "Completed: {0}", result);
|
// :GW# is not terminated with a # for some reason, see reported comment
|
||||||
|
// https://bitbucket.org/cjdskunkworks/meadeautostar497/issues/24/get-set-tracking#comment-60586901
|
||||||
|
if (command == (raw ? ":GW#" : "GW"))
|
||||||
|
{
|
||||||
|
result = SharedResourcesWrapper.SendChars(command, raw, count: 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = SharedResourcesWrapper.SendString(command, raw);
|
||||||
|
}
|
||||||
|
LogMessage("CommandString", "Completed: {0}", result);
|
||||||
return result;
|
return result;
|
||||||
//throw new ASCOM.MethodNotImplementedException("CommandString");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
@@ -416,7 +419,6 @@ namespace ASCOM.Meade.net
|
|||||||
$"Connected to port {ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}");
|
$"Connected to port {ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}");
|
||||||
|
|
||||||
_userNewerPulseGuiding = IsNewPulseGuidingSupported();
|
_userNewerPulseGuiding = IsNewPulseGuidingSupported();
|
||||||
_tracking = true;
|
|
||||||
|
|
||||||
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
|
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
|
||||||
IsConnected = true;
|
IsConnected = true;
|
||||||
@@ -620,22 +622,18 @@ namespace ASCOM.Meade.net
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// true iff the mount will perform a meridian flip when required
|
private bool IsGWCommandSupported() => FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg);
|
||||||
// TODO: Needs checking what mounts actually support this
|
|
||||||
private bool IsMeridianFlipOnSlewSupported()
|
|
||||||
{
|
|
||||||
if (SharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
// true iff the mount will perform a meridian flip when required
|
||||||
}
|
// According to "A User's Guide to the Meade LXD55 and LXD75 Telescopes" Autostar supports meridian flip so
|
||||||
|
// we assume that for any telescope that supports the GW command and is not in Alt-Az mode then
|
||||||
|
// meridian flip on slew is supported
|
||||||
|
private bool IsMeridianFlipOnSlewSupported() => IsGWCommandSupported() && AlignmentMode != AlignmentModes.algAltAz;
|
||||||
|
|
||||||
private bool FirmwareIsGreaterThan(string minVersion)
|
private bool FirmwareIsGreaterThan(string minVersion)
|
||||||
{
|
{
|
||||||
var currentVersion = SharedResourcesWrapper.FirmwareVersion;
|
var currentVersion = SharedResourcesWrapper.FirmwareVersion;
|
||||||
var comparison = String.Compare(currentVersion, minVersion, StringComparison.Ordinal);
|
var comparison = string.Compare(currentVersion, minVersion, StringComparison.Ordinal);
|
||||||
return comparison >= 0;
|
return comparison >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,16 +645,16 @@ namespace ASCOM.Meade.net
|
|||||||
if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC)
|
if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_isTargetCoordinateInitRequired)
|
if (!SharedResourcesWrapper.IsTargetCoordinateInitRequired)
|
||||||
return _isTargetCoordinateInitRequired;
|
return SharedResourcesWrapper.IsTargetCoordinateInitRequired;
|
||||||
|
|
||||||
if (!IsConnected)
|
if (!IsConnected)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC)
|
if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC)
|
||||||
{
|
{
|
||||||
_isTargetCoordinateInitRequired = false;
|
SharedResourcesWrapper.IsTargetCoordinateInitRequired = false;
|
||||||
return _isTargetCoordinateInitRequired;
|
return SharedResourcesWrapper.IsTargetCoordinateInitRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double eps = 0.00001d;
|
const double eps = 0.00001d;
|
||||||
@@ -665,16 +663,16 @@ namespace ASCOM.Meade.net
|
|||||||
//target RA == 0
|
//target RA == 0
|
||||||
if (Math.Abs(rightTargetAscension) > eps)
|
if (Math.Abs(rightTargetAscension) > eps)
|
||||||
{
|
{
|
||||||
_isTargetCoordinateInitRequired = false;
|
SharedResourcesWrapper.IsTargetCoordinateInitRequired = false;
|
||||||
return _isTargetCoordinateInitRequired;
|
return SharedResourcesWrapper.IsTargetCoordinateInitRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
double targetDeclination = Declination;
|
double targetDeclination = Declination;
|
||||||
//target DE == 0
|
//target DE == 0
|
||||||
if (Math.Abs(targetDeclination) > eps)
|
if (Math.Abs(targetDeclination) > eps)
|
||||||
{
|
{
|
||||||
_isTargetCoordinateInitRequired = false;
|
SharedResourcesWrapper.IsTargetCoordinateInitRequired = false;
|
||||||
return _isTargetCoordinateInitRequired;
|
return SharedResourcesWrapper.IsTargetCoordinateInitRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
//target coordinates are equal current coordinates
|
//target coordinates are equal current coordinates
|
||||||
@@ -682,12 +680,12 @@ namespace ASCOM.Meade.net
|
|||||||
(Math.Abs(Declination - targetDeclination) <= eps))
|
(Math.Abs(Declination - targetDeclination) <= eps))
|
||||||
{
|
{
|
||||||
LogMessage("IsTargetCoordinateInitRequired", "0 diff -> false");
|
LogMessage("IsTargetCoordinateInitRequired", "0 diff -> false");
|
||||||
_isTargetCoordinateInitRequired = false;
|
SharedResourcesWrapper.IsTargetCoordinateInitRequired = false;
|
||||||
return _isTargetCoordinateInitRequired;
|
return SharedResourcesWrapper.IsTargetCoordinateInitRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("IsTargetCoordinateInitRequired", $"{_isTargetCoordinateInitRequired}");
|
LogMessage("IsTargetCoordinateInitRequired", $"{SharedResourcesWrapper.IsTargetCoordinateInitRequired}");
|
||||||
return _isTargetCoordinateInitRequired;
|
return SharedResourcesWrapper.IsTargetCoordinateInitRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitTargetCoordinates()
|
private void InitTargetCoordinates()
|
||||||
@@ -701,7 +699,7 @@ namespace ASCOM.Meade.net
|
|||||||
SyncToCoordinates(raAndDec.RightAscension, raAndDec.Declination);
|
SyncToCoordinates(raAndDec.RightAscension, raAndDec.Declination);
|
||||||
|
|
||||||
//do it only once
|
//do it only once
|
||||||
_isTargetCoordinateInitRequired = false;
|
SharedResourcesWrapper.IsTargetCoordinateInitRequired = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -957,54 +955,48 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
CheckConnected("AlignmentMode Get");
|
CheckConnected("AlignmentMode Get");
|
||||||
|
|
||||||
const char ack = (char) 6;
|
if (IsGWCommandSupported())
|
||||||
|
|
||||||
var alignmentString = SharedResourcesWrapper.SendChar(ack.ToString(), true);
|
|
||||||
//ACK <0x06> Query of alignment mounting mode.
|
|
||||||
//Returns:
|
|
||||||
//A If scope in AltAz Mode
|
|
||||||
//D If scope is currently in the Downloader[Autostar II & Autostar]
|
|
||||||
//L If scope in Land Mode
|
|
||||||
//P If scope in Polar Mode
|
|
||||||
|
|
||||||
//todo implement GW Command - Supported in Autostar 43Eg and above
|
|
||||||
//if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG)
|
|
||||||
//{
|
|
||||||
//var alignmentString = SerialPort.CommandTerminated(":GW#", "#");
|
|
||||||
//: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.
|
|
||||||
//}
|
|
||||||
|
|
||||||
AlignmentModes alignmentMode;
|
|
||||||
switch (alignmentString)
|
|
||||||
{
|
{
|
||||||
case "A":
|
var alignmentStatus = GetScopeAlignmentStatus();
|
||||||
alignmentMode = AlignmentModes.algAltAz;
|
return alignmentStatus.AlignmentMode;
|
||||||
break;
|
|
||||||
case "P":
|
|
||||||
alignmentMode = AlignmentModes.algPolar;
|
|
||||||
break;
|
|
||||||
case "G":
|
|
||||||
alignmentMode = AlignmentModes.algGermanPolar;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new InvalidValueException(
|
|
||||||
$"unknown alignment returned from telescope: {alignmentString}");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char ack = (char)6;
|
||||||
|
//ACK <0x06> Query of alignment mounting mode.
|
||||||
|
//Returns:
|
||||||
|
//A If scope in AltAz Mode
|
||||||
|
//D If scope is currently in the Downloader[Autostar II & Autostar]
|
||||||
|
//L If scope in Land Mode
|
||||||
|
//P If scope in Polar Mode
|
||||||
|
var alignmentString = SharedResourcesWrapper.SendChar(ack.ToString());
|
||||||
|
AlignmentModes alignmentMode;
|
||||||
|
switch (alignmentString)
|
||||||
|
{
|
||||||
|
case "A":
|
||||||
|
alignmentMode = AlignmentModes.algAltAz;
|
||||||
|
break;
|
||||||
|
case "P":
|
||||||
|
alignmentMode = AlignmentModes.algPolar;
|
||||||
|
break;
|
||||||
|
//case "G":
|
||||||
|
// alignmentMode = AlignmentModes.algGermanPolar;
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
throw new InvalidValueException(
|
||||||
|
$"unknown alignment returned from telescope: {alignmentString}");
|
||||||
|
}
|
||||||
|
|
||||||
LogMessage("AlignmentMode Get", $"alignmode = {alignmentMode}");
|
LogMessage("AlignmentMode Get", $"alignmode = {alignmentMode}");
|
||||||
return alignmentMode;
|
return alignmentMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
CheckConnected("AlignmentMode Set");
|
CheckConnected("AlignmentMode Set");
|
||||||
|
|
||||||
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
|
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
|
||||||
if (!FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg))
|
if (!IsGWCommandSupported())
|
||||||
throw new PropertyNotImplementedException("AlignmentMode", true);
|
throw new PropertyNotImplementedException("AlignmentMode", true);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
@@ -1029,6 +1021,56 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AlignmentStatus GetScopeAlignmentStatus()
|
||||||
|
{
|
||||||
|
var alignmentString = CommandString("GW", false);
|
||||||
|
//: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, S - sleeping
|
||||||
|
//alignment: 0 - needs alignment, 1 - one star aligned, 2 - two star aligned, 3 - three star aligned., H - Aligned on Home, P - Scope was parked
|
||||||
|
// https://www.cloudynights.com/topic/72166-lx-200-gps-serial-commands/
|
||||||
|
|
||||||
|
var alignmentStatus = new AlignmentStatus();
|
||||||
|
switch (alignmentString[0])
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
alignmentStatus.AlignmentMode = AlignmentModes.algAltAz;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
alignmentStatus.AlignmentMode = AlignmentModes.algPolar;
|
||||||
|
break;
|
||||||
|
case 'G':
|
||||||
|
alignmentStatus.AlignmentMode = AlignmentModes.algGermanPolar;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
alignmentStatus.Tracking = alignmentString[1] == 'T';
|
||||||
|
switch (alignmentString[2])
|
||||||
|
{
|
||||||
|
case '0':
|
||||||
|
alignmentStatus.Status = Alignment.NeedsAlignment;
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
alignmentStatus.Status = Alignment.OneStarAligned;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
alignmentStatus.Status = Alignment.TwoStarAligned;
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
alignmentStatus.Status = Alignment.ThreeStarAligned;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
alignmentStatus.Status = Alignment.AlignedOnHome;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
alignmentStatus.Status = Alignment.ScopeWasParked;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return alignmentStatus;
|
||||||
|
}
|
||||||
|
|
||||||
public double Altitude
|
public double Altitude
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -1190,7 +1232,7 @@ namespace ASCOM.Meade.net
|
|||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case TelescopeAxes.axisPrimary: return true; //RA or AZ
|
case TelescopeAxes.axisPrimary: return true; //RA or AZ
|
||||||
case TelescopeAxes.axisSecondary: return true; //Dev or Alt
|
case TelescopeAxes.axisSecondary: return true; //DEC or Alt
|
||||||
case TelescopeAxes.axisTertiary: return false; //rotator / derotator
|
case TelescopeAxes.axisTertiary: return false; //rotator / derotator
|
||||||
default: throw new InvalidValueException("CanMoveAxis", axis.ToString(), "0 to 2");
|
default: throw new InvalidValueException("CanMoveAxis", axis.ToString(), "0 to 2");
|
||||||
}
|
}
|
||||||
@@ -1267,8 +1309,9 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
LogMessage("CanSetTracking", "Get - " + true);
|
var canSetTracking = IsGWCommandSupported();
|
||||||
return true;
|
LogMessage("CanSetTracking", "Get - " + canSetTracking);
|
||||||
|
return canSetTracking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1338,7 +1381,6 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _lastGoodDeclination;
|
|
||||||
|
|
||||||
public double Declination
|
public double Declination
|
||||||
{
|
{
|
||||||
@@ -1357,7 +1399,6 @@ namespace ASCOM.Meade.net
|
|||||||
double declination = _utilities.DMSToDegrees(result);
|
double declination = _utilities.DMSToDegrees(result);
|
||||||
|
|
||||||
LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
|
LogMessage("Declination", $"Get - {result} convert to {declination} {_utilitiesExtra.DegreesToDMS(declination, ":", ":")}");
|
||||||
_lastGoodDeclination = declination;
|
|
||||||
return declination;
|
return declination;
|
||||||
}
|
}
|
||||||
catch (ParkedException)
|
catch (ParkedException)
|
||||||
@@ -1565,7 +1606,7 @@ namespace ASCOM.Meade.net
|
|||||||
switch (rate.Compare(0))
|
switch (rate.Compare(0))
|
||||||
{
|
{
|
||||||
case ComparisonResult.Equals:
|
case ComparisonResult.Equals:
|
||||||
if (!_isGuiding)
|
if (!SharedResourcesWrapper.IsGuiding)
|
||||||
{
|
{
|
||||||
SetSlewingMinEndTime();
|
SetSlewingMinEndTime();
|
||||||
}
|
}
|
||||||
@@ -1596,7 +1637,7 @@ namespace ASCOM.Meade.net
|
|||||||
switch (rate.Compare(0))
|
switch (rate.Compare(0))
|
||||||
{
|
{
|
||||||
case ComparisonResult.Equals:
|
case ComparisonResult.Equals:
|
||||||
if (!_isGuiding)
|
if (!SharedResourcesWrapper.IsGuiding)
|
||||||
{
|
{
|
||||||
SetSlewingMinEndTime();
|
SetSlewingMinEndTime();
|
||||||
}
|
}
|
||||||
@@ -1644,7 +1685,9 @@ namespace ASCOM.Meade.net
|
|||||||
Altitude = Altitude,
|
Altitude = Altitude,
|
||||||
Azimuth = Azimuth,
|
Azimuth = Azimuth,
|
||||||
RightAscension = RightAscension,
|
RightAscension = RightAscension,
|
||||||
Declination = Declination
|
Declination = Declination,
|
||||||
|
SiteLatitude = SiteLatitude,
|
||||||
|
SiteLongitude = SiteLongitude
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case ParkedBehaviour.ReportCoordinates:
|
case ParkedBehaviour.ReportCoordinates:
|
||||||
@@ -1658,7 +1701,9 @@ namespace ASCOM.Meade.net
|
|||||||
Altitude = ParkedAltAz.Altitude,
|
Altitude = ParkedAltAz.Altitude,
|
||||||
Azimuth = ParkedAltAz.Azimuth,
|
Azimuth = ParkedAltAz.Azimuth,
|
||||||
RightAscension = raDec.RightAscension,
|
RightAscension = raDec.RightAscension,
|
||||||
Declination = raDec.Declination
|
Declination = raDec.Declination,
|
||||||
|
SiteLatitude = latitude,
|
||||||
|
SiteLongitude = longitude
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1685,7 +1730,7 @@ namespace ASCOM.Meade.net
|
|||||||
if (IsSlewingToTarget())
|
if (IsSlewingToTarget())
|
||||||
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
||||||
|
|
||||||
_isGuiding = true;
|
SharedResourcesWrapper.IsGuiding = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (SharedResourcesWrapper.MovingPrimary &&
|
if (SharedResourcesWrapper.MovingPrimary &&
|
||||||
@@ -1768,7 +1813,7 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_isGuiding = false;
|
SharedResourcesWrapper.IsGuiding = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1792,7 +1837,6 @@ namespace ASCOM.Meade.net
|
|||||||
return _utilities.HMSToHours(hms);
|
return _utilities.HMSToHours(hms);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _lastGoodRightAsension;
|
|
||||||
|
|
||||||
public double RightAscension
|
public double RightAscension
|
||||||
{
|
{
|
||||||
@@ -1811,7 +1855,6 @@ namespace ASCOM.Meade.net
|
|||||||
double rightAscension = HmToHours(result);
|
double rightAscension = HmToHours(result);
|
||||||
|
|
||||||
LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
|
LogMessage("RightAscension", $"Get - {result} convert to {rightAscension} {_utilitiesExtra.HoursToHMS(rightAscension)}");
|
||||||
_lastGoodRightAsension = rightAscension;
|
|
||||||
return rightAscension;
|
return rightAscension;
|
||||||
}
|
}
|
||||||
catch (ParkedException)
|
catch (ParkedException)
|
||||||
@@ -1852,18 +1895,25 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsMeridianFlipOnSlewSupported())
|
if (!IsMeridianFlipOnSlewSupported())
|
||||||
{
|
{
|
||||||
// while mount is slewing return unknown, this is required since
|
LogMessage("SideOfPier Get", "Not implemented");
|
||||||
// DoSlewAsync updates _pierSide before slew is finished
|
throw new PropertyNotImplementedException("SideOfPier", false);
|
||||||
var pierSide = Slewing ? PierSide.pierUnknown : SharedResourcesWrapper.SideOfPier;
|
|
||||||
|
|
||||||
LogMessage("SideOfPier", "Get - " + pierSide);
|
|
||||||
return pierSide;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("SideOfPier Get", "Not implemented");
|
PierSide pierSide;
|
||||||
throw new PropertyNotImplementedException("SideOfPier", false);
|
if (Slewing)
|
||||||
|
{
|
||||||
|
// because we update SideOfPier after initiating the slew command we return unknown while still slewing
|
||||||
|
pierSide = PierSide.pierUnknown;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pierSide = SharedResourcesWrapper.SideOfPier;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogMessage("SideOfPier", "Get - " + pierSide);
|
||||||
|
return pierSide;
|
||||||
}
|
}
|
||||||
// ReSharper disable once ValueParameterNotUsed
|
// ReSharper disable once ValueParameterNotUsed
|
||||||
set
|
set
|
||||||
@@ -1931,7 +1981,6 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double? _lastGoodSiteLatitude;
|
|
||||||
public double SiteLatitude
|
public double SiteLatitude
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -1950,19 +1999,14 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
var siteLatitude = _utilities.DMSToDegrees(latitude);
|
var siteLatitude = _utilities.DMSToDegrees(latitude);
|
||||||
LogMessage("SiteLatitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLatitude)}");
|
LogMessage("SiteLatitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLatitude)}");
|
||||||
|
|
||||||
_lastGoodSiteLatitude = siteLatitude;
|
|
||||||
return siteLatitude;
|
return siteLatitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidOperationException("unable to get site latitude from telescope.");
|
throw new InvalidOperationException("unable to get site latitude from telescope.");
|
||||||
}
|
}
|
||||||
catch (ParkedException)
|
catch (ParkedException) when (ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition)
|
||||||
{
|
{
|
||||||
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
|
return parkedPosition.SiteLatitude;
|
||||||
throw;
|
|
||||||
|
|
||||||
return _lastGoodSiteLatitude.Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
@@ -1992,12 +2036,9 @@ namespace ASCOM.Meade.net
|
|||||||
//1 - Valid
|
//1 - Valid
|
||||||
if (result != "1")
|
if (result != "1")
|
||||||
throw new InvalidOperationException("Failed to set site latitude.");
|
throw new InvalidOperationException("Failed to set site latitude.");
|
||||||
|
|
||||||
_lastGoodSiteLatitude = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _lastGoodSiteLongitude;
|
|
||||||
|
|
||||||
public double SiteLongitude
|
public double SiteLongitude
|
||||||
{
|
{
|
||||||
@@ -2015,18 +2056,15 @@ namespace ASCOM.Meade.net
|
|||||||
double siteLongitude = -_utilities.DMSToDegrees(longitude);
|
double siteLongitude = -_utilities.DMSToDegrees(longitude);
|
||||||
|
|
||||||
if (siteLongitude < -180)
|
if (siteLongitude < -180)
|
||||||
siteLongitude = siteLongitude + 360;
|
siteLongitude += 360;
|
||||||
|
|
||||||
LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}");
|
LogMessage("SiteLongitude Get", $"{_utilitiesExtra.DegreesToDMS(siteLongitude)}");
|
||||||
_lastGoodSiteLongitude = siteLongitude;
|
|
||||||
return siteLongitude;
|
return siteLongitude;
|
||||||
}
|
}
|
||||||
catch (ParkedException)
|
catch (ParkedException) when (ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition)
|
||||||
{
|
{
|
||||||
if (ParkedBehaviour == ParkedBehaviour.NoCoordinates)
|
return parkedPosition.SiteLongitude;
|
||||||
throw;
|
|
||||||
|
|
||||||
return _lastGoodSiteLongitude;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
@@ -2061,8 +2099,6 @@ namespace ASCOM.Meade.net
|
|||||||
//1 - Valid
|
//1 - Valid
|
||||||
if (result != "1")
|
if (result != "1")
|
||||||
throw new InvalidOperationException("Failed to set site longitude.");
|
throw new InvalidOperationException("Failed to set site longitude.");
|
||||||
|
|
||||||
_lastGoodSiteLongitude = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2269,7 +2305,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private bool MovingAxis()
|
private bool MovingAxis()
|
||||||
{
|
{
|
||||||
if (_isGuiding)
|
if (SharedResourcesWrapper.IsGuiding)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return SharedResourcesWrapper.MovingPrimary || SharedResourcesWrapper.MovingSecondary;
|
return SharedResourcesWrapper.MovingPrimary || SharedResourcesWrapper.MovingSecondary;
|
||||||
@@ -2321,7 +2357,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
CheckConnected("IsSlewingToTarget");
|
CheckConnected("IsSlewingToTarget");
|
||||||
|
|
||||||
if (_isGuiding)
|
if (SharedResourcesWrapper.IsGuiding)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
@@ -2550,41 +2586,42 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _tracking = true;
|
|
||||||
public bool Tracking
|
public bool Tracking
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
LogMessage("Tracking", $"Get - {_tracking}");
|
LogMessage("Tracking", "Get");
|
||||||
return _tracking;
|
if (IsGWCommandSupported())
|
||||||
|
{
|
||||||
|
var alignmentStatus = GetScopeAlignmentStatus();
|
||||||
|
return alignmentStatus.Tracking;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (!CanSetTracking)
|
||||||
|
{
|
||||||
|
throw new ASCOM.NotImplementedException("Tracking Set");
|
||||||
|
}
|
||||||
|
|
||||||
LogMessage("Tracking Set", $"{value}");
|
LogMessage("Tracking Set", $"{value}");
|
||||||
_tracking = value;
|
SharedResourcesWrapper.SendBlind(value ? "AP" : "AL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DriveRates _trackingRate = DriveRates.driveSidereal;
|
|
||||||
|
|
||||||
public DriveRates TrackingRate
|
public DriveRates TrackingRate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//todo implement this with the GW command
|
var rate = CommandString("GT", false);
|
||||||
//var result = SerialPort.CommandTerminated(":GT#", "#");
|
|
||||||
|
|
||||||
//double rate = double.Parse(result);
|
if (rate == "+60.1")
|
||||||
|
return DriveRates.driveSidereal;
|
||||||
|
|
||||||
|
// we only support two rates ATM so return lunar tracking rate
|
||||||
//if (rate == 60.1)
|
return DriveRates.driveLunar;
|
||||||
// return DriveRates.driveLunar;
|
|
||||||
//else if (rate == 60.1)
|
|
||||||
// return DriveRates.driveSidereal;
|
|
||||||
|
|
||||||
//return DriveRates.driveKing;
|
|
||||||
LogMessage("TrackingRate Get", $"{_trackingRate}");
|
|
||||||
return _trackingRate;
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -2616,8 +2653,6 @@ namespace ASCOM.Meade.net
|
|||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(value), value, null);
|
throw new ArgumentOutOfRangeException(nameof(value), value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
_trackingRate = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -649,5 +649,11 @@ namespace Meade.net.UnitTests
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CheckTargetRightAscensionIsNullByDefault() => Assert.That(SharedResources.TargetRightAscension.HasValue, Is.False);
|
public void CheckTargetRightAscensionIsNullByDefault() => Assert.That(SharedResources.TargetRightAscension.HasValue, Is.False);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CheckIsTargetCoordinateInitRequired() => Assert.That(SharedResources.IsTargetCoordinateInitRequired, Is.True);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CheckIsGuiding() => Assert.That(SharedResources.IsGuiding, Is.False);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,7 @@ namespace ASCOM.Meade.net
|
|||||||
public double Azimuth { get; set; }
|
public double Azimuth { get; set; }
|
||||||
public double RightAscension { get; set; }
|
public double RightAscension { get; set; }
|
||||||
public double Declination { get; set; }
|
public double Declination { get; set; }
|
||||||
|
public double SiteLongitude { get; set; }
|
||||||
|
public double SiteLatitude { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,13 +124,17 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
public static bool SendBool(string command, bool raw = false)
|
public static bool SendBool(string command, bool raw = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
var result = SendChar(command, raw);
|
var result = SendChar(command, raw);
|
||||||
|
|
||||||
return result == "1";
|
return result == "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SendChar(string command, bool raw = false)
|
public static string SendChar(string command, bool raw = false)
|
||||||
|
{
|
||||||
|
return SendChars(command, raw, count: 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SendChars(string command, bool raw = false, int count = 1)
|
||||||
{
|
{
|
||||||
lock (LockObject)
|
lock (LockObject)
|
||||||
{
|
{
|
||||||
@@ -141,14 +145,11 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return SharedSerial.ReceiveCounted(1);
|
return SharedSerial.ReceiveCounted(count);
|
||||||
}
|
}
|
||||||
catch (COMException ex)
|
catch (COMException ex) when (ex.Message.Contains("Timed out waiting for received data"))
|
||||||
{
|
{
|
||||||
if (ex.Message.Contains("Timed out waiting for received data"))
|
throw new TimeoutException(ex.Message, ex);
|
||||||
throw new TimeoutException(ex.Message, ex);
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -575,5 +576,19 @@ namespace ASCOM.Meade.net
|
|||||||
get => _earliestNonSlewingTime;
|
get => _earliestNonSlewingTime;
|
||||||
internal set => _earliestNonSlewingTime.Set(value);
|
internal set => _earliestNonSlewingTime.Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly ThreadSafeValue<bool> _isTargetCoordinateInitRequired = true;
|
||||||
|
public static bool IsTargetCoordinateInitRequired
|
||||||
|
{
|
||||||
|
get => _isTargetCoordinateInitRequired;
|
||||||
|
internal set => _isTargetCoordinateInitRequired.Set(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly ThreadSafeValue<bool> _isGuiding = false;
|
||||||
|
public static bool IsGuiding
|
||||||
|
{
|
||||||
|
get => _isGuiding;
|
||||||
|
internal set => _isGuiding.Set(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
void SendBlind(string message, bool raw = false);
|
void SendBlind(string message, bool raw = false);
|
||||||
bool SendBool(string command, bool raw = false);
|
bool SendBool(string command, bool raw = false);
|
||||||
string SendChar(string message, bool raw = false);
|
string SendChar(string message, bool raw = false);
|
||||||
|
string SendChars(string message, bool raw = false, int count = 1);
|
||||||
|
|
||||||
string ReadTerminated();
|
string ReadTerminated();
|
||||||
|
|
||||||
@@ -46,6 +47,10 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
bool MovingSecondary { get; set; }
|
bool MovingSecondary { get; set; }
|
||||||
|
|
||||||
DateTime EarliestNonSlewingTime { get; set; }
|
DateTime EarliestNonSlewingTime { get; set; }
|
||||||
|
|
||||||
|
bool IsTargetCoordinateInitRequired { get; set; }
|
||||||
|
|
||||||
|
bool IsGuiding { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
||||||
@@ -94,6 +99,11 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
return SharedResources.SendChar(message, raw);
|
return SharedResources.SendChar(message, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string SendChars(string message, bool raw = false, int count = 1)
|
||||||
|
{
|
||||||
|
return SharedResources.SendChars(message, raw, count);
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadTerminated()
|
public string ReadTerminated()
|
||||||
{
|
{
|
||||||
return SharedResources.ReadTerminated();
|
return SharedResources.ReadTerminated();
|
||||||
@@ -175,5 +185,17 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
get => SharedResources.EarliestNonSlewingTime;
|
get => SharedResources.EarliestNonSlewingTime;
|
||||||
set => SharedResources.EarliestNonSlewingTime = value;
|
set => SharedResources.EarliestNonSlewingTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsTargetCoordinateInitRequired
|
||||||
|
{
|
||||||
|
get => SharedResources.IsTargetCoordinateInitRequired;
|
||||||
|
set => SharedResources.IsTargetCoordinateInitRequired = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsGuiding
|
||||||
|
{
|
||||||
|
get => SharedResources.IsGuiding;
|
||||||
|
set => SharedResources.IsGuiding = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user