Compare commits

..

70 Commits

Author SHA1 Message Date
ColinD 4aa5cf233e Merged in develop (pull request #17)
Added support for LX-200 EMC
2019-09-30 21:27:36 +00:00
ColinD eb775bba18 Code inspections 2019-09-30 22:14:34 +01:00
ColinD 4ff193fadf Unneeded collection, so commented it out 2019-09-30 22:11:58 +01:00
ColinD a61915a3b5 Adding some experimental support for the LX-200 EMC 2019-09-30 22:10:00 +01:00
ColinD f33ca49592 Code inspections 2019-09-29 23:20:44 +01:00
ColinD 1c4d65bec3 Code inspections 2019-09-29 23:07:56 +01:00
ColinD 300e042340 Code inspections 2019-09-29 23:00:44 +01:00
ColinD ec48f1f36e Code inspections 2019-09-29 22:56:58 +01:00
ColinD 13176cb286 Code inspections 2019-09-29 22:51:18 +01:00
ColinD 970b1f1571 Code inspections 2019-09-29 22:43:48 +01:00
ColinD 7465260354 Code inspections 2019-09-29 22:34:46 +01:00
ColinD 2a13fcd40a Code inspections 2019-09-29 22:26:17 +01:00
ColinD 19f831695d code inspections 2019-09-29 22:24:58 +01:00
ColinD 07bf72a8c3 Code inspections 2019-09-29 22:16:03 +01:00
ColinD 7905da9651 Code inspections 2019-09-29 20:22:42 +01:00
ColinD ecd9813f8a Code inspections 2019-09-29 20:16:48 +01:00
ColinD 0e0ea2d2b0 Code inspections 2019-09-29 19:51:19 +01:00
ColinD 272fdb58d1 Code inspections 2019-09-29 19:43:34 +01:00
ColinD 4489a91eb7 Code inspections 2019-09-29 19:38:56 +01:00
ColinD 013c2fd672 Removed unneeded html files, which contain lots of code inspection issues 2019-09-29 18:00:38 +01:00
ColinD 6394e08c4c Code inspections 2019-09-29 17:49:21 +01:00
ColinD 15bf977458 Code inspections 2019-09-29 17:37:07 +01:00
ColinD b8faab13b3 Code inspections 2019-09-28 23:10:37 +01:00
ColinD 0bbfa5f9c3 Code inspections 2019-09-28 23:04:55 +01:00
ColinD 69fbb14410 Code inspections 2019-09-28 22:52:30 +01:00
ColinD 101784adb3 Code inspections 2019-09-28 22:45:34 +01:00
ColinD ca982edbf8 Code inspections 2019-09-28 22:40:09 +01:00
ColinD e782ac36fb Code inspection cleanup 2019-09-28 22:20:21 +01:00
ColinD b962420b94 Merge branch 'master' into develop 2019-09-28 14:05:25 +01:00
ColinD 0594355072 Adding version number to the settings dialog
Added feature where setup dialog controls are disabled when the telescope or focuser is attached
Modified the whole solution to use Any CPU, and changed the installer to use the /register /unregister commands
ASCOM Profile for Meade Generic removed on uninstall, but not on upgrade
2019-09-28 13:04:56 +00:00
ColinD aec6cc19ab Code tidyup 2019-09-28 13:56:20 +01:00
ColinD 58b0e1395c Reverting change as I think it was better before. 2019-09-28 13:50:55 +01:00
ColinD 274ecbab6b Changing the place for uninstall deregister 2019-09-28 13:43:02 +01:00
ColinD 544cdd826b Installer modification 2019-09-28 13:41:39 +01:00
ColinD fc68a788ac Attempting to delete ascom profile entries on uninstall 2019-09-28 13:24:31 +01:00
ColinD 9c689f1179 Changed the served classname 2019-09-28 13:01:13 +01:00
ColinD 6e7ff70862 Tidying up meade.net to read as meade generic 2019-09-28 12:45:32 +01:00
ColinD 0a0072ce43 made sure that relese build contains the setup project. 2019-09-28 12:32:37 +01:00
ColinD 0e31149e31 installer modification 2019-09-28 12:23:48 +01:00
ColinD d332243772 anycpu 2019-09-27 22:28:22 +01:00
ColinD d9aa68f1e9 Modified the whole solution to use Any CPU, and changed the installer to use the /register /unregister commands 2019-09-27 22:05:14 +01:00
ColinD 2cc27788c8 Added feature where setup dialog controls are disabled when the telescope or focuser is attached 2019-08-25 19:45:54 +01:00
ColinD 5a0b3bba25 Adding version number to the settings dialog 2019-08-25 15:09:08 +01:00
ColinD 7a80ad4662 Merged in develop (pull request #15)
Develop
2019-08-24 21:49:00 +00:00
ColinD 3eddc52c6a Tidy up a few code inspection issues and add the MIT License to the installer. 2019-08-24 22:38:16 +01:00
ColinD 64a72560bc Fixed missing closing bracket 2019-08-24 17:40:25 +01:00
ColinD 0a6ba16c61 Merge branch 'master' into develop 2019-08-24 17:31:38 +01:00
ColinD b932bd8eb6 Merged in develop (pull request #14)
Adding log message when making connections using a telescope device to show that if it's the first or secondary connection.
2019-08-24 16:31:22 +00:00
ColinD 5aec81b45f Adding log message when making connections using a telescope device to show that if it's the first or secondary connection. 2019-08-24 17:30:28 +01:00
ColinD d68d51bd9c Merge branch 'master' into develop 2019-08-24 17:12:06 +01:00
ColinD badc519f37 Merged in develop (pull request #13)
Develop
2019-08-24 16:11:12 +00:00
ColinD 77ca457646 Finished the basic unit testing for the focuser 2019-08-24 16:59:24 +01:00
ColinD 7ed79d6954 Added more code towards focuser unit testing 2019-08-24 16:40:15 +01:00
ColinD 43e630283c Edited with Bitbucket 2019-08-24 13:59:04 +00:00
ColinD 09df67c67f Edited with Bitbucket 2019-08-24 13:58:29 +00:00
ColinD 9a30e02a4b Started working on the focuser unit testing 2019-08-23 21:30:12 +01:00
ColinD 036fd48bcf Another attempt to sort out the dialog appearing behind other windows. 2019-08-23 19:16:02 +01:00
ColinD 5476331073 Another attempt to sort out the dialog appearing behind other windows. 2019-08-23 18:57:48 +01:00
ColinD c6cab848f9 Another attempt to sort out the dialog appearing behind other windows. 2019-08-23 18:16:02 +01:00
ColinD efa78ec8a0 Attempt to make sure that the setup dialog comes up on top of windows. 2019-08-23 18:05:10 +01:00
ColinD c311fb8cbe Second and subsequent Connections to the telescope driver now no longer trigger resetting the Guide rate and precision. It's assumed they are already set correctly. 2019-08-22 23:22:36 +01:00
ColinD 633babd967 Merged in develop (pull request #12)
Develop
2019-08-18 22:12:57 +00:00
ColinD 81a3a29743 Made the Precision combobox a bit wider. 2019-08-18 23:05:51 +01:00
ColinD e1a0d6449d Added ability to read an unterminated buffer when changing slewing precision 2019-08-18 22:57:24 +01:00
ColinD f6556716a5 Modified the precision toggle to only use the first letter of the response rather than try to detect the entire string 2019-08-18 22:43:38 +01:00
ColinD f10936a9e8 Changes the installer name to ASCOM Meade Generic 2019-08-18 22:30:05 +01:00
ColinD 98feb74870 Changed how the precision item is saved. Removed the case-sensitivity. 2019-08-18 22:26:58 +01:00
ColinD 7542e86aeb Added missing log message for the new precision parameter. 2019-08-18 21:39:07 +01:00
ColinD 68928a2289 Added a config setting to be able to choose whether the telescope uses high or low precision. Set to Unchanged for the telescope settings to not be altered. 2019-08-18 21:30:22 +01:00
ColinD b3dc507aff Merge branch 'master' into develop 2019-07-26 11:49:13 +01:00
60 changed files with 2145 additions and 1788 deletions
@@ -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" />
+11 -7
View File
@@ -113,11 +113,13 @@ namespace AstroMath.UnitTests
{ {
var latitude = 52.0; var latitude = 52.0;
EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates(); var equatorialCoordinates = new EquatorialCoordinates
equatorialCoordinates.RightAscension = 5.862222222222222;//5 51' 44" {
equatorialCoordinates.Declination = 23.21944444444444;//23 13' 10" RightAscension = 5.862222222222222, //5 51' 44"
Declination = 23.21944444444444 //23 13' 10"
};
var hourAngle = 5.682222; const double hourAngle = 5.682222;
var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates); var altAz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
@@ -131,9 +133,11 @@ namespace AstroMath.UnitTests
DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc); DateTime dateTime = new DateTime(2019, 05, 18, 22, 26, 15, DateTimeKind.Utc);
var longitude = -1.7833333333333332; var longitude = -1.7833333333333332;
var latitude = 52.0; var latitude = 52.0;
EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates(); EquatorialCoordinates equatorialCoordinates = new EquatorialCoordinates
equatorialCoordinates.RightAscension = 4.15361111111111; {
equatorialCoordinates.Declination = 30.0019444444444; RightAscension = 4.15361111111111,
Declination = 30.0019444444444
};
var hourAngle = _astroMath.RightAscensionToHourAngle(dateTime, longitude, equatorialCoordinates.RightAscension); var hourAngle = _astroMath.RightAscensionToHourAngle(dateTime, longitude, equatorialCoordinates.RightAscension);
var altaz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates); var altaz = _astroMath.ConvertEqToHoz(hourAngle, latitude, equatorialCoordinates);
+11
View File
@@ -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>
+1 -1
View File
@@ -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,475 @@
using System;
using System.Reflection;
using ASCOM;
using ASCOM.DeviceInterface;
using ASCOM.Meade.net;
using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities.Interfaces;
using Moq;
using NUnit.Framework;
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
{
TraceLogger = false,
ComPort = "TestCom1",
GuideRateArcSecondsPerSecond = 1.23,
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";
Assert.Throws<ActionNotImplementedException>(() =>
{
var actualResult = _focuser.Action(actionName, string.Empty);
Assert.Fail($"{actualResult} should not have a value");
});
}
[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 = 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()
{
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.Fail($"{result} should not have a value");
});
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.Fail($"{result} should not have a value");
});
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.Fail($"{result} should not have a value");
});
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.Fail($"{result} should not have a value");
});
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,35 @@
using System.Reflection;
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")]
+11
View File
@@ -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>
-35
View File
@@ -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>
+25 -15
View File
@@ -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="&quot;[#filLocalServerAssembly]&quot; /register"
Execute="deferred"
Return="ignore"
Impersonate="no"
/>
<CustomAction Id="UnRegisterEXE"
Directory="INSTALLFOLDER"
ExeCommand="&quot;[#filLocalServerAssembly]&quot; /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>
-35
View File
@@ -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>
+1 -1
View File
@@ -11,7 +11,7 @@
UpgradeCode must be unique to this product and should not be changed for the product lifetime. UpgradeCode must be unique to this product and should not be changed for the product lifetime.
--> -->
<?define InstallName = "ASCOM Meade.net" ?> <?define InstallName = "ASCOM Meade Generic" ?>
<?define Manufacturer = "cjdawson.com" ?> <?define Manufacturer = "cjdawson.com" ?>
<?define UpgradeCode = "{57597bb6-f207-4998-97f4-8a041950d062}" ?> <?define UpgradeCode = "{57597bb6-f207-4998-97f4-8a041950d062}" ?>
<?define INSTALLFOLDER = "$(var.InstallName)" ?> <?define INSTALLFOLDER = "$(var.InstallName)" ?>
Binary file not shown.
+1
View File
@@ -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">
+1 -5
View File
@@ -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" />
@@ -1,4 +1,5 @@
using System; using System;
using System.Reflection;
using ASCOM; using ASCOM;
using ASCOM.Astrometry.AstroUtils; using ASCOM.Astrometry.AstroUtils;
using ASCOM.DeviceInterface; using ASCOM.DeviceInterface;
@@ -23,14 +24,18 @@ 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()
{ {
_profileProperties = new ProfileProperties(); _profileProperties = new ProfileProperties
_profileProperties.TraceLogger = false; {
_profileProperties.ComPort = "TestCom1"; TraceLogger = false,
_profileProperties.GuideRateArcSecondsPerSecond = 1.23; ComPort = "TestCom1",
GuideRateArcSecondsPerSecond = 1.23,
Precision = "Unchanged"
};
_utilMock = new Mock<IUtil>(); _utilMock = new Mock<IUtil>();
_utilExtraMock = new Mock<IUtilExtra>(); _utilExtraMock = new Mock<IUtilExtra>();
@@ -39,10 +44,14 @@ namespace Meade.net.Telescope.UnitTests
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>(); _sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MMSS"); _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MMSS");
_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);
@@ -97,7 +106,10 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void Action_WhenNotConnected_ThrowsNotConnectedException() public void Action_WhenNotConnected_ThrowsNotConnectedException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var actualResult = _telescope.Action(string.Empty, string.Empty); }); var exception = Assert.Throws<NotConnectedException>(() =>
{
_telescope.Action(string.Empty, string.Empty);
});
Assert.That(exception.Message,Is.EqualTo("Not connected to telescope when trying to execute: Action")); Assert.That(exception.Message,Is.EqualTo("Not connected to telescope when trying to execute: Action"));
} }
@@ -232,7 +244,7 @@ namespace Meade.net.Telescope.UnitTests
{ {
ConnectTelescope(); ConnectTelescope();
string parameters = $"unknown"; string parameters = "unknown";
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); }); var exception = Assert.Throws<InvalidValueException>(() => { _telescope.Action("site", parameters); });
Assert.That(exception.Message, Is.EqualTo($"Site parameters {parameters} not known")); Assert.That(exception.Message, Is.EqualTo($"Site parameters {parameters} not known"));
@@ -337,49 +349,70 @@ namespace Meade.net.Telescope.UnitTests
_telescope.Connected = expectedConnected; _telescope.Connected = expectedConnected;
Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected)); Assert.That(_telescope.Connected, Is.EqualTo(expectedConnected));
if (expectedConnected)
{
_sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never);
}
} }
[Test] [Test]
public void Connected_Set_WhenConnecting_Then() public void Connected_Set_WhenConnectingLX200GPS_Then_ConnectsToSerialDevice()
{ {
var productName = "LX2001"; var productName = TelescopeList.LX200GPS;
var firmware = string.Empty; var firmware = string.Empty;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
_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);
} }
[Test]
public void Connected_Set_WhenConnectingToLX200EMC_Then_ConnectsToSerialDevice()
{
var productName = TelescopeList.LX200CLASSIC;
var firmware = string.Empty;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Verify(x => x.Connect("Serial", It.IsAny<string>()), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendString(":GZ#"), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Rg{_profileProperties.GuideRateArcSecondsPerSecond:00.0}#"), Times.Never);
}
[Test] [Test]
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]
@@ -394,7 +427,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)]
@@ -402,6 +435,7 @@ namespace Meade.net.Telescope.UnitTests
[TestCase("Autostar", "43Eg", true)] [TestCase("Autostar", "43Eg", true)]
[TestCase("Autostar II", "", false)] [TestCase("Autostar II", "", false)]
[TestCase("LX2001", "", true)] [TestCase("LX2001", "", true)]
[TestCase(":GVP", "", false)] //LX200 Classic
public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported) public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported)
{ {
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName);
@@ -503,7 +537,7 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void DriverVersion_Get() public void DriverVersion_Get()
{ {
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version; Version version = Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version;
string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; string exptectedDriverInfo = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
@@ -515,8 +549,6 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void DriverInfo_Get() public void DriverInfo_Get()
{ {
Version version = System.Reflection.Assembly.GetAssembly(typeof(ASCOM.Meade.net.Telescope)).GetName().Version;
string exptectedDriverInfo = $"{_telescope.Description} .net driver. Version: {_telescope.DriverVersion}"; string exptectedDriverInfo = $"{_telescope.Description} .net driver. Version: {_telescope.DriverVersion}";
var driverInfo = _telescope.DriverInfo; var driverInfo = _telescope.DriverInfo;
@@ -546,7 +578,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void AlignmentMode_Get_WhenNotConnected_ThrowsException() public void AlignmentMode_Get_WhenNotConnected_ThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var actualResult = _telescope.AlignmentMode; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var actualResult = _telescope.AlignmentMode;
Assert.Fail($"{actualResult} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Get"));
} }
@@ -571,7 +607,11 @@ namespace Meade.net.Telescope.UnitTests
{ {
ConnectTelescope(); ConnectTelescope();
Assert.Throws<InvalidValueException>(() => { var actualResult = _telescope.AlignmentMode; }); Assert.Throws<InvalidValueException>(() =>
{
var actualResult = _telescope.AlignmentMode;
Assert.Fail($"{actualResult} should not have returned");
});
} }
[Test] [Test]
@@ -611,7 +651,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void ApertureArea_Get_ThrowsNotImplementedException() public void ApertureArea_Get_ThrowsNotImplementedException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.ApertureArea; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.ApertureArea;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("ApertureArea")); Assert.That(excpetion.Property, Is.EqualTo("ApertureArea"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -620,7 +664,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void ApertureDiameter_Get_ThrowsNotImplementedException() public void ApertureDiameter_Get_ThrowsNotImplementedException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.ApertureDiameter; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.ApertureDiameter;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("ApertureDiameter")); Assert.That(excpetion.Property, Is.EqualTo("ApertureDiameter"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -708,7 +756,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException() public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.CanSetGuideRates; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.CanSetGuideRates;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get"));
} }
@@ -734,6 +786,58 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(result, Is.True); Assert.That(result, Is.True);
} }
[Test]
public void Precision_Set_WhenConnectedAndPrecisionSetUnChanged_ThenDoesNotSetPrecision()
{
_telescope.Connected = true;
_sharedResourcesWrapperMock.Verify( x => x.SendString(":P#"), Times.Never);
}
[TestCase("High", false, true)]
[TestCase("High", true, true)]
[TestCase("Low", false, false)]
[TestCase("Low", true, false)]
public void Precision_Set_WhenConnectedAndPrecisionSetHighScopeIsLow_ThenTelescopePrecisionChanged(string desiredPresision, bool telescopePrecision, bool finalPrecision)
{
_profileProperties.Precision = desiredPresision;
var currentPrecision = telescopePrecision;
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":P#")).Returns(() =>
{
currentPrecision = !currentPrecision;
switch (currentPrecision)
{
case true:
return "H";
default:
return "L";
}
});
_telescope.Connected = true;
Assert.That(currentPrecision, Is.EqualTo(finalPrecision));
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.AtLeastOnce);
}
[TestCase("High", false, true)]
[TestCase("High", true, true)]
[TestCase("Low", false, false)]
[TestCase("Low", true, false)]
public void Precision_Set_WhenSecondConnectionMade_ThenTelescopePrecisionNotChanged(string desiredPresision, bool telescopePrecision, bool finalPrecision)
{
_profileProperties.Precision = desiredPresision;
_connectionInfo.SameDevice = 2;
_connectionInfo.Connections = 2;
_telescope.Connected = true;
_sharedResourcesWrapperMock.Verify(x => x.SendChar(":P#"), Times.Never);
}
[Test] [Test]
public void CanSetPark_Get_ReturnsFalse() public void CanSetPark_Get_ReturnsFalse()
{ {
@@ -825,7 +929,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void Declination_Get_WhenNotConnected_ThenThrowsException() public void Declination_Get_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var actualResult = _telescope.Declination; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var actualResult = _telescope.Declination;
Assert.Fail($"{actualResult} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Declination Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Declination Get"));
} }
@@ -863,7 +971,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void DestinationSideOfPier_ThenThrowsException() public void DestinationSideOfPier_ThenThrowsException()
{ {
var excpetion = Assert.Throws<MethodNotImplementedException>(() => { var result = _telescope.DestinationSideOfPier(0,0); }); var excpetion = Assert.Throws<MethodNotImplementedException>(() =>
{
var result = _telescope.DestinationSideOfPier(0,0);
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Method, Is.EqualTo("DestinationSideOfPier")); Assert.That(excpetion.Method, Is.EqualTo("DestinationSideOfPier"));
} }
@@ -871,7 +983,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void DoesRefraction_Get_ThenThrowsException() public void DoesRefraction_Get_ThenThrowsException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.DoesRefraction; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.DoesRefraction;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("DoesRefraction")); Assert.That(excpetion.Property, Is.EqualTo("DoesRefraction"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -905,7 +1021,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void FocalLength_Get_ThenThrowsException() public void FocalLength_Get_ThenThrowsException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.FocalLength; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.FocalLength;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("FocalLength")); Assert.That(excpetion.Property, Is.EqualTo("FocalLength"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -1086,7 +1206,7 @@ namespace Meade.net.Telescope.UnitTests
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.MoveAxis(TelescopeAxes.axisTertiary, testRate); }); var exception = Assert.Throws<InvalidValueException>(() => { _telescope.MoveAxis(TelescopeAxes.axisTertiary, testRate); });
Assert.That(exception.Message, Is.EqualTo($"Can not move this axis.")); Assert.That(exception.Message, Is.EqualTo("Can not move this axis."));
} }
[Test] [Test]
@@ -1242,7 +1362,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void RightAscension_Get_WhenNotConnected_ThenThrowsException() public void RightAscension_Get_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.RightAscension; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.RightAscension;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: RightAscension Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: RightAscension Get"));
} }
@@ -1293,7 +1417,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void SideOfPier_Get_ThenThrowsException() public void SideOfPier_Get_ThenThrowsException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.SideOfPier; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.SideOfPier;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("SideOfPier")); Assert.That(excpetion.Property, Is.EqualTo("SideOfPier"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -1311,7 +1439,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void SiteElevation_Get_ThenThrowsException() public void SiteElevation_Get_ThenThrowsException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.SiteElevation; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.SiteElevation;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("SiteElevation")); Assert.That(excpetion.Property, Is.EqualTo("SiteElevation"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -1329,7 +1461,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void SlewSettleTime_Get_ThenThrowsException() public void SlewSettleTime_Get_ThenThrowsException()
{ {
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.SlewSettleTime; }); var excpetion = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _telescope.SlewSettleTime;
Assert.Fail($"{result} should not have returned");
});
Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime")); Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime"));
Assert.That(excpetion.AccessorSet, Is.False); Assert.That(excpetion.AccessorSet, Is.False);
@@ -1355,7 +1491,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void SiteLatitude_Get_WhenNotConnected_ThenThrowsException() public void SiteLatitude_Get_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.SiteLatitude; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.SiteLatitude;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLatitude Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLatitude Get"));
} }
@@ -1430,7 +1570,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void SiteLongitude_Get_WhenNotConnected_ThenThrowsException() public void SiteLongitude_Get_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.SiteLongitude; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.SiteLongitude;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLongitude Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLongitude Get"));
} }
@@ -1601,7 +1745,11 @@ namespace Meade.net.Telescope.UnitTests
{ {
ConnectTelescope(); ConnectTelescope();
var exception = Assert.Throws<InvalidOperationException>(() => { var result = _telescope.TargetDeclination; }); var exception = Assert.Throws<InvalidOperationException>(() =>
{
var result = _telescope.TargetDeclination;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Target not set")); Assert.That(exception.Message, Is.EqualTo("Target not set"));
} }
@@ -1675,7 +1823,11 @@ namespace Meade.net.Telescope.UnitTests
{ {
ConnectTelescope(); ConnectTelescope();
var exception = Assert.Throws<InvalidOperationException>(() => { var result = _telescope.TargetRightAscension; }); var exception = Assert.Throws<InvalidOperationException>(() =>
{
var result = _telescope.TargetRightAscension;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Target not set")); Assert.That(exception.Message, Is.EqualTo("Target not set"));
} }
@@ -1772,7 +1924,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void UTCDate_Get_WhenNotConnected_ThenThrowsException() public void UTCDate_Get_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.UTCDate; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.UTCDate;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: UTCDate Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: UTCDate Get"));
} }
@@ -2057,7 +2213,6 @@ namespace Meade.net.Telescope.UnitTests
slewCounter++; slewCounter++;
if (slewCounter <= iterations) if (slewCounter <= iterations)
return "|"; return "|";
else
return ""; return "";
}); });
@@ -2126,7 +2281,6 @@ namespace Meade.net.Telescope.UnitTests
slewCounter++; slewCounter++;
if (slewCounter <= iterations) if (slewCounter <= iterations)
return "|"; return "|";
else
return ""; return "";
}); });
@@ -2197,7 +2351,7 @@ namespace Meade.net.Telescope.UnitTests
_astroMathsMock _astroMathsMock
.Setup(x => x.ConvertHozToEq(It.IsAny<DateTime>(), It.IsAny<double>(), It.IsAny<double>(), .Setup(x => x.ConvertHozToEq(It.IsAny<DateTime>(), It.IsAny<double>(), It.IsAny<double>(),
It.IsAny<HorizonCoordinates>())).Returns(new EquatorialCoordinates(){ Declination = declination, RightAscension = rightAscension }); It.IsAny<HorizonCoordinates>())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension });
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0");
@@ -2231,7 +2385,7 @@ namespace Meade.net.Telescope.UnitTests
_astroMathsMock _astroMathsMock
.Setup(x => x.ConvertHozToEq(It.IsAny<DateTime>(), It.IsAny<double>(), It.IsAny<double>(), .Setup(x => x.ConvertHozToEq(It.IsAny<DateTime>(), It.IsAny<double>(), It.IsAny<double>(),
It.IsAny<HorizonCoordinates>())).Returns(new EquatorialCoordinates() { Declination = declination, RightAscension = rightAscension }); It.IsAny<HorizonCoordinates>())).Returns(new EquatorialCoordinates { Declination = declination, RightAscension = rightAscension });
_sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0"); _sharedResourcesWrapperMock.Setup(x => x.SendChar(":MS#")).Returns("0");
@@ -2242,7 +2396,6 @@ namespace Meade.net.Telescope.UnitTests
slewCounter++; slewCounter++;
if (slewCounter <= iterations) if (slewCounter <= iterations)
return "|"; return "|";
else
return ""; return "";
}); });
@@ -2257,7 +2410,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void Azimuth_WhenNotConnected_ThenThrowsException() public void Azimuth_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.Azimuth; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.Azimuth;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Azimuth Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Azimuth Get"));
} }
@@ -2298,7 +2455,11 @@ namespace Meade.net.Telescope.UnitTests
[Test] [Test]
public void Altitude_WhenNotConnected_ThenThrowsException() public void Altitude_WhenNotConnected_ThenThrowsException()
{ {
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.Altitude; }); var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _telescope.Altitude;
Assert.Fail($"{result} should not have returned");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Altitude Get")); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Altitude Get"));
} }
@@ -2359,4 +2520,3 @@ namespace Meade.net.Telescope.UnitTests
} }
} }
} }
;
+8 -4
View File
@@ -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>
+6 -5
View File
@@ -9,7 +9,7 @@ namespace ASCOM.Meade.net.AstroMaths
//returns the decimal hour angle for given right ascension on a given datetime for a given logitude. //returns the decimal hour angle for given right ascension on a given datetime for a given logitude.
public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension) public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension)
{ {
var ut = DateTimeToDecimalHours( utcDateTime); //var ut = DateTimeToDecimalHours( utcDateTime);
var gst = UTtoGst( utcDateTime); var gst = UTtoGst( utcDateTime);
var lst = GsTtoLst( gst, longitude); var lst = GsTtoLst( gst, longitude);
var raHours = rightAscension; var raHours = rightAscension;
@@ -82,10 +82,11 @@ namespace ASCOM.Meade.net.AstroMaths
var upperA = Math.Atan2(y, x); var upperA = Math.Atan2(y, x);
var upperB = RadiansToDegrees(upperA); var upperB = RadiansToDegrees(upperA);
var horizonCoordinates = new HorizonCoordinates(); var horizonCoordinates = new HorizonCoordinates
horizonCoordinates.Altitude = RadiansToDegrees(Math.Asin(sinA)); {
Altitude = RadiansToDegrees(Math.Asin(sinA)), Azimuth = upperB
};
horizonCoordinates.Azimuth = upperB;
if (upperB < 0) if (upperB < 0)
{ {
@@ -106,7 +107,7 @@ namespace ASCOM.Meade.net.AstroMaths
public double RadiansToDegrees(double radians) public double RadiansToDegrees(double radians)
{ {
double degrees = (180 / Math.PI) * radians; double degrees = (180 / Math.PI) * radians;
return (degrees); return degrees;
} }
//todo convert to extension method //todo convert to extension method
@@ -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">
@@ -152,7 +152,6 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<Content Include="ASCOM.ico" /> <Content Include="ASCOM.ico" />
<Content Include="ReadMe.htm" />
<None Include="Resources\ASCOM.bmp" /> <None Include="Resources\ASCOM.bmp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+52 -19
View File
@@ -8,10 +8,16 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Globalization;
using System.Resources;
using System.Runtime.CompilerServices;
namespace ASCOM.Meade.net.Properties { namespace ASCOM.Meade.net.Properties {
using System;
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
@@ -19,27 +25,27 @@ namespace ASCOM.Meade.net.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [DebuggerNonUserCode()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [CompilerGenerated()]
internal class Resources { internal class Resources {
private static global::System.Resources.ResourceManager resourceMan; private static ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() { internal Resources() {
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
@@ -50,8 +56,8 @@ namespace ASCOM.Meade.net.Properties {
/// Overrides the current thread's CurrentUICulture property for all /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
@@ -63,20 +69,47 @@ namespace ASCOM.Meade.net.Properties {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap ASCOM { internal static Bitmap ASCOM {
get { get {
object obj = ResourceManager.GetObject("ASCOM", resourceCulture); object obj = ResourceManager.GetObject("ASCOM", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((Bitmap)(obj));
} }
} }
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary> /// </summary>
internal static System.Drawing.Icon DefaultIcon { internal static Icon DefaultIcon {
get { get {
object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture); object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture);
return ((System.Drawing.Icon)(obj)); return ((Icon)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to Site out of range.
/// </summary>
internal static string Telescope_GetSiteName_Site_out_of_range {
get {
return ResourceManager.GetString("Telescope_GetSiteName_Site_out_of_range", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Site cannot be higher than 4.
/// </summary>
internal static string Telescope_SelectSite_Site_cannot_be_higher_than_4 {
get {
return ResourceManager.GetString("Telescope_SelectSite_Site_cannot_be_higher_than_4", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Site cannot be lower than 1.
/// </summary>
internal static string Telescope_SelectSite_Site_cannot_be_lower_than_1 {
get {
return ResourceManager.GetString("Telescope_SelectSite_Site_cannot_be_lower_than_1", resourceCulture);
} }
} }
} }
@@ -124,4 +124,13 @@
<data name="DefaultIcon" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="DefaultIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ASCOM.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\ASCOM.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Telescope_SelectSite_Site_cannot_be_lower_than_1" xml:space="preserve">
<value>Site cannot be lower than 1</value>
</data>
<data name="Telescope_SelectSite_Site_cannot_be_higher_than_4" xml:space="preserve">
<value>Site cannot be higher than 4</value>
</data>
<data name="Telescope_GetSiteName_Site_out_of_range" xml:space="preserve">
<value>Site out of range</value>
</data>
</root> </root>
+8 -4
View File
@@ -8,14 +8,18 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using System.CodeDom.Compiler;
using System.Configuration;
using System.Runtime.CompilerServices;
namespace ASCOM.Meade.net.Properties { namespace ASCOM.Meade.net.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [CompilerGenerated()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(Synchronized(new Settings())));
public static Settings Default { public static Settings Default {
get { get {
+18 -22
View File
@@ -1,7 +1,7 @@
using System.Runtime.InteropServices; using System.Collections;
using ASCOM.DeviceInterface; using System.Runtime.InteropServices;
using System.Collections;
using System.Threading; using System.Threading;
using ASCOM.DeviceInterface;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -19,17 +19,14 @@ namespace ASCOM.Meade.net
[ComVisible(true)] [ComVisible(true)]
public class Rate : IRate public class Rate : IRate
{ {
private double _maximum = 0;
private double _minimum = 0;
// //
// Default constructor - Internal prevents public creation // Default constructor - Internal prevents public creation
// of instances. These are values for AxisRates. // of instances. These are values for AxisRates.
// //
internal Rate(double minimum, double maximum) internal Rate(double minimum, double maximum)
{ {
_maximum = maximum; Maximum = maximum;
_minimum = minimum; Minimum = minimum;
} }
#region Implementation of IRate #region Implementation of IRate
@@ -39,17 +36,9 @@ namespace ASCOM.Meade.net
// TODO Add any required object cleanup here // TODO Add any required object cleanup here
} }
public double Maximum public double Maximum { get; set; }
{
get => _maximum;
set => _maximum = value;
}
public double Minimum public double Minimum { get; set; }
{
get => _minimum;
set => _minimum = value;
}
#endregion #endregion
} }
@@ -96,12 +85,12 @@ namespace ASCOM.Meade.net
// TODO Initialize this array with any Primary axis rates that your driver may provide // TODO Initialize this array with any Primary axis rates that your driver may provide
// Example: m_Rates = new Rate[] { new Rate(10.5, 30.2), new Rate(54.0, 43.6) } // Example: m_Rates = new Rate[] { new Rate(10.5, 30.2), new Rate(54.0, 43.6) }
//this.rates = new Rate[0]; //this.rates = new Rate[0];
_rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; _rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break; break;
case TelescopeAxes.axisSecondary: case TelescopeAxes.axisSecondary:
// TODO Initialize this array with any Secondary axis rates that your driver may provide // TODO Initialize this array with any Secondary axis rates that your driver may provide
//this.rates = new Rate[0]; //this.rates = new Rate[0];
_rates = new Rate[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) }; _rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break; break;
case TelescopeAxes.axisTertiary: case TelescopeAxes.axisTertiary:
// TODO Initialize this array with any Tertiary axis rates that your driver may provide // TODO Initialize this array with any Tertiary axis rates that your driver may provide
@@ -152,7 +141,7 @@ namespace ASCOM.Meade.net
private readonly DriveRates[] _trackingRates; private readonly DriveRates[] _trackingRates;
// this is used to make the index thread safe // this is used to make the index thread safe
private readonly ThreadLocal<int> _pos = new ThreadLocal<int>(() => { return -1; }); private readonly ThreadLocal<int> _pos = new ThreadLocal<int>(() => -1);
private static readonly object LockObj = new object(); private static readonly object LockObj = new object();
// //
@@ -175,9 +164,13 @@ namespace ASCOM.Meade.net
public int Count => _trackingRates.Length; public int Count => _trackingRates.Length;
public IEnumerator GetEnumerator() public IEnumerator GetEnumerator()
{
lock (LockObj)
{ {
_pos.Value = -1; _pos.Value = -1;
return this as IEnumerator; }
return this;
} }
public void Dispose() public void Dispose()
@@ -219,9 +212,12 @@ namespace ASCOM.Meade.net
} }
public void Reset() public void Reset()
{
lock (LockObj)
{ {
_pos.Value = -1; _pos.Value = -1;
} }
}
#endregion #endregion
} }
#endregion #endregion
-147
View File
@@ -1,147 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE>Untitled Document</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Win32)">
<META NAME="CREATED" CONTENT="0;0">
<META NAME="CHANGEDBY" CONTENT="Chris Rowland">
<META NAME="CHANGED" CONTENT="20110918;14150500">
<STYLE TYPE="text/css">
<!--
@page { margin: 2cm }
P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
TD P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
H3 { font-family: "Arial", "Helvetica", sans-serif }
H2 { font-family: "Arial", "Helvetica", sans-serif }
H4 { font-family: "Arial", "Helvetica", sans-serif }
TD P.note { background: #33ffff; font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
TD P.underline { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal; text-decoration: underline }
-->
</STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
<TR>
<TD>
<H2>ASCOM Telescope Driver (C#)</H2>
</TD>
</TR>
</TABLE>
<P><BR><BR>
</P>
<H4>You have just created the skeleton of an ASCOM
Telescope driver in C#. It produces an in-process
(assembly) based driver.</H4>
<HR>
<P CLASS="note">Prior to developing your first driver, please
familiarize yourself with the <A HREF="http://ascom-standards.org/developer.html">developer
information we've provided</A> at the ASCOM Initiative web site
(internet required).
</P>
<P CLASS="underline">You must do the following in order to complete
your implementation:</P>
<OL>
<LI><P STYLE="margin-bottom: 0cm">Switch to the Debug configuration
and build the template now. It should build without errors.
</P>
<LI><P STYLE="margin-bottom: 0cm">Add a test project to the
solution. There are templates that can be used to add either a
console or a Windows Forms application:</P>
</OL>
<UL>
<LI><P STYLE="margin-bottom: 0cm">Select the <FONT FACE="Consolas, monospace">ASCOM
Test Forms App (CS)</FONT> or <FONT FACE="Consolas, monospace">ASCOM
Test Console App (CS)</FONT> template.</P>
<LI><P STYLE="margin-bottom: 0cm">Set a name for the test
application and click on OK.</P>
<LI><P STYLE="margin-bottom: 0cm">In the Wizard: set the same device
type and model name as for the driver and select Create to build the
test project.</P>
<LI><P STYLE="margin-bottom: 0cm">Set the Test Application to Run at
Startup.</P>
<LI><P STYLE="margin-bottom: 0cm">Click on Debug and the test
application should run. You should be able to select your
application in the chooser. Selecting Properties should show the
default setup dialog for your driver.</P>
<LI><P STYLE="margin-bottom: 0cm">Trying to continue will generate
errors because the additional properties have not been implemented.</P>
</UL>
<OL START=4>
<LI><P STYLE="margin-bottom: 0cm">Go through the Driver.cs file and
replace the System.NotImplemented exceptions with code to implement
your driver's functionality. See the ASCOM ITelescopeV3
spec. If a property or method is not implemented in your driver the
System.NotImplemented exception must be replaced by an
ASCOM.PropertyNotImplemented or ASCOM.MethodNotImplemented
exception.</P>
<LI><P>Customize the Setup Dialog (SetupDialogForm) to provide the
settings and other controls for your driver. You can bind settings
directly to controls on your dialog form, there's no need to manage
settings manually. A custom Settings class takes care of managing
your settings behind the scenes.
</P>
</OL>
<H3>Notes:</H3>
<UL>
<LI><P STYLE="margin-bottom: 0cm">Successfully building the driver,
as well as using <FONT FACE="Lucida Console, Courier New, Courier, monospace">regasm</FONT>
on the assembly, registers it for both COM and ASCOM (the Chooser).
See the code in the ASCOM Registration region of Driver.vb.
</P>
<LI><P STYLE="margin-bottom: 0cm">Doing a Clean for the project, as
well doing a <FONT FACE="Lucida Console, Courier New, Courier, monospace">regasm
-u</FONT> on the assembly, unregisters it for both COM and ASCOM
(the Chooser).
</P>
<LI><P>Place a breakpoint in your driver class constructor, then
start debugging (go, F5). Your breakpoint will be hit when the test
application creates an instance of your driver (after selecting it
in the Chooser). You can now single step, examine variables, etc.
Please review the test application and make changes and additions to
activate various parts of your driver during debugging.</P>
<LI><P>The project's Debug configuration is already configured (The
test application creates an instance of your driver (after selecting
it in the Chooser). You can now single step, examine variables, etc.
Please review the test application and feel free to make changes and
additions to activate various parts of your driver during debugging.
</P>
</UL>
<DIV ALIGN=RIGHT>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
<TR>
<TD>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
<TR>
<TD>
<H3>ASCOM Initiative</H3>
</TD>
<TD>
<IMG SRC="ASCOM.png" NAME="graphics1" ALIGN=RIGHT WIDTH=48 HEIGHT=56 BORDER=0></TD>
</TR>
</TABLE>
<P><BR><BR>
</P>
</TD>
</TR>
<TR>
<TD>
<P>The ASCOM Initiative consists of a group of astronomy software
developers and instrument vendors whose goals are to promote the
driver/client model and scripting automation.
</P>
<P>See the <A HREF="http://ascom-standards.org/" TARGET="browser">ASCOM
web site</A> for more information. Please participate in the
<A HREF="http://tech.groups.yahoo.com/group/ASCOM-Talk" TARGET="browser">ASCOM-Talk
Yahoo Group</A>.
</P>
</TD>
</TR>
</TABLE>
</DIV>
<P><BR><BR>
</P><P>
<BR><BR>
</P>
</BODY>
</HTML>
+208 -115
View File
@@ -1,15 +1,18 @@
#define Telescope #define Telescope
using System; using System;
using System.Runtime.InteropServices;
using ASCOM.Astrometry.AstroUtils;
using ASCOM.Utilities;
using ASCOM.DeviceInterface;
using System.Collections; using System.Collections;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using ASCOM.Astrometry;
using ASCOM.Astrometry.AstroUtils;
using ASCOM.Astrometry.NOVAS;
using ASCOM.DeviceInterface;
using ASCOM.Meade.net.AstroMaths; using ASCOM.Meade.net.AstroMaths;
using ASCOM.Meade.net.Properties;
using ASCOM.Meade.net.Wrapper; using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces; using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
@@ -30,7 +33,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
{ {
@@ -99,8 +102,6 @@ namespace ASCOM.Meade.net
private double _guideRate; private double _guideRate;
private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
private void Initialise() private void Initialise()
{ {
//todo move the TraceLogger out to a factory class. //todo move the TraceLogger out to a factory class.
@@ -152,9 +153,7 @@ namespace ASCOM.Meade.net
get get
{ {
LogMessage("SupportedActions Get", "Returning empty arraylist"); LogMessage("SupportedActions Get", "Returning empty arraylist");
var supportedActions = new ArrayList(); var supportedActions = new ArrayList {"handbox", "site"};
supportedActions.Add("handbox");
supportedActions.Add("site");
return supportedActions; return supportedActions;
} }
} }
@@ -243,6 +242,8 @@ namespace ASCOM.Meade.net
var parames = actionParameters.ToLower().Split(' '); var parames = actionParameters.ToLower().Split(' ');
switch (parames[0]) switch (parames[0])
{ {
case "count":
return "4";
case "select": case "select":
switch (parames[1]) switch (parames[1])
{ {
@@ -275,7 +276,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])
{ {
@@ -372,12 +372,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;
@@ -386,15 +385,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");
}
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;
} }
} }
@@ -406,12 +417,30 @@ 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 SetTelescopePrecision(string propertyName)
{
switch (_precision.ToLower())
{
case "high":
TelescopePointingPrecision(true);
LogMessage(propertyName, "High precision slewing selected");
break;
case "low":
TelescopePointingPrecision(false);
LogMessage(propertyName, "Low precision slewing selected");
break;
default:
LogMessage(propertyName, "Precision slewing unchanged");
break;
}
}
public bool IsNewPulseGuidingSupported() public bool IsNewPulseGuidingSupported()
{ {
if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497) if (_sharedResourcesWrapper.ProductName == TelescopeList.Autostar497)
@@ -427,6 +456,15 @@ namespace ASCOM.Meade.net
return false; return false;
} }
private bool IsLongFormatSupported()
{
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200CLASSIC)
{
return false;
}
return true;
}
private bool IsGuideRateSettingSupported() private bool IsGuideRateSettingSupported()
{ {
if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) if (_sharedResourcesWrapper.ProductName == TelescopeList.LX200GPS)
@@ -440,11 +478,18 @@ namespace ASCOM.Meade.net
{ {
var currentVersion = _sharedResourcesWrapper.FirmwareVersion; var currentVersion = _sharedResourcesWrapper.FirmwareVersion;
var comparison = String.Compare(currentVersion, minVersion, StringComparison.Ordinal); var comparison = String.Compare(currentVersion, minVersion, StringComparison.Ordinal);
return (comparison >= 0); return comparison >= 0;
} }
private bool IsLongFormat { get; set; }
public void SetLongFormat(bool setLongFormat) public void SetLongFormat(bool setLongFormat)
{ {
IsLongFormat = false;
if (!IsLongFormatSupported())
return;
_sharedResourcesWrapper.Lock(() => _sharedResourcesWrapper.Lock(() =>
{ {
var result = _sharedResourcesWrapper.SendString(":GZ#"); var result = _sharedResourcesWrapper.SendString(":GZ#");
@@ -452,9 +497,9 @@ namespace ASCOM.Meade.net
//Returns: DDD*MM# or DDD*MMSS# //Returns: DDD*MM# or DDD*MMSS#
//The current telescope Azimuth depending on the selected precision. //The current telescope Azimuth depending on the selected precision.
bool isLongFormat = result.Length > 6; IsLongFormat = result.Length > 6;
if (isLongFormat != setLongFormat) if (IsLongFormat != setLongFormat)
{ {
_utilities.WaitForMilliseconds(500); _utilities.WaitForMilliseconds(500);
_sharedResourcesWrapper.SendBlind(":U#"); _sharedResourcesWrapper.SendBlind(":U#");
@@ -466,14 +511,53 @@ namespace ASCOM.Meade.net
}); });
} }
private bool TogglePrecision()
{
LogMessage("TogglePrecision", "Toggling slewing precision");
var result = _sharedResourcesWrapper.SendChar(":P#");
//:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target.
//Returns: <string>
//“HIGH PRECISION” Current setting after this command.
//“LOW PRECISION” Current setting after this command.
int throwAwayCharacters = "LOW PRECISION".Length - 1;
LogMessage("TogglePrecision", $"Result: {result}");
bool highPrecision = false;
switch (result)
{
case "H":
highPrecision = true;
throwAwayCharacters = "HIGH PRECISION".Length - 1;
break;
}
_sharedResourcesWrapper.ReadCharacters(throwAwayCharacters);
//Make sure that the buffers are cleared out.
_sharedResourcesWrapper.SendBlind("#");
return highPrecision;
}
private void TelescopePointingPrecision(bool high)
{
var currentPrecision = TogglePrecision();
while (currentPrecision != high)
{
currentPrecision = TogglePrecision();
}
}
public void SelectSite(int site) public void SelectSite(int site)
{ {
CheckConnected("SelectSite"); CheckConnected("SelectSite");
if (site < 1) if (site < 1)
throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1"); throw new ArgumentOutOfRangeException(nameof(site),site,Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
else if (site > 4) if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
_sharedResourcesWrapper.SendBlind($":W{site}#"); _sharedResourcesWrapper.SendBlind($":W{site}#");
//:W<n># //:W<n>#
@@ -486,9 +570,9 @@ namespace ASCOM.Meade.net
CheckConnected("SetSiteName"); CheckConnected("SetSiteName");
if (site < 1) if (site < 1)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1"); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
else if (site > 4) if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
string command = String.Empty; string command = String.Empty;
switch (site) switch (site)
@@ -540,9 +624,9 @@ namespace ASCOM.Meade.net
CheckConnected("GetSiteName"); CheckConnected("GetSiteName");
if (site < 1) if (site < 1)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1"); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
else if (site > 4) if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4"); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
switch (site) switch (site)
{ {
@@ -568,7 +652,7 @@ namespace ASCOM.Meade.net
//A # terminated string with the name of the requested site. //A # terminated string with the name of the requested site.
} }
throw new ArgumentOutOfRangeException("site", site, "Site out of range"); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range);
} }
public string Description public string Description
@@ -765,7 +849,7 @@ namespace ASCOM.Meade.net
UtcDateTime = UTCDate, UtcDateTime = UTCDate,
SiteLongitude = SiteLongitude, SiteLongitude = SiteLongitude,
SiteLatitude = SiteLatitude, SiteLatitude = SiteLatitude,
EquatorialCoordinates = new EquatorialCoordinates() EquatorialCoordinates = new EquatorialCoordinates
{ {
RightAscension = RightAscension, RightAscension = RightAscension,
Declination = Declination Declination = Declination
@@ -800,12 +884,12 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("AtHome", "Get - " + false.ToString()); LogMessage("AtHome", "Get - " + false);
return false; return false;
} }
} }
private bool _atPark = false; private bool _atPark;
public bool AtPark public bool AtPark
{ {
@@ -819,7 +903,7 @@ namespace ASCOM.Meade.net
public IAxisRates AxisRates(TelescopeAxes axis) public IAxisRates AxisRates(TelescopeAxes axis)
{ {
LogMessage("AxisRates", "Get - " + axis.ToString()); LogMessage("AxisRates", "Get - " + axis);
return new AxisRates(axis); return new AxisRates(axis);
} }
@@ -849,14 +933,14 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanFindHome", "Get - " + false.ToString()); LogMessage("CanFindHome", "Get - " + false);
return false; return false;
} }
} }
public bool CanMoveAxis(TelescopeAxes axis) public bool CanMoveAxis(TelescopeAxes axis)
{ {
LogMessage("CanMoveAxis", "Get - " + axis.ToString()); LogMessage("CanMoveAxis", "Get - " + axis);
switch (axis) switch (axis)
{ {
case TelescopeAxes.axisPrimary: return true; //RA or AZ case TelescopeAxes.axisPrimary: return true; //RA or AZ
@@ -870,7 +954,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanPark", "Get - " + true.ToString()); LogMessage("CanPark", "Get - " + true);
return true; return true;
} }
} }
@@ -879,7 +963,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanPulseGuide", "Get - " + true.ToString()); LogMessage("CanPulseGuide", "Get - " + true);
return true; return true;
} }
} }
@@ -888,7 +972,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSetDeclinationRate", "Get - " + false.ToString()); LogMessage("CanSetDeclinationRate", "Get - " + false);
return false; return false;
} }
} }
@@ -901,7 +985,7 @@ namespace ASCOM.Meade.net
var canSetGuideRate = IsGuideRateSettingSupported(); var canSetGuideRate = IsGuideRateSettingSupported();
LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate.ToString()); LogMessage("CanSetGuideRates", "Get - " + canSetGuideRate);
return canSetGuideRate; return canSetGuideRate;
} }
} }
@@ -910,7 +994,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSetPark", "Get - " + false.ToString()); LogMessage("CanSetPark", "Get - " + false);
return false; return false;
} }
} }
@@ -919,7 +1003,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSetPierSide", "Get - " + false.ToString()); LogMessage("CanSetPierSide", "Get - " + false);
return false; return false;
} }
} }
@@ -928,7 +1012,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSetRightAscensionRate", "Get - " + false.ToString()); LogMessage("CanSetRightAscensionRate", "Get - " + false);
return false; return false;
} }
} }
@@ -937,7 +1021,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSetTracking", "Get - " + true.ToString()); LogMessage("CanSetTracking", "Get - " + true);
return true; return true;
} }
} }
@@ -946,7 +1030,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSlew", "Get - " + true.ToString()); LogMessage("CanSlew", "Get - " + true);
return true; return true;
} }
} }
@@ -955,7 +1039,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSlewAltAz", "Get - " + true.ToString()); LogMessage("CanSlewAltAz", "Get - " + true);
return true; return true;
} }
} }
@@ -964,7 +1048,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSlewAltAzAsync", "Get - " + true.ToString()); LogMessage("CanSlewAltAzAsync", "Get - " + true);
return true; return true;
} }
} }
@@ -973,7 +1057,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSlewAsync", "Get - " + true.ToString()); LogMessage("CanSlewAsync", "Get - " + true);
return true; return true;
} }
} }
@@ -982,7 +1066,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSync", "Get - " + true.ToString()); LogMessage("CanSync", "Get - " + true);
return true; return true;
} }
} }
@@ -991,7 +1075,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanSyncAltAz", "Get - " + false.ToString()); LogMessage("CanSyncAltAz", "Get - " + false);
return false; return false;
} }
} }
@@ -1000,7 +1084,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
LogMessage("CanUnpark", "Get - " + false.ToString()); LogMessage("CanUnpark", "Get - " + false);
return false; return false;
} }
} }
@@ -1031,6 +1115,7 @@ namespace ASCOM.Meade.net
LogMessage("DeclinationRate", "Get - " + declination.ToString(CultureInfo.InvariantCulture)); LogMessage("DeclinationRate", "Get - " + declination.ToString(CultureInfo.InvariantCulture));
return declination; return declination;
} }
// ReSharper disable once ValueParameterNotUsed
set set
{ {
LogMessage("DeclinationRate Set", "Not implemented"); LogMessage("DeclinationRate Set", "Not implemented");
@@ -1051,6 +1136,7 @@ namespace ASCOM.Meade.net
LogMessage("DoesRefraction Get", "Not implemented"); LogMessage("DoesRefraction Get", "Not implemented");
throw new PropertyNotImplementedException("DoesRefraction", false); throw new PropertyNotImplementedException("DoesRefraction", false);
} }
// ReSharper disable once ValueParameterNotUsed
set set
{ {
LogMessage("DoesRefraction Set", "Not implemented"); LogMessage("DoesRefraction Set", "Not implemented");
@@ -1063,7 +1149,7 @@ namespace ASCOM.Meade.net
get get
{ {
EquatorialCoordinateType equatorialSystem = EquatorialCoordinateType.equTopocentric; EquatorialCoordinateType equatorialSystem = EquatorialCoordinateType.equTopocentric;
LogMessage("DeclinationRate", "Get - " + equatorialSystem.ToString()); LogMessage("DeclinationRate", "Get - " + equatorialSystem);
return equatorialSystem; return equatorialSystem;
} }
} }
@@ -1093,10 +1179,10 @@ namespace ASCOM.Meade.net
if (!value.InRange(0, 15.0417)) if (!value.InRange(0, 15.0417))
{ {
throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec"); throw new InvalidValueException(propertyName, value.ToString(CultureInfo.CurrentCulture), $"{0.ToString(CultureInfo.CurrentCulture)} to {15.0417.ToString(CultureInfo.CurrentCulture)}”/sec");
} }
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)"); LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)");
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#"); _sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
//:RgSS.S# //:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking //Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
@@ -1302,7 +1388,7 @@ namespace ASCOM.Meade.net
if (_userNewerPulseGuiding && duration < 10000) if (_userNewerPulseGuiding && duration < 10000)
{ {
LogMessage("PulseGuide", $"Using new pulse guiding technique"); LogMessage("PulseGuide", "Using new pulse guiding technique");
_sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#"); _sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#");
//:MgnDDDD# //:MgnDDDD#
//:MgsDDDD# //:MgsDDDD#
@@ -1316,7 +1402,7 @@ namespace ASCOM.Meade.net
} }
else else
{ {
LogMessage("PulseGuide", $"Using old pulse guiding technique"); LogMessage("PulseGuide", "Using old pulse guiding technique");
_sharedResourcesWrapper.Lock(() => _sharedResourcesWrapper.Lock(() =>
{ {
_sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate _sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate
@@ -1370,6 +1456,7 @@ namespace ASCOM.Meade.net
LogMessage("RightAscensionRate", "Get - " + rightAscensionRate.ToString(CultureInfo.InvariantCulture)); LogMessage("RightAscensionRate", "Get - " + rightAscensionRate.ToString(CultureInfo.InvariantCulture));
return rightAscensionRate; return rightAscensionRate;
} }
// ReSharper disable once ValueParameterNotUsed
set set
{ {
LogMessage("RightAscensionRate Set", "Not implemented"); LogMessage("RightAscensionRate Set", "Not implemented");
@@ -1390,6 +1477,7 @@ namespace ASCOM.Meade.net
LogMessage("SideOfPier Get", "Not implemented"); LogMessage("SideOfPier Get", "Not implemented");
throw new PropertyNotImplementedException("SideOfPier", false); throw new PropertyNotImplementedException("SideOfPier", false);
} }
// ReSharper disable once ValueParameterNotUsed
set set
{ {
LogMessage("SideOfPier Set", "Not implemented"); LogMessage("SideOfPier Set", "Not implemented");
@@ -1403,13 +1491,13 @@ namespace ASCOM.Meade.net
{ {
// Now using NOVAS 3.1 // Now using NOVAS 3.1
double siderealTime = 0.0; double siderealTime = 0.0;
using (var novas = new Astrometry.NOVAS.NOVAS31()) using (var novas = new NOVAS31())
{ {
var jd = _utilities.DateUTCToJulian(DateTime.UtcNow); var jd = _utilities.DateUTCToJulian(DateTime.UtcNow);
novas.SiderealTime(jd, 0, novas.DeltaT(jd), novas.SiderealTime(jd, 0, novas.DeltaT(jd),
Astrometry.GstType.GreenwichApparentSiderealTime, GstType.GreenwichApparentSiderealTime,
Astrometry.Method.EquinoxBased, Method.EquinoxBased,
Astrometry.Accuracy.Reduced, ref siderealTime); Accuracy.Reduced, ref siderealTime);
} }
// Allow for the longitude // Allow for the longitude
@@ -1430,6 +1518,7 @@ namespace ASCOM.Meade.net
LogMessage("SiteElevation Get", "Not implemented"); LogMessage("SiteElevation Get", "Not implemented");
throw new PropertyNotImplementedException("SiteElevation", false); throw new PropertyNotImplementedException("SiteElevation", false);
} }
// ReSharper disable once ValueParameterNotUsed
set set
{ {
LogMessage("SiteElevation Set", "Not implemented"); LogMessage("SiteElevation Set", "Not implemented");
@@ -1544,6 +1633,7 @@ namespace ASCOM.Meade.net
LogMessage("SlewSettleTime Get", "Not implemented"); LogMessage("SlewSettleTime Get", "Not implemented");
throw new PropertyNotImplementedException("SlewSettleTime", false); throw new PropertyNotImplementedException("SlewSettleTime", false);
} }
// ReSharper disable once ValueParameterNotUsed
set set
{ {
LogMessage("SlewSettleTime Set", "Not implemented"); LogMessage("SlewSettleTime Set", "Not implemented");
@@ -1564,63 +1654,63 @@ namespace ASCOM.Meade.net
} }
} }
private double TargetAltitude //private double TargetAltitude
{ //{
set // set
{ // {
if (value > 90) // if (value > 90)
throw new InvalidValueException("Altitude cannot be greater than 90."); // throw new InvalidValueException("Altitude cannot be greater than 90.");
if (value < 0) // if (value < 0)
throw new InvalidValueException("Altitide cannot be less than 0."); // throw new InvalidValueException("Altitide cannot be less than 0.");
CheckConnected("TargetAltitude Set"); // CheckConnected("TargetAltitude Set");
//todo this serial string does not work. Calculate the EQ version instead. // //todo this serial string does not work. Calculate the EQ version instead.
var dms = _utilities.DegreesToDMS(value, "*", "'", "",0); // var dms = _utilities.DegreesToDMS(value, "*", "'", "",0);
var s = value < 0 ? string.Empty : "+"; // var s = value < 0 ? string.Empty : "+";
var result = _sharedResourcesWrapper.SendChar($":Sa{s}{dms}#"); // var result = _sharedResourcesWrapper.SendChar($":Sa{s}{dms}#");
//:SasDD*MM# // //:SasDD*MM#
//Set target object altitude to sDD*MM# or sDD*MMSS# [LX 16”, Autostar, Autostar II] // //Set target object altitude to sDD*MM# or sDD*MMSS# [LX 16”, Autostar, Autostar II]
//Returns: // //Returns:
//1 Object within slew range // //1 Object within slew range
//0 Object out of slew range // //0 Object out of slew range
if (result == "0") // if (result == "0")
throw new InvalidOperationException("Target altitude out of slew range"); // throw new InvalidOperationException("Target altitude out of slew range");
} // }
} //}
private double TargetAzimuth //private double TargetAzimuth
{ //{
set // set
{ // {
if (value >= 360) // if (value >= 360)
throw new InvalidValueException("Azimuth cannot be 360 or higher."); // throw new InvalidValueException("Azimuth cannot be 360 or higher.");
if (value < 0) // if (value < 0)
throw new InvalidValueException("Azimuth cannot be less than 0."); // throw new InvalidValueException("Azimuth cannot be less than 0.");
CheckConnected("TargetAzimuth Set"); // CheckConnected("TargetAzimuth Set");
//todo this serial string does not work. Calculate the EQ version instead. // //todo this serial string does not work. Calculate the EQ version instead.
var dms = _utilitiesExtra.DegreesToDM(value, "*" ); // var dms = _utilitiesExtra.DegreesToDM(value, "*" );
var result = _sharedResourcesWrapper.SendChar($":Sz{dms}#"); // var result = _sharedResourcesWrapper.SendChar($":Sz{dms}#");
//:SzDDD*MM# // //:SzDDD*MM#
//Sets the target Object Azimuth[LX 16” and Autostar II only] // //Sets the target Object Azimuth[LX 16” and Autostar II only]
//Returns: // //Returns:
//0 Invalid // //0 Invalid
//1 - Valid // //1 - Valid
if (result == "0") // if (result == "0")
throw new InvalidOperationException("Target Azimuth out of slew range"); // throw new InvalidOperationException("Target Azimuth out of slew range");
} // }
} //}
public void SlewToAltAzAsync(double azimuth, double altitude) public void SlewToAltAzAsync(double azimuth, double altitude)
{ {
@@ -1640,9 +1730,7 @@ namespace ASCOM.Meade.net
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}"); LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
HorizonCoordinates altAz = new HorizonCoordinates(); HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude};
altAz.Azimuth = azimuth;
altAz.Altitude = altitude;
var utcDateTime = UTCDate; var utcDateTime = UTCDate;
var latitude = SiteLatitude; var latitude = SiteLatitude;
@@ -1957,12 +2045,13 @@ namespace ASCOM.Meade.net
} }
set set
{ {
LogMessage($"Tracking Set", $"{value}"); LogMessage("Tracking Set", $"{value}");
_tracking = value; _tracking = value;
} }
} }
private DriveRates _trackingRate = DriveRates.driveSidereal; private DriveRates _trackingRate = DriveRates.driveSidereal;
private string _precision;
public DriveRates TrackingRate public DriveRates TrackingRate
{ {
@@ -2025,7 +2114,7 @@ namespace ASCOM.Meade.net
LogMessage("TrackingRates", "Get - "); LogMessage("TrackingRates", "Get - ");
foreach (DriveRates driveRate in trackingRates) foreach (DriveRates driveRate in trackingRates)
{ {
LogMessage("TrackingRates", "Get - " + driveRate.ToString()); LogMessage("TrackingRates", "Get - " + driveRate);
} }
return trackingRates; return trackingRates;
} }
@@ -2058,18 +2147,20 @@ namespace ASCOM.Meade.net
LogMessage("UTCDate", "Get started"); LogMessage("UTCDate", "Get started");
TelescopeDateDetails telescopeDateDetails = _sharedResourcesWrapper.Lock(() => var telescopeDateDetails = _sharedResourcesWrapper.Lock(() =>
{ {
TelescopeDateDetails tdd = new TelescopeDateDetails(); var tdd = new TelescopeDateDetails
tdd.TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"); {
TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"),
//:GC# Get current date. //:GC# Get current date.
//Returns: MM/DD/YY# //Returns: MM/DD/YY#
//The current local calendar date for the telescope. //The current local calendar date for the telescope.
tdd.TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"); TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"),
//:GL# Get Local Time in 24 hour format //:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS# //Returns: HH:MM:SS#
//The Local Time in 24 - hour Format //The Local Time in 24 - hour Format
tdd.UtcCorrection = GetUtcCorrection(); UtcCorrection = GetUtcCorrection()
};
return tdd; return tdd;
}); });
@@ -2243,19 +2334,21 @@ 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;
_comPort = profileProperties.ComPort; _comPort = profileProperties.ComPort;
_guideRate = profileProperties.GuideRateArcSecondsPerSecond; _guideRate = profileProperties.GuideRateArcSecondsPerSecond;
_precision = profileProperties.Precision;
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}"); LogMessage("ReadProfile", $"Com Port: {_comPort}");
LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); LogMessage("ReadProfile", $"Guide Rate: {_guideRate}");
LogMessage("ReadProfile", $"Precision: {_precision}");
} }
internal void WriteProfile() private void WriteProfile()
{ {
var profileProperties = new ProfileProperties var profileProperties = new ProfileProperties
{ {
@@ -2273,7 +2366,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 void LogMessage(string identifier, string message, params object[] args) private 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);
+61 -93
View File
@@ -1,14 +1,13 @@
#define Focuser #define Focuser
using System; using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ASCOM.Utilities;
using ASCOM.DeviceInterface;
using System.Globalization;
using System.Collections; using System.Collections;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using ASCOM.DeviceInterface;
using ASCOM.Meade.net.Wrapper; using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces; using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
@@ -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,16 +65,25 @@ 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.
Tl = new TraceLogger("", "Meade.Generic.focusser"); _tl = new TraceLogger("", "Meade.Generic.focusser");
ReadProfile(); // Read device configuration from the ASCOM Profile store ReadProfile(); // Read device configuration from the ASCOM Profile store
@@ -100,17 +108,17 @@ namespace ASCOM.Meade.net
/// </summary> /// </summary>
public void SetupDialog() public void SetupDialog()
{ {
Tl.LogMessage("SetupDialog", "Opening setup dialog"); _tl.LogMessage("SetupDialog", "Opening setup dialog");
_sharedResourcesWrapper.SetupDialog(); _sharedResourcesWrapper.SetupDialog();
ReadProfile(); ReadProfile();
Tl.LogMessage("SetupDialog", "complete"); _tl.LogMessage("SetupDialog", "complete");
} }
public ArrayList SupportedActions public ArrayList SupportedActions
{ {
get get
{ {
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); _tl.LogMessage("SupportedActions Get", "Returning empty arraylist");
return new ArrayList(); return new ArrayList();
} }
} }
@@ -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,16 +157,15 @@ 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()
{ {
// Clean up the tracelogger and util objects // Clean up the tracelogger and util objects
Tl.Enabled = false; _tl.Enabled = false;
Tl.Dispose(); _tl.Dispose();
Tl = null; _tl = null;
} }
public bool Connected public bool Connected
@@ -170,7 +177,7 @@ namespace ASCOM.Meade.net
} }
set set
{ {
Tl.LogMessage("Connected", "Set {0}", value); _tl.LogMessage("Connected", "Set {0}", value);
if (value == IsConnected) if (value == IsConnected)
return; return;
@@ -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,49 +205,18 @@ 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*MMSS#
//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
get get
{ {
Tl.LogMessage("Description Get", DriverDescription); _tl.LogMessage("Description Get", DriverDescription);
return DriverDescription; return DriverDescription;
} }
} }
@@ -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;
} }
} }
@@ -287,7 +259,7 @@ namespace ASCOM.Meade.net
{ {
//string name = "Short driver name - please customise"; //string name = "Short driver name - please customise";
string name = DriverDescription; string name = DriverDescription;
Tl.LogMessage("Name Get", name); _tl.LogMessage("Name Get", name);
return name; return name;
} }
} }
@@ -300,18 +272,21 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("Absolute Get", false.ToString()); CheckConnected("Absolute Get");
_tl.LogMessage("Absolute Get", false.ToString());
return false; // This is a relative focuser return false; // This is a relative focuser
} }
} }
public void Halt() public void Halt()
{ {
Tl.LogMessage("Halt", "Halting"); _tl.LogMessage("Halt", "Halting");
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)
{ {
@@ -327,7 +302,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("IsMoving Get", false.ToString()); _tl.LogMessage("IsMoving Get", false.ToString());
return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True
} }
} }
@@ -336,12 +311,12 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("Link Get", Connected.ToString()); _tl.LogMessage("Link Get", Connected.ToString());
return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility
} }
set set
{ {
Tl.LogMessage("Link Set", value.ToString()); _tl.LogMessage("Link Set", value.ToString());
Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility
} }
} }
@@ -351,7 +326,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString()); _tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString());
return _maxIncrement; // Maximum change in one move return _maxIncrement; // Maximum change in one move
} }
} }
@@ -361,14 +336,14 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("MaxStep Get", _maxStep.ToString()); _tl.LogMessage("MaxStep Get", _maxStep.ToString());
return _maxStep; return _maxStep;
} }
} }
public void Move(int position) public void Move(int position)
{ {
Tl.LogMessage("Move", position.ToString()); _tl.LogMessage("Move", position.ToString());
CheckConnected("Move"); CheckConnected("Move");
//todo implement backlash compensation //todo implement backlash compensation
@@ -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)
{ {
@@ -438,7 +405,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("StepSize Get", "Not implemented"); _tl.LogMessage("StepSize Get", "Not implemented");
throw new PropertyNotImplementedException("StepSize", false); throw new PropertyNotImplementedException("StepSize", false);
} }
} }
@@ -447,12 +414,13 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
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");
throw new PropertyNotImplementedException("TempComp", false); throw new PropertyNotImplementedException("TempComp", false);
} }
} }
@@ -461,7 +429,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("TempCompAvailable Get", false.ToString()); _tl.LogMessage("TempCompAvailable Get", false.ToString());
return false; // Temperature compensation is not available in this driver return false; // Temperature compensation is not available in this driver
} }
} }
@@ -470,7 +438,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("Temperature Get", "Not implemented"); _tl.LogMessage("Temperature Get", "Not implemented");
throw new PropertyNotImplementedException("Temperature", false); throw new PropertyNotImplementedException("Temperature", false);
} }
} }
@@ -568,20 +536,20 @@ 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;
_comPort = profileProperties.ComPort; _comPort = profileProperties.ComPort;
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}"); LogMessage("ReadProfile", $"Com Port: {_comPort}");
} }
@@ -591,10 +559,10 @@ 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);
} }
#endregion #endregion
} }
+1 -2
View File
@@ -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>
@@ -156,7 +156,6 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<Content Include="ASCOM.ico" /> <Content Include="ASCOM.ico" />
<Content Include="ReadMe.htm" />
<None Include="Resources\ASCOM.bmp" /> <None Include="Resources\ASCOM.bmp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+25 -19
View File
@@ -8,10 +8,16 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Globalization;
using System.Resources;
using System.Runtime.CompilerServices;
namespace ASCOM.Meade.net.Properties { namespace ASCOM.Meade.net.Properties {
using System;
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
@@ -19,27 +25,27 @@ namespace ASCOM.Meade.net.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [DebuggerNonUserCode()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [CompilerGenerated()]
internal class Resources { internal class Resources {
private static global::System.Resources.ResourceManager resourceMan; private static ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() { internal Resources() {
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly); ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
@@ -50,8 +56,8 @@ namespace ASCOM.Meade.net.Properties {
/// Overrides the current thread's CurrentUICulture property for all /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
@@ -63,20 +69,20 @@ namespace ASCOM.Meade.net.Properties {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap ASCOM { internal static Bitmap ASCOM {
get { get {
object obj = ResourceManager.GetObject("ASCOM", resourceCulture); object obj = ResourceManager.GetObject("ASCOM", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((Bitmap)(obj));
} }
} }
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary> /// </summary>
internal static System.Drawing.Icon DefaultIcon { internal static Icon DefaultIcon {
get { get {
object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture); object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture);
return ((System.Drawing.Icon)(obj)); return ((Icon)(obj));
} }
} }
} }
+8 -4
View File
@@ -8,14 +8,18 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using System.CodeDom.Compiler;
using System.Configuration;
using System.Runtime.CompilerServices;
namespace ASCOM.Meade.net.Properties { namespace ASCOM.Meade.net.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [CompilerGenerated()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(Synchronized(new Settings())));
public static Settings Default { public static Settings Default {
get { get {
-147
View File
@@ -1,147 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE>Untitled Document</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Win32)">
<META NAME="CREATED" CONTENT="0;0">
<META NAME="CHANGEDBY" CONTENT="Chris Rowland">
<META NAME="CHANGED" CONTENT="20110918;14150500">
<STYLE TYPE="text/css">
<!--
@page { margin: 2cm }
P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
TD P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
H3 { font-family: "Arial", "Helvetica", sans-serif }
H2 { font-family: "Arial", "Helvetica", sans-serif }
H4 { font-family: "Arial", "Helvetica", sans-serif }
TD P.note { background: #33ffff; font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
TD P.underline { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal; text-decoration: underline }
-->
</STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
<TR>
<TD>
<H2>ASCOM Focuser Driver (C#)</H2>
</TD>
</TR>
</TABLE>
<P><BR><BR>
</P>
<H4>You have just created the skeleton of an ASCOM
Focuser driver in C#. It produces an in-process
(assembly) based driver.</H4>
<HR>
<P CLASS="note">Prior to developing your first driver, please
familiarize yourself with the <A HREF="http://ascom-standards.org/developer.html">developer
information we've provided</A> at the ASCOM Initiative web site
(internet required).
</P>
<P CLASS="underline">You must do the following in order to complete
your implementation:</P>
<OL>
<LI><P STYLE="margin-bottom: 0cm">Switch to the Debug configuration
and build the template now. It should build without errors.
</P>
<LI><P STYLE="margin-bottom: 0cm">Add a test project to the
solution. There are templates that can be used to add either a
console or a Windows Forms application:</P>
</OL>
<UL>
<LI><P STYLE="margin-bottom: 0cm">Select the <FONT FACE="Consolas, monospace">ASCOM
Test Forms App (CS)</FONT> or <FONT FACE="Consolas, monospace">ASCOM
Test Console App (CS)</FONT> template.</P>
<LI><P STYLE="margin-bottom: 0cm">Set a name for the test
application and click on OK.</P>
<LI><P STYLE="margin-bottom: 0cm">In the Wizard: set the same device
type and model name as for the driver and select Create to build the
test project.</P>
<LI><P STYLE="margin-bottom: 0cm">Set the Test Application to Run at
Startup.</P>
<LI><P STYLE="margin-bottom: 0cm">Click on Debug and the test
application should run. You should be able to select your
application in the chooser. Selecting Properties should show the
default setup dialog for your driver.</P>
<LI><P STYLE="margin-bottom: 0cm">Trying to continue will generate
errors because the additional properties have not been implemented.</P>
</UL>
<OL START=4>
<LI><P STYLE="margin-bottom: 0cm">Go through the Driver.cs file and
replace the System.NotImplemented exceptions with code to implement
your driver's functionality. See the ASCOM IFocuserV3
spec. If a property or method is not implemented in your driver the
System.NotImplemented exception must be replaced by an
ASCOM.PropertyNotImplemented or ASCOM.MethodNotImplemented
exception.</P>
<LI><P>Customize the Setup Dialog (SetupDialogForm) to provide the
settings and other controls for your driver. You can bind settings
directly to controls on your dialog form, there's no need to manage
settings manually. A custom Settings class takes care of managing
your settings behind the scenes.
</P>
</OL>
<H3>Notes:</H3>
<UL>
<LI><P STYLE="margin-bottom: 0cm">Successfully building the driver,
as well as using <FONT FACE="Lucida Console, Courier New, Courier, monospace">regasm</FONT>
on the assembly, registers it for both COM and ASCOM (the Chooser).
See the code in the ASCOM Registration region of Driver.vb.
</P>
<LI><P STYLE="margin-bottom: 0cm">Doing a Clean for the project, as
well doing a <FONT FACE="Lucida Console, Courier New, Courier, monospace">regasm
-u</FONT> on the assembly, unregisters it for both COM and ASCOM
(the Chooser).
</P>
<LI><P>Place a breakpoint in your driver class constructor, then
start debugging (go, F5). Your breakpoint will be hit when the test
application creates an instance of your driver (after selecting it
in the Chooser). You can now single step, examine variables, etc.
Please review the test application and make changes and additions to
activate various parts of your driver during debugging.</P>
<LI><P>The project's Debug configuration is already configured (The
test application creates an instance of your driver (after selecting
it in the Chooser). You can now single step, examine variables, etc.
Please review the test application and feel free to make changes and
additions to activate various parts of your driver during debugging.
</P>
</UL>
<DIV ALIGN=RIGHT>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
<TR>
<TD>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
<TR>
<TD>
<H3>ASCOM Initiative</H3>
</TD>
<TD>
<IMG SRC="ASCOM.png" NAME="graphics1" ALIGN=RIGHT WIDTH=48 HEIGHT=56 BORDER=0></TD>
</TR>
</TABLE>
<P><BR><BR>
</P>
</TD>
</TR>
<TR>
<TD>
<P>The ASCOM Initiative consists of a group of astronomy software
developers and instrument vendors whose goals are to promote the
driver/client model and scripting automation.
</P>
<P>See the <A HREF="http://ascom-standards.org/" TARGET="browser">ASCOM
web site</A> for more information. Please participate in the
<A HREF="http://tech.groups.yahoo.com/group/ASCOM-Talk" TARGET="browser">ASCOM-Talk
Yahoo Group</A>.
</P>
</TD>
</TR>
</TABLE>
</DIV>
<P><BR><BR>
</P><P>
<BR><BR>
</P>
</BODY>
</HTML>
+24 -6
View File
@@ -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}
+91
View File
@@ -0,0 +1,91 @@
using System;
using System.Reflection;
namespace ASCOM.Meade.net
{
public class AssemblyInfo
{
// The assembly information values.
//public readonly string Title = string.Empty;
//public readonly string Description = string.Empty;
//public readonly string Company = string.Empty;
public readonly string Product = string.Empty;
//public readonly string Copyright = string.Empty;
//public readonly string Trademark = string.Empty;
public readonly string AssemblyVersion;
//public readonly string FileVersion = string.Empty;
//public readonly string Guid = string.Empty;
//public readonly string NeutralLanguage = string.Empty;
//public readonly bool IsComVisible;
// Return a particular assembly attribute value.
private 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.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())
{
}
private AssemblyInfo(Assembly assembly)
{
// Get values from the assembly.
//var titleAttr = GetAssemblyAttribute<AssemblyTitleAttribute>(assembly);
//if (titleAttr != null)
// Title = titleAttr.Title;
//var assemblyAttr = GetAssemblyAttribute<AssemblyDescriptionAttribute>(assembly);
//if (assemblyAttr != null)
// Description = assemblyAttr.Description;
//var companyAttr =GetAssemblyAttribute<AssemblyCompanyAttribute>(assembly);
//if (companyAttr != null)
// Company = companyAttr.Company;
var productAttr = GetAssemblyAttribute<AssemblyProductAttribute>(assembly);
if (productAttr != null)
Product = productAttr.Product;
//var copyrightAttr = GetAssemblyAttribute<AssemblyCopyrightAttribute>(assembly);
//if (copyrightAttr != null)
// Copyright = copyrightAttr.Copyright;
//var trademarkAttr = GetAssemblyAttribute<AssemblyTrademarkAttribute>(assembly);
//if (trademarkAttr != null)
// Trademark = trademarkAttr.Trademark;
var version = assembly.GetName().Version;
AssemblyVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
//var fileVersionAttr = GetAssemblyAttribute<AssemblyFileVersionAttribute>(assembly);
//if (fileVersionAttr != null) FileVersion =
// fileVersionAttr.Version;
//var guidAttr = GetAssemblyAttribute<GuidAttribute>(assembly);
//if (guidAttr != null)
// Guid = guidAttr.Value;
//var languageAttr = GetAssemblyAttribute<NeutralResourcesLanguageAttribute>(assembly);
//if (languageAttr != null)
// NeutralLanguage = languageAttr.CultureName;
//var comAttr = GetAssemblyAttribute<ComVisibleAttribute>(assembly);
//if (comAttr != null)
// IsComVisible = comAttr.Value;
}
}
}
+20 -21
View File
@@ -1,6 +1,8 @@
using System; using System;
using System.Runtime.InteropServices;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedMember.Global
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -33,8 +35,8 @@ namespace ASCOM.Meade.net
#region Access to ole32.dll functions for class factories #region Access to ole32.dll functions for class factories
// Define two common GUID objects for public usage. // Define two common GUID objects for public usage.
private static readonly Guid _iidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); private static readonly Guid IidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
private static readonly Guid _iidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}"); private static readonly Guid IidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}");
[Flags] [Flags]
enum Clsctx : uint enum Clsctx : uint
@@ -113,16 +115,16 @@ namespace ASCOM.Meade.net
private Guid _mClassId; private Guid _mClassId;
private readonly ArrayList _mInterfaceTypes; private readonly ArrayList _mInterfaceTypes;
private uint _mCookie; private uint _mCookie;
private readonly string _mProgid; //private readonly string _mProgid;
public ClassFactory(Type type) public ClassFactory(Type type)
{ {
if (type == null) if (type == null)
throw new ArgumentNullException("type"); throw new ArgumentNullException(nameof(type));
_mClassType = type; _mClassType = type;
//PWGS Get the ProgID from the MetaData //PWGS Get the ProgID from the MetaData
_mProgid = Marshal.GenerateProgIdForType(type); //_mProgid = Marshal.GenerateProgIdForType(type);
_mClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)] _mClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)]
ClassContext = (uint)Clsctx.ClsctxLocalServer; // Default ClassContext = (uint)Clsctx.ClsctxLocalServer; // Default
Flags = (uint)Regcls.RegclsMultipleuse | // Default Flags = (uint)Regcls.RegclsMultipleuse | // Default
@@ -135,7 +137,8 @@ namespace ASCOM.Meade.net
#endregion #endregion
#region Common ClassFactory Methods #region Common ClassFactory Methods
public uint ClassContext { get; }
private uint ClassContext { get; }
public Guid ClassId public Guid ClassId
{ {
@@ -143,7 +146,7 @@ namespace ASCOM.Meade.net
set => _mClassId = value; set => _mClassId = value;
} }
public uint Flags { get; } private uint Flags { get; }
public bool RegisterClassObject() public bool RegisterClassObject()
{ {
@@ -156,25 +159,22 @@ namespace ASCOM.Meade.net
Flags, Flags,
out _mCookie out _mCookie
); );
return (i == 0); return i == 0;
} }
public bool RevokeClassObject() public void RevokeClassObject()
{ {
int i = CoRevokeClassObject(_mCookie); CoRevokeClassObject(_mCookie);
return (i == 0);
} }
public static bool ResumeClassObjects() public static void ResumeClassObjects()
{ {
int i = CoResumeClassObjects(); CoResumeClassObjects();
return (i == 0);
} }
public static bool SuspendClassObjects() public static void SuspendClassObjects()
{ {
int i = CoSuspendClassObjects(); CoSuspendClassObjects();
return (i == 0);
} }
#endregion #endregion
@@ -201,12 +201,11 @@ namespace ASCOM.Meade.net
// //
// Handle requests for IDispatch or IUnknown on the class // Handle requests for IDispatch or IUnknown on the class
// //
if (riid == _iidIDispatch) if (riid == IidIDispatch)
{ {
ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType)); ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(_mClassType));
return;
} }
else if (riid == _iidIUnknown) else if (riid == IidIUnknown)
{ {
ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(_mClassType)); ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(_mClassType));
} }
+8
View File
@@ -0,0 +1,8 @@
namespace ASCOM.Meade.net
{
public class ConnectionInfo
{
public int Connections { get; set; }
public int SameDevice { get; set; }
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ namespace ASCOM.Meade.net
_mEventThreadEnded.Set(); _mEventThreadEnded.Set();
} }
protected bool ContinueThread() private bool ContinueThread()
{ {
lock (this) lock (this)
{ {
+82 -128
View File
@@ -12,82 +12,38 @@
// Modified by Chris Rowland and Peter Simpson to allow use with multiple devices of the same type March 2011 // Modified by Chris Rowland and Peter Simpson to allow use with multiple devices of the same type March 2011
// //
// //
using System; using System;
using System.IO;
using System.Windows.Forms;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading;
using System.Windows.Forms;
using ASCOM.Meade.net.Properties;
using ASCOM.Utilities; using ASCOM.Utilities;
using Microsoft.Win32; using Microsoft.Win32;
using System.Threading;
using System.Security.Principal;
using System.Diagnostics;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
public static class Server public static class Server
{ {
private const string DriverName = "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]
enum Clsctx : uint
{
ClsctxInprocServer = 0x1,
ClsctxInprocHandler = 0x2,
ClsctxLocalServer = 0x4,
ClsctxInprocServer16 = 0x8,
ClsctxRemoteServer = 0x10,
ClsctxInprocHandler16 = 0x20,
ClsctxReserved1 = 0x40,
ClsctxReserved2 = 0x80,
ClsctxReserved3 = 0x100,
ClsctxReserved4 = 0x200,
ClsctxNoCodeDownload = 0x400,
ClsctxReserved5 = 0x800,
ClsctxNoCustomMarshal = 0x1000,
ClsctxEnableCodeDownload = 0x2000,
ClsctxNoFailureLog = 0x4000,
ClsctxDisableAaa = 0x8000,
ClsctxEnableAaa = 0x10000,
ClsctxFromDefaultContext = 0x20000,
ClsctxInproc = ClsctxInprocServer | ClsctxInprocHandler,
ClsctxServer = ClsctxInprocServer | ClsctxLocalServer | ClsctxRemoteServer,
ClsctxAll = ClsctxServer | ClsctxInprocHandler
}
[Flags] //// CoInitializeEx() can be used to set the apartment model
enum Coinit : uint //// of individual threads.
{ //[DllImport("ole32.dll")]
/// Initializes the thread for multi-threaded object concurrency. //static extern int CoInitializeEx(IntPtr pvReserved, uint dwCoInit);
CoinitMultithreaded = 0x0,
/// Initializes the thread for apartment-threaded object concurrency.
CoinitApartmentthreaded = 0x2,
/// Disables DDE for Ole1 support.
CoinitDisableOle1Dde = 0x4,
/// Trades memory for speed.
CoinitSpeedOverMemory = 0x8
}
[Flags] //// CoUninitialize() is used to uninitialize a COM thread.
enum Regcls : uint //[DllImport("ole32.dll")]
{ //static extern void CoUninitialize();
RegclsSingleuse = 0,
RegclsMultipleuse = 1,
RegclsMultiSeparate = 2,
RegclsSuspended = 4,
RegclsSurrogate = 8
}
// CoInitializeEx() can be used to set the apartment model
// of individual threads.
[DllImport("ole32.dll")]
static extern int CoInitializeEx(IntPtr pvReserved, uint dwCoInit);
// CoUninitialize() is used to uninitialize a COM thread.
[DllImport("ole32.dll")]
static extern void CoUninitialize();
// PostThreadMessage() allows us to post a Windows Message to // PostThreadMessage() allows us to post a Windows Message to
// a specific thread (identified by its thread id). // a specific thread (identified by its thread id).
@@ -107,8 +63,8 @@ namespace ASCOM.Meade.net
#region Private Data #region Private Data
private static int _objsInUse; // Keeps a count on the total number of objects alive. private static int _objsInUse; // Keeps a count on the total number of objects alive.
private static int _serverLocks; // Keeps a lock count on this application. private static int _serverLocks; // Keeps a lock count on this application.
private static FrmMain _sMainForm = null; // Reference to our main form private static FrmMain _sMainForm; // Reference to our main form
private static ArrayList _sComObjectAssys; // Dynamically loaded assemblies containing served COM objects //private static ArrayList _sComObjectAssys; // Dynamically loaded assemblies containing served COM objects
private static ArrayList _sComObjectTypes; // Served COM object types private static ArrayList _sComObjectTypes; // Served COM object types
private static ArrayList _sClassFactories; // Served COM object class factories private static ArrayList _sClassFactories; // Served COM object class factories
private static string _sAppId = "{4e68ec46-5ffc-49e7-b298-38a548df0bfd}"; // Our AppId private static string _sAppId = "{4e68ec46-5ffc-49e7-b298-38a548df0bfd}"; // Our AppId
@@ -116,15 +72,15 @@ namespace ASCOM.Meade.net
#endregion #endregion
// This property returns the main thread's id. // This property returns the main thread's id.
public static uint MainThreadId { get; private set; } // Stores the main thread's thread id. private static uint MainThreadId { get; set; } // Stores the main thread's thread id.
// Used to tell if started by COM or manually // Used to tell if started by COM or manually
public static bool StartedByCom { get; private set; } // True if server started by COM (-embedding) private static bool StartedByCom { get; set; } // True if server started by COM (-embedding)
#region Server Lock, Object Counting, and AutoQuit on COM startup #region Server Lock, Object Counting, and AutoQuit on COM startup
// Returns the total number of objects alive currently. // Returns the total number of objects alive currently.
public static int ObjectsCount private static int ObjectsCount
{ {
get get
{ {
@@ -136,21 +92,21 @@ namespace ASCOM.Meade.net
} }
// This method performs a thread-safe incrementation of the objects count. // This method performs a thread-safe incrementation of the objects count.
public static int CountObject() public static void CountObject()
{ {
// Increment the global count of objects. // Increment the global count of objects.
return Interlocked.Increment(ref _objsInUse); Interlocked.Increment(ref _objsInUse);
} }
// This method performs a thread-safe decrementation the objects count. // This method performs a thread-safe decrementation the objects count.
public static int UncountObject() public static void UncountObject()
{ {
// Decrement the global count of objects. // Decrement the global count of objects.
return Interlocked.Decrement(ref _objsInUse); Interlocked.Decrement(ref _objsInUse);
} }
// Returns the current server lock count. // Returns the current server lock count.
public static int ServerLockCount private static int ServerLockCount
{ {
get get
{ {
@@ -163,18 +119,18 @@ namespace ASCOM.Meade.net
// This method performs a thread-safe incrementation the // This method performs a thread-safe incrementation the
// server lock count. // server lock count.
public static int CountLock() public static void CountLock()
{ {
// Increment the global lock count of this server. // Increment the global lock count of this server.
return Interlocked.Increment(ref _serverLocks); Interlocked.Increment(ref _serverLocks);
} }
// This method performs a thread-safe decrementation the // This method performs a thread-safe decrementation the
// server lock count. // server lock count.
public static int UncountLock() public static void UncountLock()
{ {
// Decrement the global lock count of this server. // Decrement the global lock count of this server.
return Interlocked.Decrement(ref _serverLocks); Interlocked.Decrement(ref _serverLocks);
} }
// AttemptToTerminateServer() will check to see if the objects count and the server // AttemptToTerminateServer() will check to see if the objects count and the server
@@ -213,7 +169,7 @@ namespace ASCOM.Meade.net
// //
private static bool LoadComObjectAssemblies() private static bool LoadComObjectAssemblies()
{ {
_sComObjectAssys = new ArrayList(); //_sComObjectAssys = new ArrayList();
_sComObjectTypes = new ArrayList(); _sComObjectTypes = new ArrayList();
// put everything into one folder, the same as the server. // put everything into one folder, the same as the server.
@@ -244,7 +200,7 @@ namespace ASCOM.Meade.net
{ {
//MessageBox.Show("Adding Type: " + type.Name + " " + type.FullName); //MessageBox.Show("Adding Type: " + type.Name + " " + type.FullName);
_sComObjectTypes.Add(type); //PWGS - much simpler _sComObjectTypes.Add(type); //PWGS - much simpler
_sComObjectAssys.Add(so); //_sComObjectAssys.Add(so);
} }
} }
} }
@@ -252,15 +208,13 @@ namespace ASCOM.Meade.net
{ {
// Probably an attempt to load a Win32 DLL (i.e. not a .net assembly) // Probably an attempt to load a Win32 DLL (i.e. not a .net assembly)
// Just swallow the exception and continue to the next item. // Just swallow the exception and continue to the next item.
continue;
} }
catch (Exception e) catch (Exception e)
{ {
MessageBox.Show("Failed to load served COM class assembly " + fi.Name + " - " + e.Message, MessageBox.Show(string.Format(Resources.Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_, fi.Name, e.Message),
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false; return false;
} }
} }
return true; return true;
} }
@@ -285,22 +239,22 @@ namespace ASCOM.Meade.net
// //
private static void ElevateSelf(string arg) private static void ElevateSelf(string arg)
{ {
ProcessStartInfo si = new ProcessStartInfo(); var si = new ProcessStartInfo
si.Arguments = arg;
si.WorkingDirectory = Environment.CurrentDirectory;
si.FileName = Application.ExecutablePath;
si.Verb = "runas";
try { Process.Start(si); }
catch (System.ComponentModel.Win32Exception)
{ {
MessageBox.Show("The Meade.net was not " + (arg == "/register" ? "registered" : "unregistered") + Arguments = arg,
" because you did not allow it.", "Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Warning); WorkingDirectory = Environment.CurrentDirectory,
FileName = Application.ExecutablePath,
Verb = "runas"
};
try { Process.Start(si); }
catch (Win32Exception)
{
MessageBox.Show(string.Format(Resources.Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_, DriverName, (arg == "/register" ? "registered" : "unregistered")), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.ToString(), "Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop); MessageBox.Show(ex.ToString(), DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
} }
return;
} }
// //
@@ -348,21 +302,18 @@ namespace ASCOM.Meade.net
// //
// HKCR\APPID\exename.ext // HKCR\APPID\exename.ext
// //
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("APPID\\{0}", using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(
Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)))) $"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}"))
{ {
key.SetValue("AppID", _sAppId); key.SetValue("AppID", _sAppId);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("Error while registering the server:\n" + ex.ToString(), MessageBox.Show(string.Format(Resources.Server_RegisterObjects_, ex),
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return; return;
} }
finally
{
}
// //
// For each of the driver assemblies // For each of the driver assemblies
@@ -380,7 +331,7 @@ namespace ASCOM.Meade.net
//PWGS Generate device type from the Class name //PWGS Generate device type from the Class name
string deviceType = type.Name; string deviceType = type.Name;
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(string.Format("CLSID\\{0}", clsid))) using (RegistryKey key = Registry.ClassesRoot.CreateSubKey($"CLSID\\{clsid}"))
{ {
key.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here key.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
key.SetValue("AppId", _sAppId); key.SetValue("AppId", _sAppId);
@@ -412,7 +363,7 @@ namespace ASCOM.Meade.net
// //
// ASCOM // ASCOM
// //
assy = type.Assembly; //assy = type.Assembly;
// Pull the display name from the ServedClassName attribute. // Pull the display name from the ServedClassName attribute.
attr = Attribute.GetCustomAttribute(type, typeof(ServedClassNameAttribute)); //PWGS Changed to search type for attribute rather than assembly attr = Attribute.GetCustomAttribute(type, typeof(ServedClassNameAttribute)); //PWGS Changed to search type for attribute rather than assembly
@@ -425,13 +376,11 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("Error while registering the server:\n" + ex.ToString(), MessageBox.Show(string.Format(Resources.Server_RegisterObjects_, ex),
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
bFail = true; bFail = true;
} }
finally
{
}
if (bFail) break; if (bFail) break;
} }
} }
@@ -453,9 +402,9 @@ namespace ASCOM.Meade.net
// //
// Local server's DCOM/AppID information // Local server's DCOM/AppID information
// //
Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", _sAppId), false); Registry.ClassesRoot.DeleteSubKey($"APPID\\{_sAppId}", false);
Registry.ClassesRoot.DeleteSubKey(string.Format("APPID\\{0}", Registry.ClassesRoot.DeleteSubKey(
Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)), false); $"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}", false);
// //
// For each of the driver assemblies // For each of the driver assemblies
@@ -471,17 +420,17 @@ namespace ASCOM.Meade.net
// //
// HKCR\progid // HKCR\progid
// //
Registry.ClassesRoot.DeleteSubKey(String.Format("{0}\\CLSID", progid), false); Registry.ClassesRoot.DeleteSubKey($"{progid}\\CLSID", false);
Registry.ClassesRoot.DeleteSubKey(progid, false); Registry.ClassesRoot.DeleteSubKey(progid, false);
// //
// HKCR\CLSID\clsid // HKCR\CLSID\clsid
// //
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", clsid), false); Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Implemented Categories\\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", false);
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Implemented Categories", clsid), false); Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Implemented Categories", false);
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\ProgId", clsid), false); Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\ProgId", false);
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\LocalServer32", clsid), false); Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\LocalServer32", false);
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}\\Programmable", clsid), false); Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}\\Programmable", false);
Registry.ClassesRoot.DeleteSubKey(String.Format("CLSID\\{0}", clsid), false); Registry.ClassesRoot.DeleteSubKey($"CLSID\\{clsid}", false);
try try
{ {
// //
@@ -493,7 +442,10 @@ namespace ASCOM.Meade.net
p.Unregister(progid); p.Unregister(progid);
} }
} }
catch (Exception) { } catch (Exception)
{
// ignored
}
} }
} }
#endregion #endregion
@@ -504,7 +456,7 @@ namespace ASCOM.Meade.net
// that we serve. This requires the class facgtory name to be // that we serve. This requires the class facgtory name to be
// equal to the served class name + "ClassFactory". // equal to the served class name + "ClassFactory".
// //
private static bool RegisterClassFactories() private static void RegisterClassFactories()
{ {
_sClassFactories = new ArrayList(); _sClassFactories = new ArrayList();
foreach (Type type in _sComObjectTypes) foreach (Type type in _sComObjectTypes)
@@ -513,13 +465,12 @@ namespace ASCOM.Meade.net
_sClassFactories.Add(factory); _sClassFactories.Add(factory);
if (!factory.RegisterClassObject()) if (!factory.RegisterClassObject())
{ {
MessageBox.Show("Failed to register class factory for " + type.Name, MessageBox.Show(string.Format(Resources.Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_, type.Name),
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Stop); DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false; return;
} }
} }
ClassFactory.ResumeClassObjects(); // Served objects now go live ClassFactory.ResumeClassObjects(); // Served objects now go live
return true;
} }
private static void RevokeClassFactories() private static void RevokeClassFactories()
@@ -569,8 +520,9 @@ namespace ASCOM.Meade.net
break; break;
default: default:
MessageBox.Show("Unknown argument: " + args[0] + "\nValid are : -register, -unregister and -embedding", MessageBox.Show(
"Meade.net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); string.Format(Resources.Server_ProcessArguments_, args[0]),
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break; break;
} }
} }
@@ -609,9 +561,11 @@ namespace ASCOM.Meade.net
RegisterClassFactories(); RegisterClassFactories();
// Start up the garbage collection thread. // Start up the garbage collection thread.
GarbageCollection garbageCollector = new GarbageCollection(1000); var garbageCollector = new GarbageCollection(1000);
Thread gcThread = new Thread(new ThreadStart(garbageCollector.GcWatch)); var gcThread = new Thread(garbageCollector.GcWatch)
gcThread.Name = "Garbage Collection Thread"; {
Name = "Garbage Collection Thread"
};
gcThread.Start(); gcThread.Start();
// //
@@ -1,36 +0,0 @@
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Reflection;
namespace ASCOM.Meade.net.Localization
{
internal class LocalisationHelper
{
private const string LocalizationNamespace = "LocalisationTest.Localization.Resources.Localization";
private readonly ResourceManager _resourceManager;
public LocalisationHelper()
{
_resourceManager = new ResourceManager(LocalizationNamespace, Assembly.GetExecutingAssembly());
SetLocalisation(CultureInfo.CurrentCulture.Name);
}
internal void SetLocalisation(string name)
{
var cultureInfo = new CultureInfo(name);
//CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
//CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
}
internal string GetString(string key)
{
return _resourceManager.GetString(key);
}
}
}
+5 -3
View File
@@ -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>
@@ -129,11 +132,11 @@
<DependentUpon>frmMain.cs</DependentUpon> <DependentUpon>frmMain.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="GarbageCollection.cs" /> <Compile Include="GarbageCollection.cs" />
<Compile Include="Localization\LocalisationHelper.cs" />
<Compile Include="LocalServer.cs" /> <Compile Include="LocalServer.cs" />
<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>
@@ -164,7 +167,6 @@
<ItemGroup> <ItemGroup>
<Content Include="ASCOM.ico" /> <Content Include="ASCOM.ico" />
<Content Include="ASCOM.png" /> <Content Include="ASCOM.png" />
<Content Include="ReadMe.htm" />
<None Include="BootstrapAscomProfileStore.ps1" /> <None Include="BootstrapAscomProfileStore.ps1" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Resources\ASCOM.bmp" /> <None Include="Resources\ASCOM.bmp" />
+1
View File
@@ -6,5 +6,6 @@ namespace ASCOM.Meade.net
public string ComPort { get; set; } public string ComPort { get; set; }
public bool TraceLogger { get; set; } public bool TraceLogger { get; set; }
public double GuideRateArcSecondsPerSecond { get; set; } public double GuideRateArcSecondsPerSecond { get; set; }
public string Precision { get; set; }
} }
} }
+2 -2
View File
@@ -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("")]
@@ -23,4 +23,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyVersion("0.0.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: ComVisibleAttribute(false)] [assembly: ComVisible(false)]
+66
View File
@@ -69,5 +69,71 @@ namespace ASCOM.Meade.net.Properties {
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
/// <summary>
/// Looks up a localized string similar to The {0} was not {1} because you did not allow it..
/// </summary>
internal static string Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_ {
get {
return ResourceManager.GetString("Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to load served COM class assembly {0} - {1}.
/// </summary>
internal static string Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_ {
get {
return ResourceManager.GetString("Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_" +
"", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown argument: {0}
///Valid are : -register, -unregister and -embedding.
/// </summary>
internal static string Server_ProcessArguments_ {
get {
return ResourceManager.GetString("Server_ProcessArguments_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to register class factory for {0}.
/// </summary>
internal static string Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_ {
get {
return ResourceManager.GetString("Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Error while registering the server:
///{0}.
/// </summary>
internal static string Server_RegisterObjects_ {
get {
return ResourceManager.GetString("Server_RegisterObjects_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} Settings ({1}).
/// </summary>
internal static string SetupDialogForm_SetupDialogForm__0__Settings___1__ {
get {
return ResourceManager.GetString("SetupDialogForm_SetupDialogForm__0__Settings___1__", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ({0:00.0}% of sidereal rate).
/// </summary>
internal static string SetupDialogForm_TextBox1_TextChanged___0_00_0___of_sidereal_rate_ {
get {
return ResourceManager.GetString("SetupDialogForm_TextBox1_TextChanged___0_00_0___of_sidereal_rate_", resourceCulture);
}
}
} }
} }
+23
View File
@@ -121,4 +121,27 @@
<data name="ASCOM" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="ASCOM" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ASCOM.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\ASCOM.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Server_ProcessArguments_" xml:space="preserve">
<value>Unknown argument: {0}
Valid are : -register, -unregister and -embedding</value>
</data>
<data name="Server_RegisterClassFactories_Failed_to_register_class_factory_for__0_" xml:space="preserve">
<value>Failed to register class factory for {0}</value>
</data>
<data name="Server_RegisterObjects_" xml:space="preserve">
<value>Error while registering the server:
{0}</value>
</data>
<data name="Server_ElevateSelf_The__0__was_not__1__because_you_did_not_allow_it_" xml:space="preserve">
<value>The {0} was not {1} because you did not allow it.</value>
</data>
<data name="Server_LoadComObjectAssemblies_Failed_to_load_served_COM_class_assembly__0_____1_" xml:space="preserve">
<value>Failed to load served COM class assembly {0} - {1}</value>
</data>
<data name="SetupDialogForm_TextBox1_TextChanged___0_00_0___of_sidereal_rate_" xml:space="preserve">
<value>({0:00.0}% of sidereal rate)</value>
</data>
<data name="SetupDialogForm_SetupDialogForm__0__Settings___1__" xml:space="preserve">
<value>{0} Settings ({1})</value>
</data>
</root> </root>
-666
View File
@@ -1,666 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252"/>
<TITLE>Untitled Document</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Win32)"/>
<META NAME="CREATED" CONTENT="0;0"/>
<META NAME="CHANGEDBY" CONTENT="Chris Rowland"/>
<META NAME="CHANGED" CONTENT="20110422;10442800"/>
<META NAME="CHANGEDBY" CONTENT="Chris Rowland"/>
<STYLE TYPE="text/css">
<!--
@page { margin: 2cm }
P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
TD P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
H3 { font-family: "Arial", "Helvetica", sans-serif }
H2 { font-family: "Arial", "Helvetica", sans-serif }
H4 { font-family: "Arial", "Helvetica", sans-serif }
PRE { margin-left: 0.18cm; margin-right: 0.18cm; margin-top: 0.18cm; margin-bottom: 0.18cm; background: #ccffff }
PRE.western { font-weight: normal }
PRE.cjk { font-family: "NSimSun", monospace; font-weight: normal }
PRE.ctl { font-weight: normal }
EM.underline { text-decoration: underline }
-->
</STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="4" CELLSPACING="0" STYLE="page-break-before: always">
<TR>
<TD>
<H2>
ASCOM LocalServer (singleton) Host
</H2>
</TD>
</TR>
</TABLE>
<P>
<BR/>
<BR/>
</P>
<H4>
You have just created a local server (singleton) host for one or
more ASCOM driver classes.
</H4>
<HR/>
<P>
This project implements an ASCOM host server for one or more
driver classes in a single-instance executable. It can be used to
serve multiple instances of a single driver class (hub), provide
driver services for multiple devices (e.g., Telescope and Focuser) to
multiple applications and allow multiple devices of the same type to
be connected. In the latter scenario, the multiple driver classes
will often share one or more resources such as the serial connection
and a microcontroller in the combined device. From the client's
perspective, using the drivers served by the local server is exactly
the same as if the drivers are loaded into the client's process space
(in-proc servers).
</P>
<P STYLE="margin-left: 0.42cm; margin-right: 0.42cm; border: 1px solid #000000; padding: 0.21cm">
<STRONG>
<SPAN STYLE="background: #ffee88">NOTE:</SPAN>
</STRONG>
<SPAN STYLE="background: #ffee88">
Unless you are prepared to handle all of the timing issues that arise
when multiple clients are accessing the properties and methods of
your driver(s), stop now. Just because the local server serializes
the calls to your driver(s)' properties and methods does not mean
that there will be no timing or concurrency issues.<BR/>
&nbsp;<BR/>For
example, suppose the hub serves instances of a Telescope driver. One
client sets the TargetRightAscension property, then another sets
TargetRightAscension to a different value, then the first client sets
TargetDeclination, then the first client calls SlewToTarget()
followed by the second client calling SlewToTarget(). Besides the
first client's slew command sending the scope to the wrong (and
possibly dangerous) coordinates, there is the problem of the second
client trying to slew a slewing scope. Local server drivers are
tricky to get right. There is no such thing as &quot;ignorance is
bliss&quot; here.
</SPAN>
</P>
<P STYLE="margin-left: 0.42cm; margin-right: 0.42cm; border: 1px solid #000000; padding: 0.21cm">
<SPAN STYLE="background: #ffee88">
This implementation has changed
from what was defined for Platform 5.5 as follows:
</SPAN>
</P>
<P STYLE="margin-left: 0.42cm; margin-right: 0.42cm; border: 1px solid #000000; padding: 0.21cm">
<SPAN STYLE="background: #ffee88">
The drivers are now installed in
the same folder as the local server executable. This makes deployment
cleaner because the whole driver can exist in a single folder
independently of other drivers.
</SPAN>
</P>
<P STYLE="margin-left: 0.42cm; margin-right: 0.42cm; border: 1px solid #000000; padding: 0.21cm">
<SPAN STYLE="background: #ffee88">
The ProgId and friendly name as
displayed by the Chooser are defined using attributes. This allows
driver dlls to be identified clearly and so avoids confusion with
other dlls that may be required such as interop dlls.
</SPAN>
</P>
<P STYLE="margin-left: 0.42cm; margin-right: 0.42cm; border: 1px solid #000000; padding: 0.21cm">
<SPAN STYLE="background: #ffee88">
Some changes have been made that
will facilitate generating multiple drivers of the same type.
</SPAN>
</P>
<P STYLE="margin-left: 0.42cm; margin-right: 0.42cm; border: 1px solid #000000; padding: 0.21cm">
<SPAN STYLE="background: #ffee88">
I've put some additional advice and
comments in the notes below <I>in italics.</I>
</SPAN>
</P>
<P>
You're probably anxious to get going, but you really should read
through the <A HREF="#theory">Theory of Operation</A> and <A HREF="#details">
Detailed
Use and Deployment
</A> below.
</P>
<P>You must do the following in order to complete your local server:</P>
<OL>
<LI>
<P STYLE="margin-bottom: 0cm">
In the local server's project
properties, Application tab, change BOTH the AssemblyName and the
default assembly name to ASCOM.xxx (e.g., ASCOM.SuperScope). <I>
This
may be done by default now.
</I>
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Add one or more driver skeleton
projects using the in-proc templates. You may use either the C# or
VB templates. Project name is not important (not used in ProgID)
choose something like TelescopeDriver. You will be changing the
substituted project name in these projects below. If you ensure that
the LocalServer and all the driver projects have the same NameSpace
e.g. ASCOM.SuperScope the renaming in section 6a will not be
required.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Develop and debug these driver
projects as normal in-process assemblies. This will be much simpler
because the driver and test code can be debugged in the same
process.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Build the LocalServer.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Set a reference to the local
server <STRONG>project</STRONG> in each of the driver skeleton
projects.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">In each skeleton driver project:</P>
<OL TYPE="a">
<LI>
<P STYLE="margin-bottom: 0cm">
Do a Find In Files for the
project name of the skeleton driver (e.g., TelescopeDriver) and
change it to match the project name of your local server (e.g.
SuperScope). You don't have to do this in the ReadMe.html file.
Everywhere else, however, is IMPORTANT. This sets the correct
namespace, progID, etc. If you're a bit more brave, you can use
Replace in Files. <I>
This may not be needed if the correct
namespace and naming conventions have been followed when the
drivers and local server were generated.
</I>
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
In project properties,
Application tab, change the assembly name to
ASCOM.<EM CLASS="underline">localserverprojectname</EM>.<EM>drivertype</EM>,
(e.g., ASCOM.SuperScope.Telescope).
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
In project properties,
Application tab, click Assembly Information...
</P>
<UL>
<LI>
<P STYLE="margin-bottom: 0cm">
Assure that Make assembly COM
visible is <STRONG>on</STRONG> (it should already be on).
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Edit the Product Name to be the
&quot;friendly name&quot; of your driver as will be shown in the
Chooser. <I>
Not used now, use the ServedClassName attribute
instead.
</I>
</P>
</LI>
</UL>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
In project properties, Build tab,
turn <STRONG>off</STRONG> Register for COM Interop.
</P>
</LI>
<LI>
<P>
Modify the driver class declaration to inherit from
ReferenceCountedObjectBase. Examples:<BR/>C#:
</P>
<PRE CLASS="western">
public class Telescope :
ReferenceCountedObjectBase,
ITelescope
</PRE>
<P>
VB:
</P>
<PRE CLASS="western">
Public Class Telescope
'==================================
Inherits ReferenceCountedObjectBase
Implements ITelescope
'==================================
</PRE>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
In driver.cs/driver.vb, remove
the entire ASCOM Registration region
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
In driver.cs/driver.vb, remove
the private strings for driver ID and driver description. <I>
They
may be needed internally, and if so should be set from the
associated attributes, ServedClassName for the description and
ProgId for the driver Id.
</I>
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Modify the class attributes by
adding the ServedClassName and ProgID attributes. The
ServedClassName attribute must be the friendly name shown as the
device name in the Chooser and the ProgId the progid of the driver
e.g. ASCOM.SuperScope.Telescope. The class header should look like
this:
</P>
<P STYLE="margin-bottom: 0cm">C#:</P>
<PRE CLASS="western" STYLE="margin-right: 0.16cm">
<FONT FACE="Consolas" SIZE="2" STYLE="font-size: 9pt">
[<FONT COLOR="#2b91af">Guid</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#a31515">&quot;0AE8B38D-10A1-4A8D-A5B7-1B050F74B48B&quot;</FONT><FONT COLOR="#000000">)] // set by the template</FONT>
<FONT COLOR="#000000">[</FONT><FONT COLOR="#2b91af">ProgId</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#a31515">&quot;ASCOM.SuperScope.Telescope&quot;</FONT><FONT COLOR="#000000">)]</FONT>
<FONT COLOR="#000000">[</FONT><FONT COLOR="#2b91af">ServedClassName</FONT><FONT COLOR="#000000"> (</FONT><FONT COLOR="#a31515">&quot;Super Scope Telescope&quot;</FONT><FONT COLOR="#000000">)]</FONT>
<FONT COLOR="#000000">[</FONT><FONT COLOR="#2b91af">ClassInterface</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2b91af">ClassInterfaceType</FONT><FONT COLOR="#000000">.None)]</FONT>
<FONT COLOR="#0000ff">public </FONT><FONT COLOR="#0000ff">class </FONT><FONT COLOR="#2b91af">Telescope </FONT><FONT COLOR="#000000">: </FONT><FONT COLOR="#2b91af">ReferenceCountedObjectBase</FONT><FONT COLOR="#000000"> , </FONT><FONT COLOR="#2b91af">ITelescope</FONT>
</FONT>
</PRE>
</LI>
</OL>
</LI>
</OL>
<P STYLE="margin-bottom: 0cm">
<BR/>
</P>
<OL>
<OL TYPE="a">
<P>VB:</P>
<PRE CLASS="western">
<FONT FACE="Consolas" SIZE="2" STYLE="font-size: 9pt">
&lt;Guid(&ldquo;<FONT COLOR="#a31515">0AE8B38D-10A1-4A8D-A5B7-1B050F74B48B</FONT>&rdquo;)&gt;
&lt;ProgId(&ldquo;ASCOM.SuperScope.Telescope&rdquo;)&gt;
&lt;ServedClassName(&ldquo;Super Scope Telescope&rdquo;)&gt;
Public Class Telescope
'==================================
Inherits ReferenceCountedObjectBase
Implements ITelescope
'==================================
</FONT>
</PRE>
</OL>
</OL>
<P STYLE="margin-left: 2.5cm">
Add the following line to the driver
constructor, this sets the driver ID using the ProgId Attribute:
</P>
<OL>
<OL TYPE="a">
<P>C#</P>
<PRE CLASS="western">
<FONT FACE="Consolas" SIZE="2" STYLE="font-size: 9pt">
s_csDriverID = <FONT COLOR="#2b91af">Marshal</FONT><FONT COLOR="#000000">.GenerateProgIdForType(</FONT><FONT COLOR="#0000ff">this</FONT><FONT COLOR="#000000">.GetType());</FONT>
</FONT>
</PRE>
<P>VB:</P>
<PRE CLASS="western">
<FONT FACE="Consolas" SIZE="2" STYLE="font-size: 9pt">
s_csDriverID = <FONT COLOR="#2b91af">Marshal</FONT><FONT COLOR="#000000">.GenerateProgIdForType(</FONT><FONT COLOR="#0000ff">Me</FONT><FONT COLOR="#000000">.GetType())</FONT>
</FONT>
</PRE>
</OL>
<LI>
<P STYLE="margin-bottom: 0cm">
Unless you're writing a
single-driver hub, you will have two or more driver types (e.g.
Telescope and Focuser) and thus two or more driver assembly projects
added. Presumably, these drivers need to share some resources (e.g.
a single COM port via Helper.Serial). <U>
Put shared resources into
the SharedResources class provided
</U>. There are some examples that
should give a clue, modify and delete these as required.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
A shared serial port is already
provided (see SharedResources.cs) as <FONT FACE="Lucida Console, Courier New, Courier, monospace">SharedResources.SharedSerial</FONT>
and it is an ASCOM Helper Serial object. You may wish to define
additional shared resources in static member variables with public
static accessor properties as is already done for SharedSerial.
Unfortunately, if you are a Visual Basic programmer, you will have
to make these additions in C#.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
If you are writing a hub and don't
need the serial port, in SharedResources.cs you can remove the
public static SharedSerial property, the m_SharedSerial member in
the private data region, and the line in main that initializes it.
If you don't need any other shared resources for your hub, then you
can remove the SharedResources.cs file completely.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
If you modified the LocalServer,
build it again now. This will refresh the stuff that's visible to
the drivers.
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
Build the driver skeletons to
verify that you got all of the namespace and other variable changes.
</P>
</LI>
<LI>
<P>
The local server dynamically loads the driver assemblies from
the same folder as the local server executable. <BR/>
<BR/>During
development, you'll need to add a post-build task to each of your
driver assembly projects which puts a copy of the driver assembly
into the local server executable folder. Here is an example:
</P>
<PRE CLASS="western"> copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\SuperScope\$(OutDir)\$(TargetFileName)&quot;</PRE>
<P STYLE="margin-bottom: 0cm">
This assumes that the server project is called &ldquo;SuperScope&rdquo;,
and handles using the debug or release build.<BR/>
Note the quotes for
possible path elements with spaces in them. <I>
An alternative is to
set the build path to the required destination instead of the
default path.
</I>
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
<I>
Make sure the drivers are
registered through the local server by running it with the /register
parameter, see below for details.
</I>
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
<SPAN STYLE="background: #ffff00">IMPORTANT:</SPAN>
With a local server based driver (or hub) it is possible for
multiple clients to control the device(s). It is up to you to
safeguard against abuse. <I>
The sort of thing that's needed is to
have a counter of the number of connections to a device, the
connection is only fully broken when the number of connections is
zero. You may also need code to prevent several drivers from talking
to the hardware at the same time, the lock pattern is useful for
that.
</I>
</P>
</LI>
<LI>
<P>
You may want to add controls and/or status information to the
main form frmMain of the local server. Please resist the temptation
to turn the local server's main form into a graphical device control
panel. Instead, make a separate application that uses the served
driver(s). <U>A driver is not a program!</U>
</P>
</LI>
</OL>
<H3>Notes</H3>
<UL>
<LI>
<P STYLE="margin-bottom: 0cm">
The local server handles all of
the registration and unregistration for each of its served driver
classes, including the ASCOM Chooser info and the DCOM/AppID info
needed for activation from TheSky. By running the server from a
command line and giving /register or /unregister as the command line
option, it will register or unregister all served classes
(respectively). <SPAN STYLE="background: #ffff00">
Never use REGASM
on the local server executable!
</SPAN> <I>
This can be done in the
Visual Studio IDE by setting the server project to run as startup
and setting the command line argument to /register in Debug &ndash;
Start Options.
</I>
</P>
</LI>
<LI>
<P STYLE="margin-bottom: 0cm">
When you make the installer for
your local server based driver/hub, do not let it register the
executable for COM. Instead, have it activate the installed local
server with the /register option.
</P>
</LI>
<LI>
<P>
The ASCOM registration uses the ServedClassName attribute as
the friendly name that will show in the chooser and the ProgId
attribute as the driver Id.
</P>
</LI>
<LI>
<P>
The best deployment way is to install all the files in a
folder that's a sub folder of the main driver, so the SuperScope
driver files will be in the folder ...\ASCOM\Telescope\SuperScope.
This can be done in the Inno script by changing the DefaultDirName
like this:<BR/>
DefaultDirName=&quot;{cf}\ASCOM\Telescope\SuperScope&quot;<BR/>then
the files can all be installed with DestDir: {app};
</P>
</LI>
</UL>
<H3>
<A NAME="theory"></A>Theory of Operation
</H3>
<P>
The local server is an executable which can provide multiple
instances of multiple drivers to multiple clients. This capability is
needed for two applications:
</P>
<UL>
<LI>
<P STYLE="margin-bottom: 0cm">
A hub, which allows multiple
clients to share a single device
</P>
</LI>
<LI>
<P>
A device which provides multiple services, such as a
telescope which has a focuser built-in where both the telescope and
focuser are controlled by the same serial connection and different
client programs need to control to the focuser and telescope.
</P>
</LI>
</UL>
<P>
By simply dropping suitably developed driver assemblies into the
same folder as the local server executable, the local server will
find them and register them for COM and ASCOM and serve any number of
instances of the drivers' interfaces to any number of client
programs. It does this by locating and loading the driver assemblies,
analysing them to detect their classes and interfaces, and
implementing a class factory that can create instances of them for
clients.
</P>
<P>
A driver is an assembly which contains a class that <EM>implements</EM>
one of the ASCOM standard driver interfaces and <EM>inherits</EM> the
ReferenceCountedObjectBase class of the local server. Apart from
that, driver assemblies are identical to those that are used
in-process (DLL-type). The instructions above detail the steps needed
to convert an in-process driver into one that can be served by the
local server.
</P>
<P>
The name of the local server is important, so we provide it as a
<EM>template</EM> from which you can create a local server for your
produce. To make this clear, let's assume that your company AlphaTech
produces a telescope system which contains a microcontroller that is
able to control not only the telescope mount, but also a focuser and
a camera rotator. The mount, focuser, and rotator are all controlled
via commands sent through a common serial line connecting the
computer to the microcontroller, so you need a local server. In
ASCOM, then, you probably want your system to appear as
AlphaTech.Telescope, AlphaTech.Focuser, and AlphaTech.Rotator. Then
you would name the local server AlphaTech. Be sure to give this due
consideration before creating the template, the project name is the
name of your local server. <I>
Is this still correct? I get the
impression that ASCOM.AlphaTech.Server would be OK.
</I>
</P>
<P>
The fact that driver classes inherit from the local server's
ReferenceCountedObjectBase class allows the local server to maintain
a reference count on the driver class. If a client creates an
instance of a served driver, the local server automatically starts up
and provides an instance of the class to the client. Once started the
local server can provide additional instances of any of its served
driver classes. If the reference count of all served classes drops to
zero as a result of clients releasing their instances, the local
server will automatically exit.
</P>
<P>
Registration services provided include not only the basic COM
class registration, but also DCOM/AppID info needed to use the served
classes from outbound connections from Software Bisque's TheSky. It
also registers the served classes for the ASCOM Chooser. The
&quot;friendly&quot; name of each served driver that appears in the
chooser comes from the driver's ServedClassName attribute. This also
used to identify a driver so that non driver dlls, such as Interop
dlls can be ignored. The COM ProgID for each served driver is
specified in the ProgId attribute - ASCOM.<EM>localservername</EM>.<EM>drivertype</EM>,
for example, ASCOM.AlphaTech.Telescope, where AlphaTech is the local
server name and Telescope is the type of the driver. Unregistering
removes all of this information from the system. Specifying the
ProgId as an attribute allows multiple driver assemblies to be
generated using the same source and namespace. This is used to
provide multiple instances of the same driver, each with a different
ProgId and so able to be registered separately.
</P>
<P>
Driver DLLs are identified for registering/unregistering because
they contain a type with the ServedClassName attribute. Only these
will be registered for Com and ASCOM. This has changed; in Platform
5 there was no attribute and the local server attempted to register
all dlls. The new behaviour allows support dlls such as interop dlls
to be included without them being registered incorrectly. There was
also an interim version where the ServedClassName attribute was on
the assembly, not the class. <I>
All these previous versions, and the
new drivers will operate together with Platform 6, the changes are
local to the individual drivers.
</I>
</P>
<H3>
<A NAME="details"></A>Detailed Use and Deployment
</H3>
<P>
Once you have built your local server and the served driver class
assemblies, here's how to use it. To register the served classes,
activate the local server from a shell command line with the option
/register (or /regserver, for VB6 compatibility):
</P>
<PRE CLASS="western">
C:\xxx&gt; <EM>localserver</EM>.exe /register
</PRE>
<P>
To unregister the local server and its drivers, activate the local
server from a shell command line with the option /unregister (or
/unregserver for VB6 compatibility):
</P>
<PRE CLASS="western">
C:\xxx&gt; <EM>localserver</EM>.exe /unregister
</PRE>
<P>
When the operating system starts the local server in response to a
client creating one of it's served driver classes, the command option
/embedding is included. The local server's code detects this and sets
a variable that you can use.
</P>
<P STYLE="margin-bottom: 0cm">
When deploying a hub or set of drivers
with the local server, you'll have to arrange for the local server
and the driver assemblies to be placed together in a folder in the
ASCOM driver folder. Any support files, such as Interop DLLs can be
put in the same fiolder. That's all you need to do, the local server
will find them in the same folder as it is located in.
</P>
<DIV ALIGN="RIGHT">
<TABLE WIDTH="100"% BORDER="0" CELLPADDING="4" CELLSPACING="0">
<TR>
<TD>
<TABLE WIDTH="100"% BORDER="0" CELLPADDING="4" CELLSPACING="0">
<TR>
<TD>
<H3>ASCOM Initiative</H3>
</TD>
<TD>
<IMG SRC="ASCOM.png" NAME="graphics1" ALIGN="RIGHT" WIDTH="48" HEIGHT="56" BORDER="0"/>
</TD>
</TR>
</TABLE>
<P>
<BR/>
<BR/>
</P>
</TD>
</TR>
<TR>
<TD>
<P>
The ASCOM Initiative consists of a group of astronomy software
developers and instrument vendors whose goals are to promote the
driver/client model and scripting automation.
</P>
<P>
See the <A HREF="http://ascom-standards.org/" TARGET="browser">
ASCOM
web site
</A> for more information. Please participate in the
<A HREF="http://tech.groups.yahoo.com/group/ASCOM-Talk" TARGET="browser">
ASCOM-Talk
Yahoo Group
</A>.
</P>
</TD>
</TR>
</TABLE>
</DIV>
<P>
<BR/>
<BR/>
</P>
<P>
<BR/>
<BR/>
</P>
</BODY>
</HTML>
+49 -11
View File
@@ -1,7 +1,11 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO.Ports;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using ASCOM.Meade.net.Properties;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -11,6 +15,16 @@ namespace ASCOM.Meade.net
public SetupDialogForm() public SetupDialogForm()
{ {
InitializeComponent(); InitializeComponent();
var assemblyInfo = new AssemblyInfo();
Text = string.Format(Resources.SetupDialogForm_SetupDialogForm__0__Settings___1__, assemblyInfo.Product, assemblyInfo.AssemblyVersion);
}
public sealed override string Text
{
get => base.Text;
set => base.Text = value;
} }
private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler
@@ -22,7 +36,7 @@ namespace ASCOM.Meade.net
{ {
try try
{ {
System.Diagnostics.Process.Start("http://ascom-standards.org/"); Process.Start("http://ascom-standards.org/");
} }
catch (Win32Exception noBrowser) catch (Win32Exception noBrowser)
{ {
@@ -40,7 +54,7 @@ namespace ASCOM.Meade.net
chkTrace.Checked = profileProperties.TraceLogger; chkTrace.Checked = profileProperties.TraceLogger;
// set the list of com ports to those that are currently available // set the list of com ports to those that are currently available
comboBoxComPort.Items.Clear(); comboBoxComPort.Items.Clear();
comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort comboBoxComPort.Items.AddRange(SerialPort
.GetPortNames()); // use System.IO because it's static .GetPortNames()); // use System.IO because it's static
// select the current port if possible // select the current port if possible
if (comboBoxComPort.Items.Contains(profileProperties.ComPort)) if (comboBoxComPort.Items.Contains(profileProperties.ComPort))
@@ -48,7 +62,15 @@ namespace ASCOM.Meade.net
comboBoxComPort.SelectedItem = profileProperties.ComPort; comboBoxComPort.SelectedItem = profileProperties.ComPort;
} }
txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(); txtGuideRate.Text = profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture);
try
{
cboPrecision.SelectedItem = profileProperties.Precision;
}
catch (Exception)
{
cboPrecision.SelectedItem = "Unchanged";
}
} }
public ProfileProperties GetProfile() public ProfileProperties GetProfile()
@@ -57,7 +79,8 @@ namespace ASCOM.Meade.net
{ {
TraceLogger = chkTrace.Checked, TraceLogger = chkTrace.Checked,
ComPort = comboBoxComPort.SelectedItem.ToString(), ComPort = comboBoxComPort.SelectedItem.ToString(),
GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()) GuideRateArcSecondsPerSecond = double.Parse(txtGuideRate.Text.Trim()),
Precision = cboPrecision.SelectedItem.ToString()
}; };
return profileProperties; return profileProperties;
@@ -65,6 +88,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();
} }
@@ -72,34 +96,48 @@ namespace ASCOM.Meade.net
private void TextBox1_TextChanged(object sender, EventArgs e) private void TextBox1_TextChanged(object sender, EventArgs e)
{ {
//const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
try try
{ {
double newGuideRate = double.Parse(txtGuideRate.Text.Trim()); double newGuideRate = double.Parse(txtGuideRate.Text.Trim());
const double siderealArcSecondsPerSecond = 15.041; const double siderealArcSecondsPerSecond = 15.041;
var percentOfSideReal = (newGuideRate / siderealArcSecondsPerSecond * 100); var percentOfSideReal = newGuideRate / siderealArcSecondsPerSecond * 100;
lblPercentOfSiderealRate.Text = $"({percentOfSideReal:00.0}% of sidereal rate)"; lblPercentOfSiderealRate.Text = string.Format(Resources.SetupDialogForm_TextBox1_TextChanged___0_00_0___of_sidereal_rate_, percentOfSideReal);
_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;
} }
UpdateOKButton(); UpdateOkButton();
} }
private void UpdateOKButton() private void UpdateOkButton()
{ {
cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null); cmdOK.Enabled = _guideRateValid && (comboBoxComPort.SelectedItem != null);
} }
private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e) private void ComboBoxComPort_SelectedValueChanged(object sender, EventArgs e)
{ {
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;
} }
} }
} }
+38 -12
View File
@@ -1,3 +1,6 @@
using System.ComponentModel;
using System.Windows.Forms;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
partial class SetupDialogForm partial class SetupDialogForm
@@ -5,7 +8,7 @@ namespace ASCOM.Meade.net
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
@@ -40,6 +43,8 @@ namespace ASCOM.Meade.net
this.txtGuideRate = new System.Windows.Forms.TextBox(); this.txtGuideRate = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.lblPercentOfSiderealRate = new System.Windows.Forms.Label(); this.lblPercentOfSiderealRate = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.cboPrecision = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -112,10 +117,28 @@ namespace ASCOM.Meade.net
resources.ApplyResources(this.lblPercentOfSiderealRate, "lblPercentOfSiderealRate"); resources.ApplyResources(this.lblPercentOfSiderealRate, "lblPercentOfSiderealRate");
this.lblPercentOfSiderealRate.Name = "lblPercentOfSiderealRate"; this.lblPercentOfSiderealRate.Name = "lblPercentOfSiderealRate";
// //
// label5
//
resources.ApplyResources(this.label5, "label5");
this.label5.Name = "label5";
//
// cboPrecision
//
this.cboPrecision.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboPrecision.FormattingEnabled = true;
this.cboPrecision.Items.AddRange(new object[] {
resources.GetString("cboPrecision.Items"),
resources.GetString("cboPrecision.Items1"),
resources.GetString("cboPrecision.Items2")});
resources.ApplyResources(this.cboPrecision, "cboPrecision");
this.cboPrecision.Name = "cboPrecision";
//
// SetupDialogForm // SetupDialogForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cboPrecision);
this.Controls.Add(this.label5);
this.Controls.Add(this.lblPercentOfSiderealRate); this.Controls.Add(this.lblPercentOfSiderealRate);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.txtGuideRate); this.Controls.Add(this.txtGuideRate);
@@ -132,6 +155,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);
@@ -141,16 +165,18 @@ namespace ASCOM.Meade.net
#endregion #endregion
private System.Windows.Forms.Button cmdOK; private Button cmdOK;
private System.Windows.Forms.Button cmdCancel; private Button cmdCancel;
private System.Windows.Forms.Label label1; private Label label1;
private System.Windows.Forms.PictureBox picASCOM; private PictureBox picASCOM;
private System.Windows.Forms.Label label2; private Label label2;
private System.Windows.Forms.CheckBox chkTrace; private CheckBox chkTrace;
private System.Windows.Forms.ComboBox comboBoxComPort; private ComboBox comboBoxComPort;
private System.Windows.Forms.Label label3; private Label label3;
private System.Windows.Forms.TextBox txtGuideRate; private TextBox txtGuideRate;
private System.Windows.Forms.Label label4; private Label label4;
private System.Windows.Forms.Label lblPercentOfSiderealRate; private Label lblPercentOfSiderealRate;
private Label label5;
private ComboBox cboPrecision;
} }
} }
+74 -17
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
@@ -145,7 +145,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve"> <data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve">
<value>10</value> <value>12</value>
</data> </data>
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value> <value>Bottom, Right</value>
@@ -172,13 +172,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve"> <data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve">
<value>9</value> <value>11</value>
</data> </data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing"> <data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<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>
@@ -196,7 +196,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>8</value> <value>10</value>
</data> </data>
<data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value> <value>Top, Right</value>
@@ -223,7 +223,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;picASCOM.ZOrder" xml:space="preserve"> <data name="&gt;&gt;picASCOM.ZOrder" xml:space="preserve">
<value>7</value> <value>9</value>
</data> </data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib"> <data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
@@ -250,13 +250,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>6</value> <value>8</value>
</data> </data>
<data name="chkTrace.AutoSize" type="System.Boolean, mscorlib"> <data name="chkTrace.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing"> <data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 118</value> <value>77, 136</value>
</data> </data>
<data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing"> <data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 17</value> <value>69, 17</value>
@@ -277,7 +277,7 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve"> <data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve">
<value>5</value> <value>7</value>
</data> </data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing"> <data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 87</value> <value>77, 87</value>
@@ -298,13 +298,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve"> <data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>4</value> <value>6</value>
</data> </data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib"> <data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="label3.Location" type="System.Drawing.Point, System.Drawing"> <data name="label3.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 225</value> <value>10, 162</value>
</data> </data>
<data name="label3.Size" type="System.Drawing.Size, System.Drawing"> <data name="label3.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 13</value> <value>61, 13</value>
@@ -325,10 +325,10 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>3</value> <value>5</value>
</data> </data>
<data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing"> <data name="txtGuideRate.Location" type="System.Drawing.Point, System.Drawing">
<value>80, 222</value> <value>77, 159</value>
</data> </data>
<data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing"> <data name="txtGuideRate.Size" type="System.Drawing.Size, System.Drawing">
<value>46, 20</value> <value>46, 20</value>
@@ -349,13 +349,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve"> <data name="&gt;&gt;txtGuideRate.ZOrder" xml:space="preserve">
<value>2</value> <value>4</value>
</data> </data>
<data name="label4.AutoSize" type="System.Boolean, mscorlib"> <data name="label4.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="label4.Location" type="System.Drawing.Point, System.Drawing"> <data name="label4.Location" type="System.Drawing.Point, System.Drawing">
<value>132, 225</value> <value>129, 162</value>
</data> </data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing"> <data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<value>122, 13</value> <value>122, 13</value>
@@ -376,13 +376,13 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve"> <data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<value>1</value> <value>3</value>
</data> </data>
<data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib"> <data name="lblPercentOfSiderealRate.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="lblPercentOfSiderealRate.Location" type="System.Drawing.Point, System.Drawing"> <data name="lblPercentOfSiderealRate.Location" type="System.Drawing.Point, System.Drawing">
<value>132, 238</value> <value>129, 175</value>
</data> </data>
<data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing"> <data name="lblPercentOfSiderealRate.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 13</value> <value>105, 13</value>
@@ -403,6 +403,63 @@
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve"> <data name="&gt;&gt;lblPercentOfSiderealRate.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="label5.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label5.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 194</value>
</data>
<data name="label5.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 13</value>
</data>
<data name="label5.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="label5.Text" xml:space="preserve">
<value>Precision</value>
</data>
<data name="&gt;&gt;label5.Name" xml:space="preserve">
<value>label5</value>
</data>
<data name="&gt;&gt;label5.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label5.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label5.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cboPrecision.Items" xml:space="preserve">
<value>Unchanged</value>
</data>
<data name="cboPrecision.Items1" xml:space="preserve">
<value>Low</value>
</data>
<data name="cboPrecision.Items2" xml:space="preserve">
<value>High</value>
</data>
<data name="cboPrecision.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 191</value>
</data>
<data name="cboPrecision.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value>
</data>
<data name="cboPrecision.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="&gt;&gt;cboPrecision.Name" xml:space="preserve">
<value>cboPrecision</value>
</data>
<data name="&gt;&gt;cboPrecision.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cboPrecision.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cboPrecision.ZOrder" xml:space="preserve">
<value>0</value> <value>0</value>
</data> </data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+56 -98
View File
@@ -13,8 +13,11 @@
// Written by: Bob Denny 29-May-2007 // Written by: Bob Denny 29-May-2007
// Modified by Chris Rowland and Peter Simpson to hamdle multiple hardware devices March 2011 // Modified by Chris Rowland and Peter Simpson to hamdle multiple hardware devices March 2011
// //
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using ASCOM.Utilities; using ASCOM.Utilities;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
@@ -58,12 +61,7 @@ namespace ASCOM.Meade.net
/// <summary> /// <summary>
/// Shared serial port /// Shared serial port
/// </summary> /// </summary>
public static Serial SharedSerial => _sSharedSerial ?? (_sSharedSerial = new Serial()); private static Serial SharedSerial => _sSharedSerial ?? (_sSharedSerial = new Serial());
/// <summary>
/// number of connections to the shared serial port
/// </summary>
public static int Connections { get; set; } = 0;
public static void SendBlind(string message) public static void SendBlind(string message)
{ {
@@ -74,12 +72,6 @@ namespace ASCOM.Meade.net
} }
} }
public static bool SendBool(string message)
{
SharedSerial.ClearBuffers();
return SendChar(message) == "1";
}
/// <summary> /// <summary>
/// Example of a shared SendMessage method, the lock /// Example of a shared SendMessage method, the lock
/// prevents different drivers tripping over one another. /// prevents different drivers tripping over one another.
@@ -116,37 +108,12 @@ namespace ASCOM.Meade.net
} }
} }
/// <summary> public static void ReadCharacters(int throwAwayCharacters)
/// Example of handling connecting to and disconnection from the
/// shared serial port.
/// Needs error handling
/// the port name etc. needs to be set up first, this could be done by the driver
/// checking Connected and if it's false setting up the port before setting connected to true.
/// It could also be put here.
/// </summary>
public static bool Connected
{
set
{ {
lock (LockObject) lock (LockObject)
{ {
if (value) SharedSerial.ReceiveCounted(throwAwayCharacters);
{
if (Connections == 0)
SharedSerial.Connected = true;
Connections++;
} }
else
{
Connections--;
if (Connections <= 0)
{
SharedSerial.Connected = false;
}
}
}
}
get => SharedSerial.Connected;
} }
#endregion #endregion
@@ -159,6 +126,7 @@ namespace ASCOM.Meade.net
private const string ComPortProfileName = "COM Port"; private const string ComPortProfileName = "COM Port";
private const string TraceStateProfileName = "Trace Level"; private const string TraceStateProfileName = "Trace Level";
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second"; private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
private const string PrecisionProfileName = "Precision";
public static void WriteProfile(ProfileProperties profileProperties) public static void WriteProfile(ProfileProperties profileProperties)
{ {
@@ -169,7 +137,8 @@ namespace ASCOM.Meade.net
driverProfile.DeviceType = "Telescope"; driverProfile.DeviceType = "Telescope";
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString()); driverProfile.WriteValue(DriverId, GuideRateProfileName, profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture));
driverProfile.WriteValue(DriverId, PrecisionProfileName, profileProperties.Precision);
} }
} }
} }
@@ -177,6 +146,7 @@ namespace ASCOM.Meade.net
private const string ComPortDefault = "COM1"; private const string ComPortDefault = "COM1";
private const string TraceStateDefault = "false"; private const string TraceStateDefault = "false";
private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate private const string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
private const string PrecisionDefault = "Unchanged";
public static ProfileProperties ReadProfile() public static ProfileProperties ReadProfile()
{ {
@@ -189,6 +159,7 @@ namespace ASCOM.Meade.net
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault); profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault)); profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault)); profileProperties.GuideRateArcSecondsPerSecond = double.Parse(driverProfile.GetValue(DriverId, GuideRateProfileName, string.Empty, GuideRateProfileNameDefault));
profileProperties.Precision = driverProfile.GetValue(DriverId, PrecisionProfileName, string.Empty, PrecisionDefault);
} }
return profileProperties; return profileProperties;
@@ -201,22 +172,19 @@ namespace ASCOM.Meade.net
public static void SetupDialog() public static void SetupDialog()
{ {
// consider only showing the setup dialog if not connected
// or call a different dialog if connected
if (Connections > 0)
{
System.Windows.Forms.MessageBox.Show("Already connected, please disconnect before altering settings");
return;
}
var profileProperties = ReadProfile(); var profileProperties = ReadProfile();
using (SetupDialogForm f = new SetupDialogForm()) using (SetupDialogForm f = new SetupDialogForm())
{ {
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 == DialogResult.OK)
{ {
profileProperties = f.GetProfile(); profileProperties = f.GetProfile();
@@ -246,24 +214,32 @@ namespace ASCOM.Meade.net
/// The Key is the connection number that identifies the device, it could be the COM port name, /// The Key is the connection number that identifies the device, it could be the COM port name,
/// USB ID or IP Address, the Value is the DeviceHardware class /// USB ID or IP Address, the Value is the DeviceHardware class
/// </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) /// <param name="driverId"></param>
public static ConnectionInfo Connect(string deviceId, string driverId)
{ {
lock (LockObject) lock (LockObject)
{ {
if (!_connectedDevices.ContainsKey(deviceId)) if (!ConnectedDevices.ContainsKey(deviceId))
_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)
{ {
var profileProperties = ReadProfile(); var profileProperties = ReadProfile();
SharedSerial.PortName = profileProperties.ComPort; SharedSerial.PortName = profileProperties.ComPort;
@@ -280,33 +256,47 @@ 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)
{ {
if (_connectedDevices.ContainsKey(deviceId)) if (ConnectedDevices.ContainsKey(deviceId))
{ {
_connectedDevices[deviceId].Count--; ConnectedDevices[deviceId].Count--;
if (_connectedDevices[deviceId].Count <= 0) if (ConnectedDevices[deviceId].Count <= 0)
{ {
_connectedDevices.Remove(deviceId); ConnectedDevices.Remove(deviceId);
if (deviceId == "Serial") if (deviceId == "Serial")
{ {
SharedSerial.Connected = false; SharedSerial.Connected = false;
} }
} }
} }
if (ConnectedDeviceIds.ContainsKey(driverId))
{
ConnectedDeviceIds[driverId].Count--;
}
} }
} }
public static bool IsConnected(string deviceId) private static bool IsConnected()
{ {
if (_connectedDevices.ContainsKey(deviceId)) foreach (var device in ConnectedDevices)
return (_connectedDevices[deviceId].Count > 0); {
else if (device.Value.Count > 0)
return true;
}
return false; return false;
} }
@@ -332,46 +322,14 @@ namespace ASCOM.Meade.net
/// Skeleton of a hardware class, all this does is hold a count of the connections, /// Skeleton of a hardware class, all this does is hold a count of the connections,
/// in reality extra code will be needed to handle the hardware in some way /// in reality extra code will be needed to handle the hardware in some way
/// </summary> /// </summary>
public class DeviceHardware private class DeviceHardware
{ {
private int _count; internal int Count { set; get; }
internal int Count
{
set => _count = value;
get => _count;
}
internal DeviceHardware() internal DeviceHardware()
{ {
Count = 0; Count = 0;
} }
} }
//#region ServedClassName attribute
///// <summary>
///// This is only needed if the driver is targeted at platform 5.5, it is included with Platform 6
///// </summary>
//[global::System.AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
//public sealed class ServedClassNameAttribute : Attribute
//{
// // See the attribute guidelines at
// // http://go.microsoft.com/fwlink/?LinkId=85236
// /// <summary>
// /// Gets or sets the 'friendly name' of the served class, as registered with the ASCOM Chooser.
// /// </summary>
// /// <value>The 'friendly name' of the served class.</value>
// public string DisplayName { get; private set; }
// /// <summary>
// /// Initializes a new instance of the <see cref="ServedClassNameAttribute"/> class.
// /// </summary>
// /// <param name="servedClassName">The 'friendly name' of the served class.</param>
// public ServedClassNameAttribute(string servedClassName)
// {
// DisplayName = servedClassName;
// }
//}
//#endregion
} }
} }
+16 -13
View File
@@ -1,30 +1,33 @@
using System; namespace ASCOM.Meade.net
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
namespace ASCOM.Meade.net
{ {
public static class TelescopeList public static class TelescopeList
{ {
#region Autostar 497/Audiostar #region Autostar 497/Audiostar
public readonly static string Autostar497 = "Autostar"; public static readonly string Autostar497 = "Autostar";
//Autostar/Audiostar firmware revisions //Autostar/Audiostar firmware revisions
public readonly static string Autostar497_30Ee = "30Ee"; // ReSharper disable once InconsistentNaming
public readonly static string Autostar497_31Ee = "31Ee"; public static readonly string Autostar497_30Ee = "30Ee";
public readonly static string Autostar497_43Eg = "43Eg"; // ReSharper disable once InconsistentNaming
public static readonly string Autostar497_31Ee = "31Ee";
// ReSharper disable once InconsistentNaming
public static readonly string Autostar497_43Eg = "43Eg";
#endregion #endregion
#region LX200GPS #region LX200GPS
public readonly static string LX200GPS = "LX2001"; // ReSharper disable once InconsistentNaming
public static readonly string LX200GPS = "LX2001";
public readonly static string LX200GPS_42G = "4.2G"; // ReSharper disable once InconsistentNaming
public static readonly string LX200GPS_42G = "4.2G";
#endregion
#region LX200EMC
// ReSharper disable once InconsistentNaming
public static readonly string LX200CLASSIC = ":GVP"; //GVP command is not supported!
#endregion #endregion
} }
} }
+148
View File
@@ -0,0 +1,148 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
// ReSharper disable UnusedMember.Global
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")]
// ReSharper disable once UnusedMember.Local
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, Int32 nMaxCount);
[DllImport("user32.dll")]
// ReSharper disable once UnusedMember.Local
private static extern int GetWindowThreadProcessId(IntPtr hWnd, ref Int32 lpdwProcessId);
[DllImport("User32.dll")]
public static extern IntPtr GetParent(IntPtr hWnd);
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_HIDE = 0;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWNORMAL = 1;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_NORMAL = 1;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWMINIMIZED = 2;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWMAXIMIZED = 3;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_MAXIMIZE = 3;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWNOACTIVATE = 4;
// ReSharper disable once InconsistentNaming
private const int SW_SHOW = 5;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_MINIMIZE = 6;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWMINNOACTIVE = 7;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWNA = 8;
// ReSharper disable once InconsistentNaming
private const int SW_RESTORE = 9;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWDEFAULT = 10;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_MAX = 10;
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private const uint SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000;
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private const uint SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001;
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
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);
}
}
}
}
+12 -6
View File
@@ -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; }
@@ -24,18 +24,19 @@ namespace ASCOM.Meade.net.Wrapper
void SetupDialog(); void SetupDialog();
void WriteProfile(ProfileProperties profileProperties); void WriteProfile(ProfileProperties profileProperties);
void ReadCharacters(int throwAwayCharacters);
} }
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;
@@ -72,6 +73,11 @@ namespace ASCOM.Meade.net.Wrapper
return SharedResources.ReadTerminated(); return SharedResources.ReadTerminated();
} }
public void ReadCharacters(int throwAwayCharacters)
{
SharedResources.ReadCharacters(throwAwayCharacters);
}
public ProfileProperties ReadProfile() public ProfileProperties ReadProfile()
{ {
return SharedResources.ReadProfile(); return SharedResources.ReadProfile();
+4 -3
View File
@@ -1,4 +1,5 @@
using System; using System.ComponentModel;
using System.Windows.Forms;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -7,7 +8,7 @@ namespace ASCOM.Meade.net
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
@@ -56,7 +57,7 @@ namespace ASCOM.Meade.net
#endregion #endregion
private System.Windows.Forms.Label label1; private Label label1;
} }
} }
-2
View File
@@ -4,8 +4,6 @@ namespace ASCOM.Meade.net
{ {
public partial class FrmMain : Form public partial class FrmMain : Form
{ {
delegate void SetTextCallback(string text);
public FrmMain() public FrmMain()
{ {
InitializeComponent(); InitializeComponent();
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
+3 -2
View File
@@ -9,6 +9,7 @@
#define UseChooser #define UseChooser
using System; using System;
using ASCOM.DriverAccess;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -19,11 +20,11 @@ namespace ASCOM.Meade.net
// Uncomment the code that's required // Uncomment the code that's required
#if UseChooser #if UseChooser
// choose the device // choose the device
string id = DriverAccess.Telescope.Choose("ASCOM.MeadeGeneric.Telescope"); string id = Telescope.Choose("ASCOM.MeadeGeneric.Telescope");
if (string.IsNullOrEmpty(id)) if (string.IsNullOrEmpty(id))
return; return;
// create this device // create this device
DriverAccess.Telescope device = new DriverAccess.Telescope(id); Telescope device = new Telescope(id);
#else #else
// this can be replaced by this code, it avoids the chooser and creates the driver class directly. // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.Meade.net.Telescope"); ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.Meade.net.Telescope");
@@ -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" />