mirror of
https://bitbucket.org/cjdskunkworks/lynxastrodewcontroller.git
synced 2026-05-03 17:28:52 +00:00
Version 1 of the LynxAstro.DewController.Switch driver
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 123 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{64308775-BD4A-469C-BCAB-3ED830B811AF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASCOM.LynxAstro.DewController</RootNamespace>
|
||||
<AssemblyName>ASCOM.LynxAstro.DewController.Switch</AssemblyName>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<ApplicationIcon>ASCOM.ico</ApplicationIcon>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>ASCOMDriverTemplate.snk</AssemblyOriginatorKeyFile>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
</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>
|
||||
<RegisterForComInterop>true</RegisterForComInterop>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</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>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ASCOM.Astrometry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.Attributes, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.Controls, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.Exceptions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.SettingsProvider, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.Utilities, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="ASCOM.Utilities.Video, Version=6.1.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Switch.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="ASCOM.png" />
|
||||
<None Include="ASCOMDriverTemplate.snk" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Content Include="ASCOM.ico" />
|
||||
<Content Include="ReadMe.htm" />
|
||||
<None Include="Resources\ASCOM.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LynxAstro.DewController\LynxAstro.DewController.csproj">
|
||||
<Project>{c708e487-e3a9-4073-a545-294b88674225}</Project>
|
||||
<Name>LynxAstro.DewController</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
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.
|
||||
//
|
||||
// TODO - Add your authorship information here
|
||||
[assembly: AssemblyTitle("ASCOM.LynxAstro.DewController.Switch")]
|
||||
[assembly: AssemblyDescription("ASCOM Switch driver for LynxAstro.DewController")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("The ASCOM Initiative")]
|
||||
[assembly: AssemblyProduct("ASCOM Switch driver for LynxAstro.DewController")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021 The ASCOM Initiative")]
|
||||
[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(true)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a567b01c-a066-45ce-af3d-0192bad973ea")]
|
||||
|
||||
// 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 Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
//
|
||||
// TODO - Set your driver's version here
|
||||
[assembly: AssemblyVersion("6.5.1.0")]
|
||||
[assembly: AssemblyFileVersion("6.5.1.0")]
|
||||
@@ -0,0 +1,96 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ASCOM.LynxAstro.DewController.Properties
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// 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.
|
||||
[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 global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASCOM.LynxAstro.DewController.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ASCOM
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = ResourceManager.GetObject("ASCOM", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon DefaultIcon
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = ResourceManager.GetObject("DefaultIcon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ASCOM" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\ASCOM.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="DefaultIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\ASCOM.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ASCOM.LynxAstro.DewController.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles />
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,147 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
|
||||
<TITLE>Untitled Document</TITLE>
|
||||
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Win32)">
|
||||
<META NAME="CREATED" CONTENT="0;0">
|
||||
<META NAME="CHANGEDBY" CONTENT="Chris Rowland">
|
||||
<META NAME="CHANGED" CONTENT="20110918;14150500">
|
||||
<STYLE TYPE="text/css">
|
||||
<!--
|
||||
@page { margin: 2cm }
|
||||
P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
|
||||
TD P { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
|
||||
H3 { font-family: "Arial", "Helvetica", sans-serif }
|
||||
H2 { font-family: "Arial", "Helvetica", sans-serif }
|
||||
H4 { font-family: "Arial", "Helvetica", sans-serif }
|
||||
TD P.note { background: #33ffff; font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal }
|
||||
TD P.underline { font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-weight: normal; text-decoration: underline }
|
||||
-->
|
||||
</STYLE>
|
||||
</HEAD>
|
||||
<BODY LANG="en-GB" DIR="LTR">
|
||||
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
|
||||
<TR>
|
||||
<TD>
|
||||
<H2>ASCOM Switch Driver (C#)</H2>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<P><BR><BR>
|
||||
</P>
|
||||
<H4>You have just created the skeleton of an ASCOM
|
||||
Switch driver in C#. It produces an in-process
|
||||
(assembly) based driver.</H4>
|
||||
<HR>
|
||||
<P CLASS="note">Prior to developing your first driver, please
|
||||
familiarize yourself with the <A HREF="https://ascom-standards.org/developer.html">developer
|
||||
information we've provided</A> at the ASCOM Initiative web site
|
||||
(internet required).
|
||||
</P>
|
||||
<P CLASS="underline">You must do the following in order to complete
|
||||
your implementation:</P>
|
||||
<OL>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Switch to the Debug configuration
|
||||
and build the template now. It should build without errors.
|
||||
</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Add a test project to the
|
||||
solution. There are templates that can be used to add either a
|
||||
console or a Windows Forms application:</P>
|
||||
</OL>
|
||||
<UL>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Select the <FONT FACE="Consolas, monospace">ASCOM
|
||||
Test Forms App (CS)</FONT> or <FONT FACE="Consolas, monospace">ASCOM
|
||||
Test Console App (CS)</FONT> template.</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Set a name for the test
|
||||
application and click on OK.</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">In the Wizard: set the same device
|
||||
type and model name as for the driver and select Create to build the
|
||||
test project.</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Set the Test Application to Run at
|
||||
Startup.</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Click on Debug and the test
|
||||
application should run. You should be able to select your
|
||||
application in the chooser. Selecting Properties should show the
|
||||
default setup dialog for your driver.</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Trying to continue will generate
|
||||
errors because the additional properties have not been implemented.</P>
|
||||
</UL>
|
||||
<OL START=4>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Go through the Driver.cs file and
|
||||
replace the System.NotImplemented exceptions with code to implement
|
||||
your driver's functionality. See the ASCOM ISwitchV2
|
||||
spec. If a property or method is not implemented in your driver the
|
||||
System.NotImplemented exception must be replaced by an
|
||||
ASCOM.PropertyNotImplemented or ASCOM.MethodNotImplemented
|
||||
exception.</P>
|
||||
<LI><P>Customize the Setup Dialog (SetupDialogForm) to provide the
|
||||
settings and other controls for your driver. You can bind settings
|
||||
directly to controls on your dialog form, there's no need to manage
|
||||
settings manually. A custom Settings class takes care of managing
|
||||
your settings behind the scenes.
|
||||
</P>
|
||||
</OL>
|
||||
<H3>Notes:</H3>
|
||||
<UL>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Successfully building the driver,
|
||||
as well as using <FONT FACE="Lucida Console, Courier New, Courier, monospace">regasm</FONT>
|
||||
on the assembly, registers it for both COM and ASCOM (the Chooser).
|
||||
See the code in the ASCOM Registration region of Driver.vb.
|
||||
</P>
|
||||
<LI><P STYLE="margin-bottom: 0cm">Doing a Clean for the project, as
|
||||
well doing a <FONT FACE="Lucida Console, Courier New, Courier, monospace">regasm
|
||||
-u</FONT> on the assembly, unregisters it for both COM and ASCOM
|
||||
(the Chooser).
|
||||
</P>
|
||||
<LI><P>Place a breakpoint in your driver class constructor, then
|
||||
start debugging (go, F5). Your breakpoint will be hit when the test
|
||||
application creates an instance of your driver (after selecting it
|
||||
in the Chooser). You can now single step, examine variables, etc.
|
||||
Please review the test application and make changes and additions to
|
||||
activate various parts of your driver during debugging.</P>
|
||||
<LI><P>The project's Debug configuration is already configured (The
|
||||
test application creates an instance of your driver (after selecting
|
||||
it in the Chooser). You can now single step, examine variables, etc.
|
||||
Please review the test application and feel free to make changes and
|
||||
additions to activate various parts of your driver during debugging.
|
||||
</P>
|
||||
</UL>
|
||||
<DIV ALIGN=RIGHT>
|
||||
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
|
||||
<TR>
|
||||
<TD>
|
||||
<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
|
||||
<TR>
|
||||
<TD>
|
||||
<H3>ASCOM Initiative</H3>
|
||||
</TD>
|
||||
<TD>
|
||||
<IMG SRC="ASCOM.png" NAME="graphics1" ALIGN=RIGHT WIDTH=48 HEIGHT=56 BORDER=0></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<P><BR><BR>
|
||||
</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<P>The ASCOM Initiative consists of a group of astronomy software
|
||||
developers and instrument vendors whose goals are to promote the
|
||||
driver/client model and scripting automation.
|
||||
</P>
|
||||
<P>See the <A HREF="https://ascom-standards.org/" TARGET="browser">ASCOM
|
||||
web site</A> for more information. Please participate in the
|
||||
<A HREF="https://ascomtalk.groups.io/g/Help/topics" TARGET="browser">ASCOM-Talk
|
||||
Groups.IO forum</A>.
|
||||
</P>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
<P><BR><BR>
|
||||
</P><P>
|
||||
<BR><BR>
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@@ -0,0 +1,695 @@
|
||||
#define Switch
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ASCOM.Utilities;
|
||||
using ASCOM.DeviceInterface;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ASCOM.LynxAstro.DewController
|
||||
{
|
||||
//
|
||||
// Your driver's DeviceID is ASCOM.LynxAstro.DewController.Switch
|
||||
//
|
||||
// The Guid attribute sets the CLSID for ASCOM.LynxAstro.DewController.Switch
|
||||
// The ClassInterface/None attribute prevents an empty interface called
|
||||
// _LynxAstro.DewController from being created and used as the [default] interface
|
||||
//
|
||||
// TODO Replace the not implemented exceptions with code to implement the function or
|
||||
// throw the appropriate ASCOM exception.
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// ASCOM Switch Driver for LynxAstro.DewController.
|
||||
/// </summary>
|
||||
[Guid("3a29744a-f33f-4843-a7e0-6938d9bd50ba")]
|
||||
[ProgId("ASCOM.LynxAstro.DewController.Switch")]
|
||||
[ServedClassName("LynxAstro.DewController")]
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
public class Switch : ISwitchV2
|
||||
{
|
||||
/// <summary>
|
||||
/// ASCOM DeviceID (COM ProgID) for this driver.
|
||||
/// The DeviceID is used by ASCOM applications to load the driver at runtime.
|
||||
/// </summary>
|
||||
internal static string DriverId = Marshal.GenerateProgIdForType(MethodBase.GetCurrentMethod().DeclaringType ?? throw new System.InvalidOperationException());
|
||||
|
||||
/// <summary>
|
||||
/// Driver description that displays in the ASCOM Chooser.
|
||||
/// </summary>
|
||||
private static string DriverDescription = "ASCOM Switch Driver for LynxAstro.DewController";
|
||||
|
||||
protected static string ComPort; // Variables to hold the currrent device configuration
|
||||
protected static TraceLogger Tl;
|
||||
|
||||
protected readonly ISharedResourcesWrapper SharedResourcesWrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LynxAstro.DewController"/> class.
|
||||
/// Must be public for COM registration.
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
public Switch()
|
||||
{
|
||||
SharedResourcesWrapper = new SharedResourcesWrapper();
|
||||
|
||||
Initialise(nameof(Switch));
|
||||
}
|
||||
|
||||
public Switch(ISharedResourcesWrapper sharedResourcesWrapper)
|
||||
{
|
||||
SharedResourcesWrapper = sharedResourcesWrapper;
|
||||
|
||||
Initialise(nameof(Switch));
|
||||
}
|
||||
|
||||
|
||||
protected void Initialise(string className)
|
||||
{
|
||||
Tl = new TraceLogger("", $"LynxAstro.DewController.{className}");
|
||||
|
||||
ReadProfile(); // Read device configuration from the ASCOM Profile store
|
||||
|
||||
IsConnected = false; // Initialise connected to false
|
||||
|
||||
LogMessage(className, "Completed initialisation");
|
||||
LogMessage(className, $"Driver version: {DriverVersion}");
|
||||
}
|
||||
|
||||
//
|
||||
// PUBLIC COM INTERFACE ISwitchV2 IMPLEMENTATION
|
||||
//
|
||||
|
||||
#region Common properties and methods.
|
||||
|
||||
/// <summary>
|
||||
/// Displays the Setup Dialog form.
|
||||
/// If the user clicks the OK button to dismiss the form, then
|
||||
/// the new settings are saved, otherwise the old values are reloaded.
|
||||
/// THIS IS THE ONLY PLACE WHERE SHOWING USER INTERFACE IS ALLOWED!
|
||||
/// </summary>
|
||||
public void SetupDialog()
|
||||
{
|
||||
LogMessage("SetupDialog", "Opening setup dialog");
|
||||
SharedResourcesWrapper.SetupDialog();
|
||||
ReadProfile();
|
||||
LogMessage("SetupDialog", "complete");
|
||||
}
|
||||
|
||||
public ArrayList SupportedActions
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist");
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
|
||||
public string Action(string actionName, string actionParameters)
|
||||
{
|
||||
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, actionParameters);
|
||||
throw new ASCOM.ActionNotImplementedException("Action " + actionName + " is not implemented by this driver");
|
||||
}
|
||||
|
||||
public void CommandBlind(string command, bool raw)
|
||||
{
|
||||
CheckConnected("CommandBlind");
|
||||
SharedResourcesWrapper.SendBlind(command);
|
||||
}
|
||||
|
||||
public bool CommandBool(string command, bool raw)
|
||||
{
|
||||
CheckConnected("CommandBool");
|
||||
throw new ASCOM.MethodNotImplementedException("CommandBool");
|
||||
}
|
||||
|
||||
public string CommandString(string command, bool raw)
|
||||
{
|
||||
CheckConnected("CommandString");
|
||||
return SharedResourcesWrapper.SendString(command);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clean up the trace logger and util objects
|
||||
Tl.Enabled = false;
|
||||
Tl.Dispose();
|
||||
Tl = null;
|
||||
}
|
||||
|
||||
private string DecodeResult(string pattern, string encodedString)
|
||||
{
|
||||
var decodedString = encodedString.Substring(pattern.Length).TrimEnd('#');
|
||||
return decodedString;
|
||||
}
|
||||
|
||||
public bool Connected
|
||||
{
|
||||
get
|
||||
{
|
||||
LogMessage("Connected", "Get {0}", IsConnected);
|
||||
return IsConnected;
|
||||
}
|
||||
set
|
||||
{
|
||||
LogMessage("Connected", "Set {0}", value);
|
||||
if (value == IsConnected)
|
||||
return;
|
||||
|
||||
if (value)
|
||||
{
|
||||
try
|
||||
{
|
||||
ReadProfile();
|
||||
|
||||
LogMessage("Connected Set", "Connecting to port {0}", ComPort);
|
||||
var connectionInfo = SharedResourcesWrapper.Connect("Serial", DriverId, Tl);
|
||||
try
|
||||
{
|
||||
LogMessage("Connected Set", $"Connected to port {ComPort}. Version:{SharedResourcesWrapper.FirmwareVersion}");
|
||||
|
||||
IsConnected = true;
|
||||
|
||||
LogMessage("Connected Set", $"Connected OK.");
|
||||
|
||||
var maxSwitch = MaxSwitch;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMessage("Connected Set", "Disconnecting from port {0}", ComPort);
|
||||
SharedResourcesWrapper.Disconnect("Serial", DriverId);
|
||||
IsConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("Description Get", DriverDescription);
|
||||
return DriverDescription;
|
||||
}
|
||||
}
|
||||
|
||||
public string DriverInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
string driverInfo = $"{Description} .net driver. Version: {DriverVersion}";
|
||||
LogMessage("DriverInfo Get", driverInfo);
|
||||
return driverInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public string DriverVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
string driverVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
|
||||
LogMessage("DriverVersion Get", driverVersion);
|
||||
return driverVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public short InterfaceVersion
|
||||
{
|
||||
// set by the driver wizard
|
||||
get
|
||||
{
|
||||
LogMessage("InterfaceVersion Get", "2");
|
||||
return Convert.ToInt16("2");
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
string name = "LynxAstro.DewController";
|
||||
Tl.LogMessage("Name Get", name);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISwitchV2 Implementation
|
||||
|
||||
private short numSwitch = 0;
|
||||
private List<string> switchNames = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The number of switches managed by this driver
|
||||
/// </summary>
|
||||
public short MaxSwitch
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckConnected("MaxSwitch Get");
|
||||
|
||||
var result = SharedResourcesWrapper.SendString(":GD#");
|
||||
var decoded = DecodeResult(":GD", result);
|
||||
|
||||
this.numSwitch = short.Parse(decoded);
|
||||
|
||||
//Command: :GD#
|
||||
//Purpose: Get the device type, i.e.the number of channels the dew controller has.
|
||||
//Response: :GDX# where X is either 1 or 4 depending on the number of channels this device has
|
||||
|
||||
Tl.LogMessage("MaxSwitch Get", numSwitch.ToString());
|
||||
return this.numSwitch;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the name of switch n
|
||||
/// </summary>
|
||||
/// <param name="id">The switch number to return</param>
|
||||
/// <returns>
|
||||
/// The name of the switch
|
||||
/// </returns>
|
||||
public string GetSwitchName(short id)
|
||||
{
|
||||
Validate("GetSwitchName", id);
|
||||
ReadProfile();
|
||||
|
||||
return switchNames.Count > id ? switchNames[id] : string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a switch name to a specified value
|
||||
/// </summary>
|
||||
/// <param name="id">The number of the switch whose name is to be set</param>
|
||||
/// <param name="name">The name of the switch</param>
|
||||
public void SetSwitchName(short id, string name)
|
||||
{
|
||||
Validate("SetSwitchName", id);
|
||||
ReadProfile();
|
||||
|
||||
while (id > switchNames.Count)
|
||||
switchNames.Add(string.Empty);
|
||||
|
||||
switchNames[id] = name;
|
||||
|
||||
WriteSwitchNames();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the switch description.
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <returns></returns>
|
||||
public string GetSwitchDescription(short id)
|
||||
{
|
||||
Validate("GetSwitchDescription", id);
|
||||
return "Control Knob";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports if the specified switch can be written to.
|
||||
/// This is false if the switch cannot be written to, for example a limit switch or a sensor.
|
||||
/// The default is true.
|
||||
/// </summary>
|
||||
/// <param name="id">The number of the switch whose write state is to be returned</param><returns>
|
||||
/// <c>true</c> if the switch can be written to, otherwise <c>false</c>.
|
||||
/// </returns>
|
||||
/// <exception cref="MethodNotImplementedException">If the method is not implemented</exception>
|
||||
/// <exception cref="InvalidValueException">If id is outside the range 0 to MaxSwitch - 1</exception>
|
||||
public bool CanWrite(short id)
|
||||
{
|
||||
Validate("CanWrite", id);
|
||||
// default behavour is to report true
|
||||
Tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - default true", id));
|
||||
return true;
|
||||
// implementation should report the correct behaviour
|
||||
//tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - not implemented", id));
|
||||
//throw new MethodNotImplementedException("CanWrite");
|
||||
}
|
||||
|
||||
#region boolean switch members
|
||||
|
||||
/// <summary>
|
||||
/// Return the state of switch n
|
||||
/// a multi-value switch must throw a not implemented exception
|
||||
/// </summary>
|
||||
/// <param name="id">The switch number to return</param>
|
||||
/// <returns>
|
||||
/// True or false
|
||||
/// </returns>
|
||||
public bool GetSwitch(short id)
|
||||
{
|
||||
var value = GetSwitchValue(id);
|
||||
return value > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a switch to the specified state
|
||||
/// If the switch cannot be set then throws a MethodNotImplementedException.
|
||||
/// A multi-value switch must throw a not implemented exception
|
||||
/// setting it to false will set it to its minimum value.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="state"></param>
|
||||
public void SetSwitch(short id, bool state)
|
||||
{
|
||||
Validate("SetSwitch", id);
|
||||
if (!CanWrite(id))
|
||||
{
|
||||
var str = string.Format("SetSwitch({0}) - Cannot Write", id);
|
||||
Tl.LogMessage("SetSwitch", str);
|
||||
throw new MethodNotImplementedException(str);
|
||||
}
|
||||
SetSwitchValue(id, state ? 1023 : 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region analogue members
|
||||
|
||||
/// <summary>
|
||||
/// returns the maximum value for this switch
|
||||
/// boolean switches must return 1.0
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public double MaxSwitchValue(short id)
|
||||
{
|
||||
Validate("MaxSwitchValue", id);
|
||||
// boolean switch implementation:
|
||||
return 1023;
|
||||
// or
|
||||
//tl.LogMessage("MaxSwitchValue", string.Format("MaxSwitchValue({0}) - not implemented", id));
|
||||
//throw new MethodNotImplementedException("MaxSwitchValue");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the minimum value for this switch
|
||||
/// boolean switches must return 0.0
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public double MinSwitchValue(short id)
|
||||
{
|
||||
Validate("MinSwitchValue", id);
|
||||
// boolean switch implementation:
|
||||
return 0;
|
||||
// or
|
||||
//tl.LogMessage("MinSwitchValue", string.Format("MinSwitchValue({0}) - not implemented", id));
|
||||
//throw new MethodNotImplementedException("MinSwitchValue");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the step size that this switch supports. This gives the difference between
|
||||
/// successive values of the switch.
|
||||
/// The number of values is ((MaxSwitchValue - MinSwitchValue) / SwitchStep) + 1
|
||||
/// boolean switches must return 1.0, giving two states.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public double SwitchStep(short id)
|
||||
{
|
||||
Validate("SwitchStep", id);
|
||||
// boolean switch implementation:
|
||||
return 1;
|
||||
// or
|
||||
//tl.LogMessage("SwitchStep", string.Format("SwitchStep({0}) - not implemented", id));
|
||||
//throw new MethodNotImplementedException("SwitchStep");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the analogue switch value for switch id
|
||||
/// boolean switches must throw a not implemented exception
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public double GetSwitchValue(short id)
|
||||
{
|
||||
Validate("GetSwitchValue", id);
|
||||
Tl.LogMessage("GetSwitchValue", string.Format("GetSwitchValue({0}) - not implemented", id));
|
||||
|
||||
var channel = ChannelToLetter(id);
|
||||
|
||||
var encoded = SharedResourcesWrapper.SendString($":GC{channel}#");
|
||||
var decoded = DecodeResult(":GC", encoded);
|
||||
|
||||
return double.Parse(decoded.TrimStart(channel));
|
||||
//Command: :GCX# where X is the channel A, B, C or D to retrieve.
|
||||
//Purpose: Get the current power setting for a specific channel.
|
||||
//Response: :GCXVVVV# where X is the channel A, B, C or D returned and VVVV is the power level between 0 - 1023.
|
||||
//Possible Errors
|
||||
//:ER5# = Channel out of range, e.g. channel B on a 1 channel device.
|
||||
}
|
||||
|
||||
private char ChannelToLetter(short id)
|
||||
{
|
||||
UInt16 ord = (UInt16) 'A';
|
||||
ord += (ushort)id;
|
||||
return (char)ord;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set the analogue value for this switch.
|
||||
/// If the switch cannot be set then throws a MethodNotImplementedException.
|
||||
/// If the value is not between the maximum and minimum then throws an InvalidValueException
|
||||
/// boolean switches must throw a not implemented exception.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
public void SetSwitchValue(short id, double value)
|
||||
{
|
||||
Validate("SetSwitchValue", id, value);
|
||||
if (!CanWrite(id))
|
||||
{
|
||||
Tl.LogMessage("SetSwitchValue", string.Format("SetSwitchValue({0}) - Cannot write", id));
|
||||
throw new ASCOM.MethodNotImplementedException(string.Format("SetSwitchValue({0}) - Cannot write", id));
|
||||
}
|
||||
//Tl.LogMessage("SetSwitchValue", string.Format("SetSwitchValue({0}) = {1} - not implemented", id, value));
|
||||
//throw new MethodNotImplementedException("SetSwitchValue");
|
||||
|
||||
|
||||
//Command: :SCXVVVV# where X is the channel A, B, C or D to set and VVVV is the power level
|
||||
//between 0 - 1023.The power level must be 4 digits long so pad with leading zeros if necessary.
|
||||
//Purpose: Set the current power setting for a specific channel.
|
||||
//Response: :SC1# indicates success. Run a GA or GC command to verify.
|
||||
//Possible Errors
|
||||
//:ER4# = Not enough data received - make sure you zero pad the power level.
|
||||
//:ER5# = Channel or power level out of range, e.g. channel B on a 1 channel device or power above 1023.
|
||||
|
||||
var channel = ChannelToLetter(id);
|
||||
|
||||
var encoded = SharedResourcesWrapper.SendString($":SC{channel}{value:0000}#");
|
||||
var decoded = DecodeResult(":SC", encoded);
|
||||
|
||||
if (decoded != "1")
|
||||
{
|
||||
throw new InvalidValueException($"Unable to set switch {{id}} to value {value}");
|
||||
}
|
||||
//return double.Parse(decoded.TrimStart(channel));
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region private methods
|
||||
|
||||
/// <summary>
|
||||
/// Checks that the switch id is in range and throws an InvalidValueException if it isn't
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="id">The id.</param>
|
||||
private void Validate(string message, short id)
|
||||
{
|
||||
if (id < 0 || id >= numSwitch)
|
||||
{
|
||||
Tl.LogMessage(message, string.Format("Switch {0} not available, range is 0 to {1}", id, numSwitch - 1));
|
||||
throw new InvalidValueException(message, id.ToString(), string.Format("0 to {0}", numSwitch - 1));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks that the switch id and value are in range and throws an
|
||||
/// InvalidValueException if they are not.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
private void Validate(string message, short id, double value)
|
||||
{
|
||||
Validate(message, id);
|
||||
var min = MinSwitchValue(id);
|
||||
var max = MaxSwitchValue(id);
|
||||
if (value < min || value > max)
|
||||
{
|
||||
Tl.LogMessage(message, string.Format("Value {1} for Switch {0} is out of the allowed range {2} to {3}", id, value, min, max));
|
||||
throw new InvalidValueException(message, value.ToString(), string.Format("Switch({0}) range {1} to {2}", id, min, max));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks that the number of states for the switch is correct and throws a methodNotImplemented exception if not.
|
||||
/// Boolean switches must have 2 states and multi-value switches more than 2.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="expectBoolean"></param>
|
||||
//private void Validate(string message, short id, bool expectBoolean)
|
||||
//{
|
||||
// Validate(message, id);
|
||||
// var ns = (int)(((MaxSwitchValue(id) - MinSwitchValue(id)) / SwitchStep(id)) + 1);
|
||||
// if ((expectBoolean && ns != 2) || (!expectBoolean && ns <= 2))
|
||||
// {
|
||||
// tl.LogMessage(message, string.Format("Switch {0} has the wriong number of states", id, ns));
|
||||
// throw new MethodNotImplementedException(string.Format("{0}({1})", message, id));
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private properties and methods
|
||||
// here are some useful properties and methods that can be used as required
|
||||
// to help with driver development
|
||||
|
||||
#region ASCOM Registration
|
||||
|
||||
// Register or unregister driver for ASCOM. This is harmless if already
|
||||
// registered or unregistered.
|
||||
//
|
||||
/// <summary>
|
||||
/// Register or unregister the driver with the ASCOM Platform.
|
||||
/// This is harmless if the driver is already registered/unregistered.
|
||||
/// </summary>
|
||||
/// <param name="bRegister">If <c>true</c>, registers the driver, otherwise unregisters it.</param>
|
||||
private static void RegUnregASCOM(bool bRegister)
|
||||
{
|
||||
using (var P = new ASCOM.Utilities.Profile())
|
||||
{
|
||||
P.DeviceType = "Switch";
|
||||
if (bRegister)
|
||||
{
|
||||
P.Register(DriverId, DriverDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
P.Unregister(DriverId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function registers the driver with the ASCOM Chooser and
|
||||
/// is called automatically whenever this class is registered for COM Interop.
|
||||
/// </summary>
|
||||
/// <param name="t">Type of the class being registered, not used.</param>
|
||||
/// <remarks>
|
||||
/// This method typically runs in two distinct situations:
|
||||
/// <list type="numbered">
|
||||
/// <item>
|
||||
/// In Visual Studio, when the project is successfully built.
|
||||
/// For this to work correctly, the option <c>Register for COM Interop</c>
|
||||
/// must be enabled in the project settings.
|
||||
/// </item>
|
||||
/// <item>During setup, when the installer registers the assembly for COM Interop.</item>
|
||||
/// </list>
|
||||
/// This technique should mean that it is never necessary to manually register a driver with ASCOM.
|
||||
/// </remarks>
|
||||
[ComRegisterFunction]
|
||||
public static void RegisterASCOM(Type t)
|
||||
{
|
||||
RegUnregASCOM(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function unregisters the driver from the ASCOM Chooser and
|
||||
/// is called automatically whenever this class is unregistered from COM Interop.
|
||||
/// </summary>
|
||||
/// <param name="t">Type of the class being registered, not used.</param>
|
||||
/// <remarks>
|
||||
/// This method typically runs in two distinct situations:
|
||||
/// <list type="numbered">
|
||||
/// <item>
|
||||
/// In Visual Studio, when the project is cleaned or prior to rebuilding.
|
||||
/// For this to work correctly, the option <c>Register for COM Interop</c>
|
||||
/// must be enabled in the project settings.
|
||||
/// </item>
|
||||
/// <item>During uninstall, when the installer unregisters the assembly from COM Interop.</item>
|
||||
/// </list>
|
||||
/// This technique should mean that it is never necessary to manually unregister a driver from ASCOM.
|
||||
/// </remarks>
|
||||
[ComUnregisterFunction]
|
||||
public static void UnregisterASCOM(Type t)
|
||||
{
|
||||
RegUnregASCOM(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected bool IsConnected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Use this function to throw an exception if we aren't connected to the hardware
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
private void CheckConnected(string message)
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new ASCOM.NotConnectedException(message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read the device configuration from the ASCOM Profile store
|
||||
/// </summary>
|
||||
protected void ReadProfile()
|
||||
{
|
||||
var profileProperties = SharedResourcesWrapper.ReadProfile();
|
||||
Tl.Enabled = profileProperties.TraceLogger;
|
||||
ComPort = profileProperties.ComPort;
|
||||
|
||||
switchNames.Clear();
|
||||
switchNames.AddRange(profileProperties.SwitchNames);
|
||||
|
||||
LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}");
|
||||
LogMessage("ReadProfile", $"Com Port: {ComPort}");
|
||||
|
||||
}
|
||||
|
||||
protected void WriteSwitchNames()
|
||||
{
|
||||
var profileProperties = SharedResourcesWrapper.ReadProfile();
|
||||
|
||||
profileProperties.SwitchNames.Clear();
|
||||
profileProperties.SwitchNames.AddRange(switchNames);
|
||||
|
||||
SharedResourcesWrapper.WriteProfile(profileProperties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log helper function that takes formatted strings and arguments
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void LogMessage(string identifier, string message, params object[] args)
|
||||
{
|
||||
var msg = string.Format(message, args);
|
||||
Tl.LogMessage(identifier, msg);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<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.7.2"/></startup></configuration>
|
||||
Reference in New Issue
Block a user