Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a80ad4662 | |||
| 3eddc52c6a | |||
| 64a72560bc | |||
| 0a6ba16c61 | |||
| b932bd8eb6 | |||
| 5aec81b45f | |||
| d68d51bd9c | |||
| badc519f37 | |||
| 77ca457646 | |||
| 7ed79d6954 | |||
| 43e630283c | |||
| 09df67c67f | |||
| 9a30e02a4b | |||
| 036fd48bcf | |||
| 5476331073 | |||
| c6cab848f9 | |||
| efa78ec8a0 | |||
| c311fb8cbe | |||
| 633babd967 | |||
| 81a3a29743 | |||
| e1a0d6449d | |||
| f6556716a5 | |||
| f10936a9e8 | |||
| 98feb74870 | |||
| 7542e86aeb | |||
| 68928a2289 | |||
| b3dc507aff | |||
| c5e9f67f84 | |||
| 4568f49f5f | |||
| fa613ecc92 | |||
| a9e2ec9528 | |||
| 027cb24d3f | |||
| 93c63cc014 | |||
| 355320a4ba | |||
| 87c8457bf0 | |||
| cc05808542 | |||
| e9d41a2412 | |||
| 1452f3cf07 | |||
| 64e2b9c6f9 | |||
| 37437b7c7c | |||
| 692e39771c | |||
| e582761f53 | |||
| c4eb74b274 | |||
| 6b9eff2b86 | |||
| 5d3688bde7 | |||
| 6d8702a011 | |||
| c2ebe329c5 | |||
| ce74e980fa | |||
| 1c3eb9f3d7 | |||
| b6e12d687b | |||
| e15537e6c3 | |||
| d9e551707f | |||
| 5f55d9f28f | |||
| c9ec7f3fca |
@@ -68,8 +68,8 @@
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -89,6 +89,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -4,5 +4,5 @@
|
||||
<package id="Moq" version="4.12.0" targetFramework="net472" />
|
||||
<package id="NUnit" version="3.12.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,36 @@
|
||||
<#
|
||||
This script initializes a bare minimum set of registry entries required for ASCOM.Utilities.Profile to work
|
||||
without throwing any exceptions. When building on a build server, or on a computer without the ASCOM Platform installed,
|
||||
it may be useful to execute this script as a build step prior to running any unit tests, or calling any code that relies on
|
||||
ASCOM.Utilities.Profile. The alternative is to install the ASCOM Platform on the build agent.
|
||||
|
||||
NOTE: This script equires elevated permissions because it creates registry keys in the LocalMachine hive.
|
||||
#>
|
||||
|
||||
$wow = Test-Path HKLM:\SOFTWARE\Wow6432Node
|
||||
if ($wow)
|
||||
{
|
||||
$root = "HKLM:\SOFTWARE\Wow6432Node"
|
||||
}
|
||||
else
|
||||
{
|
||||
$root = "HKLM:\SOFTWARE"
|
||||
}
|
||||
$ascomRoot = $root + "\ASCOM"
|
||||
|
||||
if (Test-Path $ascomRoot)
|
||||
{
|
||||
<# Don't upset an already-existing ASCOM registry #>
|
||||
exit
|
||||
}
|
||||
|
||||
<# Create the ASCOM root key and set it's ACL to allow all users read/write access #>
|
||||
New-Item -Path $root -Name ASCOM –Force
|
||||
$ascomAcl = Get-Acl $ascomRoot
|
||||
$aclRule = New-Object System.Security.AccessControl.RegistryAccessRule ("Users","FullControl","Allow")
|
||||
$ascomAcl.SetAccessRule($aclRule)
|
||||
$ascomAcl | Set-Acl -Path $ascomRoot
|
||||
|
||||
<# Now create the bare minimum keys required so that ASCOM.Utilities.Profile doesn't crash and burn #>
|
||||
New-ItemProperty -Path $ascomRoot -Name PlatformVersion -Value "6.1" -PropertyType String –Force
|
||||
New-ItemProperty -Path $ascomRoot -Name SerTraceFile -Value "C:\SerialTraceAuto.txt" -PropertyType String –Force
|
||||
@@ -0,0 +1,455 @@
|
||||
using System;
|
||||
using ASCOM;
|
||||
using ASCOM.DeviceInterface;
|
||||
using ASCOM.Meade.net;
|
||||
using ASCOM.Meade.net.Wrapper;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace Meade.net.Focuser.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FocuserUnitTests
|
||||
{
|
||||
private Mock<IUtil> _utilMock;
|
||||
private Mock<ISharedResourcesWrapper> _sharedResourcesWrapperMock;
|
||||
|
||||
private ProfileProperties _profileProperties;
|
||||
|
||||
private ASCOM.Meade.net.Focuser _focuser;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_profileProperties = new ProfileProperties();
|
||||
_profileProperties.TraceLogger = false;
|
||||
_profileProperties.ComPort = "TestCom1";
|
||||
_profileProperties.GuideRateArcSecondsPerSecond = 1.23;
|
||||
_profileProperties.Precision = "Unchanged";
|
||||
|
||||
_utilMock = new Mock<IUtil>();
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
private void ConnectFocuser()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
_focuser.Connected = true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckThatClassCreatedProperly()
|
||||
{
|
||||
Assert.That(_focuser, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotConnectedByDefault()
|
||||
{
|
||||
Assert.That(_focuser.Connected, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetupDialog()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.ReadProfile(), Times.Once);
|
||||
|
||||
_focuser.SetupDialog();
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SetupDialog(), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.ReadProfile(), Times.Exactly(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupportedActions()
|
||||
{
|
||||
var supportedActions = _focuser.SupportedActions;
|
||||
|
||||
Assert.That(supportedActions, Is.Not.Null);
|
||||
Assert.That(supportedActions.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Action_WhenNotConnected_ThrowsNotConnectedException()
|
||||
{
|
||||
var actionName = "Action";
|
||||
|
||||
var exception = Assert.Throws<ActionNotImplementedException>(() => { var actualResult = _focuser.Action(actionName, string.Empty); });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandBlind_WhenNotConnected_ThenThrowsNotConnectedException()
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { _focuser.CommandBlind(expectedMessage, true); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: CommandBlind"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandBlind_WhenConnected_ThenSendsExpectedMessage()
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
|
||||
ConnectFocuser();
|
||||
|
||||
_focuser.CommandBlind(expectedMessage, true);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedMessage), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandBool_WhenNotConnected_ThenThrowsNotConnectedException()
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { _focuser.CommandBool(expectedMessage, true); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: CommandBool"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandBool_WhenConnected_ThenSendsExpectedMessage()
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
|
||||
ConnectFocuser();
|
||||
|
||||
var exception = Assert.Throws<MethodNotImplementedException>(() => { _focuser.CommandBool(expectedMessage, true); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo("Method CommandBool is not implemented in this driver."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandString_WhenNotConnected_ThenThrowsNotConnectedException()
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { _focuser.CommandString(expectedMessage, true); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: CommandString"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CommandString_WhenConnected_ThenSendsExpectedMessage()
|
||||
{
|
||||
string expectedMessage = "expected result message";
|
||||
string sendMessage = "test blind Message";
|
||||
|
||||
ConnectFocuser();
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage)).Returns(() => expectedMessage);
|
||||
|
||||
var actualMessage = _focuser.CommandString(sendMessage, true);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage), Times.Once);
|
||||
Assert.That(actualMessage, Is.EqualTo(expectedMessage));
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void Connected_Get_ReturnsExpectedValue(bool expectedConnected)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
_focuser.Connected = expectedConnected;
|
||||
|
||||
Assert.That(_focuser.Connected, Is.EqualTo(expectedConnected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_WhenConnecting_Then_ConnectsToSerialDevice()
|
||||
{
|
||||
var productName = "LX2001";
|
||||
var firmware = string.Empty;
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
|
||||
_focuser.Connected = true;
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
|
||||
{
|
||||
ConnectFocuser();
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
|
||||
//act
|
||||
_focuser.Connected = true;
|
||||
|
||||
//assert
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
|
||||
{
|
||||
ConnectFocuser();
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
|
||||
//act
|
||||
_focuser.Connected = false;
|
||||
|
||||
//assert
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
//Commented out for now as the catch after connect is currently unreachable code.
|
||||
//[Test]
|
||||
//public void Connected_Set_WhenFailsToConnect_ThenDisconnects()
|
||||
//{
|
||||
// _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
// _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
|
||||
// _sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny<string>())).Throws(new Exception("TestFailed"));
|
||||
|
||||
// //act
|
||||
// _focuser.Connected = true;
|
||||
|
||||
// //assert
|
||||
// _sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void Description_Get()
|
||||
{
|
||||
var expectedDescription = "Meade Generic";
|
||||
|
||||
var description = _focuser.Description;
|
||||
|
||||
Assert.That(description, Is.EqualTo(expectedDescription));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DriverVersion_Get()
|
||||
{
|
||||
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Focuser)).GetName().Version;
|
||||
|
||||
string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||
|
||||
var driverVersion = _focuser.DriverVersion;
|
||||
|
||||
Assert.That(driverVersion, Is.EqualTo(exptectedDriverInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DriverInfo_Get()
|
||||
{
|
||||
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Focuser)).GetName().Version;
|
||||
|
||||
string exptectedDriverInfo = $"{_focuser.Description} .net driver. Version: {_focuser.DriverVersion}";
|
||||
|
||||
var driverInfo = _focuser.DriverInfo;
|
||||
|
||||
Assert.That(driverInfo, Is.EqualTo(exptectedDriverInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InterfaceVersion_Get()
|
||||
{
|
||||
var interfaceVersion = _focuser.InterfaceVersion;
|
||||
Assert.That(interfaceVersion, Is.EqualTo(3));
|
||||
|
||||
Assert.That(_focuser, Is.AssignableTo<IFocuserV3>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Name_Get()
|
||||
{
|
||||
string expectedName = "Meade Generic";
|
||||
|
||||
var name = _focuser.Name;
|
||||
|
||||
Assert.That(name, Is.EqualTo(expectedName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Absolute_Get_WhenNotConnected_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { var result = _focuser.Absolute; });
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: Absolute Get"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Absolute_Get_WhenConnected_ThenReturnsFalse()
|
||||
{
|
||||
ConnectFocuser();
|
||||
var result = _focuser.Absolute;
|
||||
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Halt_WhenNotConnected_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { _focuser.Halt(); });
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: Halt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Halt_WhenConnected_ThenSendsHaltCommand()
|
||||
{
|
||||
ConnectFocuser();
|
||||
|
||||
_focuser.Halt();
|
||||
|
||||
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(":FQ#"), Times.AtLeastOnce);
|
||||
_utilMock.Verify( x => x.WaitForMilliseconds(250), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsMoving_WhenCalled_ThenReturnsFalse()
|
||||
{
|
||||
ConnectFocuser();
|
||||
|
||||
var result = _focuser.IsMoving;
|
||||
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
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));
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void Link_Set_WhenSet_ThenSetsConnectedState(bool connected)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
_focuser.Link = connected;
|
||||
|
||||
Assert.That(_focuser.Link, Is.EqualTo(connected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaxIncrement_WhenCalled_ThenReturnsExpectedValue()
|
||||
{
|
||||
var result = _focuser.MaxIncrement;
|
||||
|
||||
Assert.That(result, Is.EqualTo(7000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaxStep_WhenCalled_ThenReturnsExpectedValue()
|
||||
{
|
||||
var result = _focuser.MaxStep;
|
||||
|
||||
Assert.That(result, Is.EqualTo(7000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Move_WhenNotConnected_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { _focuser.Move(0); });
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: Move"));
|
||||
}
|
||||
|
||||
[TestCase(-7001)]
|
||||
[TestCase(7001)]
|
||||
public void Move_WhenLargerThanMaxIncrement_ThenThrowsException(int position)
|
||||
{
|
||||
ConnectFocuser();
|
||||
|
||||
var exception = Assert.Throws<InvalidValueException>(() => { _focuser.Move(position); });
|
||||
Assert.That(exception.Message, Is.EqualTo($"position out of range -{_focuser.MaxIncrement} < {position} < {_focuser.MaxIncrement}"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Move_WhenIncrementIs0_ThenDoesNothing()
|
||||
{
|
||||
ConnectFocuser();
|
||||
|
||||
_focuser.Move(0);
|
||||
|
||||
_utilMock.Verify( x => x.WaitForMilliseconds(It.IsAny<int>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestCase(200)]
|
||||
[TestCase(-200)]
|
||||
public void Move_WhenIncrementIsNot0_ThenMovesFocuserAndStopsFocuser( int position)
|
||||
{
|
||||
ConnectFocuser();
|
||||
|
||||
_focuser.Move(position);
|
||||
|
||||
if (position < 0)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(":F-#"), Times.AtLeastOnce);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Never);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F-#"), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
_sharedResourcesWrapperMock.Verify( x => x.Lock(It.IsAny<Action>()), Times.Once);
|
||||
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(250), Times.AtLeastOnce);
|
||||
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Once());
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(1000), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Position_WhenCalled_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<PropertyNotImplementedException>(() => { var result = _focuser.Position; });
|
||||
Assert.That(exception.Message, Is.EqualTo("Property read Position is not implemented in this driver."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StepSize_WhenCalled_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<PropertyNotImplementedException>(() => { var result = _focuser.StepSize; });
|
||||
Assert.That(exception.Message, Is.EqualTo("Property read StepSize is not implemented in this driver."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TempComp_WhenRead_ThenReturnsFalse()
|
||||
{
|
||||
var result = _focuser.TempComp;
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TempComp_WhenWrite_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<PropertyNotImplementedException>(() => { _focuser.TempComp = false; });
|
||||
Assert.That(exception.Message, Is.EqualTo("Property read TempComp is not implemented in this driver."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TempCompAvailable_WhenRead_ThenReturnsFalse()
|
||||
{
|
||||
var result = _focuser.TempCompAvailable;
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Temperature_WhenCalled_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<PropertyNotImplementedException>(() => { var result = _focuser.Temperature; });
|
||||
Assert.That(exception.Message, Is.EqualTo("Property read Temperature is not implemented in this driver."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A3991FA7-23C3-405A-96F9-5AB03AC58F30}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Meade.net.Focuser.UnitTests</RootNamespace>
|
||||
<AssemblyName>Meade.net.Focuser.UnitTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Astrometry.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Attributes, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Attributes.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Cache, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Cache.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Controls, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DeviceInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.DriverAccess.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Exceptions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Exceptions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Internal.Extensions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Internal.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.SettingsProvider, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.SettingsProvider.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Utilities, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ASCOM.Utilities.Video, Version=6.1.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ASCOM.Platform.6.4.2\lib\net40\ASCOM.Utilities.Video.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.12.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.12.0\lib\net45\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FocuserUnitTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="BootstrapAscomProfileStore.ps1" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Meade.net.focuser\Meade.net.focuser.csproj">
|
||||
<Project>{a97e3aec-f11d-49da-b259-de99da813a86}</Project>
|
||||
<Name>Meade.net.focuser</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Meade.net\Meade.net.csproj">
|
||||
<Project>{3689a2cb-94c5-4012-a5cf-7e7d1dd27143}</Project>
|
||||
<Name>Meade.net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Meade.net.Focuser.UnitTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Meade.net.Focuser.UnitTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a3991fa7-23c3-405a-96f9-5ab03ac58f30")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ASCOM.Platform" version="6.4.2" targetFramework="net472" />
|
||||
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
|
||||
<package id="Moq" version="4.12.0" targetFramework="net472" />
|
||||
<package id="NUnit" version="3.12.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
|
||||
</packages>
|
||||
Binary file not shown.
@@ -11,7 +11,7 @@
|
||||
UpgradeCode must be unique to this product and should not be changed for the product lifetime.
|
||||
-->
|
||||
|
||||
<?define InstallName = "ASCOM Meade.net" ?>
|
||||
<?define InstallName = "ASCOM Meade Generic" ?>
|
||||
<?define Manufacturer = "cjdawson.com" ?>
|
||||
<?define UpgradeCode = "{57597bb6-f207-4998-97f4-8a041950d062}" ?>
|
||||
<?define INSTALLFOLDER = "$(var.InstallName)" ?>
|
||||
|
||||
Binary file not shown.
@@ -48,6 +48,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Config.wxi" />
|
||||
<Content Include="License.rtf" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Meade.net.focuser\Meade.net.focuser.csproj">
|
||||
|
||||
@@ -30,12 +30,7 @@
|
||||
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
|
||||
</Condition>
|
||||
|
||||
<!--todo create a method to check if ASCOM is installed.-->
|
||||
<!--<Condition Message="This application requires ASCOM Platform 6.4 or later. Please install this and try again.">
|
||||
<![CDATA[Installed or WIX_IS_NETFRAMEWORK_471_OR_LATER_INSTALLED]]>
|
||||
</Condition>-->
|
||||
|
||||
<!-- <Condition Message="Please use the correct installer for your operating system - x86 for 32-bit, x64 for 64-bit.">
|
||||
<!-- <Condition Message="Please use the correct installer for your operating system - x86 for 32-bit, x64 for 64-bit.">
|
||||
<?if $(var.Win64) = "yes" ?>
|
||||
VersionNT64
|
||||
<?else?>
|
||||
@@ -46,6 +41,7 @@
|
||||
|
||||
<UIRef Id="InstallationUI"/>
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
||||
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
|
||||
|
||||
<FeatureGroupRef Id="fgRoot"/>
|
||||
</Product>
|
||||
|
||||
@@ -104,8 +104,8 @@
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
private Mock<IAstroMaths> _astroMathsMock;
|
||||
|
||||
private ProfileProperties _profileProperties;
|
||||
private ConnectionInfo _connectionInfo;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -30,6 +31,8 @@ namespace Meade.net.Telescope.UnitTests
|
||||
_profileProperties = new ProfileProperties();
|
||||
_profileProperties.TraceLogger = false;
|
||||
_profileProperties.ComPort = "TestCom1";
|
||||
_profileProperties.GuideRateArcSecondsPerSecond = 1.23;
|
||||
_profileProperties.Precision = "Unchanged";
|
||||
|
||||
_utilMock = new Mock<IUtil>();
|
||||
_utilExtraMock = new Mock<IUtilExtra>();
|
||||
@@ -37,14 +40,16 @@ namespace Meade.net.Telescope.UnitTests
|
||||
|
||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS");
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Autostar497).Returns(() => "AUTOSTAR");
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Autostar49731Ee).Returns(() => "31Ee");
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Autostar49743Eg) .Returns(() => "43Eg");
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() =>_profileProperties);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Action>())).Callback<Action>(action => { action(); });
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>())).Returns<Func<ASCOM.Meade.net.Telescope.TelescopeDateDetails>>( (func) => func());
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny<Func<AltitudeData>>())).Returns<Func<AltitudeData>>((func) => func());
|
||||
|
||||
_connectionInfo = new ConnectionInfo {Connections = 1, SameDevice = 1};
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.Connect("Serial", It.IsAny<string>())).Returns( () => _connectionInfo );
|
||||
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties);
|
||||
|
||||
@@ -56,8 +61,8 @@ namespace Meade.net.Telescope.UnitTests
|
||||
|
||||
private void ConnectTelescope()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
_telescope.Connected = true;
|
||||
}
|
||||
|
||||
@@ -90,8 +95,9 @@ namespace Meade.net.Telescope.UnitTests
|
||||
var supportedActions = _telescope.SupportedActions;
|
||||
|
||||
Assert.That(supportedActions, Is.Not.Null);
|
||||
Assert.That(supportedActions.Count, Is.EqualTo(1));
|
||||
Assert.That(supportedActions.Count, Is.EqualTo(2));
|
||||
Assert.That(supportedActions.Contains("handbox"), Is.True);
|
||||
Assert.That(supportedActions.Contains("site"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -135,7 +141,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[TestCase("back", ":EK87#")]
|
||||
[TestCase("forward", ":EK69#")]
|
||||
[TestCase("?", ":EK63#")]
|
||||
public void Action_Handbox_blindCommands(string action, string expectedString)
|
||||
public void Action_Handbox_WhenCalling_ThenSendsAppropriateBlindCommands(string action, string expectedString)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
@@ -144,6 +150,100 @@ namespace Meade.net.Telescope.UnitTests
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedString), Times.Once);
|
||||
}
|
||||
|
||||
[TestCase("1")]
|
||||
[TestCase("2")]
|
||||
[TestCase("3")]
|
||||
[TestCase("4")]
|
||||
public void Action_Site_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
string parameters = $"select {site}";
|
||||
_telescope.Action("site", parameters);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once);
|
||||
}
|
||||
|
||||
[TestCase("0")]
|
||||
[TestCase("5")]
|
||||
public void Action_Site_WhenCallingWithInCorrectValues_ThenThrowsException(string site)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
string parameters = $"select {site}";
|
||||
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
|
||||
}
|
||||
|
||||
[TestCase("1", ":GM#", "Home")]
|
||||
[TestCase("2", ":GN#", "Club")]
|
||||
[TestCase("3", ":GO#", "GPS")]
|
||||
[TestCase("4", ":GP#", "Parents")]
|
||||
public void Action_Site_GetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(telescopeCommand)).Returns(siteName);
|
||||
|
||||
string parameters = $"GetName {site}";
|
||||
var result = _telescope.Action("site", parameters);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendString(telescopeCommand), Times.Once);
|
||||
Assert.That(result, Is.EqualTo(siteName));
|
||||
}
|
||||
|
||||
[TestCase("0")]
|
||||
[TestCase("5")]
|
||||
public void Action_Site_GetName_WhenCallingWithInCorrectValues_ThenThrowsException(string site)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
string parameters = $"GetName {site}";
|
||||
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
|
||||
}
|
||||
|
||||
[TestCase("1", ":SMHome#", "Home")]
|
||||
[TestCase("2", ":SNClub#", "Club")]
|
||||
[TestCase("3", ":SOGPS Site#", "GPS Site")]
|
||||
[TestCase("4", ":SPParents#", "Parents")]
|
||||
public void Action_Site_SetName_WhenCallingWithValidValues_ThenSelectsCorrectSite(string site, string telescopeCommand, string siteName)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar(telescopeCommand)).Returns("1");
|
||||
|
||||
string parameters = $"SetName {site} {siteName}";
|
||||
_telescope.Action("site", parameters);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar(telescopeCommand), Times.Once);
|
||||
}
|
||||
|
||||
[TestCase("0")]
|
||||
[TestCase("5")]
|
||||
public void Action_Site_SetName_WhenCallingWithInCorrectValues_ThenThrowsException(string site)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
string parameters = $"SetName {site}";
|
||||
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo($"Site {parameters} not allowed, must be between 1 and 4"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Action_Site_WhenCallingUnknownParam_ThenThrowsException()
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
string parameters = $"unknown";
|
||||
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo($"Site parameters {parameters} not known"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Action_Handbox_nonExistantAction()
|
||||
{
|
||||
@@ -238,45 +338,61 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[TestCase(false)]
|
||||
public void Connected_Get_ReturnsExpectedValue(bool expectedConnected)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
_telescope.Connected = expectedConnected;
|
||||
|
||||
Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_WhenConnecting_Then_ConnectsToSerialDevice()
|
||||
{
|
||||
var productName = "LX2001";
|
||||
var firmware = string.Empty;
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
|
||||
_telescope.Connected = true;
|
||||
|
||||
_sharedResourcesWrapperMock.Verify( x => x.Connect("Serial", It.IsAny<string>()), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
|
||||
{
|
||||
ConnectTelescope();
|
||||
_sharedResourcesWrapperMock.Verify( x => x.Connect(It.IsAny<string>()),Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify( x => x.Connect(It.IsAny<string>(), It.IsAny<string>()),Times.Once);
|
||||
|
||||
//act
|
||||
_telescope.Connected = true;
|
||||
|
||||
//assert
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>()), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
|
||||
{
|
||||
ConnectTelescope();
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>()), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Connect(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
|
||||
//act
|
||||
_telescope.Connected = false;
|
||||
|
||||
//assert
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>()), Times.Once());
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Connected_Set_WhenFailsToConnect_ThenDisconnects()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.Autostar49731Ee);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee);
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(It.IsAny<string>())).Throws(new Exception("TestFailed"));
|
||||
|
||||
@@ -284,13 +400,14 @@ namespace Meade.net.Telescope.UnitTests
|
||||
_telescope.Connected = true;
|
||||
|
||||
//assert
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>()), Times.Once());
|
||||
_sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[TestCase("AUTOSTAR", "30Ab", false)]
|
||||
[TestCase("AUTOSTAR","31Ee", true)]
|
||||
[TestCase("AUTOSTAR", "43Eg", true)]
|
||||
[TestCase("AUTOSTAR II", "", false)]
|
||||
[TestCase("Autostar", "30Ab", false)]
|
||||
[TestCase("Autostar", "31Ee", true)]
|
||||
[TestCase("Autostar", "43Eg", true)]
|
||||
[TestCase("Autostar II", "", false)]
|
||||
[TestCase("LX2001", "", true)]
|
||||
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
|
||||
@@ -337,9 +454,18 @@ namespace Meade.net.Telescope.UnitTests
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":U#"), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SelectSite_Get_WhenNotConnected_ThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { _telescope.SelectSite(1); });
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SelectSite"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SelectSite_WhenNewSiteToLow_ThenThrowsException()
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
var site = 0;
|
||||
var result = Assert.Throws<ArgumentOutOfRangeException>(() => { _telescope.SelectSite(site); });
|
||||
|
||||
@@ -349,6 +475,8 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[Test]
|
||||
public void SelectSite_WhenNewSiteToHigh_ThenThrowsException()
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
var site = 5;
|
||||
var result = Assert.Throws<ArgumentOutOfRangeException>(() => { _telescope.SelectSite(site); });
|
||||
|
||||
@@ -361,6 +489,8 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[TestCase(4)]
|
||||
public void SelectSite_WhenNewSiteToHigh_ThenThrowsException(int site)
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
_telescope.SelectSite(site);
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":W{site}#"), Times.Once);
|
||||
@@ -381,7 +511,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
{
|
||||
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version;
|
||||
|
||||
string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}";
|
||||
string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||
|
||||
var driverVersion = _telescope.DriverVersion;
|
||||
|
||||
@@ -582,13 +712,86 @@ namespace Meade.net.Telescope.UnitTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSetGuideRates_Get_ReturnsFalse()
|
||||
public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException()
|
||||
{
|
||||
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.CanSetGuideRates; });
|
||||
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSetGuideRates_Get_WhenConnectedToAutostar_ThenReturnsFalse()
|
||||
{
|
||||
ConnectTelescope();
|
||||
|
||||
var result = _telescope.CanSetGuideRates;
|
||||
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSetGuideRates_Get_WhenConnectedToLX200GPS_ThenReturnsTrue()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.LX200GPS_42G);
|
||||
_telescope.Connected = true;
|
||||
|
||||
var result = _telescope.CanSetGuideRates;
|
||||
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Precision_Set_WhenConnectedAndPrecisionSetUnChanged_ThenDoesNotSetPrecision()
|
||||
{
|
||||
_telescope.Connected = true;
|
||||
|
||||
_sharedResourcesWrapperMock.Verify( x => x.SendString(":P#"), Times.Never);
|
||||
}
|
||||
|
||||
[TestCase("High", false, true)]
|
||||
[TestCase("High", true, true)]
|
||||
[TestCase("Low", false, false)]
|
||||
[TestCase("Low", true, false)]
|
||||
public void Precision_Set_WhenConnectedAndPrecisionSetHighScopeIsLow_ThenTelescopePrecisionChanged(string desiredPresision, bool telescopePrecision, bool finalPrecision)
|
||||
{
|
||||
_profileProperties.Precision = desiredPresision;
|
||||
var currentPrecision = telescopePrecision;
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":P#")).Returns(() =>
|
||||
{
|
||||
currentPrecision = !currentPrecision;
|
||||
|
||||
switch (currentPrecision)
|
||||
{
|
||||
case true:
|
||||
return "H";
|
||||
default:
|
||||
return "L";
|
||||
}
|
||||
});
|
||||
|
||||
_telescope.Connected = true;
|
||||
|
||||
Assert.That(currentPrecision, Is.EqualTo(finalPrecision));
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[TestCase("High", false, true)]
|
||||
[TestCase("High", true, true)]
|
||||
[TestCase("Low", false, false)]
|
||||
[TestCase("Low", true, false)]
|
||||
public void Precision_Set_WhenSecondConnectionMade_ThenTelescopePrecisionNotChanged(string desiredPresision, bool telescopePrecision, bool finalPrecision)
|
||||
{
|
||||
_profileProperties.Precision = desiredPresision;
|
||||
|
||||
_connectionInfo.SameDevice = 2;
|
||||
_connectionInfo.Connections = 2;
|
||||
|
||||
_telescope.Connected = true;
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSetPark_Get_ReturnsFalse()
|
||||
{
|
||||
@@ -769,15 +972,16 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[Test]
|
||||
public void GuideRateDeclination_Get_ThenThrowsException()
|
||||
{
|
||||
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.GuideRateDeclination; });
|
||||
var result = _telescope.GuideRateDeclination;
|
||||
|
||||
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
|
||||
Assert.That(excpetion.AccessorSet, Is.False);
|
||||
Assert.That(result, Is.EqualTo(0.00034166666666666666));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuideRateDeclination_Set_ThenThrowsException()
|
||||
public void GuideRateDeclination_Set_WhenNotSupported_ThenThrowsException()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
|
||||
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateDeclination = 0; });
|
||||
|
||||
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
|
||||
@@ -785,23 +989,52 @@ namespace Meade.net.Telescope.UnitTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuideRateRightAscension_Get_ThenThrowsException()
|
||||
public void GuideRateDeclination_Set_WhenIsSupported_ThenSetsNewGuideRate()
|
||||
{
|
||||
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.GuideRateRightAscension; });
|
||||
var newGuideRate = 0.00034166666666666666;
|
||||
|
||||
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
|
||||
Assert.That(excpetion.AccessorSet, Is.False);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
|
||||
|
||||
_telescope.GuideRateDeclination = newGuideRate;
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once);
|
||||
|
||||
Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuideRateRightAscension_Set_ThenThrowsException()
|
||||
public void GuideRateRightAscension_Get_ThenThrowsException()
|
||||
{
|
||||
var result = _telescope.GuideRateRightAscension;
|
||||
|
||||
Assert.That(result, Is.EqualTo(0.00034166666666666666));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuideRateRightAscension_Set_WhenNotSupported_ThenThrowsException()
|
||||
{
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
|
||||
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateRightAscension = 0; });
|
||||
|
||||
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
|
||||
Assert.That(excpetion.AccessorSet, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuideRateRightAscension_Set_WhenIsSupported_ThenSetsNewGuideRate()
|
||||
{
|
||||
var newGuideRate = 0.00034166666666666666;
|
||||
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.LX200GPS);
|
||||
|
||||
_telescope.GuideRateRightAscension = newGuideRate;
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Rg01.2#"), Times.Once);
|
||||
|
||||
Assert.That(_telescope.GuideRateDeclination, Is.EqualTo(newGuideRate));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsPulseGuiding_Get_ReturnsFalse()
|
||||
{
|
||||
@@ -969,7 +1202,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
var duration = 0;
|
||||
ConnectTelescope();
|
||||
|
||||
_telescope.PulseGuide(direction, 0);
|
||||
_telescope.PulseGuide(direction, duration);
|
||||
|
||||
string d = string.Empty;
|
||||
switch (direction)
|
||||
@@ -999,11 +1232,47 @@ namespace Meade.net.Telescope.UnitTests
|
||||
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenSendsOldCommandsAndWaits(GuideDirections direction)
|
||||
{
|
||||
var duration = 0;
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed");
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
|
||||
_telescope.Connected = true;
|
||||
|
||||
_telescope.PulseGuide(direction, 0);
|
||||
_telescope.PulseGuide(direction, duration);
|
||||
|
||||
string d = string.Empty;
|
||||
switch (direction)
|
||||
{
|
||||
case GuideDirections.guideEast:
|
||||
d = "e";
|
||||
break;
|
||||
case GuideDirections.guideWest:
|
||||
d = "w";
|
||||
break;
|
||||
case GuideDirections.guideNorth:
|
||||
d = "n";
|
||||
break;
|
||||
case GuideDirections.guideSouth:
|
||||
d = "s";
|
||||
break;
|
||||
}
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RG#"));
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":M{d}#"));
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(duration), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#"));
|
||||
}
|
||||
|
||||
[TestCase(GuideDirections.guideEast)]
|
||||
[TestCase(GuideDirections.guideWest)]
|
||||
[TestCase(GuideDirections.guideNorth)]
|
||||
[TestCase(GuideDirections.guideSouth)]
|
||||
public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailableButDurationTooLong_ThenSendsOldCommandsAndWaits(GuideDirections direction)
|
||||
{
|
||||
var duration = 10000;
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497);
|
||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_30Ee);
|
||||
_telescope.Connected = true;
|
||||
|
||||
_telescope.PulseGuide(direction, duration);
|
||||
|
||||
string d = string.Empty;
|
||||
switch (direction)
|
||||
@@ -1294,8 +1563,6 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[Test]
|
||||
public void SyncToAltAz_WhenConnected_ThenSendsExpectedMessage()
|
||||
{
|
||||
string expectedMessage = "test blind Message";
|
||||
|
||||
ConnectTelescope();
|
||||
|
||||
var exception = Assert.Throws<MethodNotImplementedException>(() => { _telescope.SyncToAltAz(0,0); });
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1"/>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
<package id="Moq" version="4.12.0" targetFramework="net45" />
|
||||
<package id="NUnit" version="3.12.0" targetFramework="net40" requireReinstallation="true" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net45" requireReinstallation="true" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net45" requireReinstallation="true" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public static class DoubleExtensions
|
||||
{
|
||||
public static bool InRange(this double value, double low, double high)
|
||||
{
|
||||
if (value < low)
|
||||
return false;
|
||||
if (value > high)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,7 @@
|
||||
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
|
||||
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
|
||||
<Compile Include="AstroMaths\IAstroMaths.cs" />
|
||||
<Compile Include="DoubleExtensions.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="Telescope.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@@ -6,5 +6,28 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
return int.Parse(str);
|
||||
}
|
||||
|
||||
public static double ToDouble(this string str)
|
||||
{
|
||||
return double.Parse(str);
|
||||
}
|
||||
|
||||
public static int Position(this string str, char find, int instance)
|
||||
{
|
||||
var currentInstance = 0;
|
||||
for (var i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (str[i] == find)
|
||||
{
|
||||
currentInstance++;
|
||||
if (currentInstance == instance)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,17 +97,20 @@ namespace ASCOM.Meade.net
|
||||
Initialise();
|
||||
}
|
||||
|
||||
private double _guideRate;
|
||||
|
||||
private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
|
||||
|
||||
private void Initialise()
|
||||
{
|
||||
//todo move the TraceLogger out to a factory class.
|
||||
_tl = new TraceLogger("", "Meade.net.Telescope");
|
||||
LogMessage("Telescope", "Starting initialisation");
|
||||
|
||||
_tl = new TraceLogger("", "Meade.Generic.Telescope");
|
||||
ReadProfile(); // Read device configuration from the ASCOM Profile store
|
||||
|
||||
IsConnected = false; // Initialise connected to false
|
||||
|
||||
|
||||
LogMessage("Telescope", "Completed initialisation");
|
||||
LogMessage("Telescope", $"Driver version: {DriverVersion}");
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +154,7 @@ namespace ASCOM.Meade.net
|
||||
LogMessage("SupportedActions Get", "Returning empty arraylist");
|
||||
var supportedActions = new ArrayList();
|
||||
supportedActions.Add("handbox");
|
||||
supportedActions.Add("site");
|
||||
return supportedActions;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +237,72 @@ namespace ASCOM.Meade.net
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
|
||||
throw new ActionNotImplementedException($"{actionName}({actionParameters})");
|
||||
}
|
||||
|
||||
break;
|
||||
case "site":
|
||||
var parames = actionParameters.ToLower().Split(' ');
|
||||
switch (parames[0])
|
||||
{
|
||||
case "count":
|
||||
return "4";
|
||||
case "select":
|
||||
switch (parames[1])
|
||||
{
|
||||
case "1":
|
||||
case "2":
|
||||
case "3":
|
||||
case "4":
|
||||
SelectSite(parames[1].ToInteger());
|
||||
break;
|
||||
default:
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
|
||||
actionParameters);
|
||||
throw new InvalidValueException(
|
||||
$"Site {actionParameters} not allowed, must be between 1 and 4");
|
||||
|
||||
}
|
||||
break;
|
||||
case "getname":
|
||||
switch (parames[1])
|
||||
{
|
||||
case "1":
|
||||
case "2":
|
||||
case "3":
|
||||
case "4":
|
||||
return GetSiteName(parames[1].ToInteger());
|
||||
default:
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
|
||||
actionParameters);
|
||||
throw new InvalidValueException(
|
||||
$"Site {actionParameters} not allowed, must be between 1 and 4");
|
||||
|
||||
}
|
||||
case "setname":
|
||||
switch (parames[1])
|
||||
{
|
||||
case "1":
|
||||
case "2":
|
||||
case "3":
|
||||
case "4":
|
||||
var sitename = actionParameters.Substring(actionParameters.Position(' ', 2)).Trim();
|
||||
|
||||
SetSiteName(parames[1].ToInteger(), sitename);
|
||||
break;
|
||||
default:
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
|
||||
actionParameters);
|
||||
throw new InvalidValueException(
|
||||
$"Site {actionParameters} not allowed, must be between 1 and 4");
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new InvalidValueException(
|
||||
$"Site parameters {actionParameters} not known");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
|
||||
throw new ActionNotImplementedException($"{actionName}");
|
||||
@@ -299,15 +368,16 @@ namespace ASCOM.Meade.net
|
||||
|
||||
if (value)
|
||||
{
|
||||
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
|
||||
try
|
||||
{
|
||||
_sharedResourcesWrapper.Connect("Serial");
|
||||
ReadProfile();
|
||||
|
||||
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
|
||||
var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId);
|
||||
try
|
||||
{
|
||||
LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}");
|
||||
|
||||
SetLongFormat(true);
|
||||
_userNewerPulseGuiding = IsNewPulseGuidingSupported();
|
||||
_targetDeclination = InvalidParameter;
|
||||
_targetRightAscension = InvalidParameter;
|
||||
@@ -315,10 +385,28 @@ namespace ASCOM.Meade.net
|
||||
|
||||
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
|
||||
IsConnected = true;
|
||||
|
||||
if (connectionInfo.SameDevice == 1)
|
||||
{
|
||||
LogMessage("Connected Set", $"Making first connection telescope adjustments");
|
||||
//These settings are applied only when the first device connects to the telescope.
|
||||
SetLongFormat(true);
|
||||
|
||||
if (CanSetGuideRates)
|
||||
{
|
||||
SetNewGuideRate(_guideRate, "Connect");
|
||||
}
|
||||
|
||||
SetTelescopePrecision("Connect");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMessage("Connected Set", $"Skipping first connection telescope adjustments (current connections: {connectionInfo.SameDevice})");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_sharedResourcesWrapper.Disconnect("Serial");
|
||||
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -330,19 +418,51 @@ namespace ASCOM.Meade.net
|
||||
else
|
||||
{
|
||||
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
|
||||
_sharedResourcesWrapper.Disconnect("Serial");
|
||||
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
IsConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTelescopePrecision(string propertyName)
|
||||
{
|
||||
switch (_precision.ToLower())
|
||||
{
|
||||
case "high":
|
||||
TelescopePointingPrecision(true);
|
||||
LogMessage(propertyName, $"High precision slewing selected");
|
||||
break;
|
||||
case "low":
|
||||
TelescopePointingPrecision(false);
|
||||
LogMessage(propertyName, $"Low precision slewing selected");
|
||||
break;
|
||||
default:
|
||||
LogMessage(propertyName, $"Precision slewing unchanged");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewPulseGuidingSupported()
|
||||
{
|
||||
if (_sharedResourcesWrapper.ProductName == _sharedResourcesWrapper.Autostar497)
|
||||
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
|
||||
{
|
||||
return FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49731Ee);
|
||||
return FirmwareIsGreaterThan(TelescopeList.Autostar497_31Ee);
|
||||
}
|
||||
|
||||
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsGuideRateSettingSupported()
|
||||
{
|
||||
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -376,9 +496,49 @@ namespace ASCOM.Meade.net
|
||||
});
|
||||
}
|
||||
|
||||
//todo hook this up to a custom action
|
||||
private bool TogglePrecision()
|
||||
{
|
||||
LogMessage("TogglePrecision", $"Toggling slewing precision");
|
||||
var result = _sharedResourcesWrapper.SendChar(":P#");
|
||||
//:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target.
|
||||
//Returns: <string>
|
||||
//“HIGH PRECISION” Current setting after this command.
|
||||
//“LOW PRECISION” Current setting after this command.
|
||||
|
||||
int throwAwayCharacters = "LOW PRECISION".Length - 1;
|
||||
|
||||
LogMessage("TogglePrecision", $"Result: {result}");
|
||||
bool highPrecision = false;
|
||||
switch (result)
|
||||
{
|
||||
case "H":
|
||||
highPrecision = true;
|
||||
throwAwayCharacters = "HIGH PRECISION".Length - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
_sharedResourcesWrapper.ReadCharacters(throwAwayCharacters);
|
||||
|
||||
//Make sure that the buffers are cleared out.
|
||||
_sharedResourcesWrapper.SendBlind("#");
|
||||
|
||||
return highPrecision;
|
||||
}
|
||||
|
||||
private void TelescopePointingPrecision(bool high)
|
||||
{
|
||||
var currentPrecision = TogglePrecision();
|
||||
|
||||
while (currentPrecision != high)
|
||||
{
|
||||
currentPrecision = TogglePrecision();
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectSite(int site)
|
||||
{
|
||||
CheckConnected("SelectSite");
|
||||
|
||||
if (site < 1)
|
||||
throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1");
|
||||
else if (site > 4)
|
||||
@@ -390,6 +550,96 @@ namespace ASCOM.Meade.net
|
||||
//Returns: Nothing
|
||||
}
|
||||
|
||||
private void SetSiteName(int site, string sitename)
|
||||
{
|
||||
CheckConnected("SetSiteName");
|
||||
|
||||
if (site < 1)
|
||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
|
||||
else if (site > 4)
|
||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
|
||||
|
||||
string command = String.Empty;
|
||||
switch (site)
|
||||
{
|
||||
case 1:
|
||||
command = $":SM{sitename}#";
|
||||
//:SM<string>#
|
||||
//Set site 1’s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
|
||||
// Returns:
|
||||
//0 – Invalid
|
||||
//1 - Valid
|
||||
break;
|
||||
case 2:
|
||||
command = $":SN{sitename}#";
|
||||
//:SN<string>#
|
||||
//Set site 2’s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
|
||||
// Returns:
|
||||
//0 – Invalid
|
||||
//1 - Valid
|
||||
break;
|
||||
case 3:
|
||||
command = $":SO{sitename}#";
|
||||
//:SO<string>#
|
||||
//Set site 3’s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
|
||||
// Returns:
|
||||
//0 – Invalid
|
||||
//1 - Valid
|
||||
break;
|
||||
case 4:
|
||||
command = $":SP{sitename}#";
|
||||
//:SP<string>#
|
||||
//Set site 4’s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
|
||||
// Returns:
|
||||
//0 – Invalid
|
||||
//1 - Valid
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
var result = _sharedResourcesWrapper.SendChar(command);
|
||||
if (result != "1")
|
||||
{
|
||||
throw new InvalidOperationException("Failed to set site name.");
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSiteName(int site)
|
||||
{
|
||||
CheckConnected("GetSiteName");
|
||||
|
||||
if (site < 1)
|
||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
|
||||
else if (site > 4)
|
||||
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
|
||||
|
||||
switch (site)
|
||||
{
|
||||
case 1:
|
||||
return _sharedResourcesWrapper.SendString(":GM#");
|
||||
//:GM# Get Site 1 Name
|
||||
//Returns: <string>#
|
||||
//A ‘#’ terminated string with the name of the requested site.
|
||||
case 2:
|
||||
return _sharedResourcesWrapper.SendString(":GN#");
|
||||
//:GN# Get Site 2 Name
|
||||
//Returns: <string>#
|
||||
//A ‘#’ terminated string with the name of the requested site.
|
||||
case 3:
|
||||
return _sharedResourcesWrapper.SendString(":GO#");
|
||||
//:GO# Get Site 3 Name
|
||||
//Returns: <string>#
|
||||
//A ‘#’ terminated string with the name of the requested site.
|
||||
case 4:
|
||||
return _sharedResourcesWrapper.SendString(":GP#");
|
||||
//:GP# Get Site 4 Name
|
||||
//Returns: <string>#
|
||||
//A ‘#’ terminated string with the name of the requested site.
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException("site", site, "Site out of range");
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
// TODO customise this device description
|
||||
@@ -416,7 +666,7 @@ namespace ASCOM.Meade.net
|
||||
get
|
||||
{
|
||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
string driverVersion = $"{version.Major}.{version.Minor}.{version.Revision}.{version.Build}";
|
||||
string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||
LogMessage("DriverVersion Get", driverVersion);
|
||||
return driverVersion;
|
||||
}
|
||||
@@ -489,7 +739,7 @@ namespace ASCOM.Meade.net
|
||||
//P If scope in Polar Mode
|
||||
|
||||
//todo implement GW Command - Supported in Autostar 43Eg and above
|
||||
//if FirmwareIsGreaterThan(_sharedResourcesWrapper.AUTOSTAR497_43EG)
|
||||
//if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG)
|
||||
//{
|
||||
//var alignmentString = SerialPort.CommandTerminated(":GW#", "#");
|
||||
//:GW# Get Scope Alignment Status
|
||||
@@ -525,7 +775,7 @@ namespace ASCOM.Meade.net
|
||||
CheckConnected("AlignmentMode Set");
|
||||
|
||||
//todo tidy this up into a better solution that means can :GW#, :AL#, :AA#, & :AP# and checked for Autostar properly
|
||||
if (!FirmwareIsGreaterThan(_sharedResourcesWrapper.Autostar49743Eg))
|
||||
if (!FirmwareIsGreaterThan(TelescopeList.Autostar497_43Eg))
|
||||
throw new PropertyNotImplementedException("AlignmentMode",true );
|
||||
|
||||
//todo make this only try with Autostar 43Eg and above.
|
||||
@@ -716,8 +966,12 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
LogMessage("CanSetGuideRates", "Get - " + false.ToString());
|
||||
return false;
|
||||
CheckConnected("CanSetGuideRates Get");
|
||||
|
||||
var canSetGuideRate = IsGuideRateSettingSupported();
|
||||
|
||||
LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString());
|
||||
return canSetGuideRate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,31 +1152,71 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
}
|
||||
|
||||
private void SetNewGuideRate(double value, string propertyName)
|
||||
{
|
||||
if (!IsGuideRateSettingSupported())
|
||||
{
|
||||
LogMessage($"{propertyName} Set", "Not implemented");
|
||||
throw new PropertyNotImplementedException(propertyName, true);
|
||||
}
|
||||
|
||||
if (!value.InRange(0, 15.0417))
|
||||
{
|
||||
throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec");
|
||||
}
|
||||
|
||||
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)");
|
||||
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
|
||||
//:RgSS.S#
|
||||
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
|
||||
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
|
||||
//sidereal speed(approx 15.0417”/sec)[Autostar II only]
|
||||
//Returns: Nothing
|
||||
|
||||
//info from RickB says that 15.04107 is a better value for
|
||||
|
||||
_guideRate = value;
|
||||
|
||||
WriteProfile();
|
||||
}
|
||||
|
||||
private double DegreesPerSecondToArcSecondPerSecond(double value)
|
||||
{
|
||||
return value * 3600.0;
|
||||
}
|
||||
|
||||
private double ArcSecondPerSecondToDegreesPerSecond(double value)
|
||||
{
|
||||
return value / 3600.0;
|
||||
}
|
||||
|
||||
public double GuideRateDeclination
|
||||
{
|
||||
get
|
||||
{
|
||||
LogMessage("GuideRateDeclination Get", "Not implemented");
|
||||
throw new PropertyNotImplementedException("GuideRateDeclination", false);
|
||||
var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate);
|
||||
LogMessage("GuideRateDeclination Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second");
|
||||
return degreesPerSecond;
|
||||
}
|
||||
set
|
||||
{
|
||||
LogMessage("GuideRateDeclination Set", "Not implemented");
|
||||
throw new PropertyNotImplementedException("GuideRateDeclination", true);
|
||||
var newValue = DegreesPerSecondToArcSecondPerSecond(value);
|
||||
SetNewGuideRate(newValue, "GuideRateDeclination");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double GuideRateRightAscension
|
||||
{
|
||||
get
|
||||
{
|
||||
LogMessage("GuideRateRightAscension Get", "Not implemented");
|
||||
throw new PropertyNotImplementedException("GuideRateRightAscension", false);
|
||||
double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate);
|
||||
LogMessage("GuideRateRightAscension Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second");
|
||||
return degreesPerSecond;
|
||||
}
|
||||
set
|
||||
{
|
||||
LogMessage("GuideRateRightAscension Set", "Not implemented");
|
||||
throw new PropertyNotImplementedException("GuideRateRightAscension", true);
|
||||
var newValue = DegreesPerSecondToArcSecondPerSecond(value);
|
||||
SetNewGuideRate(newValue, "GuideRateRightAscension");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,8 +1369,9 @@ namespace ASCOM.Meade.net
|
||||
break;
|
||||
}
|
||||
|
||||
if (_userNewerPulseGuiding)
|
||||
if (_userNewerPulseGuiding && duration < 10000)
|
||||
{
|
||||
LogMessage("PulseGuide", $"Using new pulse guiding technique");
|
||||
_sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#");
|
||||
//:MgnDDDD#
|
||||
//:MgsDDDD#
|
||||
@@ -1086,12 +1381,11 @@ namespace ASCOM.Meade.net
|
||||
//passed in the command.These commands support serial port driven guiding.
|
||||
//Returns – Nothing
|
||||
//LX200 – Not Supported
|
||||
|
||||
//todo implement IsPulseGuiding if WaitForMilliseconds is not needed
|
||||
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMessage("PulseGuide", $"Using old pulse guiding technique");
|
||||
_sharedResourcesWrapper.Lock(() =>
|
||||
{
|
||||
_sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate
|
||||
@@ -1738,6 +2032,7 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
|
||||
private DriveRates _trackingRate = DriveRates.driveSidereal;
|
||||
private string _precision;
|
||||
|
||||
public DriveRates TrackingRate
|
||||
{
|
||||
@@ -2018,13 +2313,32 @@ namespace ASCOM.Meade.net
|
||||
/// <summary>
|
||||
/// Read the device configuration from the ASCOM Profile store
|
||||
/// </summary>
|
||||
internal void ReadProfile()
|
||||
private void ReadProfile()
|
||||
{
|
||||
var profileProperties = _sharedResourcesWrapper.ReadProfile();
|
||||
ProfileProperties profileProperties = _sharedResourcesWrapper.ReadProfile();
|
||||
_tl.Enabled = profileProperties.TraceLogger;
|
||||
_comPort = profileProperties.ComPort;
|
||||
_guideRate = profileProperties.GuideRateArcSecondsPerSecond;
|
||||
_precision = profileProperties.Precision;
|
||||
|
||||
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
|
||||
LogMessage("ReadProfile", $"Com Port: {_comPort}");
|
||||
LogMessage("ReadProfile", $"Guide Rate: {_guideRate}");
|
||||
LogMessage("ReadProfile", $"Precision: {_precision}");
|
||||
}
|
||||
|
||||
internal void WriteProfile()
|
||||
{
|
||||
var profileProperties = new ProfileProperties
|
||||
{
|
||||
TraceLogger = _tl.Enabled,
|
||||
ComPort = _comPort,
|
||||
GuideRateArcSecondsPerSecond = _guideRate
|
||||
};
|
||||
|
||||
_sharedResourcesWrapper.WriteProfile(profileProperties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log helper function that takes formatted strings and arguments
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using ASCOM.Utilities;
|
||||
using ASCOM.DeviceInterface;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using ASCOM.Meade.net.Wrapper;
|
||||
@@ -38,7 +37,7 @@ namespace ASCOM.Meade.net
|
||||
/// The DeviceID is used by ASCOM applications to load the driver at runtime.
|
||||
/// </summary>
|
||||
//internal static string driverID = "ASCOM.Meade.net.Focuser";
|
||||
private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException());
|
||||
// TODO Change the descriptive string for your driver then remove this line
|
||||
/// <summary>
|
||||
/// Driver description that displays in the ASCOM Chooser.
|
||||
@@ -55,7 +54,7 @@ namespace ASCOM.Meade.net
|
||||
/// <summary>
|
||||
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
|
||||
/// </summary>
|
||||
internal static TraceLogger Tl;
|
||||
private static TraceLogger Tl;
|
||||
|
||||
private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
|
||||
|
||||
@@ -66,22 +65,32 @@ namespace ASCOM.Meade.net
|
||||
public Focuser()
|
||||
{
|
||||
//todo move this out to IOC
|
||||
_utilities = new Util(); //Initialise util object
|
||||
var util = new Util(); //Initialise util object
|
||||
_utilities = util;
|
||||
_sharedResourcesWrapper = new SharedResourcesWrapper();
|
||||
|
||||
Initialise();
|
||||
}
|
||||
|
||||
public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper)
|
||||
{
|
||||
_utilities = util;
|
||||
_sharedResourcesWrapper = sharedResourcesWrapper;
|
||||
|
||||
Initialise();
|
||||
}
|
||||
|
||||
private void Initialise()
|
||||
{
|
||||
Tl = new TraceLogger("", "Meade.net.focusser");
|
||||
//todo move the TraceLogger out to a factory class.
|
||||
Tl = new TraceLogger("", "Meade.Generic.focusser");
|
||||
|
||||
Tl.LogMessage("Focuser", "Starting initialisation");
|
||||
ReadProfile(); // Read device configuration from the ASCOM Profile store
|
||||
|
||||
IsConnected = false; // Initialise connected to false
|
||||
|
||||
Tl.LogMessage("Focuser", "Completed initialisation");
|
||||
LogMessage("Focuser", "Completed initialisation");
|
||||
LogMessage("Focuser", $"Driver version: {DriverVersion}");
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +126,7 @@ namespace ASCOM.Meade.net
|
||||
public string Action(string actionName, string actionParameters)
|
||||
{
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
|
||||
throw new ActionNotImplementedException("Action " + actionName + " is not implemented by this driver");
|
||||
throw new ActionNotImplementedException();
|
||||
}
|
||||
|
||||
public void CommandBlind(string command, bool raw)
|
||||
@@ -148,8 +157,7 @@ namespace ASCOM.Meade.net
|
||||
// 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);
|
||||
|
||||
throw new MethodNotImplementedException("CommandString");
|
||||
//throw new ASCOM.MethodNotImplementedException("CommandString");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -177,17 +185,15 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
try
|
||||
{
|
||||
_sharedResourcesWrapper.Connect("Serial");
|
||||
ReadProfile();
|
||||
_sharedResourcesWrapper.Connect("Serial", DriverId);
|
||||
try
|
||||
{
|
||||
SelectSite(1);
|
||||
SetLongFormat(true);
|
||||
|
||||
IsConnected = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_sharedResourcesWrapper.Disconnect("Serial");
|
||||
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -199,43 +205,12 @@ namespace ASCOM.Meade.net
|
||||
else
|
||||
{
|
||||
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
|
||||
_sharedResourcesWrapper.Disconnect("Serial");
|
||||
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
IsConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetLongFormat(bool setLongFormat)
|
||||
{
|
||||
_sharedResourcesWrapper.Lock(() =>
|
||||
{
|
||||
var result = _sharedResourcesWrapper.SendString(":GZ#");
|
||||
//:GZ# Get telescope azimuth
|
||||
//Returns: DDD*MM#T or DDD*MM’SS#
|
||||
//The current telescope Azimuth depending on the selected precision.
|
||||
|
||||
bool isLongFormat = result.Length > 6;
|
||||
|
||||
if (isLongFormat != setLongFormat)
|
||||
{
|
||||
_utilities.WaitForMilliseconds(500);
|
||||
_sharedResourcesWrapper.SendBlind(":U#");
|
||||
//:U# Toggle between low/hi precision positions
|
||||
//Low - RA displays and messages HH:MM.T sDD*MM
|
||||
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
|
||||
// Returns Nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void SelectSite(int site)
|
||||
{
|
||||
_sharedResourcesWrapper.SendBlind($":W{site}#");
|
||||
//:W<n>#
|
||||
//Set current site to<n>, an ASCII digit in the range 1..4
|
||||
//Returns: Nothing
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
// TODO customise this device description
|
||||
@@ -250,10 +225,9 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
// TODO customise this driver description
|
||||
string driverInfo = "Information about the driver itself. Version: " + String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
|
||||
Tl.LogMessage("DriverInfo Get", driverInfo);
|
||||
string driverInfo = $"{Description} .net driver. Version: {DriverVersion}";
|
||||
LogMessage("DriverInfo Get", driverInfo);
|
||||
return driverInfo;
|
||||
}
|
||||
}
|
||||
@@ -263,8 +237,8 @@ namespace ASCOM.Meade.net
|
||||
get
|
||||
{
|
||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
string driverVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
|
||||
Tl.LogMessage("DriverVersion Get", driverVersion);
|
||||
string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||
LogMessage("DriverVersion Get", driverVersion);
|
||||
return driverVersion;
|
||||
}
|
||||
}
|
||||
@@ -298,6 +272,8 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckConnected("Absolute Get");
|
||||
|
||||
Tl.LogMessage("Absolute Get", false.ToString());
|
||||
return false; // This is a relative focuser
|
||||
}
|
||||
@@ -310,6 +286,7 @@ namespace ASCOM.Meade.net
|
||||
CheckConnected("Halt");
|
||||
|
||||
//A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe.
|
||||
//todo make this mockable
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
while (stopwatch.ElapsedMilliseconds < 1000)
|
||||
{
|
||||
@@ -381,16 +358,7 @@ namespace ASCOM.Meade.net
|
||||
if (position == 0)
|
||||
return;
|
||||
|
||||
if (position > 0)
|
||||
{
|
||||
//desired move direction is out
|
||||
MoveFocuser(true, Math.Abs(position));
|
||||
}
|
||||
else
|
||||
{
|
||||
//desired move direction is in
|
||||
MoveFocuser(false, Math.Abs(position));
|
||||
}
|
||||
MoveFocuser(position > 0, Math.Abs(position));
|
||||
}
|
||||
|
||||
private void MoveFocuser(bool directionOut, int steps)
|
||||
@@ -410,6 +378,7 @@ namespace ASCOM.Meade.net
|
||||
_utilities.WaitForMilliseconds(100);
|
||||
|
||||
//A Single focus command sometimes gets lost on the #909, so sending lots of them solves the issue.
|
||||
//todo make this mockable
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
while (stopwatch.ElapsedMilliseconds < steps)
|
||||
{
|
||||
@@ -448,6 +417,7 @@ namespace ASCOM.Meade.net
|
||||
Tl.LogMessage("TempComp Get", false.ToString());
|
||||
return false;
|
||||
}
|
||||
// ReSharper disable once ValueParameterNotUsed
|
||||
set
|
||||
{
|
||||
Tl.LogMessage("TempComp Set", "Not implemented");
|
||||
@@ -566,18 +536,21 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new NotConnectedException(message);
|
||||
throw new NotConnectedException($"Not connected to focuser when trying to execute: {message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read the device configuration from the ASCOM Profile store
|
||||
/// </summary>
|
||||
internal void ReadProfile()
|
||||
private void ReadProfile()
|
||||
{
|
||||
var profileProperties = _sharedResourcesWrapper.ReadProfile();
|
||||
Tl.Enabled = profileProperties.TraceLogger;
|
||||
_comPort = profileProperties.ComPort;
|
||||
|
||||
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
|
||||
LogMessage("ReadProfile", $"Com Port: {_comPort}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -586,7 +559,7 @@ namespace ASCOM.Meade.net
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
internal static void LogMessage(string identifier, string message, params object[] args)
|
||||
private static void LogMessage(string identifier, string message, params object[] args)
|
||||
{
|
||||
var msg = string.Format(message, args);
|
||||
Tl.LogMessage(identifier, msg);
|
||||
|
||||
@@ -23,6 +23,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Meade.net.Setup", "Meade.ne
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Meade.net.Telescope.UnitTests", "Meade.net.Telescope.UnitTests\Meade.net.Telescope.UnitTests.csproj", "{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Meade.net.Focuser.UnitTests", "Meade.net.Focuser.UnitTests\Meade.net.Focuser.UnitTests.csproj", "{A3991FA7-23C3-405A-96F9-5AB03AC58F30}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -120,6 +122,18 @@ Global
|
||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33}.Release|x86.ActiveCfg = Release|x86
|
||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33}.Release|x86.Build.0 = Release|x86
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -129,6 +143,7 @@ Global
|
||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49} = {BF650D97-AF98-4638-9C55-21311C6D88DA}
|
||||
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
|
||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
|
||||
{A3991FA7-23C3-405A-96F9-5AB03AC58F30} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3C0509DC-C7F5-48DC-920D-DCFD9C879BD2}
|
||||
|
||||
@@ -112,7 +112,6 @@ namespace ASCOM.Meade.net
|
||||
private readonly Type _mClassType;
|
||||
private Guid _mClassId;
|
||||
private readonly ArrayList _mInterfaceTypes;
|
||||
private UInt32 _mLocked = 0;
|
||||
private uint _mCookie;
|
||||
private readonly string _mProgid;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public class ConnectionInfo
|
||||
{
|
||||
public int Connections { get; set; }
|
||||
public int SameDevice { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,12 @@ namespace ASCOM.Meade.net
|
||||
class GarbageCollection
|
||||
{
|
||||
private bool _mbContinueThread;
|
||||
private bool _mGcWatchStopped;
|
||||
private readonly int _miInterval;
|
||||
private readonly ManualResetEvent _mEventThreadEnded;
|
||||
|
||||
public GarbageCollection(int iInterval)
|
||||
{
|
||||
_mbContinueThread = true;
|
||||
_mGcWatchStopped = false;
|
||||
_miInterval = iInterval;
|
||||
_mEventThreadEnded = new ManualResetEvent(false);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ClassFactory.cs" />
|
||||
<Compile Include="ConnectionInfo.cs" />
|
||||
<Compile Include="frmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -133,6 +134,8 @@
|
||||
<Compile Include="LocalServer.cs" />
|
||||
<Compile Include="ProfileProperties.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TelescopeList.cs" />
|
||||
<Compile Include="Win32Utilities.cs" />
|
||||
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
|
||||
<EmbeddedResource Include="frmMain.resx">
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -5,5 +5,7 @@ namespace ASCOM.Meade.net
|
||||
// properies that are part of the profile
|
||||
public string ComPort { get; set; }
|
||||
public bool TraceLogger { get; set; }
|
||||
public double GuideRateArcSecondsPerSecond { get; set; }
|
||||
public string Precision { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
[ComVisible(false)] // Form not registered for COM!
|
||||
[ComVisible(false)] // Form not registered for COM!
|
||||
public partial class SetupDialogForm : Form
|
||||
{
|
||||
public SetupDialogForm()
|
||||
@@ -33,27 +35,40 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
MessageBox.Show(other.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetProfile(ProfileProperties profileProperties)
|
||||
{
|
||||
chkTrace.Checked = profileProperties.TraceLogger;
|
||||
// set the list of com ports to those that are currently available
|
||||
comboBoxComPort.Items.Clear();
|
||||
comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); // use System.IO because it's static
|
||||
comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort
|
||||
.GetPortNames()); // use System.IO because it's static
|
||||
// select the current port if possible
|
||||
if (comboBoxComPort.Items.Contains(profileProperties.ComPort))
|
||||
{
|
||||
comboBoxComPort.SelectedItem = profileProperties.ComPort;
|
||||
}
|
||||
|
||||
txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString();
|
||||
try
|
||||
{
|
||||
cboPrecision.SelectedItem = profileProperties.Precision;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
cboPrecision.SelectedItem = "Unchanged";
|
||||
}
|
||||
}
|
||||
|
||||
public ProfileProperties GetProfile()
|
||||
public ProfileProperties GetProfile()
|
||||
{
|
||||
var profileProperties = new ProfileProperties
|
||||
{
|
||||
TraceLogger = chkTrace.Checked,
|
||||
ComPort = comboBoxComPort.SelectedItem.ToString()
|
||||
ComPort = comboBoxComPort.SelectedItem.ToString(),
|
||||
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()),
|
||||
Precision = cboPrecision.SelectedItem.ToString()
|
||||
};
|
||||
|
||||
return profileProperties;
|
||||
@@ -61,7 +76,42 @@ namespace ASCOM.Meade.net
|
||||
|
||||
private void SetupDialogForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
Win32Utilities.BringWindowToFront(Handle);
|
||||
Activate();
|
||||
}
|
||||
|
||||
private bool _guideRateValid = true;
|
||||
|
||||
private void TextBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
|
||||
try
|
||||
{
|
||||
double newGuideRate = double.Parse(txtGuideRate.Text.Trim());
|
||||
|
||||
const double siderealArcSecondsPerSecond = 15.041;
|
||||
var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100);
|
||||
|
||||
lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)";
|
||||
_guideRateValid = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Surpressing this exception as if the value is not valid then it's not useful.
|
||||
_guideRateValid = false;
|
||||
}
|
||||
|
||||
UpdateOKButton();
|
||||
}
|
||||
|
||||
private void UpdateOKButton()
|
||||
{
|
||||
cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null);
|
||||
}
|
||||
|
||||
private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateOKButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+57
@@ -36,6 +36,12 @@ namespace ASCOM.Meade.net
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.chkTrace = new System.Windows.Forms.CheckBox();
|
||||
this.comboBoxComPort = new System.Windows.Forms.ComboBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtGuideRate = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.lblPercentOfSiderealRate = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.cboPrecision = new System.Windows.Forms.ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -85,11 +91,55 @@ namespace ASCOM.Meade.net
|
||||
this.comboBoxComPort.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.comboBoxComPort, "comboBoxComPort");
|
||||
this.comboBoxComPort.Name = "comboBoxComPort";
|
||||
this.comboBoxComPort.SelectedValueChanged += new System.EventHandler(this.ComboBoxComPort_SelectedValueChanged);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
resources.ApplyResources(this.label3, "label3");
|
||||
this.label3.Name = "label3";
|
||||
//
|
||||
// txtGuideRate
|
||||
//
|
||||
resources.ApplyResources(this.txtGuideRate, "txtGuideRate");
|
||||
this.txtGuideRate.Name = "txtGuideRate";
|
||||
this.txtGuideRate.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
resources.ApplyResources(this.label4, "label4");
|
||||
this.label4.Name = "label4";
|
||||
//
|
||||
// lblPercentOfSiderealRate
|
||||
//
|
||||
resources.ApplyResources(this.lblPercentOfSiderealRate, "lblPercentOfSiderealRate");
|
||||
this.lblPercentOfSiderealRate.Name = "lblPercentOfSiderealRate";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
resources.ApplyResources(this.label5, "label5");
|
||||
this.label5.Name = "label5";
|
||||
//
|
||||
// cboPrecision
|
||||
//
|
||||
this.cboPrecision.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboPrecision.FormattingEnabled = true;
|
||||
this.cboPrecision.Items.AddRange(new object[] {
|
||||
resources.GetString("cboPrecision.Items"),
|
||||
resources.GetString("cboPrecision.Items1"),
|
||||
resources.GetString("cboPrecision.Items2")});
|
||||
resources.ApplyResources(this.cboPrecision, "cboPrecision");
|
||||
this.cboPrecision.Name = "cboPrecision";
|
||||
//
|
||||
// SetupDialogForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.cboPrecision);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.lblPercentOfSiderealRate);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.txtGuideRate);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.comboBoxComPort);
|
||||
this.Controls.Add(this.chkTrace);
|
||||
this.Controls.Add(this.label2);
|
||||
@@ -102,6 +152,7 @@ namespace ASCOM.Meade.net
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SetupDialogForm";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.TopMost = true;
|
||||
this.Shown += new System.EventHandler(this.SetupDialogForm_Shown);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
@@ -118,5 +169,11 @@ namespace ASCOM.Meade.net
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.CheckBox chkTrace;
|
||||
private System.Windows.Forms.ComboBox comboBoxComPort;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtGuideRate;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label lblPercentOfSiderealRate;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.ComboBox cboPrecision;
|
||||
}
|
||||
}
|
||||
+172
-10
@@ -123,7 +123,7 @@
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="cmdOK.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>281, 112</value>
|
||||
<value>281, 225</value>
|
||||
</data>
|
||||
<data name="cmdOK.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>59, 24</value>
|
||||
@@ -145,13 +145,13 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cmdOK.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="cmdCancel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>281, 142</value>
|
||||
<value>281, 255</value>
|
||||
</data>
|
||||
<data name="cmdCancel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>59, 25</value>
|
||||
@@ -172,7 +172,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cmdCancel.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 9</value>
|
||||
@@ -196,7 +196,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Right</value>
|
||||
@@ -223,7 +223,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>picASCOM.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
@@ -250,13 +250,13 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label2.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="chkTrace.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>77, 118</value>
|
||||
<value>77, 136</value>
|
||||
</data>
|
||||
<data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>69, 17</value>
|
||||
@@ -277,7 +277,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>chkTrace.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>77, 87</value>
|
||||
@@ -298,6 +298,168 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>comboBoxComPort.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>10, 162</value>
|
||||
</data>
|
||||
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>61, 13</value>
|
||||
</data>
|
||||
<data name="label3.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="label3.Text" xml:space="preserve">
|
||||
<value>Guide Rate</value>
|
||||
</data>
|
||||
<data name=">>label3.Name" xml:space="preserve">
|
||||
<value>label3</value>
|
||||
</data>
|
||||
<data name=">>label3.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label3.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label3.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>77, 159</value>
|
||||
</data>
|
||||
<data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>46, 20</value>
|
||||
</data>
|
||||
<data name="txtGuideRate.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="txtGuideRate.Text" xml:space="preserve">
|
||||
<value>10.0</value>
|
||||
</data>
|
||||
<data name=">>txtGuideRate.Name" xml:space="preserve">
|
||||
<value>txtGuideRate</value>
|
||||
</data>
|
||||
<data name=">>txtGuideRate.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>txtGuideRate.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>txtGuideRate.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="label4.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label4.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>129, 162</value>
|
||||
</data>
|
||||
<data name="label4.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>122, 13</value>
|
||||
</data>
|
||||
<data name="label4.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="label4.Text" xml:space="preserve">
|
||||
<value>Arc seconds per second</value>
|
||||
</data>
|
||||
<data name=">>label4.Name" xml:space="preserve">
|
||||
<value>label4</value>
|
||||
</data>
|
||||
<data name=">>label4.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label4.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label4.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="lblPercentOfSiderealRate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>129, 175</value>
|
||||
</data>
|
||||
<data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 13</value>
|
||||
</data>
|
||||
<data name="lblPercentOfSiderealRate.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="lblPercentOfSiderealRate.Text" xml:space="preserve">
|
||||
<value>(67% of sidereal rate)</value>
|
||||
</data>
|
||||
<data name=">>lblPercentOfSiderealRate.Name" xml:space="preserve">
|
||||
<value>lblPercentOfSiderealRate</value>
|
||||
</data>
|
||||
<data name=">>lblPercentOfSiderealRate.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>lblPercentOfSiderealRate.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblPercentOfSiderealRate.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="label5.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label5.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>13, 194</value>
|
||||
</data>
|
||||
<data name="label5.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>50, 13</value>
|
||||
</data>
|
||||
<data name="label5.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="label5.Text" xml:space="preserve">
|
||||
<value>Precision</value>
|
||||
</data>
|
||||
<data name=">>label5.Name" xml:space="preserve">
|
||||
<value>label5</value>
|
||||
</data>
|
||||
<data name=">>label5.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label5.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>label5.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="cboPrecision.Items" xml:space="preserve">
|
||||
<value>Unchanged</value>
|
||||
</data>
|
||||
<data name="cboPrecision.Items1" xml:space="preserve">
|
||||
<value>Low</value>
|
||||
</data>
|
||||
<data name="cboPrecision.Items2" xml:space="preserve">
|
||||
<value>High</value>
|
||||
</data>
|
||||
<data name="cboPrecision.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>77, 191</value>
|
||||
</data>
|
||||
<data name="cboPrecision.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>90, 21</value>
|
||||
</data>
|
||||
<data name="cboPrecision.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>13</value>
|
||||
</data>
|
||||
<data name=">>cboPrecision.Name" xml:space="preserve">
|
||||
<value>cboPrecision</value>
|
||||
</data>
|
||||
<data name=">>cboPrecision.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>cboPrecision.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cboPrecision.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
@@ -307,7 +469,7 @@
|
||||
<value>6, 13</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>350, 175</value>
|
||||
<value>350, 288</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterScreen</value>
|
||||
|
||||
@@ -116,6 +116,14 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadCharacters(int throwAwayCharacters)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
return SharedSerial.ReceiveCounted(throwAwayCharacters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Example of handling connecting to and disconnection from the
|
||||
/// shared serial port.
|
||||
@@ -158,6 +166,8 @@ namespace ASCOM.Meade.net
|
||||
// Constants used for Profile persistence
|
||||
private const string ComPortProfileName = "COM Port";
|
||||
private const string TraceStateProfileName = "Trace Level";
|
||||
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
|
||||
private const string PrecisionProfileName = "Precision";
|
||||
|
||||
public static void WriteProfile(ProfileProperties profileProperties)
|
||||
{
|
||||
@@ -168,12 +178,16 @@ namespace ASCOM.Meade.net
|
||||
driverProfile.DeviceType = "Telescope";
|
||||
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
||||
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
||||
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString());
|
||||
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const string ComPortDefault = "COM1";
|
||||
private const string TraceStateDefault = "false";
|
||||
private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
|
||||
private const string PrecisionDefault = "Unchanged";
|
||||
|
||||
public static ProfileProperties ReadProfile()
|
||||
{
|
||||
@@ -183,10 +197,10 @@ namespace ASCOM.Meade.net
|
||||
using (Profile driverProfile = new Profile())
|
||||
{
|
||||
driverProfile.DeviceType = "Telescope";
|
||||
profileProperties.ComPort =
|
||||
driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
|
||||
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId,
|
||||
TraceStateProfileName, string.Empty, TraceStateDefault));
|
||||
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
|
||||
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
|
||||
profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault));
|
||||
profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
|
||||
}
|
||||
|
||||
return profileProperties;
|
||||
@@ -246,12 +260,15 @@ namespace ASCOM.Meade.net
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, DeviceHardware> _connectedDevices = new Dictionary<string, DeviceHardware>();
|
||||
|
||||
private static readonly Dictionary<string, DeviceHardware> _connectedDeviceIds = new Dictionary<string, DeviceHardware>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is called in the driver Connect(true) property,
|
||||
/// it add the device id to the list of devices if it's not there and increments the device count.
|
||||
/// </summary>
|
||||
/// <param name="deviceId"></param>
|
||||
public static void Connect(string deviceId)
|
||||
public static ConnectionInfo Connect(string deviceId, string driverId)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
@@ -259,6 +276,10 @@ namespace ASCOM.Meade.net
|
||||
_connectedDevices.Add(deviceId, new DeviceHardware());
|
||||
_connectedDevices[deviceId].Count++; // increment the value
|
||||
|
||||
if (!_connectedDeviceIds.ContainsKey(driverId))
|
||||
_connectedDeviceIds.Add(driverId, new DeviceHardware());
|
||||
_connectedDeviceIds[driverId].Count++; // increment the value
|
||||
|
||||
if (deviceId == "Serial")
|
||||
{
|
||||
if (_connectedDevices[deviceId].Count == 1)
|
||||
@@ -278,10 +299,16 @@ namespace ASCOM.Meade.net
|
||||
FirmwareVersion = SendString(":GVN#");
|
||||
}
|
||||
}
|
||||
|
||||
return new ConnectionInfo
|
||||
{
|
||||
Connections = _connectedDevices[deviceId].Count,
|
||||
SameDevice = _connectedDeviceIds[driverId].Count
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static void Disconnect(string deviceId)
|
||||
public static void Disconnect(string deviceId, string driverId)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
@@ -297,6 +324,11 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_connectedDeviceIds.ContainsKey(driverId))
|
||||
{
|
||||
_connectedDeviceIds[driverId].Count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
public static class TelescopeList
|
||||
{
|
||||
#region Autostar 497/Audiostar
|
||||
|
||||
public readonly static string Autostar497 = "Autostar";
|
||||
|
||||
//Autostar/Audiostar firmware revisions
|
||||
public readonly static string Autostar497_30Ee = "30Ee";
|
||||
public readonly static string Autostar497_31Ee = "31Ee";
|
||||
public readonly static string Autostar497_43Eg = "43Eg";
|
||||
|
||||
#endregion
|
||||
|
||||
#region LX200GPS
|
||||
|
||||
public readonly static string LX200GPS = "LX2001";
|
||||
|
||||
public readonly static string LX200GPS_42G = "4.2G";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
internal static class Win32Utilities
|
||||
{
|
||||
//Win32 API calls necesary to raise an unowned processs main window
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
|
||||
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool IsIconic(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr lpdwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool BringWindowToTop(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, Int32 nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowThreadProcessId(IntPtr hWnd, ref Int32 lpdwProcessId);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern IntPtr GetParent(IntPtr hWnd);
|
||||
|
||||
private const int SW_HIDE = 0;
|
||||
private const int SW_SHOWNORMAL = 1;
|
||||
private const int SW_NORMAL = 1;
|
||||
private const int SW_SHOWMINIMIZED = 2;
|
||||
private const int SW_SHOWMAXIMIZED = 3;
|
||||
private const int SW_MAXIMIZE = 3;
|
||||
private const int SW_SHOWNOACTIVATE = 4;
|
||||
private const int SW_SHOW = 5;
|
||||
private const int SW_MINIMIZE = 6;
|
||||
private const int SW_SHOWMINNOACTIVE = 7;
|
||||
private const int SW_SHOWNA = 8;
|
||||
private const int SW_RESTORE = 9;
|
||||
private const int SW_SHOWDEFAULT = 10;
|
||||
private const int SW_MAX = 10;
|
||||
|
||||
private const uint SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000;
|
||||
private const uint SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001;
|
||||
|
||||
private const int SPIF_SENDCHANGE = 0x2;
|
||||
|
||||
|
||||
public static void BringWindowToFront(IntPtr hWnd)
|
||||
{
|
||||
if (IsIconic(hWnd))
|
||||
ShowWindowAsync(hWnd, SW_RESTORE);
|
||||
|
||||
ShowWindowAsync(hWnd, SW_SHOW);
|
||||
|
||||
SetForegroundWindow(hWnd);
|
||||
|
||||
// Code from Karl E. Peterson, www.mvps.org/vb/sample.htm
|
||||
// Converted to Delphi by Ray Lischner
|
||||
// Published in The Delphi Magazine 55, page 16
|
||||
// Converted to C# by Kevin Gale
|
||||
IntPtr foregroundWindow = GetForegroundWindow();
|
||||
IntPtr Dummy = IntPtr.Zero;
|
||||
|
||||
uint foregroundThreadId = GetWindowThreadProcessId(foregroundWindow, Dummy);
|
||||
|
||||
uint thisThreadId = GetWindowThreadProcessId(hWnd, Dummy);
|
||||
|
||||
if (AttachThreadInput(thisThreadId, foregroundThreadId, true))
|
||||
{
|
||||
BringWindowToTop(hWnd); // IE 5.5 related hack
|
||||
SetForegroundWindow(hWnd);
|
||||
AttachThreadInput(thisThreadId, foregroundThreadId, false);
|
||||
}
|
||||
|
||||
if (GetForegroundWindow() != hWnd)
|
||||
{
|
||||
// Code by Daniel P. Stasinski
|
||||
// Converted to C# by Kevin Gale
|
||||
IntPtr Timeout = IntPtr.Zero;
|
||||
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Timeout, 0);
|
||||
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Dummy, SPIF_SENDCHANGE);
|
||||
BringWindowToTop(hWnd); // IE 5.5 related hack
|
||||
SetForegroundWindow(hWnd);
|
||||
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Timeout, SPIF_SENDCHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,8 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
{
|
||||
public interface ISharedResourcesWrapper
|
||||
{
|
||||
string Autostar497 { get; }
|
||||
string Autostar49731Ee { get; }
|
||||
|
||||
string Autostar49743Eg { get;}
|
||||
|
||||
void Connect(string deviceId);
|
||||
void Disconnect(string deviceId);
|
||||
ConnectionInfo Connect(string deviceId, string driverId);
|
||||
void Disconnect(string deviceId, string driverId);
|
||||
|
||||
string ProductName { get; }
|
||||
|
||||
@@ -28,27 +23,20 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
ProfileProperties ReadProfile();
|
||||
|
||||
void SetupDialog();
|
||||
void WriteProfile(ProfileProperties profileProperties);
|
||||
string ReadCharacters(int throwAwayCharacters);
|
||||
}
|
||||
|
||||
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
||||
{
|
||||
#region AutostarProducts
|
||||
|
||||
public string Autostar497 => "Autostar";
|
||||
|
||||
public string Autostar49731Ee => "31Ee";
|
||||
public string Autostar49743Eg => "43Eg";
|
||||
|
||||
#endregion
|
||||
|
||||
public void Connect(string deviceId)
|
||||
public ConnectionInfo Connect(string deviceId, string driverId)
|
||||
{
|
||||
SharedResources.Connect( deviceId);
|
||||
return SharedResources.Connect(deviceId, driverId);
|
||||
}
|
||||
|
||||
public void Disconnect(string deviceId)
|
||||
public void Disconnect(string deviceId, string driverId)
|
||||
{
|
||||
SharedResources.Disconnect(deviceId);
|
||||
SharedResources.Disconnect(deviceId, driverId);
|
||||
}
|
||||
|
||||
public string ProductName => SharedResources.ProductName;
|
||||
@@ -85,6 +73,11 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
return SharedResources.ReadTerminated();
|
||||
}
|
||||
|
||||
public string ReadCharacters(int throwAwayCharacters)
|
||||
{
|
||||
return SharedResources.ReadCharacters(throwAwayCharacters);
|
||||
}
|
||||
|
||||
public ProfileProperties ReadProfile()
|
||||
{
|
||||
return SharedResources.ReadProfile();
|
||||
@@ -94,5 +87,10 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
{
|
||||
SharedResources.SetupDialog();
|
||||
}
|
||||
|
||||
public void WriteProfile(ProfileProperties profileProperties)
|
||||
{
|
||||
SharedResources.WriteProfile(profileProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
|
||||
Reference in New Issue
Block a user