From ecb79b120d3f618fdd5ce69dd86607b756f34be2 Mon Sep 17 00:00:00 2001 From: Robert Morgan Date: Sat, 30 Apr 2022 07:24:15 -0400 Subject: [PATCH] Improved goto logging and increased thread sleep times for status loops --- Directory.Build.props | 8 +- GS.Server/SkyTelescope/SkyServer.cs | 143 ++++++++++++++++++----- GS.Server/SkyTelescope/SkyTelescopeVM.cs | 11 ++ GS.SkyWatcher/SkyWatcher.cs | 8 +- Resources/Installer/GreenSwampSetup.iss | 8 +- 5 files changed, 136 insertions(+), 42 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b2f0828f..786cdf0f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,9 +5,9 @@ GS Server en Copyright © GreenSwamp Software 2019-2022 - 1.0.4.6 - 1.0.4.6 - 1.0.4.6 - 1.0.4.6 + 1.0.4.7 + 1.0.4.7 + 1.0.4.7 + 1.0.4.7 \ No newline at end of file diff --git a/GS.Server/SkyTelescope/SkyServer.cs b/GS.Server/SkyTelescope/SkyServer.cs index 04045afb..38d9ab90 100644 --- a/GS.Server/SkyTelescope/SkyServer.cs +++ b/GS.Server/SkyTelescope/SkyServer.cs @@ -1189,6 +1189,19 @@ private set /// private static int SimGoTo(double[] target, bool trackingState) { + + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"from|{ActualAxisX}|{ActualAxisY}|to|{target[0]}|{target[1]}|tracking|{trackingState}" + }; + MonitorLog.LogToMonitor(monitorItem); + const int returncode = 0; const int timer = 80; // stop slew after seconds var stopwatch = Stopwatch.StartNew(); @@ -1221,7 +1234,7 @@ private static int SimGoTo(double[] target, bool trackingState) } AxesStopValidate(); - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -1229,7 +1242,7 @@ private static int SimGoTo(double[] target, bool trackingState) Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"Initial|{_targetAxes}|{stopwatch.Elapsed.TotalSeconds}|{simTarget[0]}|{simTarget[1]}" + Message = $"GoToSeconds|{stopwatch.Elapsed.TotalSeconds}|SimTarget|{simTarget[0]}|{simTarget[1]}" }; MonitorLog.LogToMonitor(monitorItem); @@ -1237,7 +1250,7 @@ private static int SimGoTo(double[] target, bool trackingState) #region Final precision slew - Task decTask = Task.Run(() => SimPrecisionGotoDec(target[1], simTarget[1])); + Task decTask = Task.Run(() => SimPrecisionGotoDec(simTarget[1])); Task raTask = Task.Run(() => SimPrecisionGoToRA(target, trackingState, stopwatch)); Task.WaitAll(decTask, raTask); @@ -1253,11 +1266,22 @@ private static int SimGoTo(double[] target, bool trackingState) /// /// Performs a final precision slew of the Dec axis to target if necessary. /// - /// - /// + /// /// - private static int SimPrecisionGotoDec(double targetDec, double skyTargetDec) + private static int SimPrecisionGotoDec(double simTargetDec) { + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"from|{ActualAxisY}|to|{simTargetDec}" + }; + MonitorLog.LogToMonitor(monitorItem); + const int returncode = 0; var gotoPrecision = SkySettings.GotoPrecision; var maxtries = 0; @@ -1270,12 +1294,12 @@ private static int SimPrecisionGotoDec(double targetDec, double skyTargetDec) // Calculate error var rawPositions = GetRawDegrees(); if (rawPositions == null || double.IsNaN(rawPositions[1])) { break; } - var deltaDegree = Math.Abs(skyTargetDec - rawPositions[1]); + var deltaDegree = Math.Abs(simTargetDec - rawPositions[1]); if (deltaDegree < gotoPrecision) { break; } if (SlewState == SlewType.SlewNone) { break; } //check for a stop - object _ = new CmdAxisGoToTarget(0, Axis.Axis2, skyTargetDec); //move to target DEC + object _ = new CmdAxisGoToTarget(0, Axis.Axis2, simTargetDec); //move to target DEC // track movement until axis is stopped var stopwatch1 = Stopwatch.StartNew(); @@ -1287,7 +1311,7 @@ private static int SimPrecisionGotoDec(double targetDec, double skyTargetDec) if (axis2Status.Stopped) { break; } } - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -1295,7 +1319,7 @@ private static int SimPrecisionGotoDec(double targetDec, double skyTargetDec) Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"Dec Precision:{targetDec}|{deltaDegree}" + Message = $"DeltaDegrees|{deltaDegree}" }; MonitorLog.LogToMonitor(monitorItem); } @@ -1311,6 +1335,19 @@ private static int SimPrecisionGotoDec(double targetDec, double skyTargetDec) /// private static int SimPrecisionGoToRA(double[] target, bool trackingState, Stopwatch stopwatch) { + + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"from|{ActualAxisX}|to|{target[0]}|state|{trackingState}" + }; + MonitorLog.LogToMonitor(monitorItem); + const int returnCode = 0; if (!trackingState) return returnCode; //attempt precision moves to target @@ -1330,8 +1367,7 @@ private static int SimPrecisionGoToRA(double[] target, bool trackingState, Stopw var deltaDegree = rate * deltaTime; if (deltaDegree < gotoPrecision) { break; } - - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -1339,12 +1375,10 @@ private static int SimPrecisionGoToRA(double[] target, bool trackingState, Stopw Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"RA Delta:{rate}|{deltaTime}|{deltaDegree}" + Message = $"Deltas|Rate|{rate}|Time|{deltaTime}|Degree|{deltaDegree}" }; MonitorLog.LogToMonitor(monitorItem); - - target[0] += deltaDegree; var deltaTarget = Axes.AxesAppToMount(target); @@ -1370,7 +1404,7 @@ private static int SimPrecisionGoToRA(double[] target, bool trackingState, Stopw Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"RA Precision:{target[0]}|{deltaTime}|{deltaDegree}" + Message = $"Precision|NewTarget|{target[0]}|Time|{deltaTime}|Degree|{deltaDegree}" }; MonitorLog.LogToMonitor(monitorItem); @@ -1619,6 +1653,18 @@ private static Vector GetSlewRate() /// private static int SkyGoTo(double[] target, bool trackingState) { + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"from|{ActualAxisX}|{ActualAxisY}|to|{target[0]}|{target[1]}|tracking|{trackingState}" + }; + MonitorLog.LogToMonitor(monitorItem); + const int returncode = 0; // stop slew after 80 seconds const int timer = 80; @@ -1653,7 +1699,7 @@ private static int SkyGoTo(double[] target, bool trackingState) } AxesStopValidate(); - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -1661,14 +1707,14 @@ private static int SkyGoTo(double[] target, bool trackingState) Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"Initial|{_targetAxes}|Seconds|{stopwatch.Elapsed.TotalSeconds}|Target|{skyTarget[0]}|{skyTarget[1]}" + Message = $"GoToSeconds|{stopwatch.Elapsed.TotalSeconds}|SkyTarget|{skyTarget[0]}|{skyTarget[1]}" }; MonitorLog.LogToMonitor(monitorItem); #endregion #region Final precision slew - Task decTask = Task.Run(() => SkyPrecisionGotoDec(target[1], skyTarget[1])); + Task decTask = Task.Run(() => SkyPrecisionGotoDec(skyTarget[1])); Task raTask = Task.Run(() => SkyPrecisionGoToRA(target, trackingState, stopwatch)); Task.WaitAll(decTask, raTask); @@ -1683,11 +1729,22 @@ private static int SkyGoTo(double[] target, bool trackingState) /// /// Performs a final precision slew of the Dec axis to target if necessary. /// - /// /// /// - private static int SkyPrecisionGotoDec(double targetDec, double skyTargetDec) + private static int SkyPrecisionGotoDec(double skyTargetDec) { + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"from|{ActualAxisY}|to|{skyTargetDec}" + }; + MonitorLog.LogToMonitor(monitorItem); + const int returncode = 0; var gotoPrecision = SkySettings.GotoPrecision; var maxtries = 0; @@ -1715,9 +1772,10 @@ private static int SkyPrecisionGotoDec(double targetDec, double skyTargetDec) var statusy = new SkyIsAxisFullStop(SkyQueue.NewId, AxisId.Axis2); var axis2stopped = Convert.ToBoolean(SkyQueue.GetCommandResult(statusy).Result); if (axis2stopped) { break; } + Thread.Sleep(100); } - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -1725,7 +1783,7 @@ private static int SkyPrecisionGotoDec(double targetDec, double skyTargetDec) Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"Precision|Target|{targetDec}|Degree|{deltaDegree}" + Message = $"DeltaDegrees|{deltaDegree}" }; MonitorLog.LogToMonitor(monitorItem); } @@ -1741,6 +1799,18 @@ private static int SkyPrecisionGotoDec(double targetDec, double skyTargetDec) /// private static int SkyPrecisionGoToRA(double[] target, bool trackingState, Stopwatch stopwatch) { + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"from|{ActualAxisX}|to|{target[0]}|tracking|{trackingState}" + }; + MonitorLog.LogToMonitor(monitorItem); + const int returnCode = 0; if (!trackingState) return returnCode; //attempt precision moves to target @@ -1759,7 +1829,7 @@ private static int SkyPrecisionGoToRA(double[] target, bool trackingState, Stopw //calculate new target position var deltaDegree = rate * deltaTime; - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -1787,6 +1857,7 @@ private static int SkyPrecisionGoToRA(double[] target, bool trackingState, Stopw var statusx = new SkyIsAxisFullStop(SkyQueue.NewId, AxisId.Axis1); var axis1stopped = Convert.ToBoolean(SkyQueue.GetCommandResult(statusx).Result); if (axis1stopped) { break; } + Thread.Sleep(100); } monitorItem = new MonitorEntry @@ -1797,7 +1868,7 @@ private static int SkyPrecisionGoToRA(double[] target, bool trackingState, Stopw Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"Precision|Target|{target[0]}|Time|{deltaTime}|Degree|{deltaDegree}" + Message = $"Precision|NewTarget|{target[0]}|Time|{deltaTime}|Degree|{deltaDegree}" }; MonitorLog.LogToMonitor(monitorItem); @@ -2964,7 +3035,7 @@ private static async void GoToAsync(double[] target, SlewType slewState) Type = MonitorType.Information, Method = "GoToAsync", Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"Goto finished|{returncode}|{SlewState}|{_util.HoursToHMS(RightAscension, "h ", ":", "", 2)}" + Message = $"{SlewState} finished|code|{returncode}|{_util.HoursToHMS(RightAscension, "h ", ":", "", 2)}|at|{ActualAxisX}|{ActualAxisY}" }; MonitorLog.LogToMonitor(monitorItem); @@ -3054,6 +3125,18 @@ public static void HcMoves(SlewSpeed speed, SlewDirection direction, HCMode HcMo { if (!IsMountRunning) { return; } + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.Server, + Category = MonitorCategory.Server, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"{SkySettings.HcSpeed}|{HcMode}|{direction}|{ActualAxisX}|{ActualAxisY}" + }; + MonitorLog.LogToMonitor(monitorItem); + var change = new double[] { 0, 0 }; double delta; switch (speed) @@ -3211,7 +3294,7 @@ public static void HcMoves(SlewSpeed speed, SlewDirection direction, HCMode HcMo // Log data to Monitor if (Math.Abs(change[0]) > 0 || Math.Abs(change[1]) > 0) { - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -3282,7 +3365,7 @@ public static void HcMoves(SlewSpeed speed, SlewDirection direction, HCMode HcMo // log anti-lash moves if (Math.Abs(stepsNeededDec) > 0 && HcPrevMoveDec != null) { - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -3296,7 +3379,7 @@ public static void HcMoves(SlewSpeed speed, SlewDirection direction, HCMode HcMo } if (Math.Abs(stepsNeededRa) > 0 && HcPrevMoveRa != null) { - var monitorItem = new MonitorEntry + monitorItem = new MonitorEntry { Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, @@ -4297,7 +4380,7 @@ private static void SlewMount(Vector targetPosition, SlewType slewState) Type = MonitorType.Information, Method = MethodBase.GetCurrentMethod()?.Name, Thread = Thread.CurrentThread.ManagedThreadId, - Message = $"{targetPosition.X}|{targetPosition.Y}|{slewState}" + Message = $"from|{ActualAxisX}|{ActualAxisY}|to|{targetPosition.X}|{targetPosition.Y}|SlewType|{slewState}" }; MonitorLog.LogToMonitor(monitorItem); diff --git a/GS.Server/SkyTelescope/SkyTelescopeVM.cs b/GS.Server/SkyTelescope/SkyTelescopeVM.cs index 6739ca57..8a45307f 100644 --- a/GS.Server/SkyTelescope/SkyTelescopeVM.cs +++ b/GS.Server/SkyTelescope/SkyTelescopeVM.cs @@ -6216,6 +6216,17 @@ private void AcceptRaGoToDialog() } var radec = Transforms.CoordTypeToInternal(GoToRa, GoToDec); + var monitorItem = new MonitorEntry + { + Datetime = HiResDateTime.UtcNow, + Device = MonitorDevice.UI, + Category = MonitorCategory.Interface, + Type = MonitorType.Information, + Method = MethodBase.GetCurrentMethod()?.Name, + Thread = Thread.CurrentThread.ManagedThreadId, + Message = $"From|{SkyServer.ActualAxisX}|{SkyServer.ActualAxisY}|to|{radec.X}|{radec.Y}" + }; + MonitorLog.LogToMonitor(monitorItem); SkyServer.SlewRaDec(radec.X, radec.Y); IsDialogOpen = false; } diff --git a/GS.SkyWatcher/SkyWatcher.cs b/GS.SkyWatcher/SkyWatcher.cs index 3913d31a..d8d17a08 100644 --- a/GS.SkyWatcher/SkyWatcher.cs +++ b/GS.SkyWatcher/SkyWatcher.cs @@ -146,7 +146,7 @@ internal void AxisSlew(AxisId axis, double rate) // issue new stop if (counter % 5 == 0) { AxisStop(axis); } counter++; - Thread.Sleep(50); + Thread.Sleep(100); } return; } @@ -186,7 +186,7 @@ internal void AxisSlew(AxisId axis, double rate) // issue new stop if (counter % 5 == 0) { AxisStop(axis); } counter++; - Thread.Sleep(50); + Thread.Sleep(100); } } @@ -496,7 +496,7 @@ internal void AxisMoveSteps(AxisId axis, long movingSteps) // issue new stop if (counter % 5 == 0) { AxisStop(axis); } counter++; - Thread.Sleep(50); + Thread.Sleep(100); } } @@ -567,7 +567,7 @@ internal void AxisGoToTarget(AxisId axis, double targetPosition) if (axesstatus.FullStop) { break; } if (counter % 5 == 0) { AxisStop(axis); } counter++; - Thread.Sleep(50); + Thread.Sleep(100); } } diff --git a/Resources/Installer/GreenSwampSetup.iss b/Resources/Installer/GreenSwampSetup.iss index e3e182ee..9954bc16 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.4.6" -#define ManualName "GSS Manual v1046.pdf" -#define VersionNumber "v1046" -#define InstallerBaseName "ASCOMGSServer1046Setup" +#define MyAppVersion "1.0.4.7" +#define ManualName "GSS Manual v1047.pdf" +#define VersionNumber "v1047" +#define InstallerBaseName "ASCOMGSServer1047Setup" #define MyAppName "GSServer" #define MyAppExeName "GS.Server.exe"