From b795634d707016b048f881a8bac0ebbbe95e5663 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 15 May 2019 00:52:40 +0100 Subject: [PATCH] Added support for CommandBlind and CommandString Modified the tracking rates to be setable. However, the get is now simulated. --- .../MeadeAutostar497.UnitTests.csproj | 2 +- MeadeAutostar497/AscomClasses/Telescope.cs | 29 +++++++++----- .../Controller/ITelescopeController.cs | 4 +- .../Controller/TelescopeController.cs | 40 +++++++++++++------ MeadeAutostar497/MeadeAutostar497.csproj | 2 +- TestConsole/TestConsole.csproj | 2 +- 6 files changed, 52 insertions(+), 27 deletions(-) diff --git a/MeadeAutostar497.UnitTests/MeadeAutostar497.UnitTests.csproj b/MeadeAutostar497.UnitTests/MeadeAutostar497.UnitTests.csproj index a7a4fae..47bf469 100644 --- a/MeadeAutostar497.UnitTests/MeadeAutostar497.UnitTests.csproj +++ b/MeadeAutostar497.UnitTests/MeadeAutostar497.UnitTests.csproj @@ -26,7 +26,7 @@ prompt 4 false - x64 + AnyCPU pdbonly diff --git a/MeadeAutostar497/AscomClasses/Telescope.cs b/MeadeAutostar497/AscomClasses/Telescope.cs index b9acd64..5f3c794 100644 --- a/MeadeAutostar497/AscomClasses/Telescope.cs +++ b/MeadeAutostar497/AscomClasses/Telescope.cs @@ -163,16 +163,20 @@ namespace ASCOM.MeadeAutostar497 public void CommandBlind(string command, bool raw) { + tl.LogMessage("CommandBlind", $"command={command} raw={raw}"); + CheckConnected("CommandBlind"); // Call CommandString and return as soon as it finishes //this.CommandString(command, raw); + _telescopeController.CommandBlind(command, raw); // or - throw new ASCOM.MethodNotImplementedException("CommandBlind"); + //throw new ASCOM.MethodNotImplementedException("CommandBlind"); // DO NOT have both these sections! One or the other } public bool CommandBool(string command, bool raw) { + tl.LogMessage("CommandBool", $"command={command} raw={raw}"); CheckConnected("CommandBool"); string ret = CommandString(command, raw); // TODO decode the return string and return true or false @@ -183,11 +187,13 @@ namespace ASCOM.MeadeAutostar497 public string CommandString(string command, bool raw) { + tl.LogMessage("CommandString", $"command={command} raw={raw}"); // it's a good idea to put all the low level communication with the device here, // then all communication calls this function // you need something to ensure that only one command is in progress at a time CheckConnected("CommandString"); - throw new ASCOM.MethodNotImplementedException("CommandString"); + //throw new ASCOM.MethodNotImplementedException("CommandString"); + return _telescopeController.CommandString(command, raw); } public void Dispose() @@ -455,8 +461,8 @@ namespace ASCOM.MeadeAutostar497 { get { - tl.LogMessage("CanSetTracking", "Get - " + false.ToString()); - return false; + tl.LogMessage("CanSetTracking", "Get - " + true.ToString()); + return true; } } @@ -876,19 +882,20 @@ namespace ASCOM.MeadeAutostar497 } } + private bool _tracking = true; public bool Tracking { get { //todo implementing this, it exists. - bool tracking = true; - tl.LogMessage("Tracking", "Get - " + tracking.ToString()); - return tracking; + + tl.LogMessage("Tracking", $"Get - {_tracking}" ); + return _tracking; } set { - tl.LogMessage("Tracking Set", "Not implemented"); - throw new ASCOM.PropertyNotImplementedException("Tracking", true); + tl.LogMessage($"Tracking Set", $"{value}"); + _tracking = value; } } @@ -902,8 +909,8 @@ namespace ASCOM.MeadeAutostar497 } set { - tl.LogMessage("TrackingRate Set", "Not implemented"); - throw new ASCOM.PropertyNotImplementedException("TrackingRate", true); + tl.LogMessage("TrackingRate Set", $"{value}"); + _telescopeController.TrackingRate = value; } } diff --git a/MeadeAutostar497/Controller/ITelescopeController.cs b/MeadeAutostar497/Controller/ITelescopeController.cs index a31d9d9..9873c48 100644 --- a/MeadeAutostar497/Controller/ITelescopeController.cs +++ b/MeadeAutostar497/Controller/ITelescopeController.cs @@ -20,7 +20,7 @@ namespace ASCOM.MeadeAutostar497.Controller double Declination { get; } double TargetRightAscension { get; set; } double TargetDeclination { get; set; } - DriveRates TrackingRate { get; } + DriveRates TrackingRate { get; set; } int FocuserMaxIncrement { get; set; } int FocuserMaxStep { get; set; } void AbortSlew(); @@ -36,5 +36,7 @@ namespace ASCOM.MeadeAutostar497.Controller void MoveAxis(TelescopeAxes axis, double rate); void FocuserHalt(); void FocuserMove(int position); + string CommandString(string command, bool raw); + void CommandBlind(string command, bool raw); } } \ No newline at end of file diff --git a/MeadeAutostar497/Controller/TelescopeController.cs b/MeadeAutostar497/Controller/TelescopeController.cs index 209dd09..e314982 100644 --- a/MeadeAutostar497/Controller/TelescopeController.cs +++ b/MeadeAutostar497/Controller/TelescopeController.cs @@ -478,21 +478,23 @@ namespace ASCOM.MeadeAutostar497.Controller } } + private DriveRates _trackingRate = DriveRates.driveSidereal; public DriveRates TrackingRate { get { - var result = SerialPort.CommandTerminated(":GT#", "#"); + //var result = SerialPort.CommandTerminated(":GT#", "#"); - double rate = double.Parse(result); + //double rate = double.Parse(result); - if (rate == 60.1) - return DriveRates.driveLunar; - else if (rate == 60.1) - return DriveRates.driveSidereal; + //if (rate == 60.1) + // return DriveRates.driveLunar; + //else if (rate == 60.1) + // return DriveRates.driveSidereal; - return DriveRates.driveKing; + //return DriveRates.driveKing; + return _trackingRate; } set { @@ -508,16 +510,20 @@ namespace ASCOM.MeadeAutostar497.Controller //:TL# Set Lunar Tracking Rage //Returns: Nothing break; - case DriveRates.driveSolar: - SerialPort.Command(":TS#"); - //:TS# Select Solar tracking rate. [LS Only] - //Returns: Nothing - break; + //case DriveRates.driveSolar: + // SerialPort.Command(":TS#"); + // //:TS# Select Solar tracking rate. [LS Only] + // //Returns: Nothing + // break; case DriveRates.driveKing: + //:TM# Select custom tracking rate [ no-op in Autostar II] + //Returns: Nothing break; default: throw new ArgumentOutOfRangeException(nameof(value), value, null); } + + _trackingRate = value; } } @@ -872,6 +878,16 @@ namespace ASCOM.MeadeAutostar497.Controller } } + public string CommandString(string command, bool raw) + { + return SerialPort.CommandTerminated(command, "#"); + } + + public void CommandBlind(string command, bool raw) + { + SerialPort.Command(command); + } + private void MoveFocuser(bool directionOut, int steps) { SerialPort.Command(directionOut ? ":F+#" : ":F-#"); diff --git a/MeadeAutostar497/MeadeAutostar497.csproj b/MeadeAutostar497/MeadeAutostar497.csproj index 5109500..fe89ffa 100644 --- a/MeadeAutostar497/MeadeAutostar497.csproj +++ b/MeadeAutostar497/MeadeAutostar497.csproj @@ -46,7 +46,7 @@ prompt 4 true - x64 + AnyCPU false diff --git a/TestConsole/TestConsole.csproj b/TestConsole/TestConsole.csproj index 4392996..34ad58e 100644 --- a/TestConsole/TestConsole.csproj +++ b/TestConsole/TestConsole.csproj @@ -16,7 +16,7 @@ 512 - x64 + AnyCPU true full false