From 86ad13eecce56a44051e26a86bce8767ff723296 Mon Sep 17 00:00:00 2001 From: Robert Morgan Date: Fri, 11 Sep 2020 15:19:57 -0400 Subject: [PATCH] Park items added to API --- Directory.Build.props | 8 +- GS.Server/SkyTelescope/SkyTelescopeVM.cs | 6 +- GS.Shared/LanguageFiles/GSServer_en-US.xaml | 2 +- GS.SkyApi/GS.SkyApi.csproj | 5 ++ GS.SkyApi/Sky.cs | 91 +++++++++++++++++++++ GS.SkyApi/SkyScripts/Park.ps1 | 19 +++++ Resources/Installer/GreenSwampSetup.iss | 17 +++- 7 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 GS.SkyApi/SkyScripts/Park.ps1 diff --git a/Directory.Build.props b/Directory.Build.props index b240274..4a9d8a9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,9 +5,9 @@ GS Server en Copyright © GreenSwamp Software 2019-2020 - 1.0.1.8 - 1.0.1.8 - 1.0.1.8 - 1.0.1.8 + 1.0.1.9 + 1.0.1.9 + 1.0.1.9 + 1.0.1.9 \ No newline at end of file diff --git a/GS.Server/SkyTelescope/SkyTelescopeVM.cs b/GS.Server/SkyTelescope/SkyTelescopeVM.cs index 77aec52..eb93dfc 100644 --- a/GS.Server/SkyTelescope/SkyTelescopeVM.cs +++ b/GS.Server/SkyTelescope/SkyTelescopeVM.cs @@ -1,4 +1,4 @@ -/* Copyright(C) 2019 Rob Morgan (robert.morgan.e@gmail.com) +/* Copyright(C) 2019-2020 Rob Morgan (robert.morgan.e@gmail.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -1011,7 +1011,7 @@ public int Lat2 var sec = (int)Math.Round(SkySettings.Latitude * 3600); sec = Math.Abs(sec % 3600); var min = sec / 60; - return Math.Abs(min); + return min; } set { @@ -1075,7 +1075,7 @@ public int Long2 var sec = (int)Math.Round(SkySettings.Longitude * 3600); sec = Math.Abs(sec % 3600); var min = sec / 60; - return Math.Abs(min); + return min; } set { diff --git a/GS.Shared/LanguageFiles/GSServer_en-US.xaml b/GS.Shared/LanguageFiles/GSServer_en-US.xaml index a515a21..3ad047a 100644 --- a/GS.Shared/LanguageFiles/GSServer_en-US.xaml +++ b/GS.Shared/LanguageFiles/GSServer_en-US.xaml @@ -492,7 +492,7 @@ along with this program. If not, see . Check for Updates Updates not Available Updates not Found - Diconnect mount and connected applications before running + Disconnect mount and connected applications before running Pole Locator Copied to Clipboard diff --git a/GS.SkyApi/GS.SkyApi.csproj b/GS.SkyApi/GS.SkyApi.csproj index b96291b..badb955 100644 --- a/GS.SkyApi/GS.SkyApi.csproj +++ b/GS.SkyApi/GS.SkyApi.csproj @@ -73,4 +73,9 @@ + + + Always + + \ No newline at end of file diff --git a/GS.SkyApi/Sky.cs b/GS.SkyApi/Sky.cs index 3a64cc3..8c9bb77 100644 --- a/GS.SkyApi/Sky.cs +++ b/GS.SkyApi/Sky.cs @@ -606,6 +606,16 @@ public bool IsMountRunning } } + /// + public bool IsParked + { + get + { + CheckRunning(); + return SkyServer.AtPark; + } + } + /// public bool IsPpecInTrainingOn { @@ -717,6 +727,54 @@ public bool MountVersion } } + /// + public void Park() + { + var monitorItem = new MonitorEntry + { Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Driver, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = "Started" }; + MonitorLog.LogToMonitor(monitorItem); + CheckRunning(); + + if (SkyServer.AtPark) + { + throw new Exception("Parked"); + } + + var found = SkySettings.ParkPositions.Find(x => x.Name == SkyServer.ParkSelected.Name); + if (found != null) + { + SkyServer.GoToPark(); + } + else + { + throw new Exception("Not Found"); + } + } + + /// + public string ParkPosition + { + get => SkyServer.ParkSelected.Name; + set + { + var monitorItem = new MonitorEntry + { Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Driver, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $"{value}" }; + MonitorLog.LogToMonitor(monitorItem); + if (IsMountRunning == false) { return; } + + if (string.IsNullOrEmpty(value)) return; + var found = SkySettings.ParkPositions.Find(x => x.Name == value); + if (found != null) + { + SkyServer.ParkSelected = found; + } + else + { + throw new Exception("Not Found"); + } + } + } + /// public void SkySetAlternatingPpec(bool on) { @@ -906,6 +964,18 @@ public void ShutdownServer() SkyServer.ShutdownServer(); } + + /// + public void UnPark() + { + var monitorItem = new MonitorEntry + { Datetime = Principles.HiResDateTime.UtcNow, Device = MonitorDevice.Telescope, Category = MonitorCategory.Driver, Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = "Started" }; + MonitorLog.LogToMonitor(monitorItem); + + CheckRunning(); + SkyServer.AtPark = false; + SkyServer.Tracking = true; + } /// /// Validate axis number as 1 or 2 @@ -916,6 +986,11 @@ private void ValidateMount() if (!IsConnected) throw new Exception("Mount not connected"); } + private void CheckRunning() + { + if (!IsMountRunning) {throw new Exception("Mount not connected");} + } + /// /// validate primary or secondary axis /// @@ -1219,6 +1294,10 @@ public interface ISky /// bool IsMountRunning { get; set; } /// + /// Is mount parked + /// + bool IsParked { get; } + /// /// q Is the mount collecting PPEC data /// bool IsPpecInTrainingOn { get; } @@ -1273,6 +1352,14 @@ public interface ISky /// bool MountVersion { get; } /// + /// Park mount to the current selected park position + /// + void Park(); + /// + /// Get parked selected or Set to an existing park position name + /// + string ParkPosition { get; set; } + /// /// Turns PPEC off during movements and then back on for error correction moves /// /// @@ -1357,5 +1444,9 @@ public interface ISky /// shutdown and close the server /// void ShutdownServer(); + /// + /// UnPark mount + /// + void UnPark(); } } diff --git a/GS.SkyApi/SkyScripts/Park.ps1 b/GS.SkyApi/SkyScripts/Park.ps1 new file mode 100644 index 0000000..881b002 --- /dev/null +++ b/GS.SkyApi/SkyScripts/Park.ps1 @@ -0,0 +1,19 @@ +# Clear the console pane +Clear-Host + +#Necessary - Create a new instance of the GS.Sky.Api.dll +$GS = New-Object -COMObject "GS.SkyApi" + +Write-Host "Park Name:" $GS.ParkPosition +$GS.ParkPosition = "Home" +Write-Host "Park Name:" $GS.ParkPosition + +$p = $GS.IsParked +Write-Host "IsParked:" $p +if($p -eq "True") {$GS.UnPark()} +$GS.Park() + + +# Necessary - Relese the Com Object +[System.Runtime.Interopservices.Marshal]::ReleaseComObject($GS) +Remove-Variable GS \ No newline at end of file diff --git a/Resources/Installer/GreenSwampSetup.iss b/Resources/Installer/GreenSwampSetup.iss index 126daef..c1dd22f 100644 --- a/Resources/Installer/GreenSwampSetup.iss +++ b/Resources/Installer/GreenSwampSetup.iss @@ -1,9 +1,9 @@ ; Script generated by the ASCOM Driver Installer Script Generator 6.2.0.0 ; Generated by Robert Morgan on 5/20/2018 (UTC) -#define MyAppVersion "1.0.1.8" -#define ManualName "GSS Manual v1018.pdf" -#define VersionNumber "v1018" -#define InstallerBaseName "ASCOMGSServer1018Setup" +#define MyAppVersion "1.0.1.9" +#define ManualName "GSS Manual v1019.pdf" +#define VersionNumber "v1019" +#define InstallerBaseName "ASCOMGSServer1019Setup" #define MyAppName "GSServer" #define MyAppExeName "GS.Server.exe" @@ -134,6 +134,7 @@ var ResultCode: Integer; UninstallExe: String; UninstallRegistry: String; + logfilepathname, logfilename, newfilepathname: string; begin if (CurStep = ssInstall) then // Install step has started begin @@ -154,4 +155,12 @@ begin sleep(1000); //Give enough time for the install screen to be repainted before continuing end end; + // copy install log to the app folder + if CurStep = ssDone then + begin + logfilepathname := ExpandConstant('{log}'); + logfilename := ExtractFileName(logfilepathname); + newfilepathname := ExpandConstant('{app}\') + logfilename; + FileCopy(logfilepathname, newfilepathname, false); + end; end; \ No newline at end of file