Skip to content

Commit

Permalink
Park items added to API
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorgan001 committed Sep 11, 2020
1 parent 0e2b2fe commit 86ad13e
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Trademark>GS Server</Trademark>
<NeutralLanguage>en</NeutralLanguage>
<Copyright>Copyright © GreenSwamp Software 2019-2020</Copyright>
<AssemblyVersion>1.0.1.8</AssemblyVersion>
<FileVersion>1.0.1.8</FileVersion>
<ProductVersion>1.0.1.8</ProductVersion>
<Version>1.0.1.8</Version>
<AssemblyVersion>1.0.1.9</AssemblyVersion>
<FileVersion>1.0.1.9</FileVersion>
<ProductVersion>1.0.1.9</ProductVersion>
<Version>1.0.1.9</Version>
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions GS.Server/SkyTelescope/SkyTelescopeVM.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion GS.Shared/LanguageFiles/GSServer_en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ along with this program. If not, see<https://www.gnu.org/licenses/> .
<system:String x:Key="btnOCheckUpdates">Check for Updates</system:String>
<system:String x:Key="msgONotAvail">Updates not Available</system:String>
<system:String x:Key="msgONotFound">Updates not Found</system:String>
<system:String x:Key="msgODisconnects">Diconnect mount and connected applications before running</system:String>
<system:String x:Key="msgODisconnects">Disconnect mount and connected applications before running</system:String>
<system:String x:Key="tbOPole">Pole Locator</system:String>
<system:String x:Key="msgCopiedClip">Copied to Clipboard</system:String>

Expand Down
5 changes: 5 additions & 0 deletions GS.SkyApi/GS.SkyApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="StrongNamer" Version="0.2.5" />
</ItemGroup>
<ItemGroup>
<None Update="SkyScripts\Park.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
91 changes: 91 additions & 0 deletions GS.SkyApi/Sky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ public bool IsMountRunning
}
}

/// <inheritdoc />
public bool IsParked
{
get
{
CheckRunning();
return SkyServer.AtPark;
}
}

/// <inheritdoc />
public bool IsPpecInTrainingOn
{
Expand Down Expand Up @@ -717,6 +727,54 @@ public bool MountVersion
}
}

/// <inheritdoc />
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");
}
}

/// <inheritdoc />
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");
}
}
}

/// <inheritdoc />
public void SkySetAlternatingPpec(bool on)
{
Expand Down Expand Up @@ -906,6 +964,18 @@ public void ShutdownServer()

SkyServer.ShutdownServer();
}

/// <inheritdoc />
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;
}

/// <summary>
/// Validate axis number as 1 or 2
Expand All @@ -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");}
}

/// <summary>
/// validate primary or secondary axis
/// </summary>
Expand Down Expand Up @@ -1219,6 +1294,10 @@ public interface ISky
/// </summary>
bool IsMountRunning { get; set; }
/// <summary>
/// Is mount parked
/// </summary>
bool IsParked { get; }
/// <summary>
/// q Is the mount collecting PPEC data
/// </summary>
bool IsPpecInTrainingOn { get; }
Expand Down Expand Up @@ -1273,6 +1352,14 @@ public interface ISky
/// </summary>
bool MountVersion { get; }
/// <summary>
/// Park mount to the current selected park position
/// </summary>
void Park();
/// <summary>
/// Get parked selected or Set to an existing park position name
/// </summary>
string ParkPosition { get; set; }
/// <summary>
/// Turns PPEC off during movements and then back on for error correction moves
/// </summary>
/// <param name="on"></param>
Expand Down Expand Up @@ -1357,5 +1444,9 @@ public interface ISky
/// shutdown and close the server
/// </summary>
void ShutdownServer();
/// <summary>
/// UnPark mount
/// </summary>
void UnPark();
}
}
19 changes: 19 additions & 0 deletions GS.SkyApi/SkyScripts/Park.ps1
Original file line number Diff line number Diff line change
@@ -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
17 changes: 13 additions & 4 deletions Resources/Installer/GreenSwampSetup.iss
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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
Expand All @@ -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;

0 comments on commit 86ad13e

Please sign in to comment.