Begin of iOptron Controller

This commit is contained in:
BlubbFish 2018-08-18 23:46:35 +00:00
commit a9c9ce4604
15 changed files with 1470 additions and 0 deletions

31
iOptron-Controller.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iOptron-Controller", "iOptron-Controller\iOptron-Controller.csproj", "{D3DB1047-28F1-4C3F-8753-D17302B38E4A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3DB1047-28F1-4C3F-8753-D17302B38E4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3DB1047-28F1-4C3F-8753-D17302B38E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3DB1047-28F1-4C3F-8753-D17302B38E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3DB1047-28F1-4C3F-8753-D17302B38E4A}.Release|Any CPU.Build.0 = Release|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C6847698-39F4-4E1B-9E4E-EB41EF71414E}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,38 @@
using System;
using System.Windows.Forms;
using BlubbFish.iOptronController.Views;
using BlubbFish.Utils;
namespace BlubbFish.iOptronController.Controllers {
class ControllerWindow : OwnController {
private static ViewWindow viewwindow;
public ControllerWindow() {
}
public override void Dispose() {
if (viewwindow != null) {
viewwindow.Dispose();
}
}
protected override void Init() {
viewwindow = new ViewWindow();
}
internal static void FormClosed(Object sender, FormClosedEventArgs e) {
viewwindow.Dispose();
Application.Exit();
}
internal static void OpenButton(Object sender, EventArgs e) {
viewwindow.Model.PortOpen = true;
}
internal static void ComportChanged(Object sender, EventArgs e) {
ComboBox c = (ComboBox)sender;
viewwindow.Model.Comport = c.SelectedItem.ToString();
viewwindow.Model.PortOpen = false;
}
}
}

View File

@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Threading;
using BlubbFish.iOptronController.lib;
using BlubbFish.Utils;
namespace BlubbFish.iOptronController.Models {
public class ModelWindow : OwnModel<ModelWindow> {
private Thread comSearchThread;
private Thread SettingsWatcherThread;
private ModelWindow() {
this.Init();
}
private void ComSearchRunner() {
while (true) {
List<String> ports = SerialPort.GetPortNames().ToList();
if(!ports.SequenceEqual(this.ComportsValue)) {
this.Comports = ports;
}
Thread.Sleep(5000);
}
}
private void SettingsWatcherRunner() {
while(true) {
if(OptronConnector.Instance.Opend) {
Boolean update = false;
TimeSpan gmtoffset = OptronConnector.Instance.Gmtoffset;
if(gmtoffset != this.ConrollerGMTOffsetValue) {
update = true;
this.ConrollerGMTOffsetValue = gmtoffset;
}
Boolean summertime = OptronConnector.Instance.Summertime;
if(summertime != this.ControllerSummerTimeValue) {
update = true;
this.ControllerSummerTimeValue = summertime;
}
Double longitude = OptronConnector.Instance.Longitude;
if (longitude != this.ControllerLongitudeValue) {
update = true;
this.ControllerLongitudeValue = longitude;
}
Double latitude = OptronConnector.Instance.Latitude;
if (latitude != this.ControllerLatitudeValue) {
update = true;
this.ControllerLatitudeValue = latitude;
}
DateTime localtime = OptronConnector.Instance.Localtime;
if(localtime != this.ControllerLocalTimeValue) {
update = true;
this.ControllerLocalTimeValue = localtime;
}
TimeSpan sidrealtime = OptronConnector.Instance.Siderealtime;
if (sidrealtime != this.ControllerSiderealTimeValue) {
update = true;
this.ControllerSiderealTimeValue = sidrealtime;
}
TimeSpan rightascension = OptronConnector.Instance.Rightascension;
if (rightascension != this.ControllerRightAscensionValue) {
update = true;
this.ControllerRightAscensionValue = rightascension;
}
Double declination = OptronConnector.Instance.Declination;
if (declination != this.ControllerDeclinationValue) {
update = true;
this.ControllerDeclinationValue = declination;
}
Double azimuth = OptronConnector.Instance.Azimuth;
if (azimuth != this.ControllerAzimuthValue) {
update = true;
this.ControllerAzimuthValue = azimuth;
}
Double altitude = OptronConnector.Instance.Altitude;
if (altitude != this.ControllerAltitudeValue) {
update = true;
this.ControllerAltitudeValue = altitude;
}
if (update) {
this.Update();
}
}
Thread.Sleep(5000);
}
}
protected override void Init() {
this.comSearchThread = new Thread(this.ComSearchRunner);
this.comSearchThread.Start();
this.SettingsWatcherThread = new Thread(this.SettingsWatcherRunner);
this.SettingsWatcherThread.Start();
}
public override void Dispose() {
try {
this.comSearchThread.Abort();
this.SettingsWatcherThread.Abort();
} catch { }
}
#region Fields
private List<String> ComportsValue = new List<String>();
public List<String> Comports {
get { return this.ComportsValue; }
set { this.ComportsValue = value; this.Update(); }
}
private String ComportValue = "";
public String Comport {
get { return this.ComportValue; }
set { this.ComportValue = value; this.Update(); }
}
public Boolean PortOpen {
get { return OptronConnector.Instance.Opend; }
set {
if (value && !OptronConnector.Instance.Opend) {
OptronConnector.Instance.SetPort(this.ComportValue);
OptronConnector.Instance.Open();
}
if(!value && OptronConnector.Instance.Opend) {
OptronConnector.Instance.Close();
}
this.Update();
}
}
private TimeSpan ConrollerGMTOffsetValue = new TimeSpan();
public TimeSpan ConrollerGMTOffset {
get { return this.ConrollerGMTOffsetValue; }
set { OptronConnector.Instance.Gmtoffset = value; this.ConrollerGMTOffsetValue = value; this.Update(); }
}
private Boolean ControllerSummerTimeValue = false;
public Boolean ControllerSummerTime {
get { return this.ControllerSummerTimeValue; }
set { OptronConnector.Instance.Summertime = value; this.ControllerSummerTimeValue = value; this.Update(); }
}
private Double ControllerLongitudeValue = 0;
public Double ControllerLongitude {
get { return this.ControllerLongitudeValue; }
set { OptronConnector.Instance.Longitude = value; this.ControllerLongitudeValue = value; this.Update(); }
}
private Double ControllerLatitudeValue = 0;
public Double ControllerLatitude {
get { return this.ControllerLatitudeValue; }
set { OptronConnector.Instance.Latitude = value; this.ControllerLatitudeValue = value; this.Update(); }
}
private DateTime ControllerLocalTimeValue = new DateTime();
public DateTime ControllerLocalTime {
get { return this.ControllerLocalTimeValue; }
set { OptronConnector.Instance.Localtime = value; this.ControllerLocalTimeValue = value; this.Update(); }
}
private TimeSpan ControllerSiderealTimeValue = new TimeSpan();
public TimeSpan ControllerSiderealTime {
get { return this.ControllerSiderealTimeValue; }
set { OptronConnector.Instance.Siderealtime = value; this.ControllerSiderealTimeValue = value; this.Update(); }
}
private TimeSpan ControllerRightAscensionValue = new TimeSpan();
public TimeSpan ControllerRightAscension {
get { return this.ControllerRightAscensionValue; }
set { OptronConnector.Instance.Rightascension = value; this.ControllerRightAscensionValue = value; this.Update(); }
}
private Double ControllerDeclinationValue = 0;
public Double ControllerDeclination {
get { return this.ControllerDeclinationValue; }
set { OptronConnector.Instance.Declination = value; this.ControllerDeclinationValue = value; this.Update(); }
}
private Double ControllerAltitudeValue = 0;
public Double ControllerAltitude {
get { return this.ControllerAltitudeValue; }
set { OptronConnector.Instance.Altitude = value; this.ControllerAltitudeValue = value; this.Update(); }
}
private Double ControllerAzimuthValue = 0;
public Double ControllerAzimuth {
get { return this.ControllerAzimuthValue; }
set { OptronConnector.Instance.Azimuth = value; this.ControllerAzimuthValue = value; this.Update(); }
}
#endregion
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using BlubbFish.iOptronController.Controllers;
namespace BlubbFish.iOptronController {
static class Program {
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main() {
ControllerWindow c = new ControllerWindow();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
c.Execute();
Application.Run();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("iOptron-Controller")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("iOptron-Controller")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("d3db1047-28f1-4c3f-8753-d17302b38e4a")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace BlubbFish.iOptronController.Properties {
using System;
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.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>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </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("BlubbFish.iOptronController.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace BlubbFish.iOptronController.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.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;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BlubbFish.iOptronController.Models;
using BlubbFish.Utils;
namespace BlubbFish.iOptronController.Views {
public class ViewWindow : OwnView {
private readonly ViewWindowForm form;
public ModelWindow Model { get; private set; }
public ViewWindow() {
this.Model = ModelWindow.Instance;
this.form = new ViewWindowForm();
this.form.SetModel(this.Model);
this.form.Show();
this.Model.SetObserver(this);
}
public override void Dispose() {
this.Model.RemoveObserver(this);
this.Model.Dispose();
this.form.BeginInvoke((Action)(() => {
this.form.Dispose();
}));
}
public override void Update() {
this.form.UpdateForm();
}
}
}

View File

@ -0,0 +1,310 @@
namespace BlubbFish.iOptronController.Views {
partial class ViewWindowForm {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.serialPorts = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.comport = new System.Windows.Forms.Label();
this.openbutton = new System.Windows.Forms.Button();
this.openstatus = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.settingsgmtoffset = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.settingssummertime = new System.Windows.Forms.CheckBox();
this.label4 = new System.Windows.Forms.Label();
this.settingslongitude = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.settingslatitude = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.settingslocaltime = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.settingssiderealtime = new System.Windows.Forms.TextBox();
this.coordra = new System.Windows.Forms.Label();
this.coordsdec = new System.Windows.Forms.Label();
this.coordsaz = new System.Windows.Forms.Label();
this.coordsal = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// serialPorts
//
this.serialPorts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.serialPorts.FormattingEnabled = true;
this.serialPorts.Location = new System.Drawing.Point(551, 12);
this.serialPorts.Name = "serialPorts";
this.serialPorts.Size = new System.Drawing.Size(121, 21);
this.serialPorts.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(678, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(40, 13);
this.label1.TabIndex = 1;
this.label1.Text = "PORT:";
//
// comport
//
this.comport.AutoSize = true;
this.comport.Location = new System.Drawing.Point(724, 15);
this.comport.Name = "comport";
this.comport.Size = new System.Drawing.Size(38, 13);
this.comport.TabIndex = 2;
this.comport.Text = "NONE";
//
// openbutton
//
this.openbutton.Location = new System.Drawing.Point(551, 40);
this.openbutton.Name = "openbutton";
this.openbutton.Size = new System.Drawing.Size(121, 23);
this.openbutton.TabIndex = 3;
this.openbutton.Text = "Open";
this.openbutton.UseVisualStyleBackColor = true;
//
// openstatus
//
this.openstatus.AutoSize = true;
this.openstatus.Location = new System.Drawing.Point(678, 45);
this.openstatus.Name = "openstatus";
this.openstatus.Size = new System.Drawing.Size(39, 13);
this.openstatus.TabIndex = 4;
this.openstatus.Text = "Closed";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.settingssiderealtime);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.settingslocaltime);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.settingslatitude);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.settingslongitude);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.settingssummertime);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.settingsgmtoffset);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Location = new System.Drawing.Point(551, 69);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(237, 369);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Settings";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 20);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 13);
this.label2.TabIndex = 0;
this.label2.Text = "GMT Offset:";
//
// settingsgmtoffset
//
this.settingsgmtoffset.Location = new System.Drawing.Point(108, 17);
this.settingsgmtoffset.Name = "settingsgmtoffset";
this.settingsgmtoffset.Size = new System.Drawing.Size(123, 20);
this.settingsgmtoffset.TabIndex = 1;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(7, 44);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(67, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Summertime:";
//
// settingssummertime
//
this.settingssummertime.AutoSize = true;
this.settingssummertime.Location = new System.Drawing.Point(108, 43);
this.settingssummertime.Name = "settingssummertime";
this.settingssummertime.Size = new System.Drawing.Size(15, 14);
this.settingssummertime.TabIndex = 3;
this.settingssummertime.UseVisualStyleBackColor = true;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(7, 66);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(57, 13);
this.label4.TabIndex = 4;
this.label4.Text = "Longitude:";
//
// settingslongitude
//
this.settingslongitude.Location = new System.Drawing.Point(108, 63);
this.settingslongitude.Name = "settingslongitude";
this.settingslongitude.Size = new System.Drawing.Size(123, 20);
this.settingslongitude.TabIndex = 5;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(7, 92);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(48, 13);
this.label5.TabIndex = 6;
this.label5.Text = "Latitude:";
//
// settingslatitude
//
this.settingslatitude.Location = new System.Drawing.Point(108, 89);
this.settingslatitude.Name = "settingslatitude";
this.settingslatitude.Size = new System.Drawing.Size(123, 20);
this.settingslatitude.TabIndex = 7;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(7, 119);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(62, 13);
this.label6.TabIndex = 8;
this.label6.Text = "Local Time:";
//
// settingslocaltime
//
this.settingslocaltime.Location = new System.Drawing.Point(108, 116);
this.settingslocaltime.Name = "settingslocaltime";
this.settingslocaltime.ReadOnly = true;
this.settingslocaltime.Size = new System.Drawing.Size(123, 20);
this.settingslocaltime.TabIndex = 9;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 149);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(74, 13);
this.label7.TabIndex = 10;
this.label7.Text = "Sidereal Time:";
//
// settingssiderealtime
//
this.settingssiderealtime.Location = new System.Drawing.Point(108, 142);
this.settingssiderealtime.Name = "settingssiderealtime";
this.settingssiderealtime.ReadOnly = true;
this.settingssiderealtime.Size = new System.Drawing.Size(123, 20);
this.settingssiderealtime.TabIndex = 11;
//
// coordra
//
this.coordra.AutoSize = true;
this.coordra.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.coordra.ForeColor = System.Drawing.Color.Red;
this.coordra.Location = new System.Drawing.Point(12, 9);
this.coordra.Name = "coordra";
this.coordra.Size = new System.Drawing.Size(149, 25);
this.coordra.TabIndex = 6;
this.coordra.Text = "RA: 00:00:00";
//
// coordsdec
//
this.coordsdec.AutoSize = true;
this.coordsdec.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.coordsdec.ForeColor = System.Drawing.Color.Red;
this.coordsdec.Location = new System.Drawing.Point(191, 9);
this.coordsdec.Name = "coordsdec";
this.coordsdec.Size = new System.Drawing.Size(160, 25);
this.coordsdec.TabIndex = 7;
this.coordsdec.Text = "DEC: 0°00\'00\"";
//
// coordsaz
//
this.coordsaz.AutoSize = true;
this.coordsaz.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.coordsaz.ForeColor = System.Drawing.Color.Red;
this.coordsaz.Location = new System.Drawing.Point(12, 40);
this.coordsaz.Name = "coordsaz";
this.coordsaz.Size = new System.Drawing.Size(142, 25);
this.coordsaz.TabIndex = 8;
this.coordsaz.Text = "AZ: 0°00\'00\"";
//
// coordsal
//
this.coordsal.AutoSize = true;
this.coordsal.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.coordsal.ForeColor = System.Drawing.Color.Red;
this.coordsal.Location = new System.Drawing.Point(191, 40);
this.coordsal.Name = "coordsal";
this.coordsal.Size = new System.Drawing.Size(141, 25);
this.coordsal.TabIndex = 9;
this.coordsal.Text = "AL: 0°00\'00\"";
//
// ViewWindowForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.coordsal);
this.Controls.Add(this.coordsaz);
this.Controls.Add(this.coordsdec);
this.Controls.Add(this.coordra);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.openstatus);
this.Controls.Add(this.openbutton);
this.Controls.Add(this.comport);
this.Controls.Add(this.label1);
this.Controls.Add(this.serialPorts);
this.Name = "ViewWindowForm";
this.Text = "ViewWindowForm";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox serialPorts;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label comport;
private System.Windows.Forms.Button openbutton;
private System.Windows.Forms.Label openstatus;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox settingsgmtoffset;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox settingssummertime;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox settingslongitude;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox settingslatitude;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox settingslocaltime;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox settingssiderealtime;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label coordra;
private System.Windows.Forms.Label coordsdec;
private System.Windows.Forms.Label coordsaz;
private System.Windows.Forms.Label coordsal;
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using BlubbFish.iOptronController.Controllers;
using BlubbFish.iOptronController.Models;
namespace BlubbFish.iOptronController.Views {
public partial class ViewWindowForm : Form {
private ModelWindow model;
public ViewWindowForm() {
InitializeComponent();
this.FormClosed += ControllerWindow.FormClosed;
this.serialPorts.SelectedIndexChanged += ControllerWindow.ComportChanged;
this.openbutton.Click += ControllerWindow.OpenButton;
}
public void UpdateForm() {
this.BeginInvoke((Action)(() => {
this.serialPorts.Items.Clear();
this.serialPorts.Items.AddRange(this.model.Comports.ToArray());
//this.serialPorts.SelectedItem = this.model.Comport;
this.comport.Text = this.model.Comport;
if(this.model.PortOpen) {
this.openstatus.Text = "Connected";
this.openstatus.ForeColor = Color.DarkGreen;
} else {
this.openstatus.Text = "Closed";
this.openstatus.ForeColor = Color.OrangeRed;
}
this.settingsgmtoffset.Text = (this.model.ConrollerGMTOffset.Ticks < 0 ? "-" : "") + this.model.ConrollerGMTOffset.ToString(@"hh\:mm");
this.settingssummertime.Checked = this.model.ControllerSummerTime;
this.settingslongitude.Text = this.model.ControllerLongitude.ToString();
this.settingslatitude.Text = this.model.ControllerLatitude.ToString();
this.settingslocaltime.Text = this.model.ControllerLocalTime.ToString("HH:mm:ss dd.MM.yyyy");
this.settingssiderealtime.Text = this.model.ControllerSiderealTime.ToString(@"hh\:mm\:ss");
this.coordra.Text = "RA: " + this.model.ControllerRightAscension.ToString(@"hh\:mm\:ss");
this.coordsdec.Text = "DEC: " + this.DoubleToStringDegree(this.model.ControllerDeclination);
this.coordsal.Text = "AL: " + this.DoubleToStringDegree(this.model.ControllerAltitude);
this.coordsaz.Text = "AZ: " + this.DoubleToStringDegree(this.model.ControllerAzimuth);
}));
}
public void SetModel(ModelWindow window) {
this.model = window;
}
private String DoubleToStringDegree(Double dec) {
Int32 d = (Int32)dec;
Int32 m = (Int32)((dec - d) * 60);
Double s = Math.Round((((dec - d) * 60) - m) * 60);
return d + "°" + m + "'" + s + "\"";
}
}
}

View File

@ -0,0 +1,120 @@
<?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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{D3DB1047-28F1-4C3F-8753-D17302B38E4A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>BlubbFish.iOptronController</RootNamespace>
<AssemblyName>iOptron-Controller</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\ControllerWindow.cs" />
<Compile Include="lib\OptronConnector.cs" />
<Compile Include="Models\ModelWindow.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Views\ViewWindow.cs" />
<Compile Include="Views\ViewWindowForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Views\ViewWindowForm.Designer.cs">
<DependentUpon>ViewWindowForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Views\ViewWindowForm.resx">
<DependentUpon>ViewWindowForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
<Name>Utils</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,327 @@
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BlubbFish.iOptronController.lib {
class OptronConnector {
private static readonly Lazy<OptronConnector> _instance = new Lazy<OptronConnector>(() => CreateInstanceOfOptronConnector());
private SerialPort serialPort;
private readonly Object getLock = new Object();
private static OptronConnector CreateInstanceOfOptronConnector() {
return Activator.CreateInstance(typeof(OptronConnector), true) as OptronConnector;
}
public static OptronConnector Instance {
get {
return _instance.Value;
}
}
public Boolean Opend { get; private set; } = false;
public String Port { get; private set; }
internal void SetPort(String port) {
this.Port = port;
}
internal void Open() {
try {
this.serialPort = new SerialPort(this.Port, 9600, Parity.None, 8, StopBits.One);
this.serialPort.Open();
this.Opend = true;
if (this.Version != 1) {
this.Opend = false;
return;
}
if(this.Mountinfo != 8498) {
this.Opend = false;
return;
}
} catch {
this.Opend = false;
}
}
internal void Close() {
if(this.serialPort != null && this.serialPort.IsOpen) {
this.serialPort.Close();
}
this.Opend = false;
}
private String WriteRead(String text, Int32 length, Boolean notailingsharp = false) {
lock (this.getLock) {
if (this.Opend) {
this.serialPort.Write(text);
Byte[] buf = new Byte[length];
for (Int32 i = 0; i < length; i++) {
buf[i] = (Byte)this.serialPort.ReadChar();
}
if (!notailingsharp && buf[buf.Length - 1] != '#') {
return "";
}
return Encoding.ASCII.GetString(buf);
}
return "";
}
}
#region Eigenschaften
/// <summary>
/// Command: “:V#”
/// Response: “V1.00#”
/// This command is the first initialization command of iOptron products.
/// </summary>
public Double Version {
get {
String text = this.WriteRead(":V#", 6);
if (text == "") {
return 0;
}
if (Double.TryParse(text.Substring(1, 4), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out Double d)) {
return d;
}
return 0;
}
}
/// <summary>
/// Command: “:MountInfo#”
/// Response: “8407”,”8497”,”8408” ,”8498”
/// This command gets the mount type. “8407” means iEQ45 EQ mode or iEQ30, “8497” means iEQ45 AA mode, “8408” means ZEQ25, “8498” means SmartEQ.
/// </summary>
public Int32 Mountinfo {
get {
String text = this.WriteRead(":MountInfo#", 4, true);
if (Int32.TryParse(text, out Int32 i)) {
return i;
}
return 0;
}
}
/// <summary>
/// Command: “:GG#”
/// Response: “sHH:MM#”
/// Gets the offset from Greenwich Mean Time(Exclude Daylight Saving Time).
/// </summary>
public TimeSpan Gmtoffset {
get {
String text = this.WriteRead(":GG#", 7);
if(text == "") {
return new TimeSpan();
}
Int32.TryParse(text.Substring(1, 2), out Int32 hours);
Int32.TryParse(text.Substring(4, 2), out Int32 minutes);
TimeSpan t = new TimeSpan();
if(text[0] == '+') {
t = t.Add(TimeSpan.FromHours(hours)).Add(TimeSpan.FromMinutes(minutes));
}
if (text[0] == '-') {
t = t.Subtract(TimeSpan.FromHours(hours)).Subtract(TimeSpan.FromMinutes(minutes));
}
return t;
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GDS#”
/// Response: “0”or“1”
/// Gets the status of Daylight Saving Time. “1” means Daylight Saving Time enabled, “0” means Daylight Saving Time disabled.
/// </summary>
public Boolean Summertime {
get {
String text = this.WriteRead(":GDS#", 1, true);
if(text == "") {
return false;
}
if(text == "1") {
return true;
}
if(text == "0") {
return false;
}
return false;
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:Gg#”
/// Response: “sDDD*MM:SS#”
/// Gets the current longitude. Note the return value will be in signed format, East is positive
/// </summary>
public Double Longitude {
get {
String text = this.WriteRead(":Gg#", 11);
if (text == "") {
return 0;
}
Int32.TryParse(text.Substring(1, 3), out Int32 degrees);
Int32.TryParse(text.Substring(5, 2), out Int32 minutes);
Int32.TryParse(text.Substring(8, 2), out Int32 seconds);
return (degrees + ((minutes + ((Double)seconds / 60)) / 60)) * (text[0] == '-' ? -1 : 1);
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:Gt#”
/// Response: “sDD*MM:SS#”
/// Gets the current latitude. Note the return value will be in signed format, North is positive.
/// </summary>
public Double Latitude {
get {
String text = this.WriteRead(":Gt#", 10);
if (text == "") {
return 0;
}
Int32.TryParse(text.Substring(1, 2), out Int32 degrees);
Int32.TryParse(text.Substring(4, 2), out Int32 minutes);
Int32.TryParse(text.Substring(7, 2), out Int32 seconds);
return (degrees + ((minutes + ((Double)seconds / 60)) / 60)) * (text[0] == '-' ? -1 : 1);
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GL#”
/// Response: “HH:MM:SS#”
/// Gets the current local time in 24 hour format.Overflows from 23:59:59 to 00:00:00. Updates calendar day on overflow.
/// Command: “:GC#”
/// Response: “MM:DD:YY#” /// Gets the current calendar day.
/// </summary>
public DateTime Localtime {
get {
String time = this.WriteRead(":GL#", 9);
String date = this.WriteRead(":GC#", 9);
if (time == "" || date == "") {
return new DateTime();
}
DateTime.TryParse("20" + date.Substring(6, 2) + "-" + date.Substring(0, 2) + "-" + date.Substring(3, 2) + "T" + time.Substring(0, 8), out DateTime timestamp);
return timestamp;
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GS#”
/// Response: “HH:MM:SS#”
/// Gets the current sidereal time in 24 hour format.
/// </summary>
public TimeSpan Siderealtime {
get {
String text = this.WriteRead(":GS#", 9);
if (text == "") {
return new TimeSpan();
}
Int32.TryParse(text.Substring(0, 2), out Int32 hours);
Int32.TryParse(text.Substring(3, 2), out Int32 minutes);
Int32.TryParse(text.Substring(6, 2), out Int32 seconds);
return new TimeSpan().Add(TimeSpan.FromHours(hours)).Add(TimeSpan.FromMinutes(minutes)).Add(TimeSpan.FromSeconds(seconds));
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GR#”
/// Response: “HH:MM:SS#”
/// Gets the current Right Ascension
/// </summary>
public TimeSpan Rightascension {
get {
String text = this.WriteRead(":GR#", 9);
if (text == "") {
return new TimeSpan();
}
Int32.TryParse(text.Substring(0, 2), out Int32 hours);
Int32.TryParse(text.Substring(3, 2), out Int32 minutes);
Int32.TryParse(text.Substring(6, 2), out Int32 seconds);
return new TimeSpan().Add(TimeSpan.FromHours(hours)).Add(TimeSpan.FromMinutes(minutes)).Add(TimeSpan.FromSeconds(seconds));
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GD#”
/// Response: “sDD*MM:SS#”
/// Gets the current Declination.
/// </summary>
public Double Declination {
get {
String text = this.WriteRead(":GD#", 10);
if (text == "") {
return 0;
}
Int32.TryParse(text.Substring(1, 2), out Int32 degrees);
Int32.TryParse(text.Substring(4, 2), out Int32 minutes);
Int32.TryParse(text.Substring(7, 2), out Int32 seconds);
return (degrees + ((minutes + ((Double)seconds / 60)) / 60)) * (text[0] == '-' ? -1 : 1);
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GA#”
/// Response: “sDD*MM:SS#”
/// Gets the current Altitude.
/// </summary>
public Double Altitude {
get {
String text = this.WriteRead(":GA#", 10);
if (text == "") {
return 0;
}
Int32.TryParse(text.Substring(1, 2), out Int32 degrees);
Int32.TryParse(text.Substring(4, 2), out Int32 minutes);
Int32.TryParse(text.Substring(7, 2), out Int32 seconds);
return (degrees + ((minutes + ((Double)seconds / 60)) / 60)) * (text[0] == '-' ? -1 : 1);
}
set {
throw new NotImplementedException();
}
}
/// <summary>
/// Command: “:GZ#”
/// Response: “DDD*MM:SS#” /// Gets the current Azimuth.
/// </summary>
public Double Azimuth {
get {
String text = this.WriteRead(":GZ#", 10);
if (text == "") {
return 0;
}
Int32.TryParse(text.Substring(0, 3), out Int32 degrees);
Int32.TryParse(text.Substring(4, 2), out Int32 minutes);
Int32.TryParse(text.Substring(7, 2), out Int32 seconds);
return (degrees + ((minutes + ((Double)seconds / 60)) / 60));
}
set {
throw new NotImplementedException();
}
}
#endregion
}
}