Compare commits
145 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c2bd21f1e | |||
| 39a6bfca80 | |||
| f551081454 | |||
| 5c362a5a9a | |||
| abb985559e | |||
| ddd6178416 | |||
| 356377ce36 | |||
| 1b220334d6 | |||
| bb54356b58 | |||
| ebca231d9a | |||
| 2b5205d9c5 | |||
| 81d2b98bfe | |||
| 9ee6adf063 | |||
| 554b1af082 | |||
| 70f72e3df7 | |||
| 3af02920c4 | |||
| ede7c33302 | |||
| 9866578cab | |||
| d9093635de | |||
| 885edba1c5 | |||
| 1949c50764 | |||
| 2b7d12fac9 | |||
| f168acc90b | |||
| 8f6ea33139 | |||
| c6f938bd5c | |||
| c271f0c4d3 | |||
| 35a76fe52c | |||
| 64e42f961c | |||
| 8eb093c13a | |||
| a204f9c57f | |||
| 700802033b | |||
| 350dd23ed1 | |||
| 5e65ea7946 | |||
| 0c70688b60 | |||
| af3cca7611 | |||
| ef498fc5a0 | |||
| ceca3a15dc | |||
| a9b8a60e43 | |||
| 7a85f7ca9e | |||
| 57c5a34fe2 | |||
| a68e86d8cd | |||
| 503eec38a3 | |||
| ed54487a88 | |||
| f788320927 | |||
| dc68bb0b4c | |||
| 1a66f41d78 | |||
| 826f887bdf | |||
| 7ac3c95c8e | |||
| acb1533f21 | |||
| eda3a53d6f | |||
| 6786db65fe | |||
| df7dfb7c04 | |||
| 771e325067 | |||
| a5a3bd5bd4 | |||
| a605a3ed9d | |||
| ad9169a48d | |||
| 3b056ef7f8 | |||
| 710ae0420a | |||
| 2a6b74c6fd | |||
| 49c43358de | |||
| 27a0f54b07 | |||
| a562b848c0 | |||
| f4c26d777b | |||
| 8d8b50957c | |||
| faa6ad757e | |||
| 64df8282a0 | |||
| 8478af26bf | |||
| 77c87a51fa | |||
| 631aa91d94 | |||
| 90713de34b | |||
| a3408a86c3 | |||
| 74440b6b3b | |||
| f1d100892b | |||
| c6baab2b12 | |||
| f47b205025 | |||
| 6c27499769 | |||
| 6dff32505e | |||
| 7afd364efa | |||
| 6fc476b031 | |||
| af750549fe | |||
| 2e3572375f | |||
| b23da15022 | |||
| 0b75b8d2cd | |||
| 036a9d7116 | |||
| 6c769f3649 | |||
| bdbd206a54 | |||
| 1684bd60bd | |||
| 8c4b08d0c6 | |||
| fe3c106954 | |||
| 3d0464f379 | |||
| d1b5652228 | |||
| 65e06f2d6c | |||
| b27e50275d | |||
| a101d3a2d7 | |||
| d7637928b7 | |||
| 486a9205ee | |||
| 2c2c59290e | |||
| 70e615bb4e | |||
| 43ec63b0f5 | |||
| 8c94fd6b71 | |||
| f354bcdee1 | |||
| e32c2aa50a | |||
| 795dc0c741 | |||
| 22a8a794ba | |||
| c6b54e273d | |||
| 7eec6c0008 | |||
| f9bb2aa879 | |||
| 18ea52c972 | |||
| f4eafa668d | |||
| 53abdba374 | |||
| fdd008fcfb | |||
| eaeae4d66b | |||
| 6ac80c408c | |||
| 9c5620edee | |||
| ad40eb8b9a | |||
| aca01de4ee | |||
| 384deecc3f | |||
| b27adf2649 | |||
| 2776b469c8 | |||
| fc3c91b975 | |||
| e7c81aba24 | |||
| a15bf22785 | |||
| ed84313c2e | |||
| e4af93dd07 | |||
| 5538f51cf0 | |||
| a2abbbb3d0 | |||
| d0f12a604a | |||
| 178ef8b11d | |||
| 0835431e76 | |||
| bf6203d901 | |||
| 51bf99cb8c | |||
| 21e7bcd530 | |||
| 8713154e84 | |||
| 75b6f0b4b4 | |||
| 032fb2e8a8 | |||
| a5773aaaa9 | |||
| f88ad13f0d | |||
| 9dde0d9e81 | |||
| acc935248b | |||
| cdf1066e4e | |||
| f57a73843a | |||
| b0ef75ae66 | |||
| 136ccc8fa9 | |||
| e9491da707 | |||
| db06002ebf |
@@ -218,5 +218,4 @@ _Pvt_Extensions
|
||||
|
||||
# nCrunch items
|
||||
*.ncrunchsolution
|
||||
*.DotSettings
|
||||
*.ncrunchproject
|
||||
|
||||
@@ -90,6 +90,10 @@
|
||||
<Project>{64308775-bd4a-469c-bcab-3ed830b811af}</Project>
|
||||
<Name>Meade.net.Telescope</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Meade.net\Meade.net.csproj">
|
||||
<Project>{3689a2cb-94c5-4012-a5cf-7e7d1dd27143}</Project>
|
||||
<Name>Meade.net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -123,7 +123,8 @@ namespace AstroMath.UnitTests
|
||||
|
||||
var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
|
||||
|
||||
Assert.That(altAz.Altitude, Is.EqualTo(20.958562421092779));
|
||||
Assert.That(altAz.Altitude, Is.GreaterThan(20.958562421092770));
|
||||
Assert.That(altAz.Altitude, Is.LessThanOrEqualTo(20.958562421092779));
|
||||
Assert.That(altAz.Azimuth, Is.EqualTo(281.2728706962269));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,12 @@ namespace Meade.net.Focuser.UnitTests
|
||||
{
|
||||
TraceLogger = false,
|
||||
ComPort = "TestCom1",
|
||||
Speed = 9600,
|
||||
Parity = "None",
|
||||
Handshake = "None",
|
||||
StopBits = "One",
|
||||
DataBits = 8,
|
||||
|
||||
GuideRateArcSecondsPerSecond = 1.23,
|
||||
Precision = "Unchanged",
|
||||
GuidingStyle = "Auto"
|
||||
@@ -36,8 +42,6 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties);
|
||||
|
||||
_focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object);
|
||||
@@ -103,16 +107,17 @@ namespace Meade.net.Focuser.UnitTests
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: CommandBlind"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandBlind_WhenConnected_ThenSendsExpectedMessage()
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void CommandBlind_WhenConnected_ThenSendsExpectedMessage(bool raw)
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
|
||||
ConnectFocuser();
|
||||
|
||||
_focuser.CommandBlind(expectedMessage, true);
|
||||
_focuser.CommandBlind(expectedMessage, raw);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedMessage), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedMessage, raw), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -124,16 +129,19 @@ namespace Meade.net.Focuser.UnitTests
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: CommandBool"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandBool_WhenConnected_ThenSendsExpectedMessage()
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void CommandBool_WhenConnected_ThenSendsExpectedMessage(bool raw)
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendBool(expectedMessage, raw)).Returns(true);
|
||||
|
||||
ConnectFocuser();
|
||||
|
||||
var exception = Assert.Throws<MethodNotImplementedException>(() => { _focuser.CommandBool(expectedMessage, true); });
|
||||
var result = _focuser.CommandBool(expectedMessage, raw);
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo("Method CommandBool is not implemented in this driver."));
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBool(expectedMessage, raw), Times.Once);
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -153,11 +161,11 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
ConnectFocuser();
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage)).Returns(() => expectedMessage);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage, true)).Returns(() => expectedMessage);
|
||||
|
||||
var actualMessage = _focuser.CommandString(sendMessage, true);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage, true), Times.Once);
|
||||
Assert.That(actualMessage, Is.EqualTo(expectedMessage));
|
||||
}
|
||||
|
||||
@@ -313,7 +321,7 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
_focuser.Halt();
|
||||
|
||||
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(":FQ#"), Times.AtLeastOnce);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("FQ", false), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -328,13 +336,13 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void Link_Get_ReturnsSameValueAsConnected( bool connected)
|
||||
public void Link_Get_ReturnsSameValueAsConnected(bool connected)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
_focuser.Connected = connected;
|
||||
|
||||
Assert.That( _focuser.Link, Is.EqualTo(connected));
|
||||
Assert.That(_focuser.Link, Is.EqualTo(connected));
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
@@ -388,12 +396,12 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
_focuser.Move(0);
|
||||
|
||||
_utilMock.Verify( x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Never);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestCase(200)]
|
||||
[TestCase(-200)]
|
||||
public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuser( int position)
|
||||
public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuser(int position)
|
||||
{
|
||||
_profileProperties.BacklashCompensation = 0;
|
||||
|
||||
@@ -403,17 +411,15 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
if (position < 0)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(":F-#"), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Never);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once);
|
||||
}
|
||||
|
||||
_sharedResourcesWrapperMock.Verify( x => x.Lock(It.IsAny<Action>()), Times.Once);
|
||||
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once());
|
||||
@@ -431,22 +437,20 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
if (position < 0)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Never);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position) + _profileProperties.BacklashCompensation), Times.Once);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2));
|
||||
}
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Lock(It.IsAny<Action>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -497,7 +501,7 @@ namespace Meade.net.Focuser.UnitTests
|
||||
{
|
||||
var exception = Assert.Throws<PropertyNotImplementedException>(() =>
|
||||
{
|
||||
var result = _focuser.Temperature;
|
||||
var result = _focuser.Temperature;
|
||||
Assert.Fail($"{result} should not have a value");
|
||||
});
|
||||
Assert.That(exception.Message, Is.EqualTo("Property read Temperature is not implemented in this driver."));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public enum Alignment
|
||||
{
|
||||
NeedsAlignment,
|
||||
OneStarAligned,
|
||||
TwoStarAligned,
|
||||
ThreeStarAligned,
|
||||
AlignedOnHome,
|
||||
ScopeWasParked,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"AlignmentStatus AlignmentMode={AlignmentMode};Tracking={Tracking};Status={Status}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace ASCOM.Meade.net.AstroMaths
|
||||
t0 -= 24;
|
||||
}
|
||||
|
||||
var ut = DateTimeToDecimalHours(utcDateTime);
|
||||
var ut = utcDateTime.DateTimeToDecimalHours();
|
||||
var a = ut * 1.002737909;
|
||||
|
||||
var t1 = t0 + a;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public class Clock : IClock
|
||||
{
|
||||
public DateTime UtcNow => DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace System
|
||||
{
|
||||
static class DoubelExtensions
|
||||
{
|
||||
public static bool Between(this double value, double lower, double higher)
|
||||
{
|
||||
return value >= lower & value <= higher;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public interface IClock
|
||||
{
|
||||
DateTime UtcNow { get; }
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<OutputPath>..\bin\Debug\</OutputPath>
|
||||
@@ -118,14 +118,18 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Alignment.cs" />
|
||||
<Compile Include="AlignmentStatus.cs" />
|
||||
<Compile Include="AstroMaths\AltitudeData.cs" />
|
||||
<Compile Include="AstroMaths\AstroMathExtensions.cs" />
|
||||
<Compile Include="AstroMaths\AstroMaths.cs" />
|
||||
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
|
||||
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
|
||||
<Compile Include="AstroMaths\IAstroMaths.cs" />
|
||||
<Compile Include="Clock.cs" />
|
||||
<Compile Include="ComparisonResult.cs" />
|
||||
<Compile Include="DoubleExtensions.cs" />
|
||||
<Compile Include="ExtensionMethods\DoubelExtensions.cs" />
|
||||
<Compile Include="IClock.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="Telescope.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -184,12 +188,17 @@
|
||||
<Name>Meade.net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
|
||||
@@ -149,15 +149,19 @@ namespace ASCOM.Meade.net
|
||||
// Default constructor - Internal prevents public creation
|
||||
// of instances. Returned by Telescope.AxisRates.
|
||||
//
|
||||
internal TrackingRates()
|
||||
internal TrackingRates(bool supportsLunar)
|
||||
{
|
||||
//
|
||||
// This array must hold ONE or more DriveRates values, indicating
|
||||
// the tracking rates supported by your telescope. The one value
|
||||
// (tracking rate) that MUST be supported is driveSidereal!
|
||||
//
|
||||
_trackingRates = new[] { DriveRates.driveSidereal, DriveRates.driveLunar };
|
||||
// TODO Initialize this array with any additional tracking rates that your driver may provide
|
||||
if (supportsLunar)
|
||||
{
|
||||
_trackingRates = new[] {DriveRates.driveSidereal, DriveRates.driveLunar};
|
||||
}
|
||||
else
|
||||
_trackingRates = new[] { DriveRates.driveSidereal };
|
||||
}
|
||||
|
||||
#region ITrackingRates Members
|
||||
|
||||
+2573
-1094
File diff suppressed because it is too large
Load Diff
@@ -98,6 +98,10 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="SharedResourcesUnitTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ThreadSafeBoolTests.cs" />
|
||||
<Compile Include="ThreadSafeDateTimeTests.cs" />
|
||||
<Compile Include="ThreadSafeEnumTests.cs" />
|
||||
<Compile Include="ThreadSafeNullableDoubleTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Meade.net\Meade.net.csproj">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using ASCOM.DeviceInterface;
|
||||
using ASCOM.Meade.net;
|
||||
using ASCOM.Meade.net.Wrapper;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
@@ -29,45 +30,47 @@ namespace Meade.net.UnitTests
|
||||
[Test]
|
||||
public void CheckThatSerialPortIsSetToUseMock()
|
||||
{
|
||||
Assert.That(SharedResources.SharedSerial,Is.EqualTo(_serialMock.Object));
|
||||
Assert.That(SharedResources.SharedSerial, Is.EqualTo(_serialMock.Object));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendBlind_WhenCalled_Then_ClearsBuffersAndSendsMessage()
|
||||
[TestCase(true, "Test")]
|
||||
[TestCase(false, "#:Test#")]
|
||||
public void SendBlind_WhenCalled_Then_ClearsBuffersAndSendsMessage(bool raw, string expectedMessage)
|
||||
{
|
||||
var expectedMessage = "Test";
|
||||
|
||||
SharedResources.SendBlind(expectedMessage);
|
||||
var sendMessage = "Test";
|
||||
SharedResources.SendBlind(sendMessage, raw);
|
||||
|
||||
_serialMock.Verify(x=> x.ClearBuffers(), Times.Once);
|
||||
_serialMock.Verify(x=>x.Transmit(expectedMessage), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendChar_WhenCalled_ThenSendsMessageAndReadsExpectedNumberOfCharacters()
|
||||
[TestCase(false, "#:Test#")]
|
||||
[TestCase(true, "Test")]
|
||||
public void SendChar_WhenCalled_ThenSendsMessageAndReadsExpectedNumberOfCharacters(bool raw, string expectedCommand)
|
||||
{
|
||||
var expectedMessage = "Test";
|
||||
var command = "Test";
|
||||
var expectedResult = "A";
|
||||
|
||||
_serialMock.Setup(x => x.ReceiveCounted(1)).Returns(expectedResult);
|
||||
|
||||
var result = SharedResources.SendChar(expectedMessage);
|
||||
var result = SharedResources.SendChar(command, raw);
|
||||
|
||||
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
|
||||
_serialMock.Verify(x => x.Transmit(expectedMessage), Times.Once);
|
||||
_serialMock.Verify(x => x.Transmit(expectedCommand), Times.Once);
|
||||
_serialMock.Verify(x => x.ReceiveCounted(1), Times.Once);
|
||||
Assert.That(result, Is.EqualTo(expectedResult));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendString_WhenCalled_ThenSendsMessageAndReadsResultUntilTerminatorFound()
|
||||
[TestCase(true, "Test")]
|
||||
[TestCase(false, "#:Test#")]
|
||||
public void SendString_WhenCalled_ThenSendsMessageAndReadsResultUntilTerminatorFound(bool includePrefix, string expectedMessage)
|
||||
{
|
||||
var expectedMessage = "Test";
|
||||
var transmitMessage = "Test";
|
||||
var expectedResult = "TestMessage#";
|
||||
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(expectedResult);
|
||||
|
||||
var result = SharedResources.SendString(expectedMessage);
|
||||
var result = SharedResources.SendString(transmitMessage, includePrefix);
|
||||
|
||||
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
|
||||
_serialMock.Verify(x => x.Transmit(expectedMessage), Times.Once);
|
||||
@@ -123,10 +126,19 @@ namespace Meade.net.UnitTests
|
||||
|
||||
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
|
||||
profileWrapperMock.Verify( x => x.WriteValue(DriverId, "Trace Level", profileProperties.TraceLogger.ToString()), Times.Once);
|
||||
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Speed", profileProperties.Speed.ToString()), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Data Bits", profileProperties.DataBits.ToString()), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Stop Bits", profileProperties.StopBits), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Hand Shake", profileProperties.Handshake), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Parity", profileProperties.Parity), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Rts / Dtr", profileProperties.RtsDtrEnabled.ToString()), Times.Once);
|
||||
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guiding Style", profileProperties.GuidingStyle), Times.Once);
|
||||
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Backlash Compensation", profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture)), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Reverse Focuser Direction", profileProperties.ReverseFocusDirection.ToString()), Times.Once);
|
||||
}
|
||||
@@ -136,14 +148,33 @@ namespace Meade.net.UnitTests
|
||||
{
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "true";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
string GuidingStyleDefault = "Auto";
|
||||
|
||||
string BacklashCompensationDefault = "3000";
|
||||
string ReverseFocuserDiectionDefault = "true";
|
||||
|
||||
string SendDateTimeDefault = "true";
|
||||
string SkipPromptsDefault = "true";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
@@ -163,8 +194,59 @@ namespace Meade.net.UnitTests
|
||||
x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault))
|
||||
.Returns(BacklashCompensationDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault))
|
||||
x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, "true"))
|
||||
.Returns(() => ReverseFocuserDiectionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => SpeedDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, "false"))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false"))
|
||||
.Returns(() => SendDateTimeDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Skip date prompts on connect", string.Empty, "false"))
|
||||
.Returns(() => SkipPromptsDefault);
|
||||
|
||||
|
||||
|
||||
IProfileWrapper profeWrapper = profileWrapperMock.Object;
|
||||
|
||||
@@ -176,14 +258,27 @@ namespace Meade.net.UnitTests
|
||||
var profileProperties = SharedResources.ReadProfile();
|
||||
|
||||
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
|
||||
|
||||
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
|
||||
|
||||
Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault));
|
||||
|
||||
Assert.That(profileProperties.GuideRateArcSecondsPerSecond,
|
||||
Is.EqualTo(double.Parse(GuideRateProfileNameDefault)));
|
||||
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
|
||||
Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault));
|
||||
Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault));
|
||||
|
||||
Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(int.Parse(BacklashCompensationDefault)));
|
||||
Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(bool.Parse(ReverseFocuserDiectionDefault)));
|
||||
|
||||
Assert.That(profileProperties.Speed, Is.EqualTo(int.Parse(SpeedDefault)));
|
||||
Assert.That(profileProperties.DataBits, Is.EqualTo(int.Parse(DataBitsDefault)));
|
||||
Assert.That(profileProperties.StopBits, Is.EqualTo(StopBitsDefault));
|
||||
Assert.That(profileProperties.Handshake, Is.EqualTo(HandshakeDefault));
|
||||
Assert.That(profileProperties.Parity, Is.EqualTo(ParityDefault));
|
||||
Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(bool.Parse(RtsDtrEnabledDefault)));
|
||||
|
||||
Assert.That(profileProperties.SendDateTime, Is.EqualTo(bool.Parse(SendDateTimeDefault)));
|
||||
}
|
||||
|
||||
[TestCase("TCP")]
|
||||
@@ -199,27 +294,81 @@ namespace Meade.net.UnitTests
|
||||
public void Connect_WhenDeviceIdIsSerialButGVPEchos_ThenThrowsException()
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
|
||||
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string TraceStateDefault = "false";
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => SpeedDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
|
||||
@@ -229,7 +378,7 @@ namespace Meade.net.UnitTests
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = ":GVP#"; });
|
||||
_serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; });
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns( () => serialPortReturn);
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
|
||||
|
||||
var result = Assert.Throws<Exception>(() => { SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object); });
|
||||
Assert.That(result.Message, Is.EqualTo("Serial port is looping back data, something is wrong with the hardware."));
|
||||
@@ -239,26 +388,77 @@ namespace Meade.net.UnitTests
|
||||
public void Connect_WhenDeviceIdIsSerialButGVPNotSupported_ThenConnectsAndSetsProductToLX200Classic()
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string TraceStateDefault = "false";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => SpeedDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
@@ -267,7 +467,7 @@ namespace Meade.net.UnitTests
|
||||
|
||||
string serialPortReturn = string.Empty;
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => {
|
||||
_serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => {
|
||||
serialPortReturn = string.Empty;
|
||||
throw new Exception("Testerror");
|
||||
});
|
||||
@@ -293,25 +493,77 @@ namespace Meade.net.UnitTests
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
|
||||
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string TraceStateDefault = "false";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => SpeedDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
@@ -339,29 +591,423 @@ namespace Meade.net.UnitTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connect_WhenSerialPortIsNotRespondingCorrectly_ThenExceptionThrown()
|
||||
public void Connect_WhenSpeedIsFastAndAutostarSetToFast_ThenConnectsDirectlyAtFastSpeed()
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
|
||||
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string TraceStateDefault = "false";
|
||||
string SpeedDefault = "57600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => SpeedDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
|
||||
SharedResources.ProfileFactory = profileFactoryMock.Object;
|
||||
|
||||
string serialPortReturn = string.Empty;
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = TelescopeList.LX200GPS; });
|
||||
_serialMock.Setup(x => x.Transmit("#:GVN#")).Callback(() => { serialPortReturn = TelescopeList.LX200GPS_42G; });
|
||||
_serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = "0"; });
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
|
||||
|
||||
var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
|
||||
try
|
||||
{
|
||||
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
|
||||
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200GPS));
|
||||
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.LX200GPS_42G));
|
||||
}
|
||||
finally
|
||||
{
|
||||
SharedResources.Disconnect(deviceId, String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("57600")]
|
||||
[TestCase("38400")]
|
||||
[TestCase("28800")]
|
||||
[TestCase("19200")]
|
||||
[TestCase("14400")]
|
||||
[TestCase("4800")]
|
||||
[TestCase("2400")]
|
||||
[TestCase("1200")]
|
||||
public void Connect_WhenSpeedIsFastAndAutostarAtDefault_ThenConnectsAutoStarSpeedChanged(string WantedSpeed)
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => WantedSpeed);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
|
||||
SharedResources.ProfileFactory = profileFactoryMock.Object;
|
||||
|
||||
string serialPortReturn = string.Empty;
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = TelescopeList.LX200GPS; });
|
||||
_serialMock.Setup(x => x.Transmit("#:GVN#")).Callback(() => { serialPortReturn = TelescopeList.LX200GPS_42G; });
|
||||
_serialMock.Setup(x => x.Transmit("#:SB1#")).Callback(() => { serialPortReturn = "1"; });
|
||||
|
||||
var ggCall = 0;
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => {
|
||||
ggCall++;
|
||||
if (ggCall == 1)
|
||||
throw new Exception("Fake Timeout");
|
||||
else
|
||||
serialPortReturn = "0"; });
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
|
||||
_serialMock.Setup(x => x.ReceiveCounted(1)).Returns(() => "1");
|
||||
|
||||
var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
|
||||
try
|
||||
{
|
||||
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200GPS));
|
||||
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.LX200GPS_42G));
|
||||
|
||||
_traceLoggerMock.Verify(x => x.LogIssue("Connect", $"Telescope serial port speed change, connecting at ps{WantedSpeed}."), Times.Once);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SharedResources.Disconnect(deviceId, String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("57600")]
|
||||
[TestCase("38400")]
|
||||
[TestCase("28800")]
|
||||
[TestCase("19200")]
|
||||
[TestCase("14400")]
|
||||
[TestCase("4800")]
|
||||
[TestCase("2400")]
|
||||
[TestCase("1200")]
|
||||
public void Connect_WhenAutostarReportsFailedToChangeSpeec_ThenConnectsAutoStarAtDefaultSpeed(string WantedSpeed)
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => WantedSpeed);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
|
||||
SharedResources.ProfileFactory = profileFactoryMock.Object;
|
||||
|
||||
string serialPortReturn = string.Empty;
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GVP#")).Callback(() => { serialPortReturn = TelescopeList.LX200GPS; });
|
||||
_serialMock.Setup(x => x.Transmit("#:GVN#")).Callback(() => { serialPortReturn = TelescopeList.LX200GPS_42G; });
|
||||
_serialMock.Setup(x => x.Transmit("#:SB1#")).Callback(() => { serialPortReturn = "1"; });
|
||||
|
||||
var ggCall = 0;
|
||||
|
||||
_serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => {
|
||||
ggCall++;
|
||||
if (ggCall == 1)
|
||||
throw new Exception("Fake Timeout");
|
||||
else
|
||||
serialPortReturn = "0";
|
||||
});
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
|
||||
_serialMock.Setup(x => x.ReceiveCounted(1)).Returns(() => "0");
|
||||
|
||||
var connectionResult = SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
|
||||
try
|
||||
{
|
||||
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200GPS));
|
||||
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.LX200GPS_42G));
|
||||
|
||||
_traceLoggerMock.Verify(x => x.LogIssue("Connect", $"Telescope not responding to speed change, connecting at ps{SpeedDefault}."), Times.Once);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SharedResources.Disconnect(deviceId, String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connect_WhenSerialPortIsNotRespondingCorrectly_ThenExceptionThrown()
|
||||
{
|
||||
string deviceId = "Serial";
|
||||
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
|
||||
string TraceStateDefault = "false";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string SpeedDefault = "9600";
|
||||
string DataBitsDefault = "8";
|
||||
string StopBitsDefault = "One";
|
||||
string HandshakeDefault = "None";
|
||||
string ParityDefault = "None";
|
||||
string RtsDtrEnabledDefault = "false";
|
||||
|
||||
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
string PrecisionDefault = "Unchanged";
|
||||
|
||||
string ParkedBehaviourDefault = "No Coordinates";
|
||||
string ParkedAltDefault = "0";
|
||||
string ParkedAzimuthDefault = "180";
|
||||
string FocalLengthDefault = "2000";
|
||||
string ApertureAreaDefault = "32685";
|
||||
string ApertureDiameterDefault = "203";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault))
|
||||
.Returns(() => SpeedDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))
|
||||
.Returns(() => DataBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault))
|
||||
.Returns(() => StopBitsDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Hand Shake", string.Empty, HandshakeDefault))
|
||||
.Returns(() => HandshakeDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parity", string.Empty, ParityDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Rts / Dtr", string.Empty, RtsDtrEnabledDefault))
|
||||
.Returns(() => RtsDtrEnabledDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Behaviour", string.Empty, ParkedBehaviourDefault))
|
||||
.Returns(() => ParityDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Altitude", string.Empty, ParkedAltDefault))
|
||||
.Returns(() => ParkedAltDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault))
|
||||
.Returns(() => ParkedAzimuthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault))
|
||||
.Returns(() => FocalLengthDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Area (mm²)", string.Empty, ApertureAreaDefault))
|
||||
.Returns(() => ApertureAreaDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Aperture Diameter (mm)", string.Empty, ApertureDiameterDefault))
|
||||
.Returns(() => ApertureDiameterDefault);
|
||||
|
||||
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
|
||||
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
|
||||
@@ -383,5 +1029,41 @@ namespace Meade.net.UnitTests
|
||||
|
||||
_traceLoggerMock.Verify( x => x.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckIsParkedIsFalseByDefault() => Assert.That(SharedResources.IsParked, Is.False);
|
||||
|
||||
[Test]
|
||||
public void CheckParkedPositionIsNullByDefault() => Assert.That(SharedResources.ParkedPosition, Is.Null);
|
||||
|
||||
[Test]
|
||||
public void CheckIsLongFormatIsFalseByDefault() => Assert.That(SharedResources.IsLongFormat, Is.False);
|
||||
|
||||
[Test]
|
||||
public void CheckMovingPrimaryIsFalseBydefault() => Assert.That(SharedResources.MovingPrimary, Is.False);
|
||||
|
||||
[Test]
|
||||
public void CheckMovingSecondaryIsFalseBydefault() => Assert.That(SharedResources.MovingSecondary, Is.False);
|
||||
|
||||
[Test]
|
||||
public void CheckSideOfPierIsUnknownByDefault() => Assert.That(SharedResources.SideOfPier, Is.EqualTo(PierSide.pierUnknown));
|
||||
|
||||
[Test]
|
||||
public void CheckSlewSettleTimeIsZeroByDefault() => Assert.That(SharedResources.SlewSettleTime, Is.EqualTo((short)0));
|
||||
|
||||
[Test]
|
||||
public void CheckEarliestNonNonSlewingTimeIsMinValueByDefault() => Assert.That(SharedResources.EarliestNonSlewingTime, Is.EqualTo(DateTime.MinValue));
|
||||
|
||||
[Test]
|
||||
public void CheckTargetDeclinationIsNullByDefault() => Assert.That(SharedResources.TargetDeclination.HasValue, Is.False);
|
||||
|
||||
[Test]
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using ASCOM.Meade.net;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Meade.net.UnitTests
|
||||
{
|
||||
public class ThreadSafeBoolTests
|
||||
{
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void When_Assigned_ThenValueIsSame(bool value)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<bool> sut = value;
|
||||
|
||||
// when
|
||||
bool actual = sut;
|
||||
|
||||
// then
|
||||
Assert.That(actual, Is.EqualTo(value));
|
||||
}
|
||||
|
||||
[TestCase(false, false)]
|
||||
[TestCase(false, true)]
|
||||
[TestCase(true, false)]
|
||||
[TestCase(true, true)]
|
||||
public void When_SetValue_ThenValueIsUpdated(bool initialValue, bool setValue)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<bool> sut = initialValue;
|
||||
|
||||
// when
|
||||
sut.Set(setValue);
|
||||
bool afterset = sut;
|
||||
|
||||
// then
|
||||
Assert.That(afterset, Is.EqualTo(setValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using ASCOM.Meade.net;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Meade.net.UnitTests
|
||||
{
|
||||
public class ThreadSafeDateTimeTests
|
||||
{
|
||||
[TestCaseSource(nameof(DateTimeSource))]
|
||||
public void When_Assigned_ThenValueIsSame(DateTime value)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<DateTime> sut = value;
|
||||
|
||||
// when
|
||||
DateTime actual = sut;
|
||||
|
||||
// then
|
||||
Assert.That(actual, Is.EqualTo(value));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(DateTimeSetSource))]
|
||||
public void When_SetValue_ThenValueIsUpdated(DateTime initialValue, DateTime setValue)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<DateTime> sut = initialValue;
|
||||
|
||||
// when
|
||||
sut.Set(setValue);
|
||||
DateTime afterset = sut;
|
||||
|
||||
// then
|
||||
Assert.That(afterset, Is.EqualTo(setValue));
|
||||
}
|
||||
|
||||
static readonly DateTime Example1 = DateTimeOffset.Parse("2012-05-09T02:10:31.296761Z", CultureInfo.InvariantCulture).UtcDateTime;
|
||||
static readonly DateTime Example2 = DateTimeOffset.Parse("2051-03-09T23:15:11.556081Z", CultureInfo.InvariantCulture).UtcDateTime;
|
||||
|
||||
static IEnumerable<DateTime> DateTimeSource => new[]
|
||||
{
|
||||
DateTime.MinValue,
|
||||
Example1,
|
||||
Example2
|
||||
};
|
||||
|
||||
static IEnumerable<TestCaseData> DateTimeSetSource => new[]
|
||||
{
|
||||
new TestCaseData(DateTime.MinValue, Example1),
|
||||
new TestCaseData(DateTime.MinValue, Example2),
|
||||
new TestCaseData(DateTime.MinValue, DateTime.MinValue),
|
||||
new TestCaseData(Example1, Example1),
|
||||
new TestCaseData(Example1, Example2),
|
||||
new TestCaseData(Example1, DateTime.MinValue),
|
||||
new TestCaseData(Example2, Example1),
|
||||
new TestCaseData(Example2, Example2),
|
||||
new TestCaseData(Example2, DateTime.MinValue)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using ASCOM.DeviceInterface;
|
||||
using ASCOM.Meade.net;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Meade.net.UnitTests
|
||||
{
|
||||
public class ThreadSafeEnumTests
|
||||
{
|
||||
[TestCase(PierSide.pierUnknown)]
|
||||
[TestCase(PierSide.pierEast)]
|
||||
[TestCase(PierSide.pierWest)]
|
||||
public void When_Assigned_ThenValueIsSame(PierSide value)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<PierSide> sut = value;
|
||||
|
||||
// when
|
||||
PierSide actual = sut;
|
||||
|
||||
// then
|
||||
Assert.That(actual, Is.EqualTo(value));
|
||||
}
|
||||
|
||||
[TestCase(PierSide.pierUnknown, PierSide.pierUnknown)]
|
||||
[TestCase(PierSide.pierUnknown, PierSide.pierEast)]
|
||||
[TestCase(PierSide.pierUnknown, PierSide.pierWest)]
|
||||
[TestCase(PierSide.pierEast, PierSide.pierUnknown)]
|
||||
[TestCase(PierSide.pierEast, PierSide.pierEast)]
|
||||
[TestCase(PierSide.pierEast, PierSide.pierWest)]
|
||||
[TestCase(PierSide.pierWest, PierSide.pierUnknown)]
|
||||
[TestCase(PierSide.pierWest, PierSide.pierEast)]
|
||||
[TestCase(PierSide.pierWest, PierSide.pierWest)]
|
||||
public void When_SetValue_ThenValueIsUpdated(PierSide initialValue, PierSide setValue)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<PierSide> sut = initialValue;
|
||||
|
||||
// when
|
||||
sut.Set(setValue);
|
||||
PierSide afterset = sut;
|
||||
|
||||
// then
|
||||
Assert.That(afterset, Is.EqualTo(setValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using ASCOM.Meade.net;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Meade.net.UnitTests
|
||||
{
|
||||
public class ThreadSafeNullableDoubleTests
|
||||
{
|
||||
[TestCase(0.1d)]
|
||||
[TestCase(-12.34d)]
|
||||
[TestCase(0d)]
|
||||
[TestCase(null)]
|
||||
public void When_Assigned_ThenValueIsSame(double? value)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<double?> sut = value;
|
||||
|
||||
// when
|
||||
double? actual = sut;
|
||||
|
||||
// then
|
||||
Assert.That(actual, Is.EqualTo(value));
|
||||
}
|
||||
|
||||
[TestCase(0.1d, 0.2d)]
|
||||
[TestCase(-12.34d, 5d)]
|
||||
[TestCase(0d, 1d)]
|
||||
[TestCase(null, 2d)]
|
||||
[TestCase(0.1d, null)]
|
||||
[TestCase(-12.34d, null)]
|
||||
[TestCase(0d, null)]
|
||||
[TestCase(null, null)]
|
||||
public void When_SetValue_ThenValueIsUpdated(double? initialValue, double? setValue)
|
||||
{
|
||||
// given
|
||||
ThreadSafeValue<double?> sut = initialValue;
|
||||
|
||||
// when
|
||||
sut.Set(setValue);
|
||||
double? afterset = sut;
|
||||
|
||||
// then
|
||||
Assert.That(afterset, Is.EqualTo(setValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
<package id="JetBrains.Annotations" version="2020.3.0" targetFramework="net472" />
|
||||
<package id="Moq" version="4.15.2" targetFramework="net472" />
|
||||
<package id="NUnit" version="3.13.0" targetFramework="net472" />
|
||||
<package id="NUnit.ConsoleRunner" version="3.12.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -43,7 +43,7 @@ namespace ASCOM.Meade.net
|
||||
/// Private variable to hold an ASCOM Utilities object
|
||||
/// </summary>
|
||||
private readonly IUtil _utilities;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Meade.net"/> class.
|
||||
/// Must be public for COM registration.
|
||||
@@ -101,32 +101,39 @@ namespace ASCOM.Meade.net
|
||||
|
||||
public void CommandBlind(string command, bool raw)
|
||||
{
|
||||
LogMessage("CommandBlind", "raw: {0} command {0}", raw, command);
|
||||
CheckConnected("CommandBlind");
|
||||
// Call CommandString and return as soon as it finishes
|
||||
//this.CommandString(command, raw);
|
||||
SharedResourcesWrapper.SendBlind(command);
|
||||
SharedResourcesWrapper.SendBlind(command, raw);
|
||||
// or
|
||||
//throw new ASCOM.MethodNotImplementedException("CommandBlind");
|
||||
// DO NOT have both these sections! One or the other
|
||||
LogMessage("CommandBlind", "Completed");
|
||||
}
|
||||
|
||||
public bool CommandBool(string command, bool raw)
|
||||
{
|
||||
LogMessage("CommandBool", "raw: {0} command {0}", raw, command);
|
||||
CheckConnected("CommandBool");
|
||||
//string ret = CommandString(command, raw);
|
||||
// decode the return string and return true or false
|
||||
var result = SharedResourcesWrapper.SendBool(command, raw);
|
||||
LogMessage("CommandBool", "Completed: {0}", result);
|
||||
return result;
|
||||
// or
|
||||
throw new MethodNotImplementedException("CommandBool");
|
||||
//throw new MethodNotImplementedException("CommandBool");
|
||||
// DO NOT have both these sections! One or the other
|
||||
}
|
||||
|
||||
public string CommandString(string command, bool raw)
|
||||
{
|
||||
LogMessage("CommandString", "raw: {0} command {0}", raw, command);
|
||||
CheckConnected("CommandString");
|
||||
// it's a good idea to put all the low level communication with the device here,
|
||||
// then all communication calls this function
|
||||
// you need something to ensure that only one command is in progress at a time
|
||||
return SharedResourcesWrapper.SendString(command);
|
||||
var result = SharedResourcesWrapper.SendString(command, raw);
|
||||
LogMessage("CommandBool", "Completed: {0}", result);
|
||||
return result;
|
||||
//throw new ASCOM.MethodNotImplementedException("CommandString");
|
||||
}
|
||||
|
||||
@@ -169,12 +176,12 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message);
|
||||
LogMessage("Connected Set", "Error connecting to port {0} - {1}", _profileProperties.ComPort, ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMessage("Connected Set", "Disconnecting from port {0}", ComPort);
|
||||
LogMessage("Connected Set", "Disconnecting from port {0}", _profileProperties.ComPort);
|
||||
SharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
IsConnected = false;
|
||||
}
|
||||
@@ -225,7 +232,7 @@ namespace ASCOM.Meade.net
|
||||
|
||||
//todo fix this issue: A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe.
|
||||
|
||||
SharedResourcesWrapper.SendBlind(":FQ#");
|
||||
SharedResourcesWrapper.SendBlind("FQ");
|
||||
//:FQ# Halt Focuser Motion
|
||||
//Returns: Nothing
|
||||
}
|
||||
@@ -288,37 +295,34 @@ namespace ASCOM.Meade.net
|
||||
return;
|
||||
|
||||
var direction = position > 0;
|
||||
if (ReverseFocusDirection)
|
||||
if (_profileProperties.ReverseFocusDirection)
|
||||
direction = !direction;
|
||||
|
||||
//backlash compensation.
|
||||
var backlashCompensationSteps = direction ? Math.Abs(_profileProperties.BacklashCompensation) : 0;
|
||||
|
||||
SharedResourcesWrapper.Lock(() =>
|
||||
var steps = Math.Abs(position) + backlashCompensationSteps;
|
||||
|
||||
|
||||
MoveFocuser(direction, steps);
|
||||
|
||||
|
||||
//todo refactor the backlash compensation to combine the commands into as few moves as practicle.
|
||||
//ApplyBacklashCompensation(direction);
|
||||
if (direction & backlashCompensationSteps != 0)
|
||||
{
|
||||
//backlash compensation.
|
||||
var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0;
|
||||
Tl.LogMessage("Move", "Applying backlash compensation");
|
||||
MoveFocuser(!direction, backlashCompensationSteps);
|
||||
}
|
||||
|
||||
var steps = Math.Abs(position) + backlashCompensationSteps;
|
||||
|
||||
|
||||
MoveFocuser(direction, steps);
|
||||
|
||||
|
||||
//todo refactor the backlash compensation to combine the commands into as few moves as practicle.
|
||||
//ApplyBacklashCompensation(direction);
|
||||
if (direction & backlashCompensationSteps != 0)
|
||||
{
|
||||
Tl.LogMessage("Move", "Applying backlash compensation");
|
||||
MoveFocuser(!direction, backlashCompensationSteps);
|
||||
}
|
||||
|
||||
DynamicBreaking(direction);
|
||||
//todo implement dynamic braking
|
||||
//dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop.
|
||||
});
|
||||
DynamicBreaking(direction);
|
||||
//todo implement dynamic braking
|
||||
//dynamic breaking is sending the command to move in the opposite direction immediatly followed by the command to stop.
|
||||
}
|
||||
|
||||
private void DynamicBreaking(bool directionOut)
|
||||
{
|
||||
if (!UseDynamicBreaking)
|
||||
if (!_profileProperties.DynamicBreaking)
|
||||
return;
|
||||
|
||||
Tl.LogMessage("Move", "Applying dynamic breaking");
|
||||
@@ -329,18 +333,18 @@ namespace ASCOM.Meade.net
|
||||
|
||||
private void MoveFocuser(bool directionOut, int steps)
|
||||
{
|
||||
//_sharedResourcesWrapper.SendBlind(":FF#");
|
||||
//_sharedResourcesWrapper.SendBlind("FF");
|
||||
//:FF# Set Focus speed to fastest setting
|
||||
//Returns: Nothing
|
||||
|
||||
//:FS# Set Focus speed to slowest setting
|
||||
//Returns: Nothing
|
||||
|
||||
//:F<n># Autostar, Autostar II – set focuser speed to <n> where <n> is an ASCII digit 1..4
|
||||
//:F<n># Autostar, Autostar II - set focuser speed to <n> where <n> is an ASCII digit 1..4
|
||||
//Returns: Nothing
|
||||
//All others – Not Supported
|
||||
//All others - Not Supported
|
||||
_utilities.WaitForMilliseconds(100);
|
||||
|
||||
|
||||
PerformFocuserMove(directionOut);
|
||||
|
||||
_utilities.WaitForMilliseconds(steps);
|
||||
@@ -350,7 +354,7 @@ namespace ASCOM.Meade.net
|
||||
|
||||
private void PerformFocuserMove(bool directionOut)
|
||||
{
|
||||
SharedResourcesWrapper.SendBlind(directionOut ? ":F+#" : ":F-#");
|
||||
SharedResourcesWrapper.SendBlind(directionOut ? "F+" : "F-");
|
||||
//:F+# Start Focuser moving inward (toward objective)
|
||||
//Returns: None
|
||||
|
||||
@@ -411,7 +415,7 @@ namespace ASCOM.Meade.net
|
||||
#region ASCOM Registration
|
||||
|
||||
// Register or unregister driver for ASCOM. This is harmless if already
|
||||
// registered or unregistered.
|
||||
// registered or unregistered.
|
||||
//
|
||||
/// <summary>
|
||||
/// Register or unregister the driver with the ASCOM Platform.
|
||||
@@ -481,7 +485,7 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Use this function to throw an exception if we aren't connected to the hardware
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002A_005C_002A_002EUnitTests/@EntryIndexedValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002A_005C_002A_002EUnitTests/@EntryIndexRemoved">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Housekeeping/ExcludedProjects/ProjectMasksToIgnore/=_002A_002EUnitTests_002E_002A/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ASCOM/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autostar/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public static class EnumExtensionMethods
|
||||
{
|
||||
public static string GetDescription(this Enum GenericEnum)
|
||||
{
|
||||
var genericEnumType = GenericEnum.GetType();
|
||||
var memberInfo = genericEnumType.GetMember(GenericEnum.ToString());
|
||||
if (memberInfo.Length > 0)
|
||||
{
|
||||
var _Attribs = memberInfo[0]
|
||||
.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
|
||||
if (_Attribs.Any())
|
||||
{
|
||||
return ((System.ComponentModel.DescriptionAttribute) _Attribs.ElementAt(0)).Description;
|
||||
}
|
||||
}
|
||||
|
||||
return GenericEnum.ToString();
|
||||
}
|
||||
|
||||
public static T GetValueFromDescription<T>( string description) where T : Enum
|
||||
{
|
||||
foreach (T value in Enum.GetValues(typeof(T)))
|
||||
{
|
||||
if (value.GetDescription() == description)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-11
@@ -337,18 +337,23 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
key?.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
|
||||
key?.SetValue("AppId", _sAppId);
|
||||
using (RegistryKey key2 = key.CreateSubKey("Implemented Categories"))
|
||||
if (key != null)
|
||||
{
|
||||
key2?.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
|
||||
}
|
||||
using (RegistryKey key2 = key.CreateSubKey("ProgId"))
|
||||
{
|
||||
key2?.SetValue(null, progid);
|
||||
}
|
||||
key.CreateSubKey("Programmable");
|
||||
using (RegistryKey key2 = key.CreateSubKey("LocalServer32"))
|
||||
{
|
||||
key2?.SetValue(null, Application.ExecutablePath);
|
||||
using (RegistryKey key2 = key.CreateSubKey("Implemented Categories"))
|
||||
{
|
||||
key2?.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
|
||||
}
|
||||
|
||||
using (RegistryKey key2 = key.CreateSubKey("ProgId"))
|
||||
{
|
||||
key2?.SetValue(null, progid);
|
||||
}
|
||||
|
||||
key.CreateSubKey("Programmable");
|
||||
using (RegistryKey key2 = key.CreateSubKey("LocalServer32"))
|
||||
{
|
||||
key2?.SetValue(null, Application.ExecutablePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="ClassFactory.cs" />
|
||||
<Compile Include="ConnectionInfo.cs" />
|
||||
<Compile Include="EnumExtensionMethods.cs" />
|
||||
<Compile Include="frmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -136,12 +137,16 @@
|
||||
<DependentUpon>frmMain.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GarbageCollection.cs" />
|
||||
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
|
||||
<Compile Include="LocalServer.cs" />
|
||||
<Compile Include="MeadeTelescopeBase.cs" />
|
||||
<Compile Include="ParkedBehaviour.cs" />
|
||||
<Compile Include="ParkedPosition.cs" />
|
||||
<Compile Include="ProfileFactory.cs" />
|
||||
<Compile Include="ProfileProperties.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TelescopeList.cs" />
|
||||
<Compile Include="ThreadSafeValue.cs" />
|
||||
<Compile Include="Win32Utilities.cs" />
|
||||
<Compile Include="Wrapper\IProfileWrapper.cs" />
|
||||
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
|
||||
@@ -199,6 +204,7 @@
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
|
||||
@@ -19,16 +19,8 @@ namespace ASCOM.Meade.net
|
||||
/// </summary>
|
||||
protected static readonly string DriverDescription = "Meade Generic";
|
||||
|
||||
protected static string ComPort; // Variables to hold the currrent device configuration
|
||||
protected static int BacklashCompensation;
|
||||
protected static bool ReverseFocusDirection;
|
||||
protected static bool UseDynamicBreaking;
|
||||
protected double GuideRate;
|
||||
protected string Precision;
|
||||
protected string GuidingStyle;
|
||||
protected double SiteElevation;
|
||||
|
||||
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
|
||||
protected ProfileProperties _profileProperties;
|
||||
|
||||
public MeadeTelescopeBase()
|
||||
{
|
||||
@@ -57,25 +49,25 @@ namespace ASCOM.Meade.net
|
||||
/// </summary>
|
||||
protected void ReadProfile()
|
||||
{
|
||||
var profileProperties = SharedResourcesWrapper.ReadProfile();
|
||||
Tl.Enabled = profileProperties.TraceLogger;
|
||||
ComPort = profileProperties.ComPort;
|
||||
BacklashCompensation = profileProperties.BacklashCompensation;
|
||||
ReverseFocusDirection = profileProperties.ReverseFocusDirection;
|
||||
UseDynamicBreaking = profileProperties.DynamicBreaking;
|
||||
GuideRate = profileProperties.GuideRateArcSecondsPerSecond;
|
||||
Precision = profileProperties.Precision;
|
||||
GuidingStyle = profileProperties.GuidingStyle.ToLower();
|
||||
SiteElevation = profileProperties.SiteElevation;
|
||||
_profileProperties = SharedResourcesWrapper.ReadProfile();
|
||||
Tl.Enabled = _profileProperties.TraceLogger;
|
||||
|
||||
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
|
||||
LogMessage("ReadProfile", $"Com Port: {ComPort}");
|
||||
LogMessage("ReadProfile", $"Backlash Steps: {BacklashCompensation}");
|
||||
LogMessage("ReadProfile", $"Dynamic breaking: {UseDynamicBreaking}");
|
||||
LogMessage("ReadProfile", $"Guide Rate: {GuideRate}");
|
||||
LogMessage("ReadProfile", $"Precision: {Precision}");
|
||||
LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}");
|
||||
LogMessage("ReadProfile", $"Site Elevation: {SiteElevation}");
|
||||
LogMessage("ReadProfile", $"Com Port: {_profileProperties.ComPort}");
|
||||
LogMessage("ReadProfile", $"Backlash Steps: {_profileProperties.BacklashCompensation}");
|
||||
LogMessage("ReadProfile", $"Dynamic breaking: {_profileProperties.DynamicBreaking}");
|
||||
LogMessage("ReadProfile", $"Guide Rate: {_profileProperties.GuideRateArcSecondsPerSecond}");
|
||||
LogMessage("ReadProfile", $"Precision: {_profileProperties.Precision}");
|
||||
LogMessage("ReadProfile", $"Guiding Style: {_profileProperties.GuidingStyle}");
|
||||
LogMessage("ReadProfile", $"Site Elevation: {_profileProperties.SiteElevation}");
|
||||
LogMessage("ReadProfile", $"Settle Time after slew: {_profileProperties.SettleTime}");
|
||||
LogMessage("ReadProfile", $"Send date and time on connect: {_profileProperties.SendDateTime}");
|
||||
LogMessage("ReadProfile", $"Parked Behaviour: {_profileProperties.ParkedBehaviour}");
|
||||
LogMessage("ReadProfile", $"Parked Alt: {_profileProperties.ParkedAlt}");
|
||||
LogMessage("ReadProfile", $"Parked Az: {_profileProperties.ParkedAz}");
|
||||
LogMessage("ReadProfile", $"Focal Length: {_profileProperties.FocalLength}");
|
||||
LogMessage("ReadProfile", $"Aperture Area: {_profileProperties.ApertureArea}");
|
||||
LogMessage("ReadProfile", $"Aperture Area: {_profileProperties.ApertureDiameter}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -140,7 +132,7 @@ namespace ASCOM.Meade.net
|
||||
protected void UpdateSiteElevation()
|
||||
{
|
||||
var profileProperties = SharedResourcesWrapper.ReadProfile();
|
||||
profileProperties.SiteElevation = SiteElevation;
|
||||
profileProperties.SiteElevation = _profileProperties.SiteElevation;
|
||||
SharedResourcesWrapper.WriteProfile(profileProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public enum ParkedBehaviour
|
||||
{
|
||||
[Description("No Coordinates")]
|
||||
NoCoordinates,
|
||||
[Description("Last Good Position")]
|
||||
LastGoodPosition,
|
||||
[Description("Report coordinates as")]
|
||||
ReportCoordinates
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public class ParkedPosition
|
||||
{
|
||||
public double Altitude { get; set; }
|
||||
public double Azimuth { get; set; }
|
||||
public double RightAscension { get; set; }
|
||||
public double Declination { get; set; }
|
||||
public double SiteLongitude { get; set; }
|
||||
public double SiteLatitude { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,18 @@ namespace ASCOM.Meade.net
|
||||
public bool DynamicBreaking { get; set; }
|
||||
public bool RtsDtrEnabled { get; set; }
|
||||
public double SiteElevation { get; set; }
|
||||
public short SettleTime { get; set; }
|
||||
public int DataBits { get; set; }
|
||||
public string StopBits { get; set; }
|
||||
public string Parity { get; set; }
|
||||
public int Speed { get; set; }
|
||||
public string Handshake { get; set; }
|
||||
public bool SendDateTime { get; set; }
|
||||
public ParkedBehaviour ParkedBehaviour { get; set; }
|
||||
public double ParkedAlt { get; set; }
|
||||
public double ParkedAz { get; set; }
|
||||
public double FocalLength { get; set; }
|
||||
public double ApertureArea { get; set; }
|
||||
public double ApertureDiameter { get; set; }
|
||||
}
|
||||
}
|
||||
+18
@@ -135,5 +135,23 @@ namespace ASCOM.Meade.net.Properties {
|
||||
return ResourceManager.GetString("SetupDialogForm_TextBox1_TextChanged___0_00_0___of_sidereal_rate_", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please enter only numbers..
|
||||
/// </summary>
|
||||
internal static string SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_ {
|
||||
get {
|
||||
return ResourceManager.GetString("SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please enter only numbers..
|
||||
/// </summary>
|
||||
internal static string SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_ {
|
||||
get {
|
||||
return ResourceManager.GetString("SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,4 +144,10 @@ Valid are : -register, -unregister and -embedding</value>
|
||||
<data name="SetupDialogForm_SetupDialogForm__0__Settings___1__" xml:space="preserve">
|
||||
<value>{0} Settings ({1})</value>
|
||||
</data>
|
||||
<data name="SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_" xml:space="preserve">
|
||||
<value>Please enter only numbers.</value>
|
||||
</data>
|
||||
<data name="SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_" xml:space="preserve">
|
||||
<value>Please enter only numbers.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
@@ -7,6 +8,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using ASCOM.Meade.net.Properties;
|
||||
using ASCOM.Utilities;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
@@ -20,6 +22,50 @@ namespace ASCOM.Meade.net
|
||||
var assemblyInfo = new AssemblyInfo();
|
||||
|
||||
Text = string.Format(Resources.SetupDialogForm_SetupDialogForm__0__Settings___1__, assemblyInfo.Product, assemblyInfo.AssemblyVersion);
|
||||
|
||||
SetItemsFromEnum(cboStopBits.Items, typeof(SerialStopBits));
|
||||
SetItemsFromEnum(cboParity.Items, typeof(SerialParity));
|
||||
SetItemFromEnumValues(cboSpeed.Items, SerialSpeed.ps1200, SerialSpeed.ps57600);
|
||||
SetItemsFromEnum(cboHandShake.Items, typeof(SerialHandshake));
|
||||
SetItemsFromEnum(cboParkedBehaviour.Items, typeof(ParkedBehaviour));
|
||||
}
|
||||
|
||||
private void SetItemsFromEnum(IList items, Type enumItems)
|
||||
{
|
||||
items.Clear();
|
||||
|
||||
foreach (var value in Enum.GetValues(enumItems) )
|
||||
{
|
||||
var val = value as Enum;
|
||||
items.Add(val.GetDescription());
|
||||
}
|
||||
}
|
||||
|
||||
//private void SetItemsFromEnumValues(IList items, Type enumItems)
|
||||
//{
|
||||
// items.Clear();
|
||||
|
||||
// foreach (int item in Enum.GetValues(enumItems))
|
||||
// {
|
||||
// items.Add(item);
|
||||
// }
|
||||
//}
|
||||
|
||||
private void SetItemFromEnumValues<T>(IList items, T minValue, T maxValue)
|
||||
{
|
||||
items.Clear();
|
||||
|
||||
var type = typeof(T);
|
||||
|
||||
var intMinValue = (int)Convert.ChangeType(minValue, typeof(int));
|
||||
|
||||
var intMaxValue = (int)Convert.ChangeType(maxValue, typeof(int));
|
||||
|
||||
foreach (int item in Enum.GetValues(type))
|
||||
{
|
||||
if ((item >= intMinValue) && (item <= intMaxValue))
|
||||
items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override string Text
|
||||
@@ -83,11 +129,110 @@ namespace ASCOM.Meade.net
|
||||
cboGuidingStyle.SelectedItem = "Auto";
|
||||
}
|
||||
|
||||
numDatabits.Value = profileProperties.DataBits;
|
||||
|
||||
try
|
||||
{
|
||||
cboStopBits.SelectedItem = profileProperties.StopBits;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
cboStopBits.SelectedItem = "One";
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
cboParity.SelectedItem = profileProperties.Parity;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
cboParity.SelectedItem = "None";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cboSpeed.SelectedItem = profileProperties.Speed;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
cboParity.SelectedItem = "9600";
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
cboHandShake.SelectedItem = profileProperties.Handshake;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
cboHandShake.SelectedItem = "None";
|
||||
}
|
||||
|
||||
txtBacklashSteps.Text = profileProperties.BacklashCompensation.ToString(CultureInfo.CurrentCulture);
|
||||
txtElevation.Text = profileProperties.SiteElevation.ToString(CultureInfo.CurrentCulture);
|
||||
|
||||
cbxReverseDirection.Checked = profileProperties.ReverseFocusDirection;
|
||||
cbxDynamicBreaking.Checked = profileProperties.DynamicBreaking;
|
||||
nudSettleTime.Value = profileProperties.SettleTime;
|
||||
|
||||
cbxSendDateTime.Checked = profileProperties.SendDateTime;
|
||||
|
||||
try
|
||||
{
|
||||
cboParkedBehaviour.SelectedItem = profileProperties.ParkedBehaviour.GetDescription();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
cboParkedBehaviour.SelectedItem = ParkedBehaviour.NoCoordinates.GetDescription();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
txtParkedAlt.Text = profileProperties.ParkedAlt.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
txtParkedAlt.Text = "0";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
txtParkedAz.Text = profileProperties.ParkedAz.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
txtParkedAz.Text = "180";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
txtFocalLength.Text = profileProperties.FocalLength.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
txtFocalLength.Text = "2000";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
txtApertureArea.Text = profileProperties.ApertureArea.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
txtApertureArea.Text = "32685";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
txtApertureDiameter.Text = profileProperties.ApertureDiameter.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
txtApertureDiameter.Text = "203";
|
||||
}
|
||||
|
||||
UpdateParkedItemsEnabled();
|
||||
}
|
||||
|
||||
public ProfileProperties GetProfile()
|
||||
@@ -97,13 +242,26 @@ namespace ASCOM.Meade.net
|
||||
TraceLogger = chkTrace.Checked,
|
||||
ComPort = comboBoxComPort.SelectedItem.ToString(),
|
||||
RtsDtrEnabled = cbxRtsDtr.Checked,
|
||||
DataBits = Convert.ToInt32(numDatabits.Value),
|
||||
StopBits = cboStopBits.SelectedItem.ToString(),
|
||||
Parity = cboParity.SelectedItem.ToString(),
|
||||
Speed = Convert.ToInt32(cboSpeed.SelectedItem),
|
||||
Handshake = cboHandShake.SelectedItem.ToString(),
|
||||
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()),
|
||||
Precision = cboPrecision.SelectedItem.ToString(),
|
||||
GuidingStyle = cboGuidingStyle.SelectedItem.ToString(),
|
||||
BacklashCompensation = int.Parse(txtBacklashSteps.Text),
|
||||
ReverseFocusDirection = cbxReverseDirection.Checked,
|
||||
DynamicBreaking = cbxDynamicBreaking.Checked,
|
||||
SiteElevation = double.Parse(txtElevation.Text)
|
||||
SiteElevation = double.Parse(txtElevation.Text),
|
||||
SettleTime = Convert.ToInt16(nudSettleTime.Value),
|
||||
SendDateTime = cbxSendDateTime.Checked,
|
||||
ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription<ParkedBehaviour>(cboParkedBehaviour.SelectedItem.ToString()),
|
||||
ParkedAlt = double.Parse(txtParkedAlt.Text),
|
||||
ParkedAz = double.Parse(txtParkedAz.Text),
|
||||
FocalLength = double.Parse(txtFocalLength.Text),
|
||||
ApertureArea = double.Parse(txtApertureArea.Text),
|
||||
ApertureDiameter = double.Parse(txtApertureDiameter.Text)
|
||||
};
|
||||
|
||||
return profileProperties;
|
||||
@@ -167,7 +325,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(txtElevation.Text, "[^0-9]"))
|
||||
{
|
||||
MessageBox.Show("Please enter only numbers.");
|
||||
MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_);
|
||||
txtElevation.Text = txtElevation.Text.Remove(txtElevation.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
@@ -176,9 +334,49 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(txtBacklashSteps.Text, "[^0-9]"))
|
||||
{
|
||||
MessageBox.Show("Please enter only numbers.");
|
||||
MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_);
|
||||
txtBacklashSteps.Text = txtElevation.Text.Remove(txtBacklashSteps.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void cboParkedBehaviour_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
UpdateParkedItemsEnabled();
|
||||
}
|
||||
|
||||
private void UpdateParkedItemsEnabled()
|
||||
{
|
||||
txtParkedAlt.Enabled = cboParkedBehaviour.SelectedItem?.ToString() == "Report coordinates as";
|
||||
txtParkedAz.Enabled = txtParkedAlt.Enabled;
|
||||
}
|
||||
|
||||
private void txtParkedAlt_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(txtParkedAlt.Text, "[^0-9]"))
|
||||
{
|
||||
MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_);
|
||||
txtParkedAlt.Text = txtParkedAlt.Text.Remove(txtParkedAlt.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void txtParkedAz_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(txtParkedAz.Text, "[^0-9]"))
|
||||
{
|
||||
MessageBox.Show(Resources.SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_);
|
||||
txtParkedAz.Text = txtParkedAz.Text.Remove(txtParkedAz.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void txt_FocalLength_TextChanged_1(object sender, EventArgs e)
|
||||
{
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(txtFocalLength.Text, "[^0-9]"))
|
||||
{
|
||||
MessageBox.Show(Resources.SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_);
|
||||
txtFocalLength.Text = txtFocalLength.Text.Remove(txtFocalLength.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Generated
+275
@@ -58,10 +58,42 @@ namespace ASCOM.Meade.net
|
||||
this.cbxDynamicBreaking = new System.Windows.Forms.CheckBox();
|
||||
this.cbxRtsDtr = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.cbxSendDateTime = new System.Windows.Forms.CheckBox();
|
||||
this.label12 = new System.Windows.Forms.Label();
|
||||
this.txtElevation = new System.Windows.Forms.TextBox();
|
||||
this.label13 = new System.Windows.Forms.Label();
|
||||
this.label14 = new System.Windows.Forms.Label();
|
||||
this.nudSettleTime = new System.Windows.Forms.NumericUpDown();
|
||||
this.label15 = new System.Windows.Forms.Label();
|
||||
this.label16 = new System.Windows.Forms.Label();
|
||||
this.cboStopBits = new System.Windows.Forms.ComboBox();
|
||||
this.numDatabits = new System.Windows.Forms.NumericUpDown();
|
||||
this.cboParity = new System.Windows.Forms.ComboBox();
|
||||
this.cboSpeed = new System.Windows.Forms.ComboBox();
|
||||
this.cboHandShake = new System.Windows.Forms.ComboBox();
|
||||
this.label17 = new System.Windows.Forms.Label();
|
||||
this.label18 = new System.Windows.Forms.Label();
|
||||
this.label19 = new System.Windows.Forms.Label();
|
||||
this.label20 = new System.Windows.Forms.Label();
|
||||
this.label21 = new System.Windows.Forms.Label();
|
||||
this.cboParkedBehaviour = new System.Windows.Forms.ComboBox();
|
||||
this.label22 = new System.Windows.Forms.Label();
|
||||
this.label23 = new System.Windows.Forms.Label();
|
||||
this.label24 = new System.Windows.Forms.Label();
|
||||
this.txtParkedAlt = new System.Windows.Forms.TextBox();
|
||||
this.txtParkedAz = new System.Windows.Forms.TextBox();
|
||||
this.label25 = new System.Windows.Forms.Label();
|
||||
this.txtFocalLength = new System.Windows.Forms.TextBox();
|
||||
this.label26 = new System.Windows.Forms.Label();
|
||||
this.label27 = new System.Windows.Forms.Label();
|
||||
this.txtApertureDiameter = new System.Windows.Forms.TextBox();
|
||||
this.label28 = new System.Windows.Forms.Label();
|
||||
this.label29 = new System.Windows.Forms.Label();
|
||||
this.txtApertureArea = new System.Windows.Forms.TextBox();
|
||||
this.label30 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cmdOK
|
||||
@@ -121,6 +153,7 @@ namespace ASCOM.Meade.net
|
||||
//
|
||||
resources.ApplyResources(this.txtGuideRate, "txtGuideRate");
|
||||
this.txtGuideRate.Name = "txtGuideRate";
|
||||
this.toolTip1.SetToolTip(this.txtGuideRate, resources.GetString("txtGuideRate.ToolTip"));
|
||||
this.txtGuideRate.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
|
||||
//
|
||||
// label4
|
||||
@@ -215,6 +248,13 @@ namespace ASCOM.Meade.net
|
||||
this.toolTip1.SetToolTip(this.cbxRtsDtr, resources.GetString("cbxRtsDtr.ToolTip"));
|
||||
this.cbxRtsDtr.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbxSendDateTime
|
||||
//
|
||||
resources.ApplyResources(this.cbxSendDateTime, "cbxSendDateTime");
|
||||
this.cbxSendDateTime.Name = "cbxSendDateTime";
|
||||
this.toolTip1.SetToolTip(this.cbxSendDateTime, resources.GetString("cbxSendDateTime.ToolTip"));
|
||||
this.cbxSendDateTime.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label12
|
||||
//
|
||||
resources.ApplyResources(this.label12, "label12");
|
||||
@@ -231,10 +271,213 @@ namespace ASCOM.Meade.net
|
||||
resources.ApplyResources(this.label13, "label13");
|
||||
this.label13.Name = "label13";
|
||||
//
|
||||
// label14
|
||||
//
|
||||
resources.ApplyResources(this.label14, "label14");
|
||||
this.label14.Name = "label14";
|
||||
//
|
||||
// nudSettleTime
|
||||
//
|
||||
resources.ApplyResources(this.nudSettleTime, "nudSettleTime");
|
||||
this.nudSettleTime.Maximum = new decimal(new int[] {
|
||||
32767,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudSettleTime.Name = "nudSettleTime";
|
||||
//
|
||||
// label15
|
||||
//
|
||||
resources.ApplyResources(this.label15, "label15");
|
||||
this.label15.Name = "label15";
|
||||
//
|
||||
// label16
|
||||
//
|
||||
resources.ApplyResources(this.label16, "label16");
|
||||
this.label16.Name = "label16";
|
||||
//
|
||||
// cboStopBits
|
||||
//
|
||||
this.cboStopBits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboStopBits.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.cboStopBits, "cboStopBits");
|
||||
this.cboStopBits.Name = "cboStopBits";
|
||||
//
|
||||
// numDatabits
|
||||
//
|
||||
resources.ApplyResources(this.numDatabits, "numDatabits");
|
||||
this.numDatabits.Maximum = new decimal(new int[] {
|
||||
32767,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numDatabits.Name = "numDatabits";
|
||||
//
|
||||
// cboParity
|
||||
//
|
||||
this.cboParity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboParity.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.cboParity, "cboParity");
|
||||
this.cboParity.Name = "cboParity";
|
||||
//
|
||||
// cboSpeed
|
||||
//
|
||||
this.cboSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboSpeed.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.cboSpeed, "cboSpeed");
|
||||
this.cboSpeed.Name = "cboSpeed";
|
||||
//
|
||||
// cboHandShake
|
||||
//
|
||||
this.cboHandShake.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboHandShake.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.cboHandShake, "cboHandShake");
|
||||
this.cboHandShake.Name = "cboHandShake";
|
||||
//
|
||||
// label17
|
||||
//
|
||||
resources.ApplyResources(this.label17, "label17");
|
||||
this.label17.Name = "label17";
|
||||
//
|
||||
// label18
|
||||
//
|
||||
resources.ApplyResources(this.label18, "label18");
|
||||
this.label18.Name = "label18";
|
||||
//
|
||||
// label19
|
||||
//
|
||||
resources.ApplyResources(this.label19, "label19");
|
||||
this.label19.Name = "label19";
|
||||
//
|
||||
// label20
|
||||
//
|
||||
resources.ApplyResources(this.label20, "label20");
|
||||
this.label20.Name = "label20";
|
||||
//
|
||||
// label21
|
||||
//
|
||||
resources.ApplyResources(this.label21, "label21");
|
||||
this.label21.Name = "label21";
|
||||
//
|
||||
// cboParkedBehaviour
|
||||
//
|
||||
this.cboParkedBehaviour.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboParkedBehaviour.FormattingEnabled = true;
|
||||
this.cboParkedBehaviour.Items.AddRange(new object[] {
|
||||
resources.GetString("cboParkedBehaviour.Items"),
|
||||
resources.GetString("cboParkedBehaviour.Items1"),
|
||||
resources.GetString("cboParkedBehaviour.Items2")});
|
||||
resources.ApplyResources(this.cboParkedBehaviour, "cboParkedBehaviour");
|
||||
this.cboParkedBehaviour.Name = "cboParkedBehaviour";
|
||||
this.cboParkedBehaviour.SelectionChangeCommitted += new System.EventHandler(this.cboParkedBehaviour_SelectionChangeCommitted);
|
||||
//
|
||||
// label22
|
||||
//
|
||||
resources.ApplyResources(this.label22, "label22");
|
||||
this.label22.Name = "label22";
|
||||
//
|
||||
// label23
|
||||
//
|
||||
resources.ApplyResources(this.label23, "label23");
|
||||
this.label23.Name = "label23";
|
||||
//
|
||||
// label24
|
||||
//
|
||||
resources.ApplyResources(this.label24, "label24");
|
||||
this.label24.Name = "label24";
|
||||
//
|
||||
// txtParkedAlt
|
||||
//
|
||||
resources.ApplyResources(this.txtParkedAlt, "txtParkedAlt");
|
||||
this.txtParkedAlt.Name = "txtParkedAlt";
|
||||
this.txtParkedAlt.TextChanged += new System.EventHandler(this.txtParkedAlt_TextChanged);
|
||||
//
|
||||
// txtParkedAz
|
||||
//
|
||||
resources.ApplyResources(this.txtParkedAz, "txtParkedAz");
|
||||
this.txtParkedAz.Name = "txtParkedAz";
|
||||
this.txtParkedAz.TextChanged += new System.EventHandler(this.txtParkedAz_TextChanged);
|
||||
//
|
||||
// label25
|
||||
//
|
||||
resources.ApplyResources(this.label25, "label25");
|
||||
this.label25.Name = "label25";
|
||||
//
|
||||
// txtFocalLength
|
||||
//
|
||||
resources.ApplyResources(this.txtFocalLength, "txtFocalLength");
|
||||
this.txtFocalLength.Name = "txtFocalLength";
|
||||
this.txtFocalLength.TextChanged += new System.EventHandler(this.txt_FocalLength_TextChanged_1);
|
||||
//
|
||||
// label26
|
||||
//
|
||||
resources.ApplyResources(this.label26, "label26");
|
||||
this.label26.Name = "label26";
|
||||
//
|
||||
// label27
|
||||
//
|
||||
resources.ApplyResources(this.label27, "label27");
|
||||
this.label27.Name = "label27";
|
||||
//
|
||||
// txtApetureDiameter
|
||||
//
|
||||
resources.ApplyResources(this.txtApertureDiameter, "txtApertureDiameter");
|
||||
this.txtApertureDiameter.Name = "txtApertureDiameter";
|
||||
//
|
||||
// label28
|
||||
//
|
||||
resources.ApplyResources(this.label28, "label28");
|
||||
this.label28.Name = "label28";
|
||||
//
|
||||
// label29
|
||||
//
|
||||
resources.ApplyResources(this.label29, "label29");
|
||||
this.label29.Name = "label29";
|
||||
//
|
||||
// txtApetureArea
|
||||
//
|
||||
resources.ApplyResources(this.txtApertureArea, "txtApertureArea");
|
||||
this.txtApertureArea.Name = "txtApertureArea";
|
||||
//
|
||||
// label30
|
||||
//
|
||||
resources.ApplyResources(this.label30, "label30");
|
||||
this.label30.Name = "label30";
|
||||
//
|
||||
// SetupDialogForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.label29);
|
||||
this.Controls.Add(this.txtApertureArea);
|
||||
this.Controls.Add(this.label30);
|
||||
this.Controls.Add(this.label27);
|
||||
this.Controls.Add(this.txtApertureDiameter);
|
||||
this.Controls.Add(this.label28);
|
||||
this.Controls.Add(this.label26);
|
||||
this.Controls.Add(this.txtFocalLength);
|
||||
this.Controls.Add(this.label25);
|
||||
this.Controls.Add(this.txtParkedAz);
|
||||
this.Controls.Add(this.txtParkedAlt);
|
||||
this.Controls.Add(this.label24);
|
||||
this.Controls.Add(this.label23);
|
||||
this.Controls.Add(this.label22);
|
||||
this.Controls.Add(this.cboParkedBehaviour);
|
||||
this.Controls.Add(this.cbxSendDateTime);
|
||||
this.Controls.Add(this.label21);
|
||||
this.Controls.Add(this.label20);
|
||||
this.Controls.Add(this.label19);
|
||||
this.Controls.Add(this.label18);
|
||||
this.Controls.Add(this.label17);
|
||||
this.Controls.Add(this.cboHandShake);
|
||||
this.Controls.Add(this.cboSpeed);
|
||||
this.Controls.Add(this.cboParity);
|
||||
this.Controls.Add(this.numDatabits);
|
||||
this.Controls.Add(this.cboStopBits);
|
||||
this.Controls.Add(this.label16);
|
||||
this.Controls.Add(this.label15);
|
||||
this.Controls.Add(this.nudSettleTime);
|
||||
this.Controls.Add(this.label14);
|
||||
this.Controls.Add(this.label13);
|
||||
this.Controls.Add(this.txtElevation);
|
||||
this.Controls.Add(this.label12);
|
||||
@@ -270,6 +513,8 @@ namespace ASCOM.Meade.net
|
||||
this.TopMost = true;
|
||||
this.Shown += new System.EventHandler(this.SetupDialogForm_Shown);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numDatabits)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -305,5 +550,35 @@ namespace ASCOM.Meade.net
|
||||
private Label label12;
|
||||
private TextBox txtElevation;
|
||||
private Label label13;
|
||||
private Label label14;
|
||||
private NumericUpDown nudSettleTime;
|
||||
private Label label15;
|
||||
private Label label16;
|
||||
private ComboBox cboStopBits;
|
||||
private NumericUpDown numDatabits;
|
||||
private ComboBox cboParity;
|
||||
private ComboBox cboSpeed;
|
||||
private ComboBox cboHandShake;
|
||||
private Label label17;
|
||||
private Label label18;
|
||||
private Label label19;
|
||||
private Label label20;
|
||||
private Label label21;
|
||||
private CheckBox cbxSendDateTime;
|
||||
private ComboBox cboParkedBehaviour;
|
||||
private Label label22;
|
||||
private Label label23;
|
||||
private Label label24;
|
||||
private TextBox txtParkedAlt;
|
||||
private TextBox txtParkedAz;
|
||||
private Label label25;
|
||||
private TextBox txtFocalLength;
|
||||
private Label label26;
|
||||
private Label label27;
|
||||
private TextBox txtApertureDiameter;
|
||||
private Label label28;
|
||||
private Label label29;
|
||||
private TextBox txtApertureArea;
|
||||
private Label label30;
|
||||
}
|
||||
}
|
||||
+837
-57
File diff suppressed because it is too large
Load Diff
+329
-52
@@ -4,7 +4,7 @@
|
||||
// ================
|
||||
//
|
||||
// This class is a container for all shared resources that may be needed
|
||||
// by the drivers served by the Local Server.
|
||||
// by the drivers served by the Local Server.
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
@@ -17,7 +17,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using ASCOM.DeviceInterface;
|
||||
using ASCOM.Meade.net.Wrapper;
|
||||
using ASCOM.Utilities;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
@@ -47,7 +51,7 @@ namespace ASCOM.Meade.net
|
||||
#region single serial port connector
|
||||
|
||||
//
|
||||
// this region shows a way that a single serial port could be connected to by multiple
|
||||
// this region shows a way that a single serial port could be connected to by multiple
|
||||
// drivers.
|
||||
//
|
||||
// Connected is used to handle the connections to the port.
|
||||
@@ -71,17 +75,18 @@ namespace ASCOM.Meade.net
|
||||
|
||||
public static IProfileFactory ProfileFactory
|
||||
{
|
||||
get => _profileFactory ?? ( _profileFactory = new ProfileFactory());
|
||||
get => _profileFactory ?? (_profileFactory = new ProfileFactory());
|
||||
set => _profileFactory = value;
|
||||
}
|
||||
|
||||
//todo add code to ensure that there is a minimum gap between commands. 5ms as default.
|
||||
public static void SendBlind(string message)
|
||||
public static void SendBlind(string message, bool raw = false)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
SharedSerial.ClearBuffers();
|
||||
SharedSerial.Transmit(message);
|
||||
var encodedMessage = raw ? message : $"#:{message}#";
|
||||
SharedSerial.Transmit(encodedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,24 +97,60 @@ namespace ASCOM.Meade.net
|
||||
/// and that the reply will always be terminated by a "#" character.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="raw"></param>
|
||||
/// <returns></returns>
|
||||
public static string SendString(string message)
|
||||
public static string SendString(string message, bool raw = false)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
SharedSerial.ClearBuffers();
|
||||
SharedSerial.Transmit(message);
|
||||
return SharedSerial.ReceiveTerminated("#").TrimEnd('#');
|
||||
|
||||
var encodedMessage = raw ? message : $"#:{message}#";
|
||||
SharedSerial.Transmit(encodedMessage);
|
||||
|
||||
try
|
||||
{
|
||||
return SharedSerial.ReceiveTerminated("#").TrimEnd('#');
|
||||
}
|
||||
catch (COMException ex)
|
||||
{
|
||||
if (ex.Message.Contains("Timed out waiting for received data"))
|
||||
throw new TimeoutException(ex.Message, ex);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string SendChar(string message)
|
||||
public static bool SendBool(string command, bool raw = false)
|
||||
{
|
||||
var result = SendChar(command, raw);
|
||||
|
||||
return result == "1";
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
SharedSerial.ClearBuffers();
|
||||
SharedSerial.Transmit(message);
|
||||
return SharedSerial.ReceiveCounted(1);
|
||||
|
||||
var encodedMessage = raw ? command : $"#:{command}#";
|
||||
SharedSerial.Transmit(encodedMessage);
|
||||
|
||||
try
|
||||
{
|
||||
return SharedSerial.ReceiveCounted(count);
|
||||
}
|
||||
catch (COMException ex) when (ex.Message.Contains("Timed out waiting for received data"))
|
||||
{
|
||||
throw new TimeoutException(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +187,20 @@ namespace ASCOM.Meade.net
|
||||
private const string ReverseFocusDirectionName = "Reverse Focuser Direction";
|
||||
private const string DynamicBreakingName = "Dynamic Breaking";
|
||||
private const string SiteElevationName = "Site Elevation";
|
||||
private const string SettleTimeName = "Settle Time";
|
||||
|
||||
private const string SpeedName = "Speed";
|
||||
private const string DataBitsName = "Data Bits";
|
||||
private const string StopBitsName = "Stop Bits";
|
||||
private const string HandShakeName = "Hand Shake";
|
||||
private const string ParityName = "Parity";
|
||||
private const string SendDateTimeName = "Send Date and time on connect";
|
||||
private const string ParkedBehaviourName = "Parked Behaviour";
|
||||
private const string ParkedAltName = "Parked Altitude";
|
||||
private const string ParkedAzimuthName = "Parked Azimuth";
|
||||
private const string FocalLengthName = "Focal Length (mm)";
|
||||
private const string ApertureAreaName = "Aperture Area (mm²)";
|
||||
private const string ApertureDiameterName = "Aperture Diameter (mm)";
|
||||
|
||||
public static void WriteProfile(ProfileProperties profileProperties)
|
||||
{
|
||||
@@ -157,13 +212,26 @@ namespace ASCOM.Meade.net
|
||||
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
||||
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
||||
driverProfile.WriteValue(DriverId, RtsDtrProfileName, profileProperties.RtsDtrEnabled.ToString());
|
||||
driverProfile.WriteValue(DriverId, SpeedName, profileProperties.Speed.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, DataBitsName, profileProperties.DataBits.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, StopBitsName, profileProperties.StopBits);
|
||||
driverProfile.WriteValue(DriverId, HandShakeName, profileProperties.Handshake);
|
||||
driverProfile.WriteValue(DriverId, ParityName, profileProperties.Parity);
|
||||
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
|
||||
driverProfile.WriteValue(DriverId, GuidingStyleProfileName, profileProperties.GuidingStyle);
|
||||
driverProfile.WriteValue(DriverId, BacklashCompensationName, profileProperties.BacklashCompensation.ToString());
|
||||
driverProfile.WriteValue(DriverId, ReverseFocusDirectionName, profileProperties.ReverseFocusDirection.ToString());
|
||||
driverProfile.WriteValue(DriverId, DynamicBreakingName, profileProperties.DynamicBreaking.ToString());
|
||||
driverProfile.WriteValue(DriverId, SiteElevationName, profileProperties.SiteElevation.ToString());
|
||||
driverProfile.WriteValue(DriverId, SiteElevationName, profileProperties.SiteElevation.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, SettleTimeName, profileProperties.SettleTime.ToString());
|
||||
driverProfile.WriteValue(DriverId, SendDateTimeName, profileProperties.SendDateTime.ToString());
|
||||
driverProfile.WriteValue(DriverId, ParkedBehaviourName, profileProperties.ParkedBehaviour.GetDescription());
|
||||
driverProfile.WriteValue(DriverId, ParkedAltName, profileProperties.ParkedAlt.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, ParkedAzimuthName, profileProperties.ParkedAz.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, FocalLengthName, profileProperties.FocalLength.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, ApertureAreaName, profileProperties.ApertureArea.ToString(CultureInfo.InvariantCulture));
|
||||
driverProfile.WriteValue(DriverId, ApertureDiameterName, profileProperties.ApertureDiameter.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,6 +246,19 @@ namespace ASCOM.Meade.net
|
||||
private const string ReverseFocuserDiectionDefault = "true";
|
||||
private const string DynamicBreakingDefault = "true";
|
||||
private const string SiteElevationDefault = "0";
|
||||
private const string SettleTimeDefault = "2";
|
||||
private const string SpeedDefault = "9600";
|
||||
private const string DataBitsDefault = "8";
|
||||
private const string StopBitsDefault = "One";
|
||||
private const string HandShakeDefault = "None";
|
||||
private const string ParityDefault = "None";
|
||||
private const string SendDateTimeDefault = "false";
|
||||
private const string ParkedBehaviourDefault = "No Coordinates";
|
||||
private const string ParkedAltDefault = "0";
|
||||
private const string ParkedAzimuthDefault = "180";
|
||||
private const string FocalLengthDefault = "2000";
|
||||
private const string ApertureAreaDefault = "32685";
|
||||
private const string ApertureDiameterDefault = "203";
|
||||
|
||||
public static ProfileProperties ReadProfile()
|
||||
{
|
||||
@@ -197,6 +278,20 @@ namespace ASCOM.Meade.net
|
||||
profileProperties.ReverseFocusDirection = Convert.ToBoolean(driverProfile.GetValue(DriverId, ReverseFocusDirectionName, string.Empty, ReverseFocuserDiectionDefault));
|
||||
profileProperties.DynamicBreaking = Convert.ToBoolean(driverProfile.GetValue(DriverId, DynamicBreakingName, string.Empty, DynamicBreakingDefault));
|
||||
profileProperties.SiteElevation = Convert.ToInt32(driverProfile.GetValue(DriverId, SiteElevationName, string.Empty, SiteElevationDefault));
|
||||
profileProperties.SettleTime = Convert.ToInt16(driverProfile.GetValue(DriverId, SettleTimeName, string.Empty, SettleTimeDefault));
|
||||
profileProperties.StopBits = driverProfile.GetValue(DriverId, StopBitsName, string.Empty, StopBitsDefault);
|
||||
profileProperties.DataBits = Convert.ToInt32(driverProfile.GetValue(DriverId, DataBitsName, string.Empty, DataBitsDefault));
|
||||
profileProperties.Handshake = driverProfile.GetValue(DriverId, HandShakeName, string.Empty, HandShakeDefault);
|
||||
profileProperties.Speed = Convert.ToInt32(driverProfile.GetValue(DriverId, SpeedName, string.Empty, SpeedDefault));
|
||||
profileProperties.Parity = driverProfile.GetValue(DriverId, ParityName, string.Empty, ParityDefault);
|
||||
profileProperties.SendDateTime = Convert.ToBoolean(driverProfile.GetValue(DriverId, SendDateTimeName, string.Empty, SendDateTimeDefault));
|
||||
|
||||
profileProperties.ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription<ParkedBehaviour>(driverProfile.GetValue(DriverId, ParkedBehaviourName, string.Empty, ParkedBehaviourDefault));
|
||||
profileProperties.ParkedAlt = double.Parse(driverProfile.GetValue(DriverId, ParkedAltName, string.Empty, ParkedAltDefault), NumberFormatInfo.InvariantInfo);
|
||||
profileProperties.ParkedAz = double.Parse(driverProfile.GetValue(DriverId, ParkedAzimuthName, string.Empty, ParkedAzimuthDefault), NumberFormatInfo.InvariantInfo);
|
||||
profileProperties.FocalLength = double.Parse(driverProfile.GetValue(DriverId, FocalLengthName, string.Empty, FocalLengthDefault), NumberFormatInfo.InvariantInfo);
|
||||
profileProperties.ApertureArea = double.Parse(driverProfile.GetValue(DriverId, ApertureAreaName, string.Empty, ApertureAreaDefault), NumberFormatInfo.InvariantInfo);
|
||||
profileProperties.ApertureDiameter = double.Parse(driverProfile.GetValue(DriverId, ApertureDiameterName, string.Empty, ApertureDiameterDefault), NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
return profileProperties;
|
||||
@@ -209,29 +304,38 @@ namespace ASCOM.Meade.net
|
||||
|
||||
public static void SetupDialog()
|
||||
{
|
||||
var profileProperties = ReadProfile();
|
||||
|
||||
using (SetupDialogForm f = new SetupDialogForm())
|
||||
try
|
||||
{
|
||||
f.SetProfile(profileProperties);
|
||||
var profileProperties = ReadProfile();
|
||||
|
||||
if (IsConnected())
|
||||
using (SetupDialogForm f = new SetupDialogForm())
|
||||
{
|
||||
f.SetReadOnlyMode();
|
||||
}
|
||||
f.SetProfile(profileProperties);
|
||||
|
||||
var result = f.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
profileProperties = f.GetProfile();
|
||||
if (IsConnected())
|
||||
{
|
||||
f.SetReadOnlyMode();
|
||||
}
|
||||
|
||||
WriteProfile(profileProperties); // Persist device configuration values to the ASCOM Profile store
|
||||
var result = f.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
profileProperties = f.GetProfile();
|
||||
|
||||
WriteProfile(
|
||||
profileProperties); // Persist device configuration values to the ASCOM Profile store
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Multi Driver handling
|
||||
|
||||
public static string ProductName { get; private set; } = string.Empty;
|
||||
@@ -254,7 +358,7 @@ namespace ASCOM.Meade.net
|
||||
private static readonly Dictionary<string, DeviceHardware> ConnectedDevices = new Dictionary<string, DeviceHardware>();
|
||||
|
||||
private static readonly Dictionary<string, DeviceHardware> ConnectedDeviceIds = new Dictionary<string, DeviceHardware>();
|
||||
private static IProfileFactory _profileFactory ;
|
||||
private static IProfileFactory _profileFactory;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -270,7 +374,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
if (!ConnectedDevices.ContainsKey(deviceId))
|
||||
ConnectedDevices.Add(deviceId, new DeviceHardware());
|
||||
|
||||
|
||||
if (!ConnectedDeviceIds.ContainsKey(driverId))
|
||||
ConnectedDeviceIds.Add(driverId, new DeviceHardware());
|
||||
|
||||
@@ -282,17 +386,80 @@ namespace ASCOM.Meade.net
|
||||
SharedSerial.PortName = profileProperties.ComPort;
|
||||
SharedSerial.DTREnable = profileProperties.RtsDtrEnabled;
|
||||
SharedSerial.RTSEnable = profileProperties.RtsDtrEnabled;
|
||||
SharedSerial.DataBits = 8;
|
||||
SharedSerial.StopBits = SerialStopBits.One;
|
||||
SharedSerial.Parity = SerialParity.None;
|
||||
SharedSerial.DataBits = profileProperties.DataBits;
|
||||
SharedSerial.StopBits = (SerialStopBits)Enum.Parse(typeof(SerialStopBits), profileProperties.StopBits);
|
||||
SharedSerial.Parity = (SerialParity)Enum.Parse(typeof(SerialParity), profileProperties.Parity);
|
||||
SharedSerial.Handshake = (SerialHandshake)Enum.Parse(typeof(SerialHandshake), profileProperties.Handshake);
|
||||
SharedSerial.ReceiveTimeout = 5; //5 second timeout;
|
||||
SharedSerial.Speed = SerialSpeed.ps9600;
|
||||
SharedSerial.Handshake = SerialHandshake.None;
|
||||
SharedSerial.Connected = true;
|
||||
|
||||
var wantedSpeed = (SerialSpeed)profileProperties.Speed;
|
||||
if (wantedSpeed != SerialSpeed.ps9600)
|
||||
{
|
||||
SharedSerial.Speed = wantedSpeed;
|
||||
SharedSerial.Connected = true;
|
||||
|
||||
var speedRampNeeded = false;
|
||||
|
||||
//Test if communication is working.
|
||||
try
|
||||
{
|
||||
string utcOffSet = SendString("GG");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
speedRampNeeded = true;
|
||||
}
|
||||
|
||||
if (speedRampNeeded)
|
||||
{
|
||||
SharedSerial.Connected = false;
|
||||
SharedSerial.Speed = SerialSpeed.ps9600;
|
||||
SharedSerial.Connected = true;
|
||||
|
||||
int newSpeedIndex = GetSpeedIndex(wantedSpeed);
|
||||
//:SBn# Set Baud Rate n, where n is an ASCII digit (1..9) with the following interpertation
|
||||
// 1 56.7K
|
||||
// 2 38.4K
|
||||
// 3 28.8K
|
||||
// 4 19.2K
|
||||
// 5 14.4K
|
||||
// 6 9600
|
||||
// 7 4800
|
||||
// 8 2400
|
||||
// 9 1200
|
||||
//Returns:
|
||||
// 1 At the current baud rate and then changes to the new rate for further communication
|
||||
//SendBlind($"SB{newSpeedIndex}");
|
||||
try
|
||||
{
|
||||
var speedChanged = SendChar($"SB{newSpeedIndex}");
|
||||
if (speedChanged == "1")
|
||||
{
|
||||
SharedSerial.Connected = false;
|
||||
SharedSerial.Speed = wantedSpeed;
|
||||
traceLogger.LogIssue("Connect",
|
||||
$"Telescope serial port speed change, connecting at {SharedSerial.Speed}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Autostar not signalled speed change.");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SharedSerial.Connected = false;
|
||||
SharedSerial.Speed = SerialSpeed.ps9600;
|
||||
traceLogger.LogIssue("Connect", $"Telescope not responding to speed change, connecting at {SharedSerial.Speed}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
SharedSerial.Connected = true;
|
||||
|
||||
try
|
||||
{
|
||||
ProductName = SendString("#:GVP#");
|
||||
FirmwareVersion = SendString("#:GVN#");
|
||||
ProductName = SendString("GVP");
|
||||
FirmwareVersion = SendString("GVN");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -312,7 +479,7 @@ namespace ASCOM.Meade.net
|
||||
|
||||
try
|
||||
{
|
||||
string utcOffSet = SendString("#:GG#");
|
||||
string utcOffSet = SendString("GG");
|
||||
//:GG# Get UTC offset time
|
||||
//Returns: sHH# or sHH.H#
|
||||
//The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the
|
||||
@@ -347,6 +514,23 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetSpeedIndex(SerialSpeed speed)
|
||||
{
|
||||
switch (speed)
|
||||
{
|
||||
case SerialSpeed.ps57600: return 1;
|
||||
case SerialSpeed.ps38400: return 2;
|
||||
case SerialSpeed.ps28800: return 3;
|
||||
case SerialSpeed.ps19200: return 4;
|
||||
case SerialSpeed.ps14400: return 5;
|
||||
case SerialSpeed.ps9600: return 6;
|
||||
case SerialSpeed.ps4800: return 7;
|
||||
case SerialSpeed.ps2400: return 8;
|
||||
case SerialSpeed.ps1200: return 9;
|
||||
default: throw new NotSupportedException($"{SpeedDefault} not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Disconnect(string deviceId, string driverId)
|
||||
{
|
||||
lock (LockObject)
|
||||
@@ -383,23 +567,7 @@ 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
|
||||
@@ -413,5 +581,114 @@ namespace ASCOM.Meade.net
|
||||
Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetParked(bool atPark, ParkedPosition parkedPosition, bool restartTracking)
|
||||
{
|
||||
IsParked = atPark;
|
||||
ParkedPosition = parkedPosition;
|
||||
RestartTracking = restartTracking;
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<bool> _restartTracking = false;
|
||||
public static bool RestartTracking
|
||||
{
|
||||
get => _restartTracking;
|
||||
private set => _restartTracking.Set(value);
|
||||
}
|
||||
|
||||
private static ParkedPosition _parkedPosition;
|
||||
public static ParkedPosition ParkedPosition
|
||||
{
|
||||
get => _parkedPosition;
|
||||
private set => Interlocked.Exchange(ref _parkedPosition, value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<bool> _isParked = false;
|
||||
public static bool IsParked
|
||||
{
|
||||
get => _isParked;
|
||||
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"/>.
|
||||
/// As we do not know the physical declination axis position, we have to keep track manually.
|
||||
/// </summary>
|
||||
public static PierSide SideOfPier
|
||||
{
|
||||
get => _sideOfPier;
|
||||
internal set => _sideOfPier.Set(value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<double?> _targetRightAscension = null as double?;
|
||||
public static double? TargetRightAscension
|
||||
{
|
||||
get => _targetRightAscension;
|
||||
internal set => _targetRightAscension.Set(value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<double?> _targetDeclination = null as double?;
|
||||
public static double? TargetDeclination
|
||||
{
|
||||
get => _targetDeclination;
|
||||
internal set => _targetDeclination.Set(value);
|
||||
}
|
||||
|
||||
private static int _slewSettleTime;
|
||||
public static short SlewSettleTime
|
||||
{
|
||||
get => Convert.ToInt16(_slewSettleTime);
|
||||
internal set => Interlocked.Exchange(ref _slewSettleTime, value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<bool> _isLongFormat = false;
|
||||
public static bool IsLongFormat
|
||||
{
|
||||
get => _isLongFormat;
|
||||
internal set => _isLongFormat.Set(value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<bool> _movingPrimary = false;
|
||||
public static bool MovingPrimary
|
||||
{
|
||||
get => _movingPrimary;
|
||||
internal set => _movingPrimary.Set(value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<bool> _movingSecondary = false;
|
||||
public static bool MovingSecondary
|
||||
{
|
||||
get => _movingSecondary;
|
||||
internal set => _movingSecondary.Set(value);
|
||||
}
|
||||
|
||||
private static readonly ThreadSafeValue<DateTime> _earliestNonSlewingTime = DateTime.MinValue;
|
||||
public static DateTime EarliestNonSlewingTime
|
||||
{
|
||||
get => _earliestNonSlewingTime;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string Autostar497_43Eg = "43Eg";
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string AudioStar_A4S4 = "A4S4";
|
||||
#endregion
|
||||
|
||||
#region LX200GPS
|
||||
@@ -21,6 +23,7 @@
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string LX200GPS = "LX2001";
|
||||
|
||||
public const string LX200GPS_42F = "4.2F";
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string LX200GPS_42G = "4.2G";
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using JetBrains.Annotations;
|
||||
using System.Threading;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public class ThreadSafeValue<T>
|
||||
{
|
||||
private object _value;
|
||||
|
||||
public ThreadSafeValue(in T value) => _value = value;
|
||||
|
||||
public void Set(in T value) => Interlocked.Exchange(ref _value, value);
|
||||
|
||||
public static implicit operator ThreadSafeValue<T>(in T value) => new ThreadSafeValue<T>(value);
|
||||
|
||||
public static implicit operator T([NotNull] ThreadSafeValue<T> @this) => (T)(@this?._value ?? default);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ASCOM.DeviceInterface;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
|
||||
namespace ASCOM.Meade.net.Wrapper
|
||||
@@ -11,13 +12,12 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
string ProductName { get; }
|
||||
|
||||
string FirmwareVersion { get; }
|
||||
|
||||
void Lock(Action action);
|
||||
T Lock<T>(Func<T> func);
|
||||
|
||||
string SendString(string message);
|
||||
void SendBlind(string message);
|
||||
string SendChar(string message);
|
||||
|
||||
string SendString(string message, bool raw = false);
|
||||
void SendBlind(string message, bool raw = false);
|
||||
bool SendBool(string command, bool raw = false);
|
||||
string SendChar(string message, bool raw = false);
|
||||
string SendChars(string message, bool raw = false, int count = 1);
|
||||
|
||||
string ReadTerminated();
|
||||
|
||||
@@ -26,6 +26,29 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
void SetupDialog();
|
||||
void WriteProfile(ProfileProperties profileProperties);
|
||||
void ReadCharacters(int throwAwayCharacters);
|
||||
|
||||
void SetParked(bool atPark, ParkedPosition parkedPosition, bool restartTracking);
|
||||
bool IsParked { get; }
|
||||
ParkedPosition ParkedPosition { get; }
|
||||
bool RestartTracking { get; }
|
||||
|
||||
PierSide SideOfPier { get; set; }
|
||||
double? TargetRightAscension { get; set; }
|
||||
double? TargetDeclination { get; set; }
|
||||
|
||||
short SlewSettleTime { get; set; }
|
||||
|
||||
bool IsLongFormat { get; set; }
|
||||
|
||||
bool MovingPrimary { get; set; }
|
||||
|
||||
bool MovingSecondary { get; set; }
|
||||
|
||||
DateTime EarliestNonSlewingTime { get; set; }
|
||||
|
||||
bool IsTargetCoordinateInitRequired { get; set; }
|
||||
|
||||
bool IsGuiding { get; set; }
|
||||
}
|
||||
|
||||
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
||||
@@ -44,29 +67,29 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
|
||||
public string FirmwareVersion => SharedResources.FirmwareVersion;
|
||||
|
||||
public void Lock(Action action)
|
||||
public string SendString(string message, bool raw = false)
|
||||
{
|
||||
SharedResources.Lock(action);
|
||||
return SharedResources.SendString(message, raw);
|
||||
}
|
||||
|
||||
public T Lock<T>(Func<T> func)
|
||||
public void SendBlind(string message, bool raw = false)
|
||||
{
|
||||
return SharedResources.Lock(func);
|
||||
SharedResources.SendBlind(message, raw);
|
||||
}
|
||||
|
||||
public string SendString(string message)
|
||||
public bool SendBool(string command, bool raw = false)
|
||||
{
|
||||
return SharedResources.SendString(message);
|
||||
return SharedResources.SendBool(command, raw);
|
||||
}
|
||||
|
||||
public void SendBlind(string message)
|
||||
public string SendChar(string message, bool raw = false)
|
||||
{
|
||||
SharedResources.SendBlind(message);
|
||||
return SharedResources.SendChar(message, raw);
|
||||
}
|
||||
|
||||
public string SendChar(string message)
|
||||
public string SendChars(string message, bool raw = false, int count = 1)
|
||||
{
|
||||
return SharedResources.SendChar(message);
|
||||
return SharedResources.SendChars(message, raw, count);
|
||||
}
|
||||
|
||||
public string ReadTerminated()
|
||||
@@ -93,5 +116,76 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
{
|
||||
SharedResources.WriteProfile(profileProperties);
|
||||
}
|
||||
|
||||
public void SetParked(bool atPark, ParkedPosition parkedPosition, bool restartTracking)
|
||||
{
|
||||
SharedResources.SetParked(atPark, parkedPosition, restartTracking);
|
||||
}
|
||||
|
||||
public bool IsParked => SharedResources.IsParked;
|
||||
|
||||
public bool RestartTracking => SharedResources.RestartTracking;
|
||||
|
||||
public ParkedPosition ParkedPosition => SharedResources.ParkedPosition;
|
||||
|
||||
public PierSide SideOfPier
|
||||
{
|
||||
get => SharedResources.SideOfPier;
|
||||
set => SharedResources.SideOfPier = value;
|
||||
}
|
||||
|
||||
public double? TargetRightAscension
|
||||
{
|
||||
get => SharedResources.TargetRightAscension;
|
||||
set => SharedResources.TargetRightAscension = value;
|
||||
}
|
||||
|
||||
public double? TargetDeclination
|
||||
{
|
||||
get => SharedResources.TargetDeclination;
|
||||
set => SharedResources.TargetDeclination = value;
|
||||
}
|
||||
|
||||
public short SlewSettleTime
|
||||
{
|
||||
get => SharedResources.SlewSettleTime;
|
||||
set => SharedResources.SlewSettleTime = value;
|
||||
}
|
||||
|
||||
public bool IsLongFormat
|
||||
{
|
||||
get => SharedResources.IsLongFormat;
|
||||
set => SharedResources.IsLongFormat = value;
|
||||
}
|
||||
|
||||
public bool MovingPrimary
|
||||
{
|
||||
get => SharedResources.MovingPrimary;
|
||||
set => SharedResources.MovingPrimary = value;
|
||||
}
|
||||
|
||||
public bool MovingSecondary
|
||||
{
|
||||
get => SharedResources.MovingSecondary;
|
||||
set => SharedResources.MovingSecondary = value;
|
||||
}
|
||||
|
||||
public DateTime EarliestNonSlewingTime
|
||||
{
|
||||
get => SharedResources.EarliestNonSlewingTime;
|
||||
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