Added the tracelogger to the calls that send the actual serial commands.

This commit is contained in:
2022-07-25 15:53:29 +01:00
parent 0fbb2331cf
commit 6428e6d31b
8 changed files with 338 additions and 332 deletions
+18 -15
View File
@@ -15,6 +15,7 @@ namespace Meade.net.Focuser.UnitTests
{ {
private Mock<IUtil> _utilMock; private Mock<IUtil> _utilMock;
private Mock<ISharedResourcesWrapper> _sharedResourcesWrapperMock; private Mock<ISharedResourcesWrapper> _sharedResourcesWrapperMock;
private Mock<ITraceLogger> _traceLoggerMock;
private ProfileProperties _profileProperties; private ProfileProperties _profileProperties;
@@ -40,11 +41,13 @@ namespace Meade.net.Focuser.UnitTests
_utilMock = new Mock<IUtil>(); _utilMock = new Mock<IUtil>();
_traceLoggerMock = new Mock<ITraceLogger>();
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>(); _sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties); _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties);
_focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object); _focuser = new ASCOM.Meade.net.Focuser(_utilMock.Object, _sharedResourcesWrapperMock.Object, _traceLoggerMock.Object);
} }
private void ConnectFocuser() private void ConnectFocuser()
@@ -117,7 +120,7 @@ namespace Meade.net.Focuser.UnitTests
_focuser.CommandBlind(expectedMessage, raw); _focuser.CommandBlind(expectedMessage, raw);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(expectedMessage, raw), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, expectedMessage, raw), Times.Once);
} }
[Test] [Test]
@@ -134,13 +137,13 @@ namespace Meade.net.Focuser.UnitTests
public void CommandBool_WhenConnected_ThenSendsExpectedMessage(bool raw) public void CommandBool_WhenConnected_ThenSendsExpectedMessage(bool raw)
{ {
string expectedMessage = "test blind Message"; string expectedMessage = "test blind Message";
_sharedResourcesWrapperMock.Setup(x => x.SendBool(expectedMessage, raw)).Returns(true); _sharedResourcesWrapperMock.Setup(x => x.SendBool(_traceLoggerMock.Object, expectedMessage, raw)).Returns(true);
ConnectFocuser(); ConnectFocuser();
var result = _focuser.CommandBool(expectedMessage, raw); var result = _focuser.CommandBool(expectedMessage, raw);
_sharedResourcesWrapperMock.Verify(x => x.SendBool(expectedMessage, raw), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBool(_traceLoggerMock.Object, expectedMessage, raw), Times.Once);
Assert.That(result, Is.True); Assert.That(result, Is.True);
} }
@@ -161,11 +164,11 @@ namespace Meade.net.Focuser.UnitTests
ConnectFocuser(); ConnectFocuser();
_sharedResourcesWrapperMock.Setup(x => x.SendString(sendMessage, true)).Returns(() => expectedMessage); _sharedResourcesWrapperMock.Setup(x => x.SendString(_traceLoggerMock.Object, sendMessage, true)).Returns(() => expectedMessage);
var actualMessage = _focuser.CommandString(sendMessage, true); var actualMessage = _focuser.CommandString(sendMessage, true);
_sharedResourcesWrapperMock.Verify(x => x.SendString(sendMessage, true), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendString(_traceLoggerMock.Object, sendMessage, true), Times.Once);
Assert.That(actualMessage, Is.EqualTo(expectedMessage)); Assert.That(actualMessage, Is.EqualTo(expectedMessage));
} }
@@ -321,7 +324,7 @@ namespace Meade.net.Focuser.UnitTests
_focuser.Halt(); _focuser.Halt();
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("FQ", false), Times.AtLeastOnce); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "FQ", false), Times.AtLeastOnce);
} }
[Test] [Test]
@@ -411,13 +414,13 @@ namespace Meade.net.Focuser.UnitTests
if (position < 0) if (position < 0)
{ {
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Never); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F+", false), Times.Never);
} }
else else
{ {
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Never); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F+", false), Times.Once);
} }
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
@@ -437,16 +440,16 @@ namespace Meade.net.Focuser.UnitTests
if (position < 0) if (position < 0)
{ {
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Never); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F+", false), Times.Never);
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(_profileProperties.BacklashCompensation)), Times.Never);
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(1)); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(1));
} }
else else
{ {
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once); _sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F+", false), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position) + _profileProperties.BacklashCompensation), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position) + _profileProperties.BacklashCompensation), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once); _utilMock.Verify(x => x.WaitForMilliseconds(_profileProperties.BacklashCompensation), Times.Once);
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2)); _utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(2));
File diff suppressed because it is too large Load Diff
+91 -91
View File
@@ -128,7 +128,7 @@ namespace ASCOM.Meade.net
} }
public Telescope(IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, public Telescope(IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities,
ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths, IClock clock, INOVAS31 novas) : base( ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths, IClock clock, INOVAS31 novas, ITraceLogger traceLogger) : base(
sharedResourcesWrapper) sharedResourcesWrapper)
{ {
_clock = clock; _clock = clock;
@@ -138,7 +138,7 @@ namespace ASCOM.Meade.net
_astroMaths = astroMaths; _astroMaths = astroMaths;
_novas = novas; _novas = novas;
Initialise(nameof(Telescope)); Initialise(nameof(Telescope), traceLogger);
} }
// //
@@ -213,81 +213,81 @@ namespace ASCOM.Meade.net
{ {
//Read the screen //Read the screen
case "readdisplay": case "readdisplay":
var output = SharedResourcesWrapper.SendString("ED"); var output = SharedResourcesWrapper.SendString(Tl, "ED");
return output; return output;
//top row of buttons //top row of buttons
case "enter": case "enter":
SharedResourcesWrapper.SendBlind("EK13"); SharedResourcesWrapper.SendBlind(Tl,"EK13");
break; break;
case "longenter": case "longenter":
SharedResourcesWrapper.SendBlind("EK10"); SharedResourcesWrapper.SendBlind(Tl, "EK10");
break; break;
case "mode": case "mode":
SharedResourcesWrapper.SendBlind("EK9"); SharedResourcesWrapper.SendBlind(Tl, "EK9");
break; break;
case "longmode": case "longmode":
SharedResourcesWrapper.SendBlind("EK11"); SharedResourcesWrapper.SendBlind(Tl, "EK11");
break; break;
case "goto": case "goto":
SharedResourcesWrapper.SendBlind("EK24"); SharedResourcesWrapper.SendBlind(Tl, "EK24");
break; break;
case "longgoto": case "longgoto":
SharedResourcesWrapper.SendBlind("EK25"); SharedResourcesWrapper.SendBlind(Tl, "EK25");
break; break;
case "0": //light and 0 case "0": //light and 0
SharedResourcesWrapper.SendBlind("EK48"); SharedResourcesWrapper.SendBlind(Tl, "EK48");
break; break;
case "1": case "1":
SharedResourcesWrapper.SendBlind("EK49"); SharedResourcesWrapper.SendBlind(Tl, "EK49");
break; break;
case "2": case "2":
SharedResourcesWrapper.SendBlind("EK50"); SharedResourcesWrapper.SendBlind(Tl, "EK50");
break; break;
case "3": case "3":
SharedResourcesWrapper.SendBlind("EK51"); SharedResourcesWrapper.SendBlind(Tl, "EK51");
break; break;
case "4": case "4":
SharedResourcesWrapper.SendBlind("EK52"); SharedResourcesWrapper.SendBlind(Tl, "EK52");
break; break;
case "5": case "5":
SharedResourcesWrapper.SendBlind("EK53"); SharedResourcesWrapper.SendBlind(Tl, "EK53");
break; break;
case "6": case "6":
SharedResourcesWrapper.SendBlind("EK54"); SharedResourcesWrapper.SendBlind(Tl, "EK54");
break; break;
case "7": case "7":
SharedResourcesWrapper.SendBlind("EK55"); SharedResourcesWrapper.SendBlind(Tl, "EK55");
break; break;
case "8": case "8":
SharedResourcesWrapper.SendBlind("EK56"); SharedResourcesWrapper.SendBlind(Tl, "EK56");
break; break;
case "9": case "9":
SharedResourcesWrapper.SendBlind("EK57"); SharedResourcesWrapper.SendBlind(Tl, "EK57");
break; break;
case "up": case "up":
SharedResourcesWrapper.SendBlind("EK94"); SharedResourcesWrapper.SendBlind(Tl, "EK94");
break; break;
case "down": case "down":
SharedResourcesWrapper.SendBlind("EK118"); SharedResourcesWrapper.SendBlind(Tl, "EK118");
break; break;
case "back": case "back":
case "left": case "left":
SharedResourcesWrapper.SendBlind("EK87"); SharedResourcesWrapper.SendBlind(Tl, "EK87");
break; break;
case "forward": case "forward":
case "right": case "right":
SharedResourcesWrapper.SendBlind("EK69"); SharedResourcesWrapper.SendBlind(Tl, "EK69");
break; break;
case "scrollup": case "scrollup":
SharedResourcesWrapper.SendBlind("EK85"); SharedResourcesWrapper.SendBlind(Tl, "EK85");
break; break;
case "scrolldown": case "scrolldown":
SharedResourcesWrapper.SendBlind("EK68"); SharedResourcesWrapper.SendBlind(Tl, "EK68");
break; break;
case "?": case "?":
SharedResourcesWrapper.SendBlind("EK63"); SharedResourcesWrapper.SendBlind(Tl, "EK63");
break; break;
default: default:
LogMessage("", "Action {0}, parameters {1} not implemented", actionName, LogMessage("", "Action {0}, parameters {1} not implemented", actionName,
@@ -385,7 +385,7 @@ namespace ASCOM.Meade.net
CheckConnected("CommandBlind"); CheckConnected("CommandBlind");
// Call CommandString and return as soon as it finishes // Call CommandString and return as soon as it finishes
//this.CommandString(command, raw); //this.CommandString(command, raw);
SharedResourcesWrapper.SendBlind(command, raw); SharedResourcesWrapper.SendBlind(Tl, command, raw);
// or // or
//throw new ASCOM.MethodNotImplementedException("CommandBlind"); //throw new ASCOM.MethodNotImplementedException("CommandBlind");
// DO NOT have both these sections! One or the other // DO NOT have both these sections! One or the other
@@ -404,7 +404,7 @@ namespace ASCOM.Meade.net
{ {
LogMessage("CommandBool", $"raw: {raw} command {command}"); LogMessage("CommandBool", $"raw: {raw} command {command}");
CheckConnected("CommandBool"); CheckConnected("CommandBool");
var result = SharedResourcesWrapper.SendBool(command, raw); var result = SharedResourcesWrapper.SendBool(Tl, command, raw);
LogMessage("CommandBool", $"Completed: {result}"); LogMessage("CommandBool", $"Completed: {result}");
return result; return result;
} }
@@ -429,11 +429,11 @@ namespace ASCOM.Meade.net
// https://bitbucket.org/cjdskunkworks/meadeautostar497/issues/24/get-set-tracking#comment-60586901 // https://bitbucket.org/cjdskunkworks/meadeautostar497/issues/24/get-set-tracking#comment-60586901
if (command == (raw ? ":GW#" : "GW")) if (command == (raw ? ":GW#" : "GW"))
{ {
result = SharedResourcesWrapper.SendChars(command, raw, count: 3); result = SharedResourcesWrapper.SendChars(Tl, command, raw, count: 3);
} }
else else
{ {
result = SharedResourcesWrapper.SendString(command, raw); result = SharedResourcesWrapper.SendString(Tl, command, raw);
} }
LogMessage("CommandString", $"Completed: {result}"); LogMessage("CommandString", $"Completed: {result}");
@@ -453,8 +453,8 @@ namespace ASCOM.Meade.net
// Clean up the tracelogger and util objects // Clean up the tracelogger and util objects
Tl.Enabled = false; Tl.Enabled = false;
Tl.Dispose(); //Tl.Dispose();
Tl = null; //Tl = null;
} }
public bool Connected public bool Connected
@@ -805,7 +805,7 @@ namespace ASCOM.Meade.net
return; return;
} }
var result = SharedResourcesWrapper.SendString("GZ"); var result = SharedResourcesWrapper.SendString(Tl, "GZ");
LogMessage("SetLongFormat", $"Get - Azimuth {result}"); LogMessage("SetLongFormat", $"Get - Azimuth {result}");
//:GZ# Get telescope azimuth //:GZ# Get telescope azimuth
//Returns: DDD*MM.T or DDD*MM'SS# //Returns: DDD*MM.T or DDD*MM'SS#
@@ -816,12 +816,12 @@ namespace ASCOM.Meade.net
if (SharedResourcesWrapper.IsLongFormat != setLongFormat) if (SharedResourcesWrapper.IsLongFormat != setLongFormat)
{ {
_utilities.WaitForMilliseconds(500); _utilities.WaitForMilliseconds(500);
SharedResourcesWrapper.SendBlind("U"); SharedResourcesWrapper.SendBlind(Tl, "U");
//:U# Toggle between low/hi precision positions //:U# Toggle between low/hi precision positions
//Low - RA displays and messages HH:MM.T sDD*MM //Low - RA displays and messages HH:MM.T sDD*MM
//High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS //High - Dec / Az / El displays and messages HH:MM: SS sDD*MM:SS
// Returns Nothing // Returns Nothing
result = SharedResourcesWrapper.SendString("GZ"); result = SharedResourcesWrapper.SendString(Tl, "GZ");
SharedResourcesWrapper.IsLongFormat = result.Length > 6; SharedResourcesWrapper.IsLongFormat = result.Length > 6;
LogMessage("SetLongFormat", $"Get - Azimuth {result}"); LogMessage("SetLongFormat", $"Get - Azimuth {result}");
if (SharedResourcesWrapper.IsLongFormat == setLongFormat) if (SharedResourcesWrapper.IsLongFormat == setLongFormat)
@@ -844,7 +844,7 @@ namespace ASCOM.Meade.net
private bool TogglePrecision() private bool TogglePrecision()
{ {
LogMessage("TogglePrecision", "Toggling slewing precision"); LogMessage("TogglePrecision", "Toggling slewing precision");
var result = SharedResourcesWrapper.SendChar("P"); var result = SharedResourcesWrapper.SendChar(Tl,"P");
//:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target. //:P# Toggles High Precsion Pointing. When High precision pointing is enabled scope will first allow the operator to center a nearby bright star before moving to the actual target.
//Returns: <string> //Returns: <string>
//"HIGH PRECISION" Current setting after this command. //"HIGH PRECISION" Current setting after this command.
@@ -883,7 +883,7 @@ namespace ASCOM.Meade.net
{ {
CheckConnectedAndValidateSite(site, "SelectSite"); CheckConnectedAndValidateSite(site, "SelectSite");
SharedResourcesWrapper.SendBlind($"W{site}"); SharedResourcesWrapper.SendBlind(Tl, $"W{site}");
//:W<n># //:W<n>#
//Set current site to<n>, an ASCII digit in the range 1..4 //Set current site to<n>, an ASCII digit in the range 1..4
//Returns: Nothing //Returns: Nothing
@@ -951,7 +951,7 @@ namespace ASCOM.Meade.net
Resources.Telescope_GetSiteName_Site_out_of_range); Resources.Telescope_GetSiteName_Site_out_of_range);
} }
var result = SharedResourcesWrapper.SendChar(command); var result = SharedResourcesWrapper.SendChar(Tl, command);
if (result != "1") if (result != "1")
{ {
throw new InvalidOperationException("Failed to set site name."); throw new InvalidOperationException("Failed to set site name.");
@@ -965,22 +965,22 @@ namespace ASCOM.Meade.net
switch (site) switch (site)
{ {
case 1: case 1:
return SharedResourcesWrapper.SendString("GM"); return SharedResourcesWrapper.SendString(Tl, "GM");
//:GM# Get Site 1 Name //:GM# Get Site 1 Name
//Returns: <string># //Returns: <string>#
//A '#' terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
case 2: case 2:
return SharedResourcesWrapper.SendString("GN"); return SharedResourcesWrapper.SendString(Tl, "GN");
//:GN# Get Site 2 Name //:GN# Get Site 2 Name
//Returns: <string># //Returns: <string>#
//A '#' terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
case 3: case 3:
return SharedResourcesWrapper.SendString("GO"); return SharedResourcesWrapper.SendString(Tl, "GO");
//:GO# Get Site 3 Name //:GO# Get Site 3 Name
//Returns: <string># //Returns: <string>#
//A '#' terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
case 4: case 4:
return SharedResourcesWrapper.SendString("GP"); return SharedResourcesWrapper.SendString(Tl, "GP");
//:GP# Get Site 4 Name //:GP# Get Site 4 Name
//Returns: <string># //Returns: <string>#
//A '#' terminated string with the name of the requested site. //A '#' terminated string with the name of the requested site.
@@ -1016,11 +1016,11 @@ namespace ASCOM.Meade.net
{ {
//string name = "Short driver name - please customise"; //string name = "Short driver name - please customise";
//var telescopeProduceName = _sharedResourcesWrapper.SendString("GVP"); //var telescopeProduceName = _sharedResourcesWrapper.SendString(Tl, "GVP");
////:GVP# Get Telescope Product Name ////:GVP# Get Telescope Product Name
////Returns: <string># ////Returns: <string>#
//var firmwareVersion = _sharedResourcesWrapper.SendString("GVN"); //var firmwareVersion = _sharedResourcesWrapper.SendString(Tl, "GVN");
////:GVN# Get Telescope Firmware Number ////:GVN# Get Telescope Firmware Number
////Returns: dd.d# ////Returns: dd.d#
@@ -1049,7 +1049,7 @@ namespace ASCOM.Meade.net
CheckParked(); CheckParked();
LogMessage("AbortSlew", "Aborting slew"); LogMessage("AbortSlew", "Aborting slew");
SharedResourcesWrapper.SendBlind("Q"); SharedResourcesWrapper.SendBlind(Tl, "Q");
//:Q# Halt all current slewing //:Q# Halt all current slewing
//Returns:Nothing //Returns:Nothing
@@ -1138,13 +1138,13 @@ namespace ASCOM.Meade.net
switch (value) switch (value)
{ {
case AlignmentModes.algAltAz: case AlignmentModes.algAltAz:
SharedResourcesWrapper.SendBlind("AA"); SharedResourcesWrapper.SendBlind(Tl, "AA");
//:AA# Sets telescope the AltAz alignment mode //:AA# Sets telescope the AltAz alignment mode
//Returns: nothing //Returns: nothing
break; break;
case AlignmentModes.algPolar: case AlignmentModes.algPolar:
case AlignmentModes.algGermanPolar: case AlignmentModes.algGermanPolar:
SharedResourcesWrapper.SendBlind("AP"); SharedResourcesWrapper.SendBlind(Tl, "AP");
//:AP# Sets telescope to Polar alignment mode //:AP# Sets telescope to Polar alignment mode
//Returns: nothing //Returns: nothing
break; break;
@@ -1174,7 +1174,7 @@ namespace ASCOM.Meade.net
//D If scope is currently in the Downloader[Autostar II & Autostar] //D If scope is currently in the Downloader[Autostar II & Autostar]
//L If scope in Land Mode //L If scope in Land Mode
//P If scope in Polar Mode //P If scope in Polar Mode
var alignmentString = SharedResourcesWrapper.SendChar(ack.ToString()); var alignmentString = SharedResourcesWrapper.SendChar(Tl, ack.ToString());
return alignmentString; return alignmentString;
} }
@@ -1265,7 +1265,7 @@ namespace ASCOM.Meade.net
CheckParked(); CheckParked();
//firmware bug in 44Eg, :GA# is returning the dec, not the altitude! //firmware bug in 44Eg, :GA# is returning the dec, not the altitude!
var result = SharedResourcesWrapper.SendString("GA"); var result = SharedResourcesWrapper.SendString(Tl, "GA");
//:GA# Get Telescope Altitude //:GA# Get Telescope Altitude
//Returns: sDD* MM# or sDD*MM'SS# //Returns: sDD* MM# or sDD*MM'SS#
//The current scope altitude. The returned format depending on the current precision setting. //The current scope altitude. The returned format depending on the current precision setting.
@@ -1430,7 +1430,7 @@ namespace ASCOM.Meade.net
{ {
CheckParked(); CheckParked();
var result = SharedResourcesWrapper.SendString("GZ"); var result = SharedResourcesWrapper.SendString(Tl, "GZ");
//:GZ# Get telescope azimuth //:GZ# Get telescope azimuth
//Returns: DDD*MM#T or DDD*MM'SS# //Returns: DDD*MM#T or DDD*MM'SS#
//The current telescope Azimuth depending on the selected precision. //The current telescope Azimuth depending on the selected precision.
@@ -1787,7 +1787,7 @@ namespace ASCOM.Meade.net
{ {
CheckParked(); CheckParked();
var result = SharedResourcesWrapper.SendString("GD"); var result = SharedResourcesWrapper.SendString(Tl, "GD");
//:GD# Get Telescope Declination. //:GD# Get Telescope Declination.
//Returns: sDD*MM# or sDD*MM'SS# //Returns: sDD*MM# or sDD*MM'SS#
//Depending upon the current precision setting for the telescope. //Depending upon the current precision setting for the telescope.
@@ -1972,7 +1972,7 @@ namespace ASCOM.Meade.net
} }
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)"); LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)");
SharedResourcesWrapper.SendBlind($"Rg{value:00.0}"); SharedResourcesWrapper.SendBlind(Tl, $"Rg{value:00.0}");
//:RgSS.S# //:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking //Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
//Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed //Rates when the CCD guider or handbox guider buttons are pressed when the guide rate is selected.Rate shall not exceed
@@ -2097,22 +2097,22 @@ namespace ASCOM.Meade.net
//do nothing, it's ok this time as we're halting the slew. //do nothing, it's ok this time as we're halting the slew.
break; break;
case 1: case 1:
SharedResourcesWrapper.SendBlind("RG"); SharedResourcesWrapper.SendBlind(Tl, "RG");
//:RG# Set Slew rate to Guiding Rate (slowest) //:RG# Set Slew rate to Guiding Rate (slowest)
//Returns: Nothing //Returns: Nothing
break; break;
case 2: case 2:
SharedResourcesWrapper.SendBlind("RC"); SharedResourcesWrapper.SendBlind(Tl, "RC");
//:RC# Set Slew rate to Centering rate (2nd slowest) //:RC# Set Slew rate to Centering rate (2nd slowest)
//Returns: Nothing //Returns: Nothing
break; break;
case 3: case 3:
SharedResourcesWrapper.SendBlind("RM"); SharedResourcesWrapper.SendBlind(Tl, "RM");
//:RM# Set Slew rate to Find Rate (2nd Fastest) //:RM# Set Slew rate to Find Rate (2nd Fastest)
//Returns: Nothing //Returns: Nothing
break; break;
case 4: case 4:
SharedResourcesWrapper.SendBlind("RS"); SharedResourcesWrapper.SendBlind(Tl, "RS");
//:RS# Set Slew rate to max (fastest) //:RS# Set Slew rate to max (fastest)
//Returns: Nothing //Returns: Nothing
break; break;
@@ -2132,21 +2132,21 @@ namespace ASCOM.Meade.net
} }
SharedResourcesWrapper.MovingPrimary = false; SharedResourcesWrapper.MovingPrimary = false;
SharedResourcesWrapper.SendBlind("Qe"); SharedResourcesWrapper.SendBlind(Tl, "Qe");
//:Qe# Halt eastward Slews //:Qe# Halt eastward Slews
//Returns: Nothing //Returns: Nothing
SharedResourcesWrapper.SendBlind("Qw"); SharedResourcesWrapper.SendBlind(Tl, "Qw");
//:Qw# Halt westward Slews //:Qw# Halt westward Slews
//Returns: Nothing //Returns: Nothing
break; break;
case ComparisonResult.Greater: case ComparisonResult.Greater:
SharedResourcesWrapper.SendBlind("Me"); SharedResourcesWrapper.SendBlind(Tl, "Me");
//:Me# Move Telescope East at current slew rate //:Me# Move Telescope East at current slew rate
//Returns: Nothing //Returns: Nothing
SharedResourcesWrapper.MovingPrimary = true; SharedResourcesWrapper.MovingPrimary = true;
break; break;
case ComparisonResult.Lower: case ComparisonResult.Lower:
SharedResourcesWrapper.SendBlind("Mw"); SharedResourcesWrapper.SendBlind(Tl, "Mw");
//:Mw# Move Telescope West at current slew rate //:Mw# Move Telescope West at current slew rate
//Returns: Nothing //Returns: Nothing
SharedResourcesWrapper.MovingPrimary = true; SharedResourcesWrapper.MovingPrimary = true;
@@ -2164,21 +2164,21 @@ namespace ASCOM.Meade.net
} }
SharedResourcesWrapper.MovingSecondary = false; SharedResourcesWrapper.MovingSecondary = false;
SharedResourcesWrapper.SendBlind("Qn"); SharedResourcesWrapper.SendBlind(Tl, "Qn");
//:Qn# Halt northward Slews //:Qn# Halt northward Slews
//Returns: Nothing //Returns: Nothing
SharedResourcesWrapper.SendBlind("Qs"); SharedResourcesWrapper.SendBlind(Tl, "Qs");
//:Qs# Halt southward Slews //:Qs# Halt southward Slews
//Returns: Nothing //Returns: Nothing
break; break;
case ComparisonResult.Greater: case ComparisonResult.Greater:
SharedResourcesWrapper.SendBlind("Mn"); SharedResourcesWrapper.SendBlind(Tl, "Mn");
//:Mn# Move Telescope North at current slew rate //:Mn# Move Telescope North at current slew rate
//Returns: Nothing //Returns: Nothing
SharedResourcesWrapper.MovingSecondary = true; SharedResourcesWrapper.MovingSecondary = true;
break; break;
case ComparisonResult.Lower: case ComparisonResult.Lower:
SharedResourcesWrapper.SendBlind("Ms"); SharedResourcesWrapper.SendBlind(Tl, "Ms");
//:Ms# Move Telescope South at current slew rate //:Ms# Move Telescope South at current slew rate
//Returns: Nothing //Returns: Nothing
SharedResourcesWrapper.MovingSecondary = true; SharedResourcesWrapper.MovingSecondary = true;
@@ -2251,7 +2251,7 @@ namespace ASCOM.Meade.net
if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC) if (SharedResourcesWrapper.ProductName != TelescopeList.LX200CLASSIC)
{ {
SharedResourcesWrapper.SendBlind("hP"); SharedResourcesWrapper.SendBlind(Tl, "hP");
//:hP# Autostar, Autostar II and LX 16" Slew to Park Position //:hP# Autostar, Autostar II and LX 16" Slew to Park Position
//Returns: Nothing //Returns: Nothing
} }
@@ -2333,7 +2333,7 @@ namespace ASCOM.Meade.net
} }
LogMessage("PulseGuide", "Using new pulse guiding technique"); LogMessage("PulseGuide", "Using new pulse guiding technique");
SharedResourcesWrapper.SendBlind($"Mg{d}{duration:0000}"); SharedResourcesWrapper.SendBlind(Tl, $"Mg{d}{duration:0000}");
//:MgnDDDD# //:MgnDDDD#
//:MgsDDDD# //:MgsDDDD#
//:MgeDDDD# //:MgeDDDD#
@@ -2419,7 +2419,7 @@ namespace ASCOM.Meade.net
{ {
CheckParked(); CheckParked();
var result = SharedResourcesWrapper.SendString("GR"); var result = SharedResourcesWrapper.SendString(Tl, "GR");
//:GR# Get Telescope RA //:GR# Get Telescope RA
//Returns: HH:MM.T# or HH:MM:SS# //Returns: HH:MM.T# or HH:MM:SS#
//Depending which precision is set for the telescope //Depending which precision is set for the telescope
@@ -2627,7 +2627,7 @@ namespace ASCOM.Meade.net
{ {
CheckParked(); CheckParked();
var latitude = SharedResourcesWrapper.SendString("Gt"); var latitude = SharedResourcesWrapper.SendString(Tl, "Gt");
//:Gt# Get Current Site Latitude //:Gt# Get Current Site Latitude
//Returns: sDD* MM# //Returns: sDD* MM#
//The latitude of the current site. Positive inplies North latitude. //The latitude of the current site. Positive inplies North latitude.
@@ -2674,7 +2674,7 @@ namespace ASCOM.Meade.net
int m = Convert.ToInt32(60 * (absValue - d)); int m = Convert.ToInt32(60 * (absValue - d));
var commandString = $"St{sign}{d:00}*{m:00}"; var commandString = $"St{sign}{d:00}*{m:00}";
var result = SharedResourcesWrapper.SendChar(commandString); var result = SharedResourcesWrapper.SendChar(Tl, commandString);
//:StsDD*MM# //:StsDD*MM#
//Sets the current site latitude to sDD* MM# //Sets the current site latitude to sDD* MM#
//Returns: //Returns:
@@ -2702,7 +2702,7 @@ namespace ASCOM.Meade.net
{ {
CheckParked(); CheckParked();
var longitude = SharedResourcesWrapper.SendString("Gg"); var longitude = SharedResourcesWrapper.SendString(Tl, "Gg");
//:Gg# Get Current Site Longitude //:Gg# Get Current Site Longitude
//Returns: sDDD*MM# //Returns: sDDD*MM#
//The current site Longitude. East Longitudes are expressed as negative //The current site Longitude. East Longitudes are expressed as negative
@@ -2753,7 +2753,7 @@ namespace ASCOM.Meade.net
var commandstring = $"Sg{d:000}*{m:00}"; var commandstring = $"Sg{d:000}*{m:00}";
var result = SharedResourcesWrapper.SendChar(commandstring); var result = SharedResourcesWrapper.SendChar(Tl, commandstring);
//:SgDDD*MM# //:SgDDD*MM#
//Set current site's longitude to DDD*MM an ASCII position string //Set current site's longitude to DDD*MM an ASCII position string
//Returns: //Returns:
@@ -2907,7 +2907,7 @@ namespace ASCOM.Meade.net
var command = $"Sa{s}{dms}"; var command = $"Sa{s}{dms}";
LogMessage("TargetAltitude Set", $"{command}"); LogMessage("TargetAltitude Set", $"{command}");
var response = SharedResourcesWrapper.SendBool(command); var response = SharedResourcesWrapper.SendBool(Tl, command);
//:SasDD*MM# //:SasDD*MM#
// Set target object altitude to sDD*MM# or sDD*MMSS# [LX 16”, Autostar, Autostar II] // Set target object altitude to sDD*MM# or sDD*MMSS# [LX 16”, Autostar, Autostar II]
// Returns: // Returns:
@@ -2944,7 +2944,7 @@ namespace ASCOM.Meade.net
var command = $"Sz{dms}"; var command = $"Sz{dms}";
LogMessage("TargetAzimuth Set", $"{command}"); LogMessage("TargetAzimuth Set", $"{command}");
var response = SharedResourcesWrapper.SendBool(command); var response = SharedResourcesWrapper.SendBool(Tl, command);
//:SzDDD*MM# //:SzDDD*MM#
// Sets the target Object Azimuth[LX 16” and Autostar II only] // Sets the target Object Azimuth[LX 16” and Autostar II only]
// Returns: // Returns:
@@ -2978,7 +2978,7 @@ namespace ASCOM.Meade.net
{ {
case true: case true:
LogMessage("DoSlewAsync", "Executing Polar slew"); LogMessage("DoSlewAsync", "Executing Polar slew");
var response = SharedResourcesWrapper.SendChar("MS"); var response = SharedResourcesWrapper.SendChar(Tl, "MS");
//:MS# Slew to Target Object //:MS# Slew to Target Object
//Returns: //Returns:
//0 Slew is Possible //0 Slew is Possible
@@ -3018,7 +3018,7 @@ namespace ASCOM.Meade.net
Retry(6, () => Retry(6, () =>
{ {
LogMessage("DoSlewAsync", "Executing Alt Az"); LogMessage("DoSlewAsync", "Executing Alt Az");
var maResponse = SharedResourcesWrapper.SendChar("MA"); var maResponse = SharedResourcesWrapper.SendChar(Tl, "MA");
//:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az //:MA# Autostar, LX 16", Autostar II - Slew to target Alt and Az
//Returns: //Returns:
//0 - No fault //0 - No fault
@@ -3242,7 +3242,7 @@ namespace ASCOM.Meade.net
string result; string result;
try try
{ {
result = SharedResourcesWrapper.SendString("D"); result = SharedResourcesWrapper.SendString(Tl, "D");
} }
catch (TimeoutException) catch (TimeoutException)
{ {
@@ -3343,7 +3343,7 @@ namespace ASCOM.Meade.net
CheckConnected("SyncToTarget"); CheckConnected("SyncToTarget");
CheckParked(); CheckParked();
var result = SharedResourcesWrapper.SendString("CM"); var result = SharedResourcesWrapper.SendString(Tl, "CM");
//:CM# Synchronizes the telescope's position with the currently selected database object's coordinates. //:CM# Synchronizes the telescope's position with the currently selected database object's coordinates.
//Returns: //Returns:
//LX200's - a "#" terminated string with the name of the object that was synced. //LX200's - a "#" terminated string with the name of the object that was synced.
@@ -3432,7 +3432,7 @@ namespace ASCOM.Meade.net
var command = $"Sd{s}{dms}"; var command = $"Sd{s}{dms}";
LogMessage("TargetDeclination Set", $"{command}"); LogMessage("TargetDeclination Set", $"{command}");
var result = SharedResourcesWrapper.SendChar(command); var result = SharedResourcesWrapper.SendChar(Tl, command);
//:SdsDD*MM# //:SdsDD*MM#
//Set target object declination to sDD*MM or sDD*MM:SS depending on the current precision setting //Set target object declination to sDD*MM or sDD*MM:SS depending on the current precision setting
//Returns: //Returns:
@@ -3501,7 +3501,7 @@ namespace ASCOM.Meade.net
var command = $"Sr{hms}"; var command = $"Sr{hms}";
LogMessage("TargetRightAscension Set", $"{command}"); LogMessage("TargetRightAscension Set", $"{command}");
var response = SharedResourcesWrapper.SendChar(command); var response = SharedResourcesWrapper.SendChar(Tl, command);
//:SrHH:MM.T# //:SrHH:MM.T#
//:SrHH:MM:SS# //:SrHH:MM:SS#
//Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting. //Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting.
@@ -3564,7 +3564,7 @@ namespace ASCOM.Meade.net
if (!value) if (!value)
{ {
SharedResources.AlignmentMode = AlignmentMode; SharedResources.AlignmentMode = AlignmentMode;
SharedResourcesWrapper.SendBlind("AL"); SharedResourcesWrapper.SendBlind(Tl, "AL");
} }
else else
{ {
@@ -3635,22 +3635,22 @@ namespace ASCOM.Meade.net
switch (value) switch (value)
{ {
case DriveRates.driveSidereal: case DriveRates.driveSidereal:
SharedResourcesWrapper.SendBlind("TQ"); SharedResourcesWrapper.SendBlind(Tl, "TQ");
//:TQ# Selects sidereal tracking rate //:TQ# Selects sidereal tracking rate
//Returns: Nothing //Returns: Nothing
break; break;
case DriveRates.driveLunar: case DriveRates.driveLunar:
SharedResourcesWrapper.SendBlind("TL"); SharedResourcesWrapper.SendBlind(Tl, "TL");
//:TL# Set Lunar Tracking Rage //:TL# Set Lunar Tracking Rage
//Returns: Nothing //Returns: Nothing
break; break;
case DriveRates.driveSolar: case DriveRates.driveSolar:
SharedResourcesWrapper.SendBlind("TS"); SharedResourcesWrapper.SendBlind(Tl, "TS");
// //:TS# Select Solar tracking rate. [LS Only] // //:TS# Select Solar tracking rate. [LS Only]
// //Returns: Nothing // //Returns: Nothing
break; break;
//case DriveRates.driveKing: //case DriveRates.driveKing:
// SharedResourcesWrapper.SendBlind("TM"); // SharedResourcesWrapper.SendBlind(Tl, "TM");
// //:TM# Select custom tracking rate [ no-op in Autostar II] // //:TM# Select custom tracking rate [ no-op in Autostar II]
// //Returns: Nothing // //Returns: Nothing
// break; // break;
@@ -3692,7 +3692,7 @@ namespace ASCOM.Meade.net
private TimeSpan GetUtcCorrection() private TimeSpan GetUtcCorrection()
{ {
string utcOffSet = SharedResourcesWrapper.SendString("GG"); string utcOffSet = SharedResourcesWrapper.SendString(Tl, "GG");
//:GG# Get UTC offset time //:GG# Get UTC offset time
//Returns: sHH# or sHH.H# //Returns: sHH# or sHH.H#
//The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the //The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the
@@ -3723,11 +3723,11 @@ namespace ASCOM.Meade.net
var telescopeDateDetails = new TelescopeDateDetails var telescopeDateDetails = new TelescopeDateDetails
{ {
TelescopeDate = SharedResourcesWrapper.SendString("GC"), TelescopeDate = SharedResourcesWrapper.SendString(Tl, "GC"),
//:GC# Get current date. //:GC# Get current date.
//Returns: MM/DD/YY# //Returns: MM/DD/YY#
//The current local calendar date for the telescope. //The current local calendar date for the telescope.
TelescopeTime = SharedResourcesWrapper.SendString("GL"), TelescopeTime = SharedResourcesWrapper.SendString(Tl, "GL"),
//:GL# Get Local Time in 24 hour format //:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS# //Returns: HH:MM:SS#
//The Local Time in 24 - hour Format //The Local Time in 24 - hour Format
@@ -3780,7 +3780,7 @@ namespace ASCOM.Meade.net
var localDateTime = value - utcCorrection; var localDateTime = value - utcCorrection;
string localStingCommand = $"SL{localDateTime:HH:mm:ss}"; string localStingCommand = $"SL{localDateTime:HH:mm:ss}";
var timeResult = SharedResourcesWrapper.SendChar(localStingCommand); var timeResult = SharedResourcesWrapper.SendChar(Tl, localStingCommand);
//:SLHH:MM:SS# //:SLHH:MM:SS#
//Set the local Time //Set the local Time
//Returns: //Returns:
@@ -3792,7 +3792,7 @@ namespace ASCOM.Meade.net
} }
string localDateCommand = $"SC{localDateTime:MM/dd/yy}"; string localDateCommand = $"SC{localDateTime:MM/dd/yy}";
var dateResult = SharedResourcesWrapper.SendChar(localDateCommand); var dateResult = SharedResourcesWrapper.SendChar(Tl, localDateCommand);
//:SCMM/DD/YY# //:SCMM/DD/YY#
//Change Handbox Date to MM/DD/YY //Change Handbox Date to MM/DD/YY
//Returns: <D><string> //Returns: <D><string>
@@ -3833,7 +3833,7 @@ namespace ASCOM.Meade.net
{ {
case TelescopeList.RCX400: case TelescopeList.RCX400:
case TelescopeList.LX200GPS: case TelescopeList.LX200GPS:
SharedResourcesWrapper.SendChar("I"); SharedResourcesWrapper.SendChar(Tl, "I");
//:I# LX200 GPS Only - Causes the telescope to cease current operations and restart at its power on initialization. //:I# LX200 GPS Only - Causes the telescope to cease current operations and restart at its power on initialization.
//Returns: X once the handset restart has completed //Returns: X once the handset restart has completed
@@ -3871,7 +3871,7 @@ namespace ASCOM.Meade.net
var localDateTime = _clock.UtcNow - utcCorrection; var localDateTime = _clock.UtcNow - utcCorrection;
//localDateTime: HH: mm: ss //localDateTime: HH: mm: ss
var result = SharedResourcesWrapper.SendChar($"hI{localDateTime:yyMMddHHmmss}"); var result = SharedResourcesWrapper.SendChar(Tl, $"hI{localDateTime:yyMMddHHmmss}");
//:hIYYMMDDHHMMSS# //:hIYYMMDDHHMMSS#
//Bypass handbox entry of daylight savings, date and time.Use the values supplied in this command.This feature is //Bypass handbox entry of daylight savings, date and time.Use the values supplied in this command.This feature is
//intended to allow use of the Autostar II from permanent installations where GPS reception is not possible, such as within //intended to allow use of the Autostar II from permanent installations where GPS reception is not possible, such as within
@@ -38,7 +38,7 @@ namespace Meade.net.UnitTests
public void SendBlind_WhenCalled_Then_ClearsBuffersAndSendsMessage(bool raw, string expectedMessage) public void SendBlind_WhenCalled_Then_ClearsBuffersAndSendsMessage(bool raw, string expectedMessage)
{ {
var sendMessage = "Test"; var sendMessage = "Test";
SharedResources.SendBlind(sendMessage, raw); SharedResources.SendBlind(_traceLoggerMock.Object, sendMessage, raw);
_serialMock.Verify(x=> x.ClearBuffers(), Times.Once); _serialMock.Verify(x=> x.ClearBuffers(), Times.Once);
_serialMock.Verify(x=>x.Transmit(expectedMessage), Times.Once); _serialMock.Verify(x=>x.Transmit(expectedMessage), Times.Once);
+28 -28
View File
@@ -57,11 +57,11 @@ namespace ASCOM.Meade.net
Initialise(nameof(Focuser)); Initialise(nameof(Focuser));
} }
public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper) public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper, ITraceLogger traceLogger) : base(sharedResourcesWrapper)
{ {
_utilities = util; _utilities = util;
Initialise(nameof(Focuser)); Initialise(nameof(Focuser), traceLogger);
} }
// //
@@ -78,17 +78,17 @@ namespace ASCOM.Meade.net
/// </summary> /// </summary>
public void SetupDialog() public void SetupDialog()
{ {
Tl.LogMessage("SetupDialog", "Opening setup dialog"); Tl.LogMessage("SetupDialog", "Opening setup dialog", false);
SharedResourcesWrapper.SetupDialog(); SharedResourcesWrapper.SetupDialog();
ReadProfile(); ReadProfile();
Tl.LogMessage("SetupDialog", "complete"); Tl.LogMessage("SetupDialog", "complete", false);
} }
public ArrayList SupportedActions public ArrayList SupportedActions
{ {
get get
{ {
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); Tl.LogMessage("SupportedActions Get", "Returning empty arraylist", false);
return new ArrayList(); return new ArrayList();
} }
} }
@@ -105,7 +105,7 @@ namespace ASCOM.Meade.net
CheckConnected("CommandBlind"); CheckConnected("CommandBlind");
// Call CommandString and return as soon as it finishes // Call CommandString and return as soon as it finishes
//this.CommandString(command, raw); //this.CommandString(command, raw);
SharedResourcesWrapper.SendBlind(command, raw); SharedResourcesWrapper.SendBlind(Tl, command, raw);
// or // or
//throw new ASCOM.MethodNotImplementedException("CommandBlind"); //throw new ASCOM.MethodNotImplementedException("CommandBlind");
// DO NOT have both these sections! One or the other // DO NOT have both these sections! One or the other
@@ -116,7 +116,7 @@ namespace ASCOM.Meade.net
{ {
LogMessage("CommandBool", "raw: {0} command {0}", raw, command); LogMessage("CommandBool", "raw: {0} command {0}", raw, command);
CheckConnected("CommandBool"); CheckConnected("CommandBool");
var result = SharedResourcesWrapper.SendBool(command, raw); var result = SharedResourcesWrapper.SendBool(Tl, command, raw);
LogMessage("CommandBool", "Completed: {0}", result); LogMessage("CommandBool", "Completed: {0}", result);
return result; return result;
// or // or
@@ -131,7 +131,7 @@ namespace ASCOM.Meade.net
// it's a good idea to put all the low level communication with the device here, // it's a good idea to put all the low level communication with the device here,
// then all communication calls this function // then all communication calls this function
// you need something to ensure that only one command is in progress at a time // you need something to ensure that only one command is in progress at a time
var result = SharedResourcesWrapper.SendString(command, raw); var result = SharedResourcesWrapper.SendString(Tl, command, raw);
LogMessage("CommandBool", "Completed: {0}", result); LogMessage("CommandBool", "Completed: {0}", result);
return result; return result;
//throw new ASCOM.MethodNotImplementedException("CommandString"); //throw new ASCOM.MethodNotImplementedException("CommandString");
@@ -141,8 +141,8 @@ namespace ASCOM.Meade.net
{ {
// Clean up the tracelogger and util objects // Clean up the tracelogger and util objects
Tl.Enabled = false; Tl.Enabled = false;
Tl.Dispose(); //Tl.Dispose();
Tl = null; //Tl = null;
} }
public bool Connected public bool Connected
@@ -204,7 +204,7 @@ namespace ASCOM.Meade.net
{ {
//string name = "Short driver name - please customise"; //string name = "Short driver name - please customise";
string name = DriverDescription; string name = DriverDescription;
Tl.LogMessage("Name Get", name); Tl.LogMessage("Name Get", name, false);
return name; return name;
} }
} }
@@ -219,20 +219,20 @@ namespace ASCOM.Meade.net
{ {
CheckConnected("Absolute Get"); CheckConnected("Absolute Get");
Tl.LogMessage("Absolute Get", false.ToString()); Tl.LogMessage("Absolute Get", false.ToString(), false);
return false; // This is a relative focuser return false; // This is a relative focuser
} }
} }
public void Halt() public void Halt()
{ {
Tl.LogMessage("Halt", "Halting"); Tl.LogMessage("Halt", "Halting", false);
CheckConnected("Halt"); CheckConnected("Halt");
//todo fix this issue: A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe. //todo fix this issue: A single halt command is sometimes missed by the #909 apm, so let's do it a few times to be safe.
SharedResourcesWrapper.SendBlind("FQ"); SharedResourcesWrapper.SendBlind(Tl, "FQ");
//:FQ# Halt Focuser Motion //:FQ# Halt Focuser Motion
//Returns: Nothing //Returns: Nothing
} }
@@ -241,7 +241,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("IsMoving Get", false.ToString()); Tl.LogMessage("IsMoving Get", false.ToString(), false);
return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True return false; // This focuser always moves instantaneously so no need for IsMoving ever to be True
} }
} }
@@ -250,12 +250,12 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("Link Get", Connected.ToString()); Tl.LogMessage("Link Get", Connected.ToString(), false);
return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility return Connected; // Direct function to the connected method, the Link method is just here for backwards compatibility
} }
set set
{ {
Tl.LogMessage("Link Set", value.ToString()); Tl.LogMessage("Link Set", value.ToString(), false);
Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility Connected = value; // Direct function to the connected method, the Link method is just here for backwards compatibility
} }
} }
@@ -265,7 +265,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString()); Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString(), false);
return _maxIncrement; // Maximum change in one move return _maxIncrement; // Maximum change in one move
} }
} }
@@ -276,14 +276,14 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("MaxStep Get", _maxStep.ToString()); Tl.LogMessage("MaxStep Get", _maxStep.ToString(), false);
return _maxStep; return _maxStep;
} }
} }
public void Move(int position) public void Move(int position)
{ {
Tl.LogMessage("Move", position.ToString()); Tl.LogMessage("Move", position.ToString(), false);
CheckConnected("Move"); CheckConnected("Move");
if (position < -MaxIncrement || position > MaxIncrement) if (position < -MaxIncrement || position > MaxIncrement)
@@ -311,7 +311,7 @@ namespace ASCOM.Meade.net
//ApplyBacklashCompensation(direction); //ApplyBacklashCompensation(direction);
if (direction & backlashCompensationSteps != 0) if (direction & backlashCompensationSteps != 0)
{ {
Tl.LogMessage("Move", "Applying backlash compensation"); Tl.LogMessage("Move", "Applying backlash compensation", false);
MoveFocuser(!direction, backlashCompensationSteps); MoveFocuser(!direction, backlashCompensationSteps);
} }
@@ -325,7 +325,7 @@ namespace ASCOM.Meade.net
if (!_profileProperties.DynamicBreaking) if (!_profileProperties.DynamicBreaking)
return; return;
Tl.LogMessage("Move", "Applying dynamic breaking"); Tl.LogMessage("Move", "Applying dynamic breaking", false);
PerformFocuserMove(directionOut); PerformFocuserMove(directionOut);
Halt(); Halt();
@@ -354,7 +354,7 @@ namespace ASCOM.Meade.net
private void PerformFocuserMove(bool directionOut) private void PerformFocuserMove(bool directionOut)
{ {
SharedResourcesWrapper.SendBlind(directionOut ? "F+" : "F-"); SharedResourcesWrapper.SendBlind(Tl, directionOut ? "F+" : "F-");
//:F+# Start Focuser moving inward (toward objective) //:F+# Start Focuser moving inward (toward objective)
//Returns: None //Returns: None
@@ -368,7 +368,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("StepSize Get", "Not implemented"); Tl.LogMessage("StepSize Get", "Not implemented", false);
throw new PropertyNotImplementedException("StepSize", false); throw new PropertyNotImplementedException("StepSize", false);
} }
} }
@@ -377,13 +377,13 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("TempComp Get", false.ToString()); Tl.LogMessage("TempComp Get", false.ToString(), false);
return false; return false;
} }
// ReSharper disable once ValueParameterNotUsed // ReSharper disable once ValueParameterNotUsed
set set
{ {
Tl.LogMessage("TempComp Set", "Not implemented"); Tl.LogMessage("TempComp Set", "Not implemented", false);
throw new PropertyNotImplementedException("TempComp", false); throw new PropertyNotImplementedException("TempComp", false);
} }
} }
@@ -392,7 +392,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("TempCompAvailable Get", false.ToString()); Tl.LogMessage("TempCompAvailable Get", false.ToString(), false);
return false; // Temperature compensation is not available in this driver return false; // Temperature compensation is not available in this driver
} }
} }
@@ -401,7 +401,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("Temperature Get", "Not implemented"); Tl.LogMessage("Temperature Get", "Not implemented", false);
throw new PropertyNotImplementedException("Temperature", false); throw new PropertyNotImplementedException("Temperature", false);
} }
} }
+6 -5
View File
@@ -3,6 +3,7 @@ using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ASCOM.Meade.net.Wrapper; using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities; using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces;
namespace ASCOM.Meade.net namespace ASCOM.Meade.net
{ {
@@ -12,7 +13,7 @@ namespace ASCOM.Meade.net
/// <summary> /// <summary>
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify) /// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
/// </summary> /// </summary>
protected static TraceLogger Tl; protected static ITraceLogger Tl;
/// <summary> /// <summary>
/// Driver description that displays in the ASCOM Chooser. /// Driver description that displays in the ASCOM Chooser.
@@ -32,9 +33,9 @@ namespace ASCOM.Meade.net
SharedResourcesWrapper = sharedResourcesWrapper; SharedResourcesWrapper = sharedResourcesWrapper;
} }
protected void Initialise(string className) protected void Initialise(string className, ITraceLogger traceLogger = null)
{ {
Tl = new TraceLogger("", $"Meade.Generic.{className}"); Tl = traceLogger ?? new TraceLogger("", $"Meade.Generic.{className}");
ReadProfile(); // Read device configuration from the ASCOM Profile store ReadProfile(); // Read device configuration from the ASCOM Profile store
@@ -79,7 +80,7 @@ namespace ASCOM.Meade.net
public static void LogMessage(string identifier, string message, params object[] args) public static void LogMessage(string identifier, string message, params object[] args)
{ {
var msg = string.Format(message, args); var msg = string.Format(message, args);
Tl.LogMessage(identifier, msg); Tl.LogMessage(identifier, msg, false);
} }
/// <summary> /// <summary>
@@ -91,7 +92,7 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
Tl.LogMessage("Description Get", DriverDescription); Tl.LogMessage("Description Get", DriverDescription, false);
return DriverDescription; return DriverDescription;
} }
} }
+1 -1
View File
@@ -80,7 +80,7 @@ namespace ASCOM.Meade.net
} }
//todo add code to ensure that there is a minimum gap between commands. 5ms as default. //todo add code to ensure that there is a minimum gap between commands. 5ms as default.
public static void SendBlind(string message, bool raw = false) public static void SendBlind(ITraceLogger traceLogger, string message, bool raw = false)
{ {
lock (LockObject) lock (LockObject)
{ {
+11 -11
View File
@@ -13,11 +13,11 @@ namespace ASCOM.Meade.net.Wrapper
string FirmwareVersion { get; } string FirmwareVersion { get; }
string SendString(string message, bool raw = false); string SendString(ITraceLogger traceLogger, string message, bool raw = false);
void SendBlind(string message, bool raw = false); void SendBlind(ITraceLogger traceLogger, string message, bool raw = false);
bool SendBool(string command, bool raw = false); bool SendBool(ITraceLogger traceLogger, string command, bool raw = false);
string SendChar(string message, bool raw = false); string SendChar(ITraceLogger traceLogger, string message, bool raw = false);
string SendChars(string message, bool raw = false, int count = 1); string SendChars(ITraceLogger traceLogger, string message, bool raw = false, int count = 1);
string ReadTerminated(); string ReadTerminated();
@@ -66,27 +66,27 @@ namespace ASCOM.Meade.net.Wrapper
public string FirmwareVersion => SharedResources.FirmwareVersion; public string FirmwareVersion => SharedResources.FirmwareVersion;
public string SendString(string message, bool raw = false) public string SendString(ITraceLogger traceLogger, string message, bool raw = false)
{ {
return SharedResources.SendString(message, raw); return SharedResources.SendString(message, raw);
} }
public void SendBlind(string message, bool raw = false) public void SendBlind(ITraceLogger traceLogger, string message, bool raw = false)
{ {
SharedResources.SendBlind(message, raw); SharedResources.SendBlind(traceLogger, message, raw);
} }
public bool SendBool(string command, bool raw = false) public bool SendBool(ITraceLogger traceLogger, string command, bool raw = false)
{ {
return SharedResources.SendBool(command, raw); return SharedResources.SendBool(command, raw);
} }
public string SendChar(string message, bool raw = false) public string SendChar(ITraceLogger traceLogger, string message, bool raw = false)
{ {
return SharedResources.SendChar(message, raw); return SharedResources.SendChar(message, raw);
} }
public string SendChars(string message, bool raw = false, int count = 1) public string SendChars(ITraceLogger traceLogger, string message, bool raw = false, int count = 1)
{ {
return SharedResources.SendChars(message, raw, count); return SharedResources.SendChars(message, raw, count);
} }