Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0594355072 | |||
| aec6cc19ab | |||
| 58b0e1395c | |||
| 274ecbab6b | |||
| 544cdd826b | |||
| fc68a788ac | |||
| 9c689f1179 | |||
| 6e7ff70862 | |||
| 0a0072ce43 | |||
| 0e31149e31 | |||
| d332243772 | |||
| d9aa68f1e9 | |||
| 2cc27788c8 | |||
| 5a0b3bba25 | |||
| 7a80ad4662 | |||
| 3eddc52c6a | |||
| 64a72560bc | |||
| 0a6ba16c61 | |||
| b932bd8eb6 | |||
| 5aec81b45f | |||
| d68d51bd9c | |||
| badc519f37 | |||
| 77ca457646 | |||
| 7ed79d6954 | |||
| 43e630283c | |||
| 09df67c67f | |||
| 9a30e02a4b | |||
| 036fd48bcf | |||
| 5476331073 | |||
| c6cab848f9 | |||
| efa78ec8a0 | |||
| c311fb8cbe |
@@ -39,7 +39,7 @@
|
|||||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -68,8 +68,8 @@
|
|||||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<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>
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<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.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
@@ -89,6 +89,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<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="Moq" version="4.12.0" targetFramework="net472" />
|
||||||
<package id="NUnit" version="3.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.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>
|
</packages>
|
||||||
@@ -36,6 +36,25 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||||
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||||
|
|||||||
@@ -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>AnyCPU</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>
|
||||||
@@ -18,41 +18,6 @@
|
|||||||
Vital="yes"
|
Vital="yes"
|
||||||
Assembly=".net"
|
Assembly=".net"
|
||||||
AssemblyApplication="filFocuserDriverAssembly" />
|
AssemblyApplication="filFocuserDriverAssembly" />
|
||||||
<!-- Registry entries suitable for a LocalServer served class -->
|
|
||||||
<!-- HKCR\CLSID\{driver-guid} -->
|
|
||||||
<RegistryKey Root="HKCR" Key="CLSID">
|
|
||||||
<RegistryKey Key="$(var.FocuserDriverClassId)">
|
|
||||||
<RegistryValue Value="$(var.FocuserDriverProgId)" Type="string"/>
|
|
||||||
<RegistryValue Name="AppId" Value="$(var.LocalServerAppId)" Type="string"/>
|
|
||||||
<RegistryKey Key="Implemented Categories">
|
|
||||||
<RegistryKey Key="{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}"
|
|
||||||
ForceCreateOnInstall="yes"
|
|
||||||
ForceDeleteOnUninstall="yes"/>
|
|
||||||
</RegistryKey>
|
|
||||||
<RegistryKey Key="ProgId">
|
|
||||||
<RegistryValue Value="$(var.FocuserDriverProgId)" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
<RegistryKey Key="Programmable"
|
|
||||||
ForceCreateOnInstall="yes"
|
|
||||||
ForceDeleteOnUninstall="yes" />
|
|
||||||
<RegistryKey Key="LocalServer32">
|
|
||||||
<RegistryValue Value="[#filLocalServerAssembly]" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
|
|
||||||
<!-- HKCR\{driver-prog-id} -->
|
|
||||||
<RegistryKey Root="HKCR" Key="$(var.FocuserDriverProgId)">
|
|
||||||
<RegistryValue Value="$(var.FocuserDriverDescription)" Type="string"/>
|
|
||||||
<RegistryKey Key="CLSID">
|
|
||||||
<RegistryValue Value="$(var.FocuserDriverClassId)" Type="string" />
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
|
|
||||||
<!--Register the driver with the ASCOM Profile-->
|
|
||||||
<RegistryKey Root="HKLM" Key="SOFTWARE\ASCOM\Focuser Drivers\$(var.FocuserDriverProgId)">
|
|
||||||
<RegistryValue Value="$(var.FocuserDriverDescription)" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
</Component>
|
</Component>
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
@@ -12,21 +12,31 @@
|
|||||||
Assembly=".net"
|
Assembly=".net"
|
||||||
AssemblyApplication="filLocalServerAssembly" />
|
AssemblyApplication="filLocalServerAssembly" />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="cmpLocalServerRegistry" Win64="no">
|
|
||||||
<!-- LocalServer32 COM Registration -->
|
|
||||||
<RegistryKey Root="HKCR" Key="AppID" >
|
|
||||||
<!-- HKCR\AppID\{my-app-id} -->
|
|
||||||
<RegistryKey Key="$(var.LocalServerAppId)">
|
|
||||||
<RegistryValue Value="$(var.InstallName)" Type="string"/>
|
|
||||||
<RegistryValue Name="AppID" Value="$(var.LocalServerAppId)" Type="string"/>
|
|
||||||
<RegistryValue Name="AuthenticationLevel" Value="1" Type="integer"/>
|
|
||||||
</RegistryKey>
|
|
||||||
<!-- HKCR\AppID\{exe-name} -->
|
|
||||||
<RegistryKey Key="$(var.Meade.net.TargetFileName)">
|
|
||||||
<RegistryValue Name="AppID" Value="$(var.LocalServerAppId)" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
</Component>
|
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
|
|
||||||
|
<CustomAction Id="RegisterEXE"
|
||||||
|
Directory="INSTALLFOLDER"
|
||||||
|
ExeCommand=""[#filLocalServerAssembly]" /register"
|
||||||
|
Execute="deferred"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="no"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="UnRegisterEXE"
|
||||||
|
Directory="INSTALLFOLDER"
|
||||||
|
ExeCommand=""[#filLocalServerAssembly]" /unregister"
|
||||||
|
Execute="deferred"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="no"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<InstallExecuteSequence>
|
||||||
|
<Custom Action='RegisterEXE' Before="InstallFinalize">
|
||||||
|
<![CDATA[(NOT Installed)]]>
|
||||||
|
</Custom>
|
||||||
|
<Custom Action="UnRegisterEXE" After="InstallInitialize">
|
||||||
|
<![CDATA[(REMOVE ~= "ALL" AND NOT UPGRADINGPRODUCTCODE)]]>
|
||||||
|
</Custom>
|
||||||
|
</InstallExecuteSequence>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</Wix>
|
</Wix>
|
||||||
@@ -18,41 +18,6 @@
|
|||||||
Vital="yes"
|
Vital="yes"
|
||||||
Assembly=".net"
|
Assembly=".net"
|
||||||
AssemblyApplication="filTelescopeDriverAssembly" />
|
AssemblyApplication="filTelescopeDriverAssembly" />
|
||||||
<!-- Registry entries suitable for a LocalServer served class -->
|
|
||||||
<!-- HKCR\CLSID\{driver-guid} -->
|
|
||||||
<RegistryKey Root="HKCR" Key="CLSID">
|
|
||||||
<RegistryKey Key="$(var.TelescopeDriverClassId)">
|
|
||||||
<RegistryValue Value="$(var.TelescopeDriverProgId)" Type="string"/>
|
|
||||||
<RegistryValue Name="AppId" Value="$(var.LocalServerAppId)" Type="string"/>
|
|
||||||
<RegistryKey Key="Implemented Categories">
|
|
||||||
<RegistryKey Key="{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}"
|
|
||||||
ForceCreateOnInstall="yes"
|
|
||||||
ForceDeleteOnUninstall="yes"/>
|
|
||||||
</RegistryKey>
|
|
||||||
<RegistryKey Key="ProgId">
|
|
||||||
<RegistryValue Value="$(var.TelescopeDriverProgId)" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
<RegistryKey Key="Programmable"
|
|
||||||
ForceCreateOnInstall="yes"
|
|
||||||
ForceDeleteOnUninstall="yes" />
|
|
||||||
<RegistryKey Key="LocalServer32">
|
|
||||||
<RegistryValue Value="[#filLocalServerAssembly]" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
|
|
||||||
<!-- HKCR\{driver-prog-id} -->
|
|
||||||
<RegistryKey Root="HKCR" Key="$(var.TelescopeDriverProgId)">
|
|
||||||
<RegistryValue Value="$(var.TelescopeDriverDescription)" Type="string"/>
|
|
||||||
<RegistryKey Key="CLSID">
|
|
||||||
<RegistryValue Value="$(var.TelescopeDriverClassId)" Type="string" />
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
|
|
||||||
<!--Register the driver with the ASCOM Profile-->
|
|
||||||
<RegistryKey Root="HKLM" Key="SOFTWARE\ASCOM\Telescope Drivers\$(var.TelescopeDriverProgId)">
|
|
||||||
<RegistryValue Value="$(var.TelescopeDriverDescription)" Type="string"/>
|
|
||||||
</RegistryKey>
|
|
||||||
</Component>
|
</Component>
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
Binary file not shown.
@@ -48,6 +48,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Config.wxi" />
|
<Content Include="Config.wxi" />
|
||||||
|
<Content Include="License.rtf" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Meade.net.focuser\Meade.net.focuser.csproj">
|
<ProjectReference Include="..\Meade.net.focuser\Meade.net.focuser.csproj">
|
||||||
|
|||||||
@@ -30,11 +30,6 @@
|
|||||||
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
|
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
|
||||||
</Condition>
|
</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" ?>
|
<?if $(var.Win64) = "yes" ?>
|
||||||
VersionNT64
|
VersionNT64
|
||||||
@@ -46,6 +41,7 @@
|
|||||||
|
|
||||||
<UIRef Id="InstallationUI"/>
|
<UIRef Id="InstallationUI"/>
|
||||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
||||||
|
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
|
||||||
|
|
||||||
<FeatureGroupRef Id="fgRoot"/>
|
<FeatureGroupRef Id="fgRoot"/>
|
||||||
</Product>
|
</Product>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
@@ -104,8 +104,8 @@
|
|||||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<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>
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<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.2\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
private Mock<IAstroMaths> _astroMathsMock;
|
private Mock<IAstroMaths> _astroMathsMock;
|
||||||
|
|
||||||
private ProfileProperties _profileProperties;
|
private ProfileProperties _profileProperties;
|
||||||
|
private ConnectionInfo _connectionInfo;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
@@ -40,11 +41,15 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS");
|
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS");
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties);
|
_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<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<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());
|
_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);
|
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(_profileProperties);
|
||||||
|
|
||||||
@@ -341,7 +346,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Connected_Set_WhenConnecting_Then()
|
public void Connected_Set_WhenConnecting_Then_ConnectsToSerialDevice()
|
||||||
{
|
{
|
||||||
var productName = "LX2001";
|
var productName = "LX2001";
|
||||||
var firmware = string.Empty;
|
var firmware = string.Empty;
|
||||||
@@ -350,7 +355,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
|
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
|
||||||
_telescope.Connected = true;
|
_telescope.Connected = true;
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Verify( x => x.Connect("Serial"), Times.Once);
|
_sharedResourcesWrapperMock.Verify( x => x.Connect("Serial", It.IsAny<string>()), Times.Once);
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once);
|
||||||
|
|
||||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
|
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"),Times.Once);
|
||||||
@@ -361,26 +366,26 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
|
public void Connected_Set_SettingTrueWhenTrue_ThenDoesNothing()
|
||||||
{
|
{
|
||||||
ConnectTelescope();
|
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
|
//act
|
||||||
_telescope.Connected = true;
|
_telescope.Connected = true;
|
||||||
|
|
||||||
//assert
|
//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]
|
[Test]
|
||||||
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
|
public void Connected_Set_SettingFalseWhenTrue_ThenDisconnects()
|
||||||
{
|
{
|
||||||
ConnectTelescope();
|
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
|
//act
|
||||||
_telescope.Connected = false;
|
_telescope.Connected = false;
|
||||||
|
|
||||||
//assert
|
//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]
|
[Test]
|
||||||
@@ -395,7 +400,7 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_telescope.Connected = true;
|
_telescope.Connected = true;
|
||||||
|
|
||||||
//assert
|
//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", "30Ab", false)]
|
||||||
@@ -771,6 +776,22 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.AtLeastOnce);
|
_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]
|
[Test]
|
||||||
public void CanSetPark_Get_ReturnsFalse()
|
public void CanSetPark_Get_ReturnsFalse()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
<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"/>
|
<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>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</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="Moq" version="4.12.0" targetFramework="net45" />
|
||||||
<package id="NUnit" version="3.12.0" targetFramework="net40" requireReinstallation="true" />
|
<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.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>
|
</packages>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<RegisterForComInterop>true</RegisterForComInterop>
|
<RegisterForComInterop>true</RegisterForComInterop>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<OutputPath>..\bin\Debug\</OutputPath>
|
<OutputPath>..\bin\Debug\</OutputPath>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Guid("d9fd4b3e-c4f1-48ac-a16f-d02eef30d86f")]
|
[Guid("d9fd4b3e-c4f1-48ac-a16f-d02eef30d86f")]
|
||||||
[ProgId("ASCOM.MeadeGeneric.Telescope")]
|
[ProgId("ASCOM.MeadeGeneric.Telescope")]
|
||||||
[ServedClassName("Meade.net Telescope")]
|
[ServedClassName("Meade Generic")]
|
||||||
[ClassInterface(ClassInterfaceType.None)]
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
public class Telescope : ReferenceCountedObjectBase, ITelescopeV3
|
public class Telescope : ReferenceCountedObjectBase, ITelescopeV3
|
||||||
{
|
{
|
||||||
@@ -277,7 +277,6 @@ namespace ASCOM.Meade.net
|
|||||||
$"Site {actionParameters} not allowed, must be between 1 and 4");
|
$"Site {actionParameters} not allowed, must be between 1 and 4");
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "setname":
|
case "setname":
|
||||||
switch (parames[1])
|
switch (parames[1])
|
||||||
{
|
{
|
||||||
@@ -374,12 +373,11 @@ namespace ASCOM.Meade.net
|
|||||||
ReadProfile();
|
ReadProfile();
|
||||||
|
|
||||||
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
|
LogMessage("Connected Set", "Connecting to port {0}", _comPort);
|
||||||
_sharedResourcesWrapper.Connect("Serial");
|
var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}");
|
LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}");
|
||||||
|
|
||||||
SetLongFormat(true);
|
|
||||||
_userNewerPulseGuiding = IsNewPulseGuidingSupported();
|
_userNewerPulseGuiding = IsNewPulseGuidingSupported();
|
||||||
_targetDeclination = InvalidParameter;
|
_targetDeclination = InvalidParameter;
|
||||||
_targetRightAscension = InvalidParameter;
|
_targetRightAscension = InvalidParameter;
|
||||||
@@ -388,16 +386,27 @@ namespace ASCOM.Meade.net
|
|||||||
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
|
LogMessage("Connected Set", $"New Pulse Guiding Supported: {_userNewerPulseGuiding}");
|
||||||
IsConnected = true;
|
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)
|
if (CanSetGuideRates)
|
||||||
{
|
{
|
||||||
SetNewGuideRate( _guideRate, "Connect" );
|
SetNewGuideRate(_guideRate, "Connect");
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTelescopePrecision("Connect");
|
SetTelescopePrecision("Connect");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogMessage("Connected Set", $"Skipping first connection telescope adjustments (current connections: {connectionInfo.SameDevice})");
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
_sharedResourcesWrapper.Disconnect("Serial");
|
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -409,7 +418,7 @@ namespace ASCOM.Meade.net
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
|
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
|
||||||
_sharedResourcesWrapper.Disconnect("Serial");
|
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||||
IsConnected = false;
|
IsConnected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -516,7 +525,7 @@ namespace ASCOM.Meade.net
|
|||||||
return highPrecision;
|
return highPrecision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TelescopePointingPrecision(bool high)
|
private void TelescopePointingPrecision(bool high)
|
||||||
{
|
{
|
||||||
var currentPrecision = TogglePrecision();
|
var currentPrecision = TogglePrecision();
|
||||||
|
|
||||||
@@ -2304,7 +2313,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read the device configuration from the ASCOM Profile store
|
/// Read the device configuration from the ASCOM Profile store
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void ReadProfile()
|
private void ReadProfile()
|
||||||
{
|
{
|
||||||
ProfileProperties profileProperties = _sharedResourcesWrapper.ReadProfile();
|
ProfileProperties profileProperties = _sharedResourcesWrapper.ReadProfile();
|
||||||
_tl.Enabled = profileProperties.TraceLogger;
|
_tl.Enabled = profileProperties.TraceLogger;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Diagnostics;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using ASCOM.Utilities;
|
using ASCOM.Utilities;
|
||||||
using ASCOM.DeviceInterface;
|
using ASCOM.DeviceInterface;
|
||||||
using System.Globalization;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using ASCOM.Meade.net.Wrapper;
|
using ASCOM.Meade.net.Wrapper;
|
||||||
@@ -29,7 +28,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Guid("a32ac647-bf0f-42f9-8ab0-d166fa5884ad")]
|
[Guid("a32ac647-bf0f-42f9-8ab0-d166fa5884ad")]
|
||||||
[ProgId("ASCOM.MeadeGeneric.focuser")]
|
[ProgId("ASCOM.MeadeGeneric.focuser")]
|
||||||
[ServedClassName("Meade.net Focuser")]
|
[ServedClassName("Meade Generic")]
|
||||||
[ClassInterface(ClassInterfaceType.None)]
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
public class Focuser : ReferenceCountedObjectBase, IFocuserV3
|
public class Focuser : ReferenceCountedObjectBase, IFocuserV3
|
||||||
{
|
{
|
||||||
@@ -38,7 +37,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// The DeviceID is used by ASCOM applications to load the driver at runtime.
|
/// The DeviceID is used by ASCOM applications to load the driver at runtime.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//internal static string driverID = "ASCOM.Meade.net.Focuser";
|
//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
|
// TODO Change the descriptive string for your driver then remove this line
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Driver description that displays in the ASCOM Chooser.
|
/// Driver description that displays in the ASCOM Chooser.
|
||||||
@@ -55,7 +54,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
|
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static TraceLogger Tl;
|
private static TraceLogger Tl;
|
||||||
|
|
||||||
private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
|
private readonly ISharedResourcesWrapper _sharedResourcesWrapper;
|
||||||
|
|
||||||
@@ -66,12 +65,21 @@ namespace ASCOM.Meade.net
|
|||||||
public Focuser()
|
public Focuser()
|
||||||
{
|
{
|
||||||
//todo move this out to IOC
|
//todo move this out to IOC
|
||||||
_utilities = new Util(); //Initialise util object
|
var util = new Util(); //Initialise util object
|
||||||
|
_utilities = util;
|
||||||
_sharedResourcesWrapper = new SharedResourcesWrapper();
|
_sharedResourcesWrapper = new SharedResourcesWrapper();
|
||||||
|
|
||||||
Initialise();
|
Initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper)
|
||||||
|
{
|
||||||
|
_utilities = util;
|
||||||
|
_sharedResourcesWrapper = sharedResourcesWrapper;
|
||||||
|
|
||||||
|
Initialise();
|
||||||
|
}
|
||||||
|
|
||||||
private void Initialise()
|
private void Initialise()
|
||||||
{
|
{
|
||||||
//todo move the TraceLogger out to a factory class.
|
//todo move the TraceLogger out to a factory class.
|
||||||
@@ -118,7 +126,7 @@ namespace ASCOM.Meade.net
|
|||||||
public string Action(string actionName, string actionParameters)
|
public string Action(string actionName, string actionParameters)
|
||||||
{
|
{
|
||||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, 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)
|
public void CommandBlind(string command, bool raw)
|
||||||
@@ -149,8 +157,7 @@ namespace ASCOM.Meade.net
|
|||||||
// then all communication calls this function
|
// then all communication calls this function
|
||||||
// you need something to ensure that only one command is in progress at a time
|
// you need something to ensure that only one command is in progress at a time
|
||||||
return _sharedResourcesWrapper.SendString(command);
|
return _sharedResourcesWrapper.SendString(command);
|
||||||
|
//throw new ASCOM.MethodNotImplementedException("CommandString");
|
||||||
throw new MethodNotImplementedException("CommandString");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
@@ -179,17 +186,14 @@ namespace ASCOM.Meade.net
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ReadProfile();
|
ReadProfile();
|
||||||
_sharedResourcesWrapper.Connect("Serial");
|
_sharedResourcesWrapper.Connect("Serial", DriverId);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SelectSite(1);
|
|
||||||
SetLongFormat(true);
|
|
||||||
|
|
||||||
IsConnected = true;
|
IsConnected = true;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
_sharedResourcesWrapper.Disconnect("Serial");
|
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,43 +205,12 @@ namespace ASCOM.Meade.net
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
|
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort);
|
||||||
_sharedResourcesWrapper.Disconnect("Serial");
|
_sharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||||
IsConnected = false;
|
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
|
public string Description
|
||||||
{
|
{
|
||||||
// TODO customise this device description
|
// TODO customise this device description
|
||||||
@@ -252,10 +225,9 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
|
||||||
// TODO customise this driver description
|
// TODO customise this driver description
|
||||||
string driverInfo = "Information about the driver itself. Version: " + String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
|
string driverInfo = $"{Description} .net driver. Version: {DriverVersion}";
|
||||||
Tl.LogMessage("DriverInfo Get", driverInfo);
|
LogMessage("DriverInfo Get", driverInfo);
|
||||||
return driverInfo;
|
return driverInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,8 +237,8 @@ namespace ASCOM.Meade.net
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
string driverVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
|
string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||||
Tl.LogMessage("DriverVersion Get", driverVersion);
|
LogMessage("DriverVersion Get", driverVersion);
|
||||||
return driverVersion;
|
return driverVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,6 +272,8 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
CheckConnected("Absolute Get");
|
||||||
|
|
||||||
Tl.LogMessage("Absolute Get", false.ToString());
|
Tl.LogMessage("Absolute Get", false.ToString());
|
||||||
return false; // This is a relative focuser
|
return false; // This is a relative focuser
|
||||||
}
|
}
|
||||||
@@ -312,6 +286,7 @@ namespace ASCOM.Meade.net
|
|||||||
CheckConnected("Halt");
|
CheckConnected("Halt");
|
||||||
|
|
||||||
//A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe.
|
//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();
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
while (stopwatch.ElapsedMilliseconds < 1000)
|
while (stopwatch.ElapsedMilliseconds < 1000)
|
||||||
{
|
{
|
||||||
@@ -383,16 +358,7 @@ namespace ASCOM.Meade.net
|
|||||||
if (position == 0)
|
if (position == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (position > 0)
|
MoveFocuser(position > 0, Math.Abs(position));
|
||||||
{
|
|
||||||
//desired move direction is out
|
|
||||||
MoveFocuser(true, Math.Abs(position));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//desired move direction is in
|
|
||||||
MoveFocuser(false, Math.Abs(position));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveFocuser(bool directionOut, int steps)
|
private void MoveFocuser(bool directionOut, int steps)
|
||||||
@@ -412,6 +378,7 @@ namespace ASCOM.Meade.net
|
|||||||
_utilities.WaitForMilliseconds(100);
|
_utilities.WaitForMilliseconds(100);
|
||||||
|
|
||||||
//A Single focus command sometimes gets lost on the #909, so sending lots of them solves the issue.
|
//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();
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
while (stopwatch.ElapsedMilliseconds < steps)
|
while (stopwatch.ElapsedMilliseconds < steps)
|
||||||
{
|
{
|
||||||
@@ -450,6 +417,7 @@ namespace ASCOM.Meade.net
|
|||||||
Tl.LogMessage("TempComp Get", false.ToString());
|
Tl.LogMessage("TempComp Get", false.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// ReSharper disable once ValueParameterNotUsed
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Tl.LogMessage("TempComp Set", "Not implemented");
|
Tl.LogMessage("TempComp Set", "Not implemented");
|
||||||
@@ -568,14 +536,14 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
if (!IsConnected)
|
if (!IsConnected)
|
||||||
{
|
{
|
||||||
throw new NotConnectedException(message);
|
throw new NotConnectedException($"Not connected to focuser when trying to execute: {message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read the device configuration from the ASCOM Profile store
|
/// Read the device configuration from the ASCOM Profile store
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void ReadProfile()
|
private void ReadProfile()
|
||||||
{
|
{
|
||||||
var profileProperties = _sharedResourcesWrapper.ReadProfile();
|
var profileProperties = _sharedResourcesWrapper.ReadProfile();
|
||||||
Tl.Enabled = profileProperties.TraceLogger;
|
Tl.Enabled = profileProperties.TraceLogger;
|
||||||
@@ -591,7 +559,7 @@ namespace ASCOM.Meade.net
|
|||||||
/// <param name="identifier"></param>
|
/// <param name="identifier"></param>
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
/// <param name="args"></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);
|
var msg = string.Format(message, args);
|
||||||
Tl.LogMessage(identifier, msg);
|
Tl.LogMessage(identifier, msg);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<RegisterForComInterop>true</RegisterForComInterop>
|
<RegisterForComInterop>true</RegisterForComInterop>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
+24
-6
@@ -23,6 +23,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Meade.net.Setup", "Meade.ne
|
|||||||
EndProject
|
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}"
|
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
|
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
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -69,21 +71,23 @@ Global
|
|||||||
{A97E3AEC-F11D-49DA-B259-DE99DA813A86}.Release|x64.Build.0 = Release|Any CPU
|
{A97E3AEC-F11D-49DA-B259-DE99DA813A86}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{A97E3AEC-F11D-49DA-B259-DE99DA813A86}.Release|x86.ActiveCfg = Release|x86
|
{A97E3AEC-F11D-49DA-B259-DE99DA813A86}.Release|x86.ActiveCfg = Release|x86
|
||||||
{A97E3AEC-F11D-49DA-B259-DE99DA813A86}.Release|x86.Build.0 = Release|x86
|
{A97E3AEC-F11D-49DA-B259-DE99DA813A86}.Release|x86.Build.0 = Release|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|Any CPU.ActiveCfg = Debug|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x64.ActiveCfg = Debug|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x64.ActiveCfg = Debug|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x64.Build.0 = Debug|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x64.Build.0 = Debug|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x86.ActiveCfg = Debug|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x86.Build.0 = Debug|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Debug|x86.Build.0 = Debug|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|Any CPU.ActiveCfg = Release|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|x64.ActiveCfg = Release|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|x64.ActiveCfg = Release|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|x86.ActiveCfg = Release|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|x86.ActiveCfg = Release|x86
|
||||||
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|x86.Build.0 = Release|x86
|
{D5207217-61C7-4E94-8097-91DBACE57D2A}.Release|x86.Build.0 = Release|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|Any CPU.ActiveCfg = Debug|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x64.ActiveCfg = Debug|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x64.ActiveCfg = Debug|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x64.Build.0 = Debug|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x64.Build.0 = Debug|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x86.ActiveCfg = Debug|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x86.Build.0 = Debug|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Debug|x86.Build.0 = Debug|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|Any CPU.ActiveCfg = Release|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|x64.ActiveCfg = Release|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|x64.ActiveCfg = Release|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|x86.ActiveCfg = Release|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|x86.ActiveCfg = Release|x86
|
||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|x86.Build.0 = Release|x86
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49}.Release|x86.Build.0 = Release|x86
|
||||||
@@ -99,12 +103,13 @@ Global
|
|||||||
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95}.Release|x64.Build.0 = Release|Any CPU
|
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95}.Release|x86.ActiveCfg = Release|x86
|
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95}.Release|x86.ActiveCfg = Release|x86
|
||||||
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95}.Release|x86.Build.0 = Release|x86
|
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95}.Release|x86.Build.0 = Release|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|Any CPU.Build.0 = Debug|x64
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|Any CPU.Build.0 = Debug|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|x64.ActiveCfg = Debug|x64
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|x86.ActiveCfg = Debug|x86
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|x86.Build.0 = Debug|x86
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Debug|x86.Build.0 = Debug|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|Any CPU.ActiveCfg = Release|x86
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|Any CPU.ActiveCfg = Release|x86
|
||||||
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|Any CPU.Build.0 = Release|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|x64.ActiveCfg = Release|x86
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|x64.ActiveCfg = Release|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|x86.ActiveCfg = Release|x86
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|x86.ActiveCfg = Release|x86
|
||||||
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|x86.Build.0 = Release|x86
|
{8EEB5C25-8394-4257-8E57-CDED47CB6F1B}.Release|x86.Build.0 = Release|x86
|
||||||
@@ -120,6 +125,18 @@ Global
|
|||||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33}.Release|x64.Build.0 = Release|Any CPU
|
{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.ActiveCfg = Release|x86
|
||||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33}.Release|x86.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -129,6 +146,7 @@ Global
|
|||||||
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49} = {BF650D97-AF98-4638-9C55-21311C6D88DA}
|
{AABC96B8-C462-4B3A-9B5F-2929E3CB7A49} = {BF650D97-AF98-4638-9C55-21311C6D88DA}
|
||||||
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
|
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
|
||||||
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33} = {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
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3C0509DC-C7F5-48DC-920D-DCFD9C879BD2}
|
SolutionGuid = {3C0509DC-C7F5-48DC-920D-DCFD9C879BD2}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Resources;
|
||||||
|
|
||||||
|
namespace ASCOM.Meade.net
|
||||||
|
{
|
||||||
|
public class AssemblyInfo
|
||||||
|
{
|
||||||
|
// The assembly information values.
|
||||||
|
public string Title = "", Description = "", Company = "",
|
||||||
|
Product = "", Copyright = "", Trademark = "",
|
||||||
|
AssemblyVersion = "", FileVersion = "", Guid = "",
|
||||||
|
NeutralLanguage = "";
|
||||||
|
public bool IsComVisible = false;
|
||||||
|
|
||||||
|
// Return a particular assembly attribute value.
|
||||||
|
public static T GetAssemblyAttribute<T>(Assembly assembly)
|
||||||
|
where T : Attribute
|
||||||
|
{
|
||||||
|
// Get attributes of this type.
|
||||||
|
object[] attributes =
|
||||||
|
assembly.GetCustomAttributes(typeof(T), true);
|
||||||
|
|
||||||
|
// If we didn't get anything, return null.
|
||||||
|
if ((attributes == null) || (attributes.Length == 0))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Convert the first attribute value into
|
||||||
|
// the desired type and return it.
|
||||||
|
return (T)attributes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructors.
|
||||||
|
public AssemblyInfo()
|
||||||
|
: this(Assembly.GetExecutingAssembly())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyInfo(Assembly assembly)
|
||||||
|
{
|
||||||
|
// Get values from the assembly.
|
||||||
|
AssemblyTitleAttribute titleAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyTitleAttribute>(assembly);
|
||||||
|
if (titleAttr != null) Title = titleAttr.Title;
|
||||||
|
|
||||||
|
AssemblyDescriptionAttribute assemblyAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyDescriptionAttribute>(assembly);
|
||||||
|
if (assemblyAttr != null) Description =
|
||||||
|
assemblyAttr.Description;
|
||||||
|
|
||||||
|
AssemblyCompanyAttribute companyAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyCompanyAttribute>(assembly);
|
||||||
|
if (companyAttr != null) Company = companyAttr.Company;
|
||||||
|
|
||||||
|
AssemblyProductAttribute productAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyProductAttribute>(assembly);
|
||||||
|
if (productAttr != null) Product = productAttr.Product;
|
||||||
|
|
||||||
|
AssemblyCopyrightAttribute copyrightAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyCopyrightAttribute>(assembly);
|
||||||
|
if (copyrightAttr != null) Copyright = copyrightAttr.Copyright;
|
||||||
|
|
||||||
|
AssemblyTrademarkAttribute trademarkAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyTrademarkAttribute>(assembly);
|
||||||
|
if (trademarkAttr != null) Trademark = trademarkAttr.Trademark;
|
||||||
|
|
||||||
|
var version = assembly.GetName().Version;
|
||||||
|
AssemblyVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||||
|
|
||||||
|
|
||||||
|
AssemblyFileVersionAttribute fileVersionAttr =
|
||||||
|
GetAssemblyAttribute<AssemblyFileVersionAttribute>(assembly);
|
||||||
|
if (fileVersionAttr != null) FileVersion =
|
||||||
|
fileVersionAttr.Version;
|
||||||
|
|
||||||
|
GuidAttribute guidAttr = GetAssemblyAttribute<GuidAttribute>(assembly);
|
||||||
|
if (guidAttr != null) Guid = guidAttr.Value;
|
||||||
|
|
||||||
|
NeutralResourcesLanguageAttribute languageAttr =
|
||||||
|
GetAssemblyAttribute<NeutralResourcesLanguageAttribute>(assembly);
|
||||||
|
if (languageAttr != null) NeutralLanguage =
|
||||||
|
languageAttr.CultureName;
|
||||||
|
|
||||||
|
ComVisibleAttribute comAttr =
|
||||||
|
GetAssemblyAttribute<ComVisibleAttribute>(assembly);
|
||||||
|
if (comAttr != null) IsComVisible = comAttr.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace ASCOM.Meade.net
|
||||||
|
{
|
||||||
|
public class ConnectionInfo
|
||||||
|
{
|
||||||
|
public int Connections { get; set; }
|
||||||
|
public int SameDevice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-10
@@ -29,6 +29,8 @@ namespace ASCOM.Meade.net
|
|||||||
public static class Server
|
public static class Server
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private const string DRIVER_NAME = "Meade Generic";
|
||||||
|
|
||||||
#region Access to kernel32.dll, user32.dll, and ole32.dll functions
|
#region Access to kernel32.dll, user32.dll, and ole32.dll functions
|
||||||
[Flags]
|
[Flags]
|
||||||
enum Clsctx : uint
|
enum Clsctx : uint
|
||||||
@@ -256,8 +258,8 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to load served COM class assembly " + fi.Name + " - " + e.Message,
|
MessageBox.Show($"Failed to load served COM class assembly {fi.Name} - {e.Message}",
|
||||||
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,12 +295,11 @@ namespace ASCOM.Meade.net
|
|||||||
try { Process.Start(si); }
|
try { Process.Start(si); }
|
||||||
catch (System.ComponentModel.Win32Exception)
|
catch (System.ComponentModel.Win32Exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show("The Meade.net was not " + (arg == "/register" ? "registered" : "unregistered") +
|
MessageBox.Show($"The {DRIVER_NAME} was not {(arg == "/register" ? "registered" : "unregistered")} because you did not allow it.", DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
" because you did not allow it.", "Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.ToString(), "Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
MessageBox.Show(ex.ToString(), DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -356,8 +357,8 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Error while registering the server:\n" + ex.ToString(),
|
MessageBox.Show($"Error while registering the server:\n{ex}",
|
||||||
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -426,7 +427,7 @@ namespace ASCOM.Meade.net
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Error while registering the server:\n" + ex.ToString(),
|
MessageBox.Show("Error while registering the server:\n" + ex.ToString(),
|
||||||
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
bFail = true;
|
bFail = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -514,7 +515,7 @@ namespace ASCOM.Meade.net
|
|||||||
if (!factory.RegisterClassObject())
|
if (!factory.RegisterClassObject())
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to register class factory for " + type.Name,
|
MessageBox.Show("Failed to register class factory for " + type.Name,
|
||||||
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -570,7 +571,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding",
|
MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding",
|
||||||
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
DRIVER_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
@@ -68,7 +69,7 @@
|
|||||||
<OutputPath>..\bin\Debug\</OutputPath>
|
<OutputPath>..\bin\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
@@ -121,7 +122,9 @@
|
|||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AssemblyInfo.cs" />
|
||||||
<Compile Include="ClassFactory.cs" />
|
<Compile Include="ClassFactory.cs" />
|
||||||
|
<Compile Include="ConnectionInfo.cs" />
|
||||||
<Compile Include="frmMain.cs">
|
<Compile Include="frmMain.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -134,6 +137,7 @@
|
|||||||
<Compile Include="ProfileProperties.cs" />
|
<Compile Include="ProfileProperties.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="TelescopeList.cs" />
|
<Compile Include="TelescopeList.cs" />
|
||||||
|
<Compile Include="Win32Utilities.cs" />
|
||||||
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
|
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
|
||||||
<EmbeddedResource Include="frmMain.resx">
|
<EmbeddedResource Include="frmMain.resx">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyDescription("ASCOM multi-interface server for Meade.net")]
|
[assembly: AssemblyDescription("ASCOM multi-interface server for Meade.net")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("cjdawson.com")]
|
[assembly: AssemblyCompany("cjdawson.com")]
|
||||||
[assembly: AssemblyProduct("")]
|
[assembly: AssemblyProduct("ASCOM Meade Generic")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2019 cjdawson.com")]
|
[assembly: AssemblyCopyright("Copyright © 2019 cjdawson.com")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ namespace ASCOM.Meade.net
|
|||||||
public SetupDialogForm()
|
public SetupDialogForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
var assemblyInfo = new AssemblyInfo();
|
||||||
|
|
||||||
|
Text = $"{assemblyInfo.Product} Settings ({assemblyInfo.AssemblyVersion})";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler
|
private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler
|
||||||
@@ -53,7 +57,7 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
cboPrecision.SelectedItem = profileProperties.Precision;
|
cboPrecision.SelectedItem = profileProperties.Precision;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
cboPrecision.SelectedItem = "Unchanged";
|
cboPrecision.SelectedItem = "Unchanged";
|
||||||
}
|
}
|
||||||
@@ -74,6 +78,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
private void SetupDialogForm_Shown(object sender, EventArgs e)
|
private void SetupDialogForm_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Win32Utilities.BringWindowToFront(Handle);
|
||||||
Activate();
|
Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +97,7 @@ namespace ASCOM.Meade.net
|
|||||||
lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)";
|
lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)";
|
||||||
_guideRateValid = true;
|
_guideRateValid = true;
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
//Surpressing this exception as if the value is not valid then it's not useful.
|
//Surpressing this exception as if the value is not valid then it's not useful.
|
||||||
_guideRateValid = false;
|
_guideRateValid = false;
|
||||||
@@ -110,5 +115,20 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
UpdateOKButton();
|
UpdateOKButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetReadOnlyMode()
|
||||||
|
{
|
||||||
|
foreach (Control control in Controls)
|
||||||
|
{
|
||||||
|
control.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdCancel.Enabled = true;
|
||||||
|
//cmdOK.Enabled = false;
|
||||||
|
//comboBoxComPort.Enabled = false;
|
||||||
|
//chkTrace.Enabled = false;
|
||||||
|
//txtGuideRate.Enabled = false;
|
||||||
|
//cboPrecision.Enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+1
@@ -152,6 +152,7 @@ namespace ASCOM.Meade.net
|
|||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "SetupDialogForm";
|
this.Name = "SetupDialogForm";
|
||||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
|
this.TopMost = true;
|
||||||
this.Shown += new System.EventHandler(this.SetupDialogForm_Shown);
|
this.Shown += new System.EventHandler(this.SetupDialogForm_Shown);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|||||||
@@ -178,7 +178,7 @@
|
|||||||
<value>12, 9</value>
|
<value>12, 9</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>123, 31</value>
|
<value>274, 31</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using ASCOM.Utilities;
|
using ASCOM.Utilities;
|
||||||
|
|
||||||
namespace ASCOM.Meade.net
|
namespace ASCOM.Meade.net
|
||||||
@@ -227,6 +228,11 @@ namespace ASCOM.Meade.net
|
|||||||
{
|
{
|
||||||
f.SetProfile(profileProperties);
|
f.SetProfile(profileProperties);
|
||||||
|
|
||||||
|
if (IsConnected())
|
||||||
|
{
|
||||||
|
f.SetReadOnlyMode();
|
||||||
|
}
|
||||||
|
|
||||||
var result = f.ShowDialog();
|
var result = f.ShowDialog();
|
||||||
if (result == System.Windows.Forms.DialogResult.OK)
|
if (result == System.Windows.Forms.DialogResult.OK)
|
||||||
{
|
{
|
||||||
@@ -260,12 +266,15 @@ namespace ASCOM.Meade.net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Dictionary<string, DeviceHardware> _connectedDevices = new Dictionary<string, DeviceHardware>();
|
private static readonly Dictionary<string, DeviceHardware> _connectedDevices = new Dictionary<string, DeviceHardware>();
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, DeviceHardware> _connectedDeviceIds = new Dictionary<string, DeviceHardware>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called in the driver Connect(true) property,
|
/// 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.
|
/// it add the device id to the list of devices if it's not there and increments the device count.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceId"></param>
|
/// <param name="deviceId"></param>
|
||||||
public static void Connect(string deviceId)
|
public static ConnectionInfo Connect(string deviceId, string driverId)
|
||||||
{
|
{
|
||||||
lock (LockObject)
|
lock (LockObject)
|
||||||
{
|
{
|
||||||
@@ -273,6 +282,10 @@ namespace ASCOM.Meade.net
|
|||||||
_connectedDevices.Add(deviceId, new DeviceHardware());
|
_connectedDevices.Add(deviceId, new DeviceHardware());
|
||||||
_connectedDevices[deviceId].Count++; // increment the value
|
_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 (deviceId == "Serial")
|
||||||
{
|
{
|
||||||
if (_connectedDevices[deviceId].Count == 1)
|
if (_connectedDevices[deviceId].Count == 1)
|
||||||
@@ -292,10 +305,16 @@ namespace ASCOM.Meade.net
|
|||||||
FirmwareVersion = SendString(":GVN#");
|
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)
|
lock (LockObject)
|
||||||
{
|
{
|
||||||
@@ -311,8 +330,24 @@ namespace ASCOM.Meade.net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_connectedDeviceIds.ContainsKey(driverId))
|
||||||
|
{
|
||||||
|
_connectedDeviceIds[driverId].Count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsConnected()
|
||||||
|
{
|
||||||
|
foreach (var device in _connectedDevices)
|
||||||
|
{
|
||||||
|
if (device.Value.Count > 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsConnected(string deviceId)
|
public static bool IsConnected(string deviceId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,8 +4,8 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
{
|
{
|
||||||
public interface ISharedResourcesWrapper
|
public interface ISharedResourcesWrapper
|
||||||
{
|
{
|
||||||
void Connect(string deviceId);
|
ConnectionInfo Connect(string deviceId, string driverId);
|
||||||
void Disconnect(string deviceId);
|
void Disconnect(string deviceId, string driverId);
|
||||||
|
|
||||||
string ProductName { get; }
|
string ProductName { get; }
|
||||||
|
|
||||||
@@ -29,14 +29,14 @@ namespace ASCOM.Meade.net.Wrapper
|
|||||||
|
|
||||||
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
public class SharedResourcesWrapper : ISharedResourcesWrapper
|
||||||
{
|
{
|
||||||
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;
|
public string ProductName => SharedResources.ProductName;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -36,6 +36,25 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||||
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||||
|
|||||||
Reference in New Issue
Block a user