Compare commits

..

33 Commits

Author SHA1 Message Date
ColinD 2181ff5602 Added extra # in front of every command as recommended by Meade.
Code inspections
Duplicate reconcile
Code upgraded to use .net 4.5
Added log message for when a pulse guide move is completed that will show the difference.
.net 4.5 is not being recognised as installed, so trying a different variable.
Modified how the old guiding method is implmented - it's now much simplified and uses the same move axis commands as normal slewing, which is what it does under the hood anyway.
Modified how the RA detection is done, and changed the message logs
RA position report on connect to trigger for ALL connects.
Modified the LX200 Classic connections, so that if a :GVP is returned when :GVP# is sent, it assumes an error. A timeout will be assumed to be an LX200 Classic.
Started working on unit testing for the sharedresources class.
Changed the code to detect any exception when trying to run a :GVP after the initial connect.
Upgraded the Profile code to be contained inside a wrapper and started adding unit tests to cover.
2019-10-22 21:52:42 +00:00
ColinD 9505468efc Code inspection cleanup 2019-10-22 22:06:40 +01:00
ColinD 2cbb1fb68c Code inspection cleanup 2019-10-22 21:51:59 +01:00
ColinD ba0ae056ea Forcing the disconnect to make sure that the tests work as expected. 2019-10-22 21:40:45 +01:00
ColinD dff7bce6b0 Unit Testing for the connect method. 2019-10-22 21:27:07 +01:00
ColinD a155e27eac Upgraded the Profile code to be contained inside a wrapper and started adding unit tests to cover. 2019-10-21 21:16:09 +01:00
ColinD 438ec779b4 Changed the code to detect any exception when trying to run a :GVP after the initial connect. 2019-10-19 11:54:04 +01:00
ColinD 307517ded0 Updated nuget packages. Started working on unit testing for the sharedresources class. 2019-10-15 21:33:51 +01:00
ColinD 8efa8752df Corrected defect where the scope will not attempt to connect the serial port 2019-10-13 21:15:30 +01:00
ColinD 7f6f478dfc Modified the LX200 Classic connections, so that if a :GVP is returned when :GVP# is sent, it assumes an error. A timeout will be assumed to be an LX200 Classic. 2019-10-12 12:40:01 +01:00
ColinD 7a92581fa8 Moved the RA position report on connect to trigger for ALL connects, not just the first connection. 2019-10-05 13:47:14 +01:00
ColinD 7f8c2cb559 Removed the alignmode check as it is not supported on all telescopes.
Added current RA and dec to the log when the telescope connects.
2019-10-05 11:23:10 +01:00
ColinD 3dc87e3724 Added new alignment mode to the log 2019-10-04 20:42:46 +01:00
ColinD 670a5ccf81 Modified how the RA detection is done, and changed the message logs 2019-10-04 20:34:42 +01:00
ColinD 9af0613183 Modified how the old guiding method is implmented - it's now much simplified and uses the same move axis commands as normal slewing, which is what it does under the hood anyway. 2019-10-04 18:20:32 +01:00
ColinD 5df0e21a58 Another attempt at adding .net 4.5 checking 2019-10-03 23:34:13 +01:00
ColinD 149bad2d31 .net 4.5 is not being recognised as installed, so trying a different variable. 2019-10-03 23:12:27 +01:00
ColinD 276f0352e3 Added log message for when a pulse guide move is completed that will show the difference. 2019-10-02 18:55:24 +01:00
ColinD f22e9cdd02 Code inspections 2019-10-01 22:06:42 +01:00
ColinD ee3862f949 Code inspections 2019-10-01 22:03:57 +01:00
ColinD 2972ae31aa Code upgraded to use .net 4.5 2019-10-01 22:00:55 +01:00
ColinD 79cdd60d07 Duplicate reconcile 2019-10-01 21:51:06 +01:00
ColinD f92f21ab72 Code inspections 2019-10-01 21:44:36 +01:00
ColinD 2a56cfa700 Duplicate reconcile 2019-10-01 21:16:47 +01:00
ColinD babb2a7492 Code inspections 2019-10-01 20:57:49 +01:00
ColinD 23960d8c7c Code inspections 2019-10-01 19:42:40 +01:00
ColinD cb97358100 Code inspections 2019-10-01 19:37:39 +01:00
ColinD 28889bdb49 Code inspections 2019-10-01 19:12:34 +01:00
ColinD 5efde9f6e0 Code inspections 2019-10-01 19:03:48 +01:00
ColinD 12e46edc74 Code inspections 2019-10-01 18:55:20 +01:00
ColinD 9969fce375 Merge branch 'master' into develop 2019-09-30 23:30:44 +01:00
ColinD 97e77c839a Added extra # in front of every command as recommended by Meade. 2019-09-30 23:27:18 +01:00
ColinD 0ea195e073 Merge branch 'master' into develop 2019-09-30 22:28:10 +01:00
52 changed files with 1448 additions and 607 deletions
@@ -56,8 +56,8 @@
<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 Include="Moq, Version=4.13.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.13.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>
@@ -65,8 +65,8 @@
<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 Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\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>
+4
View File
@@ -6,6 +6,10 @@
<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>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+2 -2
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
<package id="Moq" version="4.12.0" targetFramework="net472" />
<package id="Moq" version="4.13.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.6.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
</packages>
+2 -1
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASCOM.MeadeGeneric</RootNamespace>
<AssemblyName>ASCOM.MeadeGeneric.Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@@ -54,6 +54,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
+2 -2
View File
@@ -14,9 +14,9 @@ using ASCOM.DriverAccess;
namespace ASCOM.MeadeGeneric
{
class Program
public static class Program
{
static void Main(string[] args)
public static void Main()
{
// Uncomment the code that's required
#if UseChooser
+1 -1
View File
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
@@ -401,13 +401,13 @@ namespace Meade.net.Focuser.UnitTests
if (position < 0)
{
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(":F-#"), Times.AtLeastOnce);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":F+#"), Times.Never);
_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.SendBlind("#:F-#"), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("#:F+#"), Times.AtLeastOnce);
}
_sharedResourcesWrapperMock.Verify( x => x.Lock(It.IsAny<Action>()), Times.Once);
@@ -71,8 +71,8 @@
<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 Include="Moq, Version=4.13.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.13.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>
@@ -80,8 +80,8 @@
<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 Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\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>
+4
View File
@@ -6,6 +6,10 @@
<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>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+2 -2
View File
@@ -2,8 +2,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="Moq" version="4.13.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.6.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
</packages>
+3 -3
View File
@@ -25,9 +25,9 @@
<![CDATA[Installed OR ASCOMPLATFORMVERSION >= "6.4.1"]]>
</Condition>
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message="This application requires .NET Framework 4.0 or higher. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="This application requires .NET Framework 4.5 or higher. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
<!-- <Condition Message="Please use the correct installer for your operating system - x86 for 32-bit, x64 for 64-bit.">
@@ -92,8 +92,8 @@
<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 Include="Moq, Version=4.13.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.13.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\net40\nunit.framework.dll</HintPath>
@@ -101,8 +101,8 @@
<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\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\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>
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
@@ -2,8 +2,8 @@
<packages>
<package id="ASCOM.Platform" version="6.4.2" targetFramework="net472" />
<package id="Castle.Core" version="4.4.0" targetFramework="net45" />
<package id="Moq" version="4.12.0" targetFramework="net45" />
<package id="Moq" version="4.13.0" targetFramework="net472" />
<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.6.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
</packages>
+1 -1
View File
@@ -22,7 +22,7 @@ namespace ASCOM.Meade.net.AstroMaths
return h;
}
public double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle )
private double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle )
{
var gst = UTtoGst(utcDateTime);
var lst = GsTtoLst( gst, longitude);
@@ -5,13 +5,13 @@ namespace ASCOM.Meade.net.AstroMaths
public interface IAstroMaths
{
double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension);
double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle );
//double HourAngleToRightAscension(DateTime utcDateTime, double longitude, double hourAngle );
EquatorialCoordinates ConvertHozToEq( DateTime utcDateTime, double latitude, double longitude, HorizonCoordinates altAz);
HorizonCoordinates ConvertEqToHoz(double hourAngle, double latitude, EquatorialCoordinates raDec);
double DegreesToRadians(double degrees);
double RadiansToDegrees(double radians);
double DateTimeToDecimalHours( DateTime utcDateTime);
double UTtoGst(DateTime utcDateTime);
double GsTtoLst(double gst, double longitude);
//double DegreesToRadians(double degrees);
//double RadiansToDegrees(double radians);
//double DateTimeToDecimalHours( DateTime utcDateTime);
//double UTtoGst(DateTime utcDateTime);
//double GsTtoLst(double gst, double longitude);
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace ASCOM.Meade.net
{
public enum ComparisonResult
{
Lower,
Equals,
Greater
}
}
+13
View File
@@ -10,5 +10,18 @@ namespace ASCOM.Meade.net
return false;
return true;
}
public static ComparisonResult Compare(this double value, double comparison)
{
var result = value.CompareTo(comparison);
if (result < 0)
return ComparisonResult.Lower;
if (result == 0)
return ComparisonResult.Equals;
return ComparisonResult.Greater;
}
}
}
@@ -15,7 +15,7 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ApplicationIcon>ASCOM.ico</ApplicationIcon>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ASCOMDriverTemplate.snk</AssemblyOriginatorKeyFile>
@@ -62,10 +62,12 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\bin\Release\</OutputPath>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>..\bin\Debug\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
@@ -118,6 +120,7 @@
<Compile Include="AstroMaths\EquatorialCoordinates.cs" />
<Compile Include="AstroMaths\HorizonCoordinates.cs" />
<Compile Include="AstroMaths\IAstroMaths.cs" />
<Compile Include="ComparisonResult.cs" />
<Compile Include="DoubleExtensions.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="Telescope.cs" />
+19 -25
View File
@@ -8,16 +8,10 @@
// </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 {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@@ -25,27 +19,27 @@ namespace ASCOM.Meade.net.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode()]
[CompilerGenerated()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static ResourceManager resourceMan;
private static global::System.Resources.ResourceManager resourceMan;
private static CultureInfo resourceCulture;
private static global::System.Globalization.CultureInfo resourceCulture;
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (ReferenceEquals(resourceMan, null)) {
ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -56,8 +50,8 @@ namespace ASCOM.Meade.net.Properties {
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -69,20 +63,20 @@ namespace ASCOM.Meade.net.Properties {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static Bitmap ASCOM {
internal static System.Drawing.Bitmap ASCOM {
get {
object obj = ResourceManager.GetObject("ASCOM", resourceCulture);
return ((Bitmap)(obj));
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static Icon DefaultIcon {
internal static System.Drawing.Icon DefaultIcon {
get {
object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture);
return ((Icon)(obj));
return ((System.Drawing.Icon)(obj));
}
}
+4 -8
View File
@@ -8,18 +8,14 @@
// </auto-generated>
//------------------------------------------------------------------------------
using System.CodeDom.Compiler;
using System.Configuration;
using System.Runtime.CompilerServices;
namespace ASCOM.Meade.net.Properties {
[CompilerGenerated()]
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : ApplicationSettingsBase {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(Synchronized(new Settings())));
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
+6 -5
View File
@@ -82,16 +82,17 @@ namespace ASCOM.Meade.net
switch (axis)
{
case TelescopeAxes.axisPrimary:
case TelescopeAxes.axisSecondary:
// 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) }
//this.rates = new Rate[0];
_rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break;
case TelescopeAxes.axisSecondary:
// TODO Initialize this array with any Secondary axis rates that your driver may provide
//this.rates = new Rate[0];
_rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
break;
//// TODO Initialize this array with any Secondary axis rates that your driver may provide
////this.rates = new Rate[0];
//_rates = new[] { new Rate(1, 1), new Rate(2, 2), new Rate(3, 3), new Rate(4, 4) };
//break;
case TelescopeAxes.axisTertiary:
// TODO Initialize this array with any Tertiary axis rates that your driver may provide
_rates = new Rate[0];
+4 -4
View File
@@ -7,10 +7,10 @@ namespace ASCOM.Meade.net
return int.Parse(str);
}
public static double ToDouble(this string str)
{
return double.Parse(str);
}
//public static double ToDouble(this string str)
//{
// return double.Parse(str);
//}
public static int Position(this string str, char find, int instance)
{
+176 -152
View File
@@ -42,7 +42,7 @@ namespace ASCOM.Meade.net
/// The DeviceID is used by ASCOM applications to load the driver at runtime.
/// </summary>
//internal static string driverID = "ASCOM.Meade.net.Telescope";
private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException());
// TODO Change the descriptive string for your driver then remove this line
/// <summary>
@@ -169,68 +169,68 @@ namespace ASCOM.Meade.net
{
//Read the screen
case "readdisplay":
var output = _sharedResourcesWrapper.SendString(":ED#");
var output = _sharedResourcesWrapper.SendString("#:ED#");
return output;
//top row of buttons
case "enter":
_sharedResourcesWrapper.SendBlind(":EK13#");
_sharedResourcesWrapper.SendBlind("#:EK13#");
break;
case "mode":
_sharedResourcesWrapper.SendBlind(":EK9#");
_sharedResourcesWrapper.SendBlind("#:EK9#");
break;
case "longmode":
_sharedResourcesWrapper.SendBlind(":EK11#");
_sharedResourcesWrapper.SendBlind("#:EK11#");
break;
case "goto":
_sharedResourcesWrapper.SendBlind(":EK24#");
_sharedResourcesWrapper.SendBlind("#:EK24#");
break;
case "0": //light and 0
_sharedResourcesWrapper.SendBlind(":EK48#");
_sharedResourcesWrapper.SendBlind("#:EK48#");
break;
case "1":
_sharedResourcesWrapper.SendBlind(":EK49#");
_sharedResourcesWrapper.SendBlind("#:EK49#");
break;
case "2":
_sharedResourcesWrapper.SendBlind(":EK50#");
_sharedResourcesWrapper.SendBlind("#:EK50#");
break;
case "3":
_sharedResourcesWrapper.SendBlind(":EK51#");
_sharedResourcesWrapper.SendBlind("#:EK51#");
break;
case "4":
_sharedResourcesWrapper.SendBlind(":EK52#");
_sharedResourcesWrapper.SendBlind("#:EK52#");
break;
case "5":
_sharedResourcesWrapper.SendBlind(":EK53#");
_sharedResourcesWrapper.SendBlind("#:EK53#");
break;
case "6":
_sharedResourcesWrapper.SendBlind(":EK54#");
_sharedResourcesWrapper.SendBlind("#:EK54#");
break;
case "7":
_sharedResourcesWrapper.SendBlind(":EK55#");
_sharedResourcesWrapper.SendBlind("#:EK55#");
break;
case "8":
_sharedResourcesWrapper.SendBlind(":EK56#");
_sharedResourcesWrapper.SendBlind("#:EK56#");
break;
case "9":
_sharedResourcesWrapper.SendBlind(":EK57#");
_sharedResourcesWrapper.SendBlind("#:EK57#");
break;
case "up":
_sharedResourcesWrapper.SendBlind(":EK94#");
_sharedResourcesWrapper.SendBlind("#:EK94#");
break;
case "down":
_sharedResourcesWrapper.SendBlind(":EK118#");
_sharedResourcesWrapper.SendBlind("#:EK118#");
break;
case "back":
_sharedResourcesWrapper.SendBlind(":EK87#");
_sharedResourcesWrapper.SendBlind("#:EK87#");
break;
case "forward":
_sharedResourcesWrapper.SendBlind(":EK69#");
_sharedResourcesWrapper.SendBlind("#:EK69#");
break;
case "?":
_sharedResourcesWrapper.SendBlind(":EK63#");
_sharedResourcesWrapper.SendBlind("#:EK63#");
break;
default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
@@ -388,6 +388,7 @@ namespace ASCOM.Meade.net
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);
@@ -402,6 +403,9 @@ namespace ASCOM.Meade.net
{
LogMessage("Connected Set", $"Skipping first connection telescope adjustments (current connections: {connectionInfo.SameDevice})");
}
var raAndDec = GetTelescopeRaAndDec();
LogMessage("Connected Set", $"Connected OK. Current RA = {_utilitiesExtra.HoursToHMS(raAndDec.RightAscension)} Dec = {_utilitiesExtra.DegreesToDMS(raAndDec.Declination)}");
}
catch (Exception)
{
@@ -488,11 +492,14 @@ namespace ASCOM.Meade.net
IsLongFormat = false;
if (!IsLongFormatSupported())
{
LogMessage("SetLongFormat", "Long coordinate format not supported for this mount");
return;
}
_sharedResourcesWrapper.Lock(() =>
{
var result = _sharedResourcesWrapper.SendString(":GZ#");
var result = _sharedResourcesWrapper.SendString("#:GZ#");
//:GZ# Get telescope azimuth
//Returns: DDD*MM# or DDD*MMSS#
//The current telescope Azimuth depending on the selected precision.
@@ -502,19 +509,21 @@ namespace ASCOM.Meade.net
if (IsLongFormat != setLongFormat)
{
_utilities.WaitForMilliseconds(500);
_sharedResourcesWrapper.SendBlind(":U#");
_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
}
});
LogMessage("SetLongFormat", $"Long coordinate format: {setLongFormat} ");
}
private bool TogglePrecision()
{
LogMessage("TogglePrecision", "Toggling slewing precision");
var result = _sharedResourcesWrapper.SendChar(":P#");
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.
@@ -552,33 +561,35 @@ namespace ASCOM.Meade.net
public void SelectSite(int site)
{
CheckConnected("SelectSite");
CheckConnectedAndValidateSite(site, "SelectSite");
if (site < 1)
throw new ArgumentOutOfRangeException(nameof(site),site,Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
if (site > 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>#
//Set current site to<n>, an ASCII digit in the range 1..4
//Returns: Nothing
}
private void SetSiteName(int site, string sitename)
private void CheckConnectedAndValidateSite(int site, string message)
{
CheckConnected("SetSiteName");
CheckConnected(message);
if (site < 1)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
throw new ArgumentOutOfRangeException(nameof(site), site,
Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
if (site > 4)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_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;
private void SetSiteName(int site, string sitename)
{
CheckConnectedAndValidateSite(site, "SetSiteName");
string command;
switch (site)
{
case 1:
command = $":SM{sitename}#";
command = $"#:SM{sitename}#";
//:SM<string>#
//Set site 1s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
@@ -586,7 +597,7 @@ namespace ASCOM.Meade.net
//1 - Valid
break;
case 2:
command = $":SN{sitename}#";
command = $"#:SN{sitename}#";
//:SN<string>#
//Set site 2s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
@@ -594,7 +605,7 @@ namespace ASCOM.Meade.net
//1 - Valid
break;
case 3:
command = $":SO{sitename}#";
command = $"#:SO{sitename}#";
//:SO<string>#
//Set site 3s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
@@ -602,14 +613,15 @@ namespace ASCOM.Meade.net
//1 - Valid
break;
case 4:
command = $":SP{sitename}#";
command = $"#:SP{sitename}#";
//:SP<string>#
//Set site 4s name to be<string>.LX200s only accept 3 character strings. Other scopes accept up to 15 characters.
// Returns:
//0 Invalid
//1 - Valid
break;
default:
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range);
}
var result = _sharedResourcesWrapper.SendChar(command);
@@ -621,39 +633,34 @@ namespace ASCOM.Meade.net
private string GetSiteName(int site)
{
CheckConnected("GetSiteName");
if (site < 1)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
if (site > 4)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
CheckConnectedAndValidateSite(site, "GetSiteName");
switch (site)
{
case 1:
return _sharedResourcesWrapper.SendString(":GM#");
return _sharedResourcesWrapper.SendString("#:GM#");
//:GM# Get Site 1 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
case 2:
return _sharedResourcesWrapper.SendString(":GN#");
return _sharedResourcesWrapper.SendString("#:GN#");
//:GN# Get Site 2 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
case 3:
return _sharedResourcesWrapper.SendString(":GO#");
return _sharedResourcesWrapper.SendString("#:GO#");
//:GO# Get Site 3 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
case 4:
return _sharedResourcesWrapper.SendString(":GP#");
return _sharedResourcesWrapper.SendString("#:GP#");
//:GP# Get Site 4 Name
//Returns: <string>#
//A # terminated string with the name of the requested site.
}
default:
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range);
}
}
public string Description
{
@@ -703,11 +710,11 @@ namespace ASCOM.Meade.net
{
//string name = "Short driver name - please customise";
//var telescopeProduceName = _sharedResourcesWrapper.SendString(":GVP#");
//var telescopeProduceName = _sharedResourcesWrapper.SendString("#:GVP#");
////:GVP# Get Telescope Product Name
////Returns: <string>#
//var firmwareVersion = _sharedResourcesWrapper.SendString(":GVN#");
//var firmwareVersion = _sharedResourcesWrapper.SendString("#:GVN#");
////:GVN# Get Telescope Firmware Number
////Returns: dd.d#
@@ -727,7 +734,7 @@ namespace ASCOM.Meade.net
CheckConnected("AbortSlew");
LogMessage("AbortSlew", "Aborting slew");
_sharedResourcesWrapper.SendBlind(":Q#");
_sharedResourcesWrapper.SendBlind("#:Q#");
//:Q# Halt all current slewing
//Returns:Nothing
@@ -756,7 +763,7 @@ namespace ASCOM.Meade.net
//todo implement GW Command - Supported in Autostar 43Eg and above
//if FirmwareIsGreaterThan(TelescopeList.Autostar497_43EG)
//{
//var alignmentString = SerialPort.CommandTerminated(":GW#", "#");
//var alignmentString = SerialPort.CommandTerminated("#:GW#", "#");
//:GW# Get Scope Alignment Status
//Returns: <mount><tracking><alignment>#
// where:
@@ -798,13 +805,13 @@ namespace ASCOM.Meade.net
switch (value)
{
case AlignmentModes.algAltAz:
_sharedResourcesWrapper.SendBlind(":AA#");
_sharedResourcesWrapper.SendBlind("#:AA#");
//:AA# Sets telescope the AltAz alignment mode
//Returns: nothing
break;
case AlignmentModes.algPolar:
case AlignmentModes.algGermanPolar:
_sharedResourcesWrapper.SendBlind(":AP#");
_sharedResourcesWrapper.SendBlind("#:AP#");
//:AP# Sets telescope to Polar alignment mode
//Returns: nothing
break;
@@ -828,7 +835,7 @@ namespace ASCOM.Meade.net
return altAz.Altitude;
////todo firmware bug in 44Eg, :GA# is returning the dec, not the altitude!
//var result = _sharedResourcesWrapper.SendString(":GA#");
//var result = _sharedResourcesWrapper.SendString("#:GA#");
////:GA# Get Telescope Altitude
////Returns: sDD* MM# or sDD*MMSS#
////The current scope altitude. The returned format depending on the current precision setting.
@@ -849,11 +856,7 @@ namespace ASCOM.Meade.net
UtcDateTime = UTCDate,
SiteLongitude = SiteLongitude,
SiteLatitude = SiteLatitude,
EquatorialCoordinates = new EquatorialCoordinates
{
RightAscension = RightAscension,
Declination = Declination
}
EquatorialCoordinates = GetTelescopeRaAndDec()
});
double hourAngle = _astroMaths.RightAscensionToHourAngle(altitudeData.UtcDateTime, altitudeData.SiteLongitude,
@@ -862,6 +865,15 @@ namespace ASCOM.Meade.net
return altAz;
}
private EquatorialCoordinates GetTelescopeRaAndDec()
{
return new EquatorialCoordinates
{
RightAscension = RightAscension,
Declination = Declination
};
}
public double ApertureArea
{
get
@@ -913,7 +925,7 @@ namespace ASCOM.Meade.net
{
CheckConnected("Azimuth Get");
//var result = _sharedResourcesWrapper.SendString(":GZ#");
//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.
@@ -1095,7 +1107,7 @@ namespace ASCOM.Meade.net
{
CheckConnected("Declination Get");
var result = _sharedResourcesWrapper.SendString(":GD#");
var result = _sharedResourcesWrapper.SendString("#:GD#");
//:GD# Get Telescope Declination.
//Returns: sDD*MM# or sDD*MMSS#
//Depending upon the current precision setting for the telescope.
@@ -1183,7 +1195,7 @@ namespace ASCOM.Meade.net
}
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#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
@@ -1264,22 +1276,22 @@ namespace ASCOM.Meade.net
//do nothing, it's ok this time as we're halting the slew.
break;
case 1:
_sharedResourcesWrapper.SendBlind(":RG#");
_sharedResourcesWrapper.SendBlind("#:RG#");
//:RG# Set Slew rate to Guiding Rate (slowest)
//Returns: Nothing
break;
case 2:
_sharedResourcesWrapper.SendBlind(":RC#");
_sharedResourcesWrapper.SendBlind("#:RC#");
//:RC# Set Slew rate to Centering rate (2nd slowest)
//Returns: Nothing
break;
case 3:
_sharedResourcesWrapper.SendBlind(":RM#");
_sharedResourcesWrapper.SendBlind("#:RM#");
//:RM# Set Slew rate to Find Rate (2nd Fastest)
//Returns: Nothing
break;
case 4:
_sharedResourcesWrapper.SendBlind(":RS#");
_sharedResourcesWrapper.SendBlind("#:RS#");
//:RS# Set Slew rate to max (fastest)
//Returns: Nothing
break;
@@ -1290,56 +1302,57 @@ namespace ASCOM.Meade.net
switch (axis)
{
case TelescopeAxes.axisPrimary:
if (rate == 0)
switch (rate.Compare(0))
{
case ComparisonResult.Equals:
_movingPrimary = false;
_sharedResourcesWrapper.SendBlind(":Qe#");
_sharedResourcesWrapper.SendBlind("#:Qe#");
//:Qe# Halt eastward Slews
//Returns: Nothing
_sharedResourcesWrapper.SendBlind(":Qw#");
_sharedResourcesWrapper.SendBlind("#:Qw#");
//:Qw# Halt westward Slews
//Returns: Nothing
}
else if (rate > 0)
{
_sharedResourcesWrapper.SendBlind(":Me#");
break;
case ComparisonResult.Greater:
_sharedResourcesWrapper.SendBlind("#:Me#");
//:Me# Move Telescope East at current slew rate
//Returns: Nothing
_movingPrimary = true;
}
else
{
_sharedResourcesWrapper.SendBlind(":Mw#");
break;
case ComparisonResult.Lower:
_sharedResourcesWrapper.SendBlind("#:Mw#");
//:Mw# Move Telescope West at current slew rate
//Returns: Nothing
_movingPrimary = true;
break;
}
break;
case TelescopeAxes.axisSecondary:
if (rate == 0)
switch (rate.Compare(0))
{
case ComparisonResult.Equals:
_movingSecondary = false;
_sharedResourcesWrapper.SendBlind(":Qn#");
_sharedResourcesWrapper.SendBlind("#:Qn#");
//:Qn# Halt northward Slews
//Returns: Nothing
_sharedResourcesWrapper.SendBlind(":Qs#");
_sharedResourcesWrapper.SendBlind("#:Qs#");
//:Qs# Halt southward Slews
//Returns: Nothing
}
else if (rate > 0)
{
_sharedResourcesWrapper.SendBlind(":Mn#");
break;
case ComparisonResult.Greater:
_sharedResourcesWrapper.SendBlind("#:Mn#");
//:Mn# Move Telescope North at current slew rate
//Returns: Nothing
_movingSecondary = true;
}
else
{
_sharedResourcesWrapper.SendBlind(":Ms#");
break;
case ComparisonResult.Lower:
_sharedResourcesWrapper.SendBlind("#:Ms#");
//:Ms# Move Telescope South at current slew rate
//Returns: Nothing
_movingSecondary = true;
break;
}
break;
@@ -1356,7 +1369,7 @@ namespace ASCOM.Meade.net
if (AtPark)
return;
_sharedResourcesWrapper.SendBlind(":hP#");
_sharedResourcesWrapper.SendBlind("#:hP#");
//:hP# Autostar, Autostar II and LX 16”Slew to Park Position
//Returns: Nothing
AtPark = true;
@@ -1369,6 +1382,10 @@ namespace ASCOM.Meade.net
LogMessage("PulseGuide", $"pulse guide direction {direction} duration {duration}");
CheckConnected("PulseGuide");
var coordinatesBeforeMove = GetTelescopeRaAndDec();
if (_userNewerPulseGuiding && duration < 10000)
{
string d = string.Empty;
switch (direction)
{
@@ -1386,10 +1403,8 @@ namespace ASCOM.Meade.net
break;
}
if (_userNewerPulseGuiding && duration < 10000)
{
LogMessage("PulseGuide", "Using new pulse guiding technique");
_sharedResourcesWrapper.SendBlind($":Mg{d}{duration:0000}#");
_sharedResourcesWrapper.SendBlind($"#:Mg{d}{duration:0000}#");
//:MgnDDDD#
//:MgsDDDD#
//:MgeDDDD#
@@ -1402,43 +1417,45 @@ namespace ASCOM.Meade.net
}
else
{
LogMessage("PulseGuide", "Using old pulse guiding technique");
_sharedResourcesWrapper.Lock(() =>
switch (direction)
{
_sharedResourcesWrapper.SendBlind(":RG#"); //Make sure we are at guide rate
//:RG# Set Slew rate to Guiding Rate (slowest)
//Returns: Nothing
_sharedResourcesWrapper.SendBlind($":M{d}#");
//:Me# Move Telescope East at current slew rate
//Returns: Nothing
//:Mn# Move Telescope North at current slew rate
//Returns: Nothing
//:Ms# Move Telescope South at current slew rate
//Returns: Nothing
//:Mw# Move Telescope West at current slew rate
//Returns: Nothing
case GuideDirections.guideEast:
MoveAxis(TelescopeAxes.axisPrimary, 1);
_utilities.WaitForMilliseconds(duration);
_sharedResourcesWrapper.SendBlind($":Q{d}#");
//:Qe# Halt eastward Slews
//Returns: Nothing
//:Qn# Halt northward Slews
//Returns: Nothing
//:Qs# Halt southward Slews
//Returns: Nothing
//:Qw# Halt westward Slews
//Returns: Nothing
});
MoveAxis(TelescopeAxes.axisPrimary, 0);
break;
case GuideDirections.guideNorth:
MoveAxis(TelescopeAxes.axisSecondary, 1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisSecondary, 0);
break;
case GuideDirections.guideSouth:
MoveAxis(TelescopeAxes.axisSecondary, -1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisSecondary, 0);
break;
case GuideDirections.guideWest:
MoveAxis(TelescopeAxes.axisPrimary, -1);
_utilities.WaitForMilliseconds(duration);
MoveAxis(TelescopeAxes.axisPrimary, 0);
break;
}
}
var coordinatesAfterMove = GetTelescopeRaAndDec();
LogMessage("PulseGuide", $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesBeforeMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesBeforeMove.Declination)}");
LogMessage("PulseGuide", $"Complete Before RA: {_utilitiesExtra.HoursToHMS(coordinatesAfterMove.RightAscension)} Dec:{_utilitiesExtra.DegreesToDMS(coordinatesAfterMove.Declination)}");
}
public double RightAscension
{
get
{
CheckConnected("RightAscension Get");
var result = _sharedResourcesWrapper.SendString(":GR#");
var result = _sharedResourcesWrapper.SendString("#:GR#");
//:GR# Get Telescope RA
//Returns: HH: MM.T# or HH:MM:SS#
//Returns: HH:MM.T# or HH:MM:SS#
//Depending which precision is set for the telescope
double rightAscension = _utilities.HMSToHours(result);
@@ -1532,7 +1549,7 @@ namespace ASCOM.Meade.net
{
CheckConnected("SiteLatitude Get");
var latitude = _sharedResourcesWrapper.SendString(":Gt#");
var latitude = _sharedResourcesWrapper.SendString("#:Gt#");
//:Gt# Get Current Site Latitude
//Returns: sDD* MM#
//The latitude of the current site. Positive inplies North latitude.
@@ -1558,7 +1575,7 @@ namespace ASCOM.Meade.net
var absValue = Math.Abs(value);
int d = Convert.ToInt32(Math.Floor(absValue));
int m = Convert.ToInt32(60 * (absValue - d));
var commandString = $":St{sign}{d:00}*{m:00}#";
var commandString = $"#:St{sign}{d:00}*{m:00}#";
var result = _sharedResourcesWrapper.SendChar(commandString);
//:StsDD*MM#
@@ -1577,7 +1594,7 @@ namespace ASCOM.Meade.net
{
CheckConnected("SiteLongitude Get");
var longitude = _sharedResourcesWrapper.SendString(":Gg#");
var longitude = _sharedResourcesWrapper.SendString("#:Gg#");
//:Gg# Get Current Site Longitude
//Returns: sDDD*MM#
//The current site Longitude. East Longitudes are expressed as negative
@@ -1613,7 +1630,7 @@ namespace ASCOM.Meade.net
int d = Convert.ToInt32(Math.Floor(newLongitude));
int m = Convert.ToInt32(60 * (newLongitude - d));
var commandstring = $":Sg{d:000}*{m:00}#";
var commandstring = $"#:Sg{d:000}*{m:00}#";
var result = _sharedResourcesWrapper.SendChar(commandstring);
//:SgDDD*MM#
@@ -1671,7 +1688,7 @@ namespace ASCOM.Meade.net
// var dms = _utilities.DegreesToDMS(value, "*", "'", "",0);
// var s = value < 0 ? string.Empty : "+";
// var result = _sharedResourcesWrapper.SendChar($":Sa{s}{dms}#");
// var result = _sharedResourcesWrapper.SendChar($"#:Sa{s}{dms}#");
// //:SasDD*MM#
// //Set target object altitude to sDD*MM# or sDD*MMSS# [LX 16”, Autostar, Autostar II]
// //Returns:
@@ -1699,7 +1716,7 @@ namespace ASCOM.Meade.net
// var dms = _utilitiesExtra.DegreesToDM(value, "*" );
// var result = _sharedResourcesWrapper.SendChar($":Sz{dms}#");
// var result = _sharedResourcesWrapper.SendChar($"#:Sz{dms}#");
// //:SzDDD*MM#
// //Sets the target Object Azimuth[LX 16” and Autostar II only]
// //Returns:
@@ -1761,7 +1778,7 @@ namespace ASCOM.Meade.net
switch (polar)
{
case true:
var response = _sharedResourcesWrapper.SendChar(":MS#");
var response = _sharedResourcesWrapper.SendChar("#:MS#");
//:MS# Slew to Target Object
//Returns:
//0 Slew is Possible
@@ -1792,7 +1809,7 @@ namespace ASCOM.Meade.net
break;
case false:
var maResponse = _sharedResourcesWrapper.SendChar(":MA#");
var maResponse = _sharedResourcesWrapper.SendChar("#:MA#");
//:MA# Autostar, LX 16”, Autostar II Slew to target Alt and Az
//Returns:
//0 - No fault
@@ -1857,7 +1874,7 @@ namespace ASCOM.Meade.net
{
CheckConnected("SlewToTargetAsync");
if (TargetDeclination == InvalidParameter || TargetRightAscension == InvalidParameter)
if (TargetDeclination.Equals(InvalidParameter) || TargetRightAscension.Equals(InvalidParameter))
throw new InvalidOperationException("No target selected to slew to.");
DoSlewAsync(true);
@@ -1880,7 +1897,7 @@ namespace ASCOM.Meade.net
CheckConnected("Slewing Get");
var result = _sharedResourcesWrapper.SendString(":D#");
var result = _sharedResourcesWrapper.SendString("#:D#");
//:D# Requests a string of bars indicating the distance to the current target location.
//Returns:
//LX200's a string of bar characters indicating the distance.
@@ -1923,7 +1940,7 @@ namespace ASCOM.Meade.net
LogMessage("SyncToTarget", "Executing");
CheckConnected("SyncToTarget");
var result = _sharedResourcesWrapper.SendString(":CM#");
var result = _sharedResourcesWrapper.SendString("#:CM#");
//:CM# Synchronizes the telescope's position with the currently selected database object's coordinates.
//Returns:
//LX200's - a "#" terminated string with the name of the object that was synced.
@@ -1938,10 +1955,10 @@ namespace ASCOM.Meade.net
{
get
{
if (_targetDeclination == InvalidParameter)
if (_targetDeclination.Equals(InvalidParameter))
throw new InvalidOperationException("Target not set");
//var result = SerialPort.CommandTerminated(":Gd#", "#");
//var result = SerialPort.CommandTerminated("#:Gd#", "#");
////:Gd# Get Currently Selected Object/Target Declination
////Returns: sDD* MM# or sDD*MMSS#
////Depending upon the current precision setting for the telescope.
@@ -1969,7 +1986,7 @@ namespace ASCOM.Meade.net
var dms = _utilities.DegreesToDMS(value, "*", ":", ":", 2);
var s = value < 0 ? string.Empty : "+";
var command = $":Sd{s}{dms}#";
var command = $"#:Sd{s}{dms}#";
LogMessage("TargetDeclination Set", $"{command}");
var result = _sharedResourcesWrapper.SendChar(command);
@@ -1993,10 +2010,10 @@ namespace ASCOM.Meade.net
{
get
{
if (_targetRightAscension == InvalidParameter)
if (_targetRightAscension.Equals(InvalidParameter))
throw new InvalidOperationException("Target not set");
//var result = SerialPort.CommandTerminated(":Gr#", "#");
//var result = SerialPort.CommandTerminated("#:Gr#", "#");
////:Gr# Get current/target object RA
////Returns: HH: MM.T# or HH:MM:SS
////Depending upon which precision is set for the telescope
@@ -2020,7 +2037,7 @@ namespace ASCOM.Meade.net
//todo implement the low precision version
var hms = _utilities.HoursToHMS(value, ":", ":", ":", 2);
var response = _sharedResourcesWrapper.SendChar($":Sr{hms}#");
var response = _sharedResourcesWrapper.SendChar($"#:Sr{hms}#");
//:SrHH:MM.T#
//:SrHH:MM:SS#
//Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting.
@@ -2058,7 +2075,7 @@ namespace ASCOM.Meade.net
get
{
//todo implement this with the GW command
//var result = SerialPort.CommandTerminated(":GT#", "#");
//var result = SerialPort.CommandTerminated("#:GT#", "#");
//double rate = double.Parse(result);
@@ -2080,17 +2097,17 @@ namespace ASCOM.Meade.net
switch (value)
{
case DriveRates.driveSidereal:
_sharedResourcesWrapper.SendBlind(":TQ#");
_sharedResourcesWrapper.SendBlind("#:TQ#");
//:TQ# Selects sidereal tracking rate
//Returns: Nothing
break;
case DriveRates.driveLunar:
_sharedResourcesWrapper.SendBlind(":TL#");
_sharedResourcesWrapper.SendBlind("#:TL#");
//:TL# Set Lunar Tracking Rage
//Returns: Nothing
break;
//case DriveRates.driveSolar:
// SerialPort.Command(":TS#");
// SerialPort.Command("#:TS#");
// //:TS# Select Solar tracking rate. [LS Only]
// //Returns: Nothing
// break;
@@ -2122,7 +2139,7 @@ namespace ASCOM.Meade.net
private TimeSpan GetUtcCorrection()
{
string utcOffSet = _sharedResourcesWrapper.SendString(":GG#");
string utcOffSet = _sharedResourcesWrapper.SendString("#:GG#");
//:GG# Get UTC offset time
//Returns: sHH# or sHH.H#
//The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the
@@ -2151,11 +2168,11 @@ namespace ASCOM.Meade.net
{
var tdd = new TelescopeDateDetails
{
TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"),
TelescopeDate = _sharedResourcesWrapper.SendString("#:GC#"),
//:GC# Get current date.
//Returns: MM/DD/YY#
//The current local calendar date for the telescope.
TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"),
TelescopeTime = _sharedResourcesWrapper.SendString("#:GL#"),
//:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS#
//The Local Time in 24 - hour Format
@@ -2196,7 +2213,7 @@ namespace ASCOM.Meade.net
var utcCorrection = GetUtcCorrection();
var localDateTime = value - utcCorrection;
string localStingCommand = $":SL{localDateTime:HH:mm:ss}#";
string localStingCommand = $"#:SL{localDateTime:HH:mm:ss}#";
var timeResult = _sharedResourcesWrapper.SendChar(localStingCommand);
//:SLHH:MM:SS#
//Set the local Time
@@ -2208,7 +2225,7 @@ namespace ASCOM.Meade.net
throw new InvalidOperationException("Failed to set local time");
}
string localDateCommand = $":SC{localDateTime:MM/dd/yy}#";
string localDateCommand = $"#:SC{localDateTime:MM/dd/yy}#";
var dateResult = _sharedResourcesWrapper.SendChar(localDateCommand);
//:SCMM/DD/YY#
//Change Handbox Date to MM/DD/YY
@@ -2242,6 +2259,13 @@ namespace ASCOM.Meade.net
#region ASCOM Registration
private static IProfileFactory _profileFactory;
public static IProfileFactory ProfileFactory
{
get => _profileFactory ?? (_profileFactory = new ProfileFactory());
set => _profileFactory = value;
}
// Register or unregister driver for ASCOM. This is harmless if already
// registered or unregistered.
//
@@ -2252,7 +2276,7 @@ namespace ASCOM.Meade.net
/// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param>
private static void RegUnregAscom(bool bRegister)
{
using (var p = new Profile())
using (IProfileWrapper p = ProfileFactory.Create())
{
p.DeviceType = "Telescope";
if (bRegister)
+1 -1
View File
@@ -5,4 +5,4 @@
<section name="ASCOM.DeviceName.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
@@ -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,117 @@
<?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>{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Meade.net.UnitTests</RootNamespace>
<AssemblyName>Meade.net.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>
</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.13.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.13.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.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\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="SharedResourcesUnitTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Meade.net\Meade.net.csproj">
<Project>{3689a2cb-94c5-4012-a5cf-7e7d1dd27143}</Project>
<Name>Meade.net</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="BootstrapAscomProfileStore.ps1" />
<None Include="packages.config" />
</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.UnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Meade.net.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("21ef28b4-d574-4a2d-a61d-5df96af46ab2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,302 @@
using System;
using System.Globalization;
using ASCOM.Meade.net;
using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities.Interfaces;
using Moq;
using NUnit.Framework;
namespace Meade.net.UnitTests
{
[TestFixture]
public class SharedResourcesUnitTests
{
private Mock<ISerial> _serialMock;
[SetUp]
public void Setup()
{
_serialMock = new Mock<ISerial>();
_serialMock.SetupAllProperties();
SharedResources.SharedSerial = _serialMock.Object;
}
[Test]
public void CheckThatSerialPortIsSetToUseMock()
{
Assert.That(SharedResources.SharedSerial,Is.EqualTo(_serialMock.Object));
}
[Test]
public void SendBlind_WhenCalled_Then_ClearsBuffersAndSendsMessage()
{
var expectedMessage = "Test";
SharedResources.SendBlind(expectedMessage);
_serialMock.Verify(x=> x.ClearBuffers(), Times.Once);
_serialMock.Verify(x=>x.Transmit(expectedMessage), Times.Once);
}
[Test]
public void SendChar_WhenCalled_ThenSendsMessageAndReadsExpectedNumberOfCharacters()
{
var expectedMessage = "Test";
var expectedResult = "A";
_serialMock.Setup(x => x.ReceiveCounted(1)).Returns(expectedResult);
var result = SharedResources.SendChar(expectedMessage);
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
_serialMock.Verify(x => x.Transmit(expectedMessage), Times.Once);
_serialMock.Verify(x => x.ReceiveCounted(1), Times.Once);
Assert.That(result, Is.EqualTo(expectedResult));
}
[Test]
public void SendString_WhenCalled_ThenSendsMessageAndReadsResultUntilTerminatorFound()
{
var expectedMessage = "Test";
var expectedResult = "TestMessage#";
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(expectedResult);
var result = SharedResources.SendString(expectedMessage);
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
_serialMock.Verify(x => x.Transmit(expectedMessage), Times.Once);
_serialMock.Verify(x => x.ReceiveTerminated("#"), Times.Once);
Assert.That(result, Is.EqualTo(expectedResult.TrimEnd('#')));
}
[Test]
public void ReadTerminated_WhenCalled_ThenReadsResultUntilTerminatorFound()
{
var expectedResult = "TestMessage#";
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(expectedResult);
var result = SharedResources.ReadTerminated();
_serialMock.Verify(x => x.ReceiveTerminated("#"), Times.Once);
Assert.That(result, Is.EqualTo(expectedResult));
}
[Test]
public void ReadCharacters_WhenCalled_ThenReadsSpecificNumberOfCharacters()
{
var numberOfCharacters = 5;
SharedResources.ReadCharacters(numberOfCharacters);
_serialMock.Verify(x => x.ReceiveCounted(numberOfCharacters), Times.Once);
}
[Test]
public void WriteProfile_WhenCalled_WritesExpectedProfileSettings()
{
string DriverId = "ASCOM.MeadeGeneric.Telescope";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties();
IProfileWrapper profeWrapper = profileWrapperMock.Object;
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
SharedResources.ProfileFactory = profileFactoryMock.Object;
var profileProperties = new ProfileProperties
{
TraceLogger = false,
ComPort = "TestComPort"
};
SharedResources.WriteProfile(profileProperties);
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
profileWrapperMock.Verify( x => x.WriteValue(DriverId, "Trace Level", profileProperties.TraceLogger.ToString()), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Guide Rate Arc Seconds Per Second", profileProperties.GuideRateArcSecondsPerSecond.ToString(CultureInfo.CurrentCulture)), Times.Once);
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Precision", profileProperties.Precision), Times.Once);
}
[Test]
public void ReadProfile_WhenCalled_ReturnsExpectedDefaultValues()
{
string DriverId = "ASCOM.MeadeGeneric.Telescope";
string ComPortDefault = "COM1";
string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties();
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
IProfileWrapper profeWrapper = profileWrapperMock.Object;
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
SharedResources.ProfileFactory = profileFactoryMock.Object;
var profileProperties = SharedResources.ReadProfile();
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault));
Assert.That(profileProperties.GuideRateArcSecondsPerSecond,
Is.EqualTo(double.Parse(GuideRateProfileNameDefault)));
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault));
}
[TestCase("TCP")]
[TestCase("Carrier Pigeon")]
public void Connect_WhenDeviceIdIsNotSerial_ThenThrowsException( string deviceId)
{
var result = Assert.Throws<ArgumentException>( () => { SharedResources.Connect(deviceId, string.Empty); } );
Assert.That( result.Message, Is.EqualTo($"deviceId {deviceId} not currently supported") );
}
[Test]
public void Connect_WhenDeviceIdIsSerialButGVPEchos_ThenThrowsException()
{
string deviceId = "Serial";
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
string ComPortDefault = "COM1";
string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties();
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
SharedResources.ProfileFactory = profileFactoryMock.Object;
string serialPortReturn = string.Empty;
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = ":GVP#"; });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns( () => serialPortReturn);
var result = Assert.Throws<Exception>(() => { SharedResources.Connect(deviceId, string.Empty); });
Assert.That(result.Message, Is.EqualTo("Serial port is looping back data, something is wrong with the hardware."));
}
[Test]
public void Connect_WhenDeviceIdIsSerialButGVPNotSupported_ThenConnectsAndSetsProductToLX200Classic()
{
string deviceId = "Serial";
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
string ComPortDefault = "COM1";
string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties();
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
SharedResources.ProfileFactory = profileFactoryMock.Object;
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror"));
var connectionResult = SharedResources.Connect(deviceId, string.Empty);
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.LX200CLASSIC));
SharedResources.Disconnect(deviceId, String.Empty);
}
[Test]
public void Connect_WhenDeviceIdIsSerialButGVPIsAutostar_ThenConnectsAndSetsProductToAutostarAndFirmware()
{
string deviceId = "Serial";
string driverDriverId = "ASCOM.MeadeGeneric.Telescope";
string ComPortDefault = "COM1";
string TraceStateDefault = "false";
string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate
string PrecisionDefault = "Unchanged";
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
profileWrapperMock.SetupAllProperties();
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Trace Level", string.Empty, TraceStateDefault))
.Returns(TraceStateDefault);
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "COM Port", string.Empty, ComPortDefault))
.Returns(ComPortDefault);
profileWrapperMock
.Setup(x => x.GetValue(driverDriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
profileWrapperMock.Setup(x => x.GetValue(driverDriverId, "Precision", string.Empty, PrecisionDefault))
.Returns(PrecisionDefault);
Mock<IProfileFactory> profileFactoryMock = new Mock<IProfileFactory>();
profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object);
SharedResources.ProfileFactory = profileFactoryMock.Object;
string serialPortReturn = string.Empty;
_serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497; });
_serialMock.Setup(x => x.Transmit(":GVN#")).Callback(() => { serialPortReturn = TelescopeList.Autostar497_43Eg; });
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
var connectionResult = SharedResources.Connect(deviceId, string.Empty);
Assert.That(connectionResult.SameDevice, Is.EqualTo(1));
Assert.That(SharedResources.ProductName, Is.EqualTo(TelescopeList.Autostar497));
Assert.That(SharedResources.FirmwareVersion, Is.EqualTo(TelescopeList.Autostar497_43Eg));
SharedResources.Disconnect(deviceId, String.Empty);
}
}
}
+15
View File
@@ -0,0 +1,15 @@
<?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>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+9
View File
@@ -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.13.0" targetFramework="net472" />
<package id="NUnit" version="3.12.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
</packages>
+10 -3
View File
@@ -365,7 +365,7 @@ namespace ASCOM.Meade.net
{
_sharedResourcesWrapper.Lock(() =>
{
//_sharedResourcesWrapper.SendBlind(":FF#");
//_sharedResourcesWrapper.SendBlind("#:FF#");
//:FF# Set Focus speed to fastest setting
//Returns: Nothing
@@ -382,7 +382,7 @@ namespace ASCOM.Meade.net
Stopwatch stopwatch = Stopwatch.StartNew();
while (stopwatch.ElapsedMilliseconds < steps)
{
_sharedResourcesWrapper.SendBlind(directionOut ? ":F+#" : ":F-#");
_sharedResourcesWrapper.SendBlind(directionOut ? "#:F+#" : "#:F-#");
//:F+# Start Focuser moving inward (toward objective)
//Returns: None
@@ -451,6 +451,13 @@ namespace ASCOM.Meade.net
#region ASCOM Registration
private static IProfileFactory _profileFactory;
public static IProfileFactory ProfileFactory
{
get => _profileFactory ?? (_profileFactory = new ProfileFactory());
set => _profileFactory = value;
}
// Register or unregister driver for ASCOM. This is harmless if already
// registered or unregistered.
//
@@ -461,7 +468,7 @@ namespace ASCOM.Meade.net
/// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param>
private static void RegUnregAscom(bool bRegister)
{
using (var p = new Profile())
using (IProfileWrapper p = ProfileFactory.Create())
{
p.DeviceType = "Focuser";
if (bRegister)
+3 -1
View File
@@ -15,7 +15,7 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ApplicationIcon>ASCOM.ico</ApplicationIcon>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ASCOMDriverTemplate.snk</AssemblyOriginatorKeyFile>
@@ -69,6 +69,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\bin\Release\</OutputPath>
@@ -78,6 +79,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
+19 -25
View File
@@ -8,16 +8,10 @@
// </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 {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@@ -25,27 +19,27 @@ namespace ASCOM.Meade.net.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode()]
[CompilerGenerated()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static ResourceManager resourceMan;
private static global::System.Resources.ResourceManager resourceMan;
private static CultureInfo resourceCulture;
private static global::System.Globalization.CultureInfo resourceCulture;
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (ReferenceEquals(resourceMan, null)) {
ResourceManager temp = new ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.Meade.net.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -56,8 +50,8 @@ namespace ASCOM.Meade.net.Properties {
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -69,20 +63,20 @@ namespace ASCOM.Meade.net.Properties {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static Bitmap ASCOM {
internal static System.Drawing.Bitmap ASCOM {
get {
object obj = ResourceManager.GetObject("ASCOM", resourceCulture);
return ((Bitmap)(obj));
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static Icon DefaultIcon {
internal static System.Drawing.Icon DefaultIcon {
get {
object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture);
return ((Icon)(obj));
return ((System.Drawing.Icon)(obj));
}
}
}
+4 -8
View File
@@ -8,18 +8,14 @@
// </auto-generated>
//------------------------------------------------------------------------------
using System.CodeDom.Compiler;
using System.Configuration;
using System.Runtime.CompilerServices;
namespace ASCOM.Meade.net.Properties {
[CompilerGenerated()]
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : ApplicationSettingsBase {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(Synchronized(new Settings())));
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
+1 -1
View File
@@ -5,4 +5,4 @@
<section name="ASCOM.DeviceName.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
+15
View File
@@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Meade.net.Telescope.UnitTes
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Meade.net.UnitTests", "Meade.net.UnitTests\Meade.net.UnitTests.csproj", "{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -137,6 +139,18 @@ Global
{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
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Debug|x64.ActiveCfg = Debug|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Debug|x64.Build.0 = Debug|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Debug|x86.ActiveCfg = Debug|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Debug|x86.Build.0 = Debug|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Release|Any CPU.Build.0 = Release|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Release|x64.ActiveCfg = Release|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Release|x64.Build.0 = Release|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Release|x86.ActiveCfg = Release|Any CPU
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -147,6 +161,7 @@ Global
{AD4959DD-33D7-4C3F-8DB0-7361D8E74A95} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
{B7EEEEFD-5BFF-443D-981C-7B8AB5DFDE33} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
{A3991FA7-23C3-405A-96F9-5AB03AC58F30} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
{21EF28B4-D574-4A2D-A61D-5DF96AF46AB2} = {0958D817-269C-44BE-BEFB-F3E6A409DE91}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3C0509DC-C7F5-48DC-920D-DCFD9C879BD2}
+4
View File
@@ -2,6 +2,10 @@
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<CopyReferencedAssembliesToWorkspace>True</CopyReferencedAssembliesToWorkspace>
<MetricsExclusionList>
<Value>FocuserTestConsole\FocuserTestConsole.csproj</Value>
<Value>TelescopeTestConsole\TelescopeTestConsole.csproj</Value>
</MetricsExclusionList>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
</SolutionConfiguration>
+1 -1
View File
@@ -11,6 +11,6 @@
<ShowUnexecutedTestsMenuOption>true</ShowUnexecutedTestsMenuOption>
<ShowIgnoredTestsMenuOption>false</ShowIgnoredTestsMenuOption>
</TestsWindowMenuOptions>
<TestsWindowSplitterDistance>451</TestsWindowSplitterDistance>
<TestsWindowSplitterDistance>544</TestsWindowSplitterDistance>
</Settings>
</SolutionConfiguration>
+1 -1
View File
@@ -2,7 +2,7 @@ namespace ASCOM.Meade.net
{
public class ConnectionInfo
{
public int Connections { get; set; }
//public int Connections { get; set; }
public int SameDevice { get; set; }
}
}
+14 -12
View File
@@ -173,8 +173,10 @@ namespace ASCOM.Meade.net
_sComObjectTypes = new ArrayList();
// put everything into one folder, the same as the server.
string assyPath = Assembly.GetEntryAssembly().Location;
string assyPath = Assembly.GetEntryAssembly()?.Location;
assyPath = Path.GetDirectoryName(assyPath);
if (assyPath == null)
throw new System.InvalidOperationException();
DirectoryInfo d = new DirectoryInfo(assyPath);
foreach (FileInfo fi in d.GetFiles("*.dll"))
@@ -295,9 +297,9 @@ namespace ASCOM.Meade.net
//
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey("APPID\\" + _sAppId))
{
key.SetValue(null, assyDescription);
key.SetValue("AppID", _sAppId);
key.SetValue("AuthenticationLevel", 1, RegistryValueKind.DWord);
key?.SetValue(null, assyDescription);
key?.SetValue("AppID", _sAppId);
key?.SetValue("AuthenticationLevel", 1, RegistryValueKind.DWord);
}
//
// HKCR\APPID\exename.ext
@@ -305,7 +307,7 @@ namespace ASCOM.Meade.net
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(
$"APPID\\{Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf('\\') + 1)}"))
{
key.SetValue("AppID", _sAppId);
key?.SetValue("AppID", _sAppId);
}
}
catch (Exception ex)
@@ -333,20 +335,20 @@ namespace ASCOM.Meade.net
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey($"CLSID\\{clsid}"))
{
key.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
key.SetValue("AppId", _sAppId);
key?.SetValue(null, progid); // Could be assyTitle/Desc??, but .NET components show ProgId here
key?.SetValue("AppId", _sAppId);
using (RegistryKey key2 = key.CreateSubKey("Implemented Categories"))
{
key2.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
key2?.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}");
}
using (RegistryKey key2 = key.CreateSubKey("ProgId"))
{
key2.SetValue(null, progid);
key2?.SetValue(null, progid);
}
key.CreateSubKey("Programmable");
using (RegistryKey key2 = key.CreateSubKey("LocalServer32"))
{
key2.SetValue(null, Application.ExecutablePath);
key2?.SetValue(null, Application.ExecutablePath);
}
}
//
@@ -354,10 +356,10 @@ namespace ASCOM.Meade.net
//
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(progid))
{
key.SetValue(null, assyTitle);
key?.SetValue(null, assyTitle);
using (RegistryKey key2 = key.CreateSubKey("CLSID"))
{
key2.SetValue(null, clsid);
key2?.SetValue(null, clsid);
}
}
//
+4 -1
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASCOM.Meade.net</RootNamespace>
<AssemblyName>ASCOM.Meade.net.Server</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
@@ -82,6 +82,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL">
@@ -133,10 +134,12 @@
</Compile>
<Compile Include="GarbageCollection.cs" />
<Compile Include="LocalServer.cs" />
<Compile Include="ProfileFactory.cs" />
<Compile Include="ProfileProperties.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TelescopeList.cs" />
<Compile Include="Win32Utilities.cs" />
<Compile Include="Wrapper\IProfileWrapper.cs" />
<Compile Include="Wrapper\SharedResourcesWrapper.cs" />
<EmbeddedResource Include="frmMain.resx">
<SubType>Designer</SubType>
+17
View File
@@ -0,0 +1,17 @@
using ASCOM.Meade.net.Wrapper;
namespace ASCOM.Meade.net
{
public interface IProfileFactory
{
IProfileWrapper Create();
}
public class ProfileFactory : IProfileFactory
{
public IProfileWrapper Create()
{
return new ProfileWrapper();
}
}
}
+2 -2
View File
@@ -3,6 +3,7 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO.Ports;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using ASCOM.Meade.net.Properties;
@@ -54,8 +55,7 @@ namespace ASCOM.Meade.net
chkTrace.Checked = profileProperties.TraceLogger;
// set the list of com ports to those that are currently available
comboBoxComPort.Items.Clear();
comboBoxComPort.Items.AddRange(SerialPort
.GetPortNames()); // use System.IO because it's static
comboBoxComPort.Items.AddRange(SerialPort.GetPortNames().ToArray<object>()); // use System.IO because it's static
// select the current port if possible
if (comboBoxComPort.Items.Contains(profileProperties.ComPort))
{
+41 -9
View File
@@ -18,7 +18,9 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net
{
@@ -36,7 +38,7 @@ namespace ASCOM.Meade.net
private static readonly object LockObject = new object();
// Shared serial port. This will allow multiple drivers to use one single serial port.
private static Serial _sSharedSerial; // Shared serial port
private static ISerial _sSharedSerial; // Shared serial port
//
// Public access to shared resources
@@ -59,9 +61,19 @@ namespace ASCOM.Meade.net
//
/// <summary>
/// Shared serial port
/// Shared serial port. Do not directly access this method.
/// </summary>
private static Serial SharedSerial => _sSharedSerial ?? (_sSharedSerial = new Serial());
public static ISerial SharedSerial
{
get => _sSharedSerial ?? (_sSharedSerial = new Serial());
set => _sSharedSerial = value;
}
public static IProfileFactory ProfileFactory
{
get => _profileFactory ?? ( _profileFactory = new ProfileFactory());
set => _profileFactory = value;
}
public static void SendBlind(string message)
{
@@ -132,7 +144,7 @@ namespace ASCOM.Meade.net
{
lock (LockObject)
{
using (Profile driverProfile = new Profile())
using (IProfileWrapper driverProfile = ProfileFactory.Create())
{
driverProfile.DeviceType = "Telescope";
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
@@ -153,7 +165,7 @@ namespace ASCOM.Meade.net
lock (LockObject)
{
ProfileProperties profileProperties = new ProfileProperties();
using (Profile driverProfile = new Profile())
using (IProfileWrapper driverProfile = ProfileFactory.Create())
{
driverProfile.DeviceType = "Telescope";
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
@@ -217,6 +229,7 @@ namespace ASCOM.Meade.net
private static readonly Dictionary<string, DeviceHardware> ConnectedDevices = new Dictionary<string, DeviceHardware>();
private static readonly Dictionary<string, DeviceHardware> ConnectedDeviceIds = new Dictionary<string, DeviceHardware>();
private static IProfileFactory _profileFactory ;
/// <summary>
@@ -231,15 +244,13 @@ namespace ASCOM.Meade.net
{
if (!ConnectedDevices.ContainsKey(deviceId))
ConnectedDevices.Add(deviceId, new DeviceHardware());
ConnectedDevices[deviceId].Count++; // increment the value
if (!ConnectedDeviceIds.ContainsKey(driverId))
ConnectedDeviceIds.Add(driverId, new DeviceHardware());
ConnectedDeviceIds[driverId].Count++; // increment the value
if (deviceId == "Serial")
{
if (ConnectedDevices[deviceId].Count == 1)
if (ConnectedDevices[deviceId].Count == 0)
{
var profileProperties = ReadProfile();
SharedSerial.PortName = profileProperties.ComPort;
@@ -252,14 +263,35 @@ namespace ASCOM.Meade.net
SharedSerial.Handshake = SerialHandshake.None;
SharedSerial.Connected = true;
try
{
ProductName = SendString(":GVP#");
FirmwareVersion = SendString(":GVN#");
}
catch (Exception)
{
ProductName = TelescopeList.LX200CLASSIC;
FirmwareVersion = "Unknown";
}
if (ProductName == ":GVP")
{
//This means that the serial port is looping back what's been sent, something is very wrong.
SharedSerial.Connected = false;
throw new Exception("Serial port is looping back data, something is wrong with the hardware.");
}
}
}
else
throw new ArgumentException($"deviceId {deviceId} not currently supported");
ConnectedDevices[deviceId].Count++; // increment the value
ConnectedDeviceIds[driverId].Count++; // increment the value
return new ConnectionInfo
{
Connections = ConnectedDevices[deviceId].Count,
//Connections = ConnectedDevices[deviceId].Count,
SameDevice = ConnectedDeviceIds[driverId].Count
};
}
+1 -1
View File
@@ -27,7 +27,7 @@
#region LX200EMC
// ReSharper disable once InconsistentNaming
public static readonly string LX200CLASSIC = ":GVP"; //GVP command is not supported!
public static readonly string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported!
#endregion
}
}
+139
View File
@@ -0,0 +1,139 @@
using System;
using System.Collections;
using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net.Wrapper
{
public interface IProfileWrapper : IProfile, IProfileExtra, IDisposable
{
}
public class ProfileWrapper : IProfileWrapper
{
private readonly Profile _profile = new Profile();
public ArrayList RegisteredDevices(string deviceType)
{
return _profile.RegisteredDevices(deviceType);
}
public bool IsRegistered(string driverId)
{
return _profile.IsRegistered(driverId);
}
public void Register(string driverId, string descriptiveName)
{
_profile.Register(driverId, descriptiveName);
}
public void Unregister(string driverId)
{
_profile.Unregister(driverId);
}
public string GetValue(string driverId, string name, string subKey, string defaultValue)
{
return _profile.GetValue(driverId, name, subKey, defaultValue);
}
public void WriteValue(string driverId, string name, string value, string subKey)
{
_profile.WriteValue(driverId, name, value);
}
public ArrayList Values(string driverId, string subKey)
{
return _profile.Values(driverId, subKey);
}
public void DeleteValue(string driverId, string name, string subKey)
{
_profile.DeleteValue(driverId, name, subKey);
}
public void CreateSubKey(string driverId, string subKey)
{
_profile.CreateSubKey(driverId, subKey);
}
public ArrayList SubKeys(string driverId, string subKey)
{
return _profile.SubKeys(driverId, subKey);
}
public void DeleteSubKey(string driverId, string subKey)
{
_profile.DeleteSubKey(driverId, subKey);
}
public string GetProfileXML(string deviceId)
{
return _profile.GetProfileXML(deviceId);
}
public void SetProfileXML(string deviceId, string xml)
{
_profile.SetProfileXML(deviceId, xml);
}
public string DeviceType
{
get => _profile.DeviceType;
set => _profile.DeviceType = value;
}
public ArrayList RegisteredDeviceTypes => _profile.RegisteredDeviceTypes;
public void MigrateProfile(string currentPlatformVersion)
{
_profile.MigrateProfile(currentPlatformVersion);
}
public void DeleteValue(string driverId, string name)
{
_profile.DeleteValue(driverId, name);
}
public string GetValue(string driverId, string name)
{
return _profile.GetValue(driverId, name);
}
public string GetValue(string driverId, string name, string subKey)
{
return _profile.GetValue(driverId, name, subKey);
}
public ArrayList SubKeys(string driverId)
{
return _profile.SubKeys(driverId);
}
public ArrayList Values(string driverId)
{
return _profile.Values(driverId);
}
public void WriteValue(string driverId, string name, string value)
{
_profile.WriteValue(driverId, name, value);
}
public ASCOMProfile GetProfile(string driverId)
{
return _profile.GetProfile(driverId);
}
public void SetProfile(string driverId, ASCOMProfile xmlProfileKey)
{
_profile.SetProfile(driverId, xmlProfileKey);
}
public void Dispose()
{
_profile.Dispose();
}
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
+49 -9
View File
@@ -9,26 +9,29 @@
#define UseChooser
using System;
using System.Linq;
using System.Threading;
using ASCOM.DeviceInterface;
using ASCOM.DriverAccess;
namespace ASCOM.Meade.net
{
class Program
public static class Program
{
static void Main(string[] args)
public static void Main()
{
// Uncomment the code that's required
#if UseChooser
//#if UseChooser
// choose the device
string id = Telescope.Choose("ASCOM.MeadeGeneric.Telescope");
string id = Telescope.Choose("ASCOM.Meade.net.Telescope");
if (string.IsNullOrEmpty(id))
return;
// create this device
Telescope device = new Telescope(id);
#else
//#else
// 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");
#endif
//ASCOM.DriverAccess.Telescope device = new ASCOM.DriverAccess.Telescope("ASCOM.Meade.net.Telescope");
//#endif
// now run some tests, adding code to your driver so that the tests will pass.
// these first tests are common to all drivers.
@@ -50,8 +53,45 @@ namespace ASCOM.Meade.net
//Console.WriteLine($"Ra {device.RightAscension}");
//Console.WriteLine($"Dec {device.Declination}");
Console.WriteLine($"Altitude {device.Altitude}");
Console.WriteLine($"Azimuth {device.Azimuth}");
//Console.WriteLine($"Altitude {device.Altitude}");
//Console.WriteLine($"Azimuth {device.Azimuth}");
var seconds = 10;
Console.WriteLine("Slewing tests 10 second in each direction");
Console.WriteLine("test 1");
device.MoveAxis(TelescopeAxes.axisPrimary, 4);
Thread.Sleep(seconds * 1000);
device.MoveAxis(TelescopeAxes.axisPrimary, 0);
Console.WriteLine("test 2");
device.MoveAxis(TelescopeAxes.axisPrimary, -4);
Thread.Sleep(seconds * 1000);
device.MoveAxis(TelescopeAxes.axisPrimary, 0);
Console.WriteLine("test 3");
device.MoveAxis(TelescopeAxes.axisSecondary, 4);
Thread.Sleep(seconds * 1000);
device.MoveAxis(TelescopeAxes.axisSecondary, 0);
Console.WriteLine("test 4");
device.MoveAxis(TelescopeAxes.axisSecondary, -4);
Thread.Sleep(seconds * 1000);
device.MoveAxis(TelescopeAxes.axisSecondary, 0);
Console.WriteLine("Slewing tests complete");
seconds = 120;
Console.WriteLine($"Guiding for {seconds} seconds!");
foreach( var direction in Enum.GetValues(typeof(GuideDirections)).Cast<GuideDirections>())
{
Console.WriteLine($"{direction.ToString()}");
device.PulseGuide(direction, seconds* 1000);
}
Console.WriteLine("Guiding Finished");
device.Connected = false;
Console.WriteLine("Press Enter to finish");
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASCOM.Meade.net</RootNamespace>
<AssemblyName>ASCOM.Meade.net.Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@@ -54,6 +54,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
+1 -1
View File
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>