@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASCOM.MeadeGeneric</RootNamespace>
|
||||
<AssemblyName>ASCOM.MeadeGeneric.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Meade.net.Focuser.UnitTests
|
||||
{
|
||||
private Mock<IUtil> _utilMock;
|
||||
private Mock<ISharedResourcesWrapper> _sharedResourcesWrapperMock;
|
||||
private Mock<ITraceLogger> _traceLoggerMock;
|
||||
|
||||
private ProfileProperties _profileProperties;
|
||||
|
||||
@@ -40,11 +41,13 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
_utilMock = new Mock<IUtil>();
|
||||
|
||||
_traceLoggerMock = new Mock<ITraceLogger>();
|
||||
|
||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||
|
||||
_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()
|
||||
@@ -117,7 +120,7 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
_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]
|
||||
@@ -134,13 +137,13 @@ namespace Meade.net.Focuser.UnitTests
|
||||
public void CommandBool_WhenConnected_ThenSendsExpectedMessage(bool raw)
|
||||
{
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -161,11 +164,11 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
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);
|
||||
|
||||
_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));
|
||||
}
|
||||
|
||||
@@ -321,7 +324,7 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
_focuser.Halt();
|
||||
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("FQ", false), Times.AtLeastOnce);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "FQ", false), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -411,13 +414,13 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
if (position < 0)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F+", false), Times.Never);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F+", false), Times.Once);
|
||||
}
|
||||
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(Math.Abs(position)), Times.Once);
|
||||
@@ -437,16 +440,16 @@ namespace Meade.net.Focuser.UnitTests
|
||||
|
||||
if (position < 0)
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F+", false), Times.Never);
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(_traceLoggerMock.Object, "F-", false), Times.Once);
|
||||
_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(_profileProperties.BacklashCompensation)), Times.Never);
|
||||
_utilMock.Verify(x => x.WaitForMilliseconds(100), Times.Exactly(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_sharedResourcesWrapperMock.Verify(x => x.SendBlind("F-", false), Times.Once);
|
||||
_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(_traceLoggerMock.Object, "F+", false), 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(100), Times.Exactly(2));
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
Type="raw" />
|
||||
</Property>
|
||||
|
||||
<Condition Message="This application requires Ascom Platform 6.4 SP1 or higher. Please install this before installing the driver.">
|
||||
<![CDATA[Installed OR ASCOMPLATFORMVERSION >= "6.4.1"]]>
|
||||
<Condition Message="This application requires Ascom Platform 6.6.0 or higher. Please install this before installing the driver.">
|
||||
<![CDATA[Installed OR ASCOMPLATFORMVERSION >= "6.6.0"]]>
|
||||
</Condition>
|
||||
|
||||
<PropertyRef Id="NETFRAMEWORK45"/>
|
||||
<Condition Message="This application requires .NET Framework 4.5 or higher. Please install the .NET Framework then run this installer again.">
|
||||
<![CDATA[Installed OR NETFRAMEWORK45]]>
|
||||
<PropertyRef Id='WIXNETFX4RELEASEINSTALLED'/>
|
||||
<Condition Message="This application requires .NET Framework 4.8 or higher. Please install the .NET Framework then run this installer again.">
|
||||
<![CDATA[Installed OR (WIXNETFX4RELEASEINSTALLED >= "#528040")]]>
|
||||
</Condition>
|
||||
|
||||
<!-- <Condition Message="Please use the correct installer for your operating system - x86 for 32-bit, x64 for 64-bit.">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,8 @@
|
||||
<ProjectConfiguration>
|
||||
<Settings>
|
||||
<HiddenComponentWarnings>
|
||||
<Value>CopyReferencedAssembliesToWorkspaceIsOn</Value>
|
||||
</HiddenComponentWarnings>
|
||||
<UseCPUArchitecture>x86</UseCPUArchitecture>
|
||||
</Settings>
|
||||
</ProjectConfiguration>
|
||||
+237
-232
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ namespace Meade.net.UnitTests
|
||||
public void SendBlind_WhenCalled_Then_ClearsBuffersAndSendsMessage(bool raw, string expectedMessage)
|
||||
{
|
||||
var sendMessage = "Test";
|
||||
SharedResources.SendBlind(sendMessage, raw);
|
||||
SharedResources.SendBlind(_traceLoggerMock.Object, sendMessage, raw);
|
||||
|
||||
_serialMock.Verify(x=> x.ClearBuffers(), Times.Once);
|
||||
_serialMock.Verify(x=>x.Transmit(expectedMessage), Times.Once);
|
||||
@@ -53,7 +53,7 @@ namespace Meade.net.UnitTests
|
||||
|
||||
_serialMock.Setup(x => x.ReceiveCounted(1)).Returns(expectedResult);
|
||||
|
||||
var result = SharedResources.SendChar(command, raw);
|
||||
var result = SharedResources.SendChar(_traceLoggerMock.Object, command, raw);
|
||||
|
||||
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
|
||||
_serialMock.Verify(x => x.Transmit(expectedCommand), Times.Once);
|
||||
@@ -70,7 +70,7 @@ namespace Meade.net.UnitTests
|
||||
|
||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(expectedResult);
|
||||
|
||||
var result = SharedResources.SendString(transmitMessage, includePrefix);
|
||||
var result = SharedResources.SendString(_traceLoggerMock.Object, transmitMessage, includePrefix);
|
||||
|
||||
_serialMock.Verify(x => x.ClearBuffers(), Times.Once);
|
||||
_serialMock.Verify(x => x.Transmit(expectedMessage), Times.Once);
|
||||
|
||||
@@ -57,11 +57,11 @@ namespace ASCOM.Meade.net
|
||||
Initialise(nameof(Focuser));
|
||||
}
|
||||
|
||||
public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper) : base(sharedResourcesWrapper)
|
||||
public Focuser(IUtil util, ISharedResourcesWrapper sharedResourcesWrapper, ITraceLogger traceLogger) : base(sharedResourcesWrapper)
|
||||
{
|
||||
_utilities = util;
|
||||
|
||||
Initialise(nameof(Focuser));
|
||||
Initialise(nameof(Focuser), traceLogger);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -78,17 +78,17 @@ namespace ASCOM.Meade.net
|
||||
/// </summary>
|
||||
public void SetupDialog()
|
||||
{
|
||||
Tl.LogMessage("SetupDialog", "Opening setup dialog");
|
||||
Tl.LogMessage("SetupDialog", "Opening setup dialog", false);
|
||||
SharedResourcesWrapper.SetupDialog();
|
||||
ReadProfile();
|
||||
Tl.LogMessage("SetupDialog", "complete");
|
||||
Tl.LogMessage("SetupDialog", "complete", false);
|
||||
}
|
||||
|
||||
public ArrayList SupportedActions
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist");
|
||||
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist", false);
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace ASCOM.Meade.net
|
||||
CheckConnected("CommandBlind");
|
||||
// Call CommandString and return as soon as it finishes
|
||||
//this.CommandString(command, raw);
|
||||
SharedResourcesWrapper.SendBlind(command, raw);
|
||||
SharedResourcesWrapper.SendBlind(Tl, command, raw);
|
||||
// or
|
||||
//throw new ASCOM.MethodNotImplementedException("CommandBlind");
|
||||
// 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);
|
||||
CheckConnected("CommandBool");
|
||||
var result = SharedResourcesWrapper.SendBool(command, raw);
|
||||
var result = SharedResourcesWrapper.SendBool(Tl, command, raw);
|
||||
LogMessage("CommandBool", "Completed: {0}", result);
|
||||
return result;
|
||||
// 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,
|
||||
// then all communication calls this function
|
||||
// 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);
|
||||
return result;
|
||||
//throw new ASCOM.MethodNotImplementedException("CommandString");
|
||||
@@ -141,8 +141,8 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
// Clean up the tracelogger and util objects
|
||||
Tl.Enabled = false;
|
||||
Tl.Dispose();
|
||||
Tl = null;
|
||||
//Tl.Dispose();
|
||||
//Tl = null;
|
||||
}
|
||||
|
||||
public bool Connected
|
||||
@@ -204,7 +204,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
//string name = "Short driver name - please customise";
|
||||
string name = DriverDescription;
|
||||
Tl.LogMessage("Name Get", name);
|
||||
Tl.LogMessage("Name Get", name, false);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -219,20 +219,20 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
CheckConnected("Absolute Get");
|
||||
|
||||
Tl.LogMessage("Absolute Get", false.ToString());
|
||||
Tl.LogMessage("Absolute Get", false.ToString(), false);
|
||||
return false; // This is a relative focuser
|
||||
}
|
||||
}
|
||||
|
||||
public void Halt()
|
||||
{
|
||||
Tl.LogMessage("Halt", "Halting");
|
||||
Tl.LogMessage("Halt", "Halting", false);
|
||||
|
||||
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.
|
||||
|
||||
SharedResourcesWrapper.SendBlind("FQ");
|
||||
SharedResourcesWrapper.SendBlind(Tl, "FQ");
|
||||
//:FQ# Halt Focuser Motion
|
||||
//Returns: Nothing
|
||||
}
|
||||
@@ -241,7 +241,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -250,12 +250,12 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString());
|
||||
Tl.LogMessage("MaxIncrement Get", _maxIncrement.ToString(), false);
|
||||
return _maxIncrement; // Maximum change in one move
|
||||
}
|
||||
}
|
||||
@@ -276,14 +276,14 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("MaxStep Get", _maxStep.ToString());
|
||||
Tl.LogMessage("MaxStep Get", _maxStep.ToString(), false);
|
||||
return _maxStep;
|
||||
}
|
||||
}
|
||||
|
||||
public void Move(int position)
|
||||
{
|
||||
Tl.LogMessage("Move", position.ToString());
|
||||
Tl.LogMessage("Move", position.ToString(), false);
|
||||
CheckConnected("Move");
|
||||
|
||||
if (position < -MaxIncrement || position > MaxIncrement)
|
||||
@@ -311,7 +311,7 @@ namespace ASCOM.Meade.net
|
||||
//ApplyBacklashCompensation(direction);
|
||||
if (direction & backlashCompensationSteps != 0)
|
||||
{
|
||||
Tl.LogMessage("Move", "Applying backlash compensation");
|
||||
Tl.LogMessage("Move", "Applying backlash compensation", false);
|
||||
MoveFocuser(!direction, backlashCompensationSteps);
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace ASCOM.Meade.net
|
||||
if (!_profileProperties.DynamicBreaking)
|
||||
return;
|
||||
|
||||
Tl.LogMessage("Move", "Applying dynamic breaking");
|
||||
Tl.LogMessage("Move", "Applying dynamic breaking", false);
|
||||
|
||||
PerformFocuserMove(directionOut);
|
||||
Halt();
|
||||
@@ -354,7 +354,7 @@ namespace ASCOM.Meade.net
|
||||
|
||||
private void PerformFocuserMove(bool directionOut)
|
||||
{
|
||||
SharedResourcesWrapper.SendBlind(directionOut ? "F+" : "F-");
|
||||
SharedResourcesWrapper.SendBlind(Tl, directionOut ? "F+" : "F-");
|
||||
//:F+# Start Focuser moving inward (toward objective)
|
||||
//Returns: None
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("StepSize Get", "Not implemented");
|
||||
Tl.LogMessage("StepSize Get", "Not implemented", false);
|
||||
throw new PropertyNotImplementedException("StepSize", false);
|
||||
}
|
||||
}
|
||||
@@ -377,13 +377,13 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("TempComp Get", false.ToString());
|
||||
Tl.LogMessage("TempComp Get", false.ToString(), false);
|
||||
return false;
|
||||
}
|
||||
// ReSharper disable once ValueParameterNotUsed
|
||||
set
|
||||
{
|
||||
Tl.LogMessage("TempComp Set", "Not implemented");
|
||||
Tl.LogMessage("TempComp Set", "Not implemented", false);
|
||||
throw new PropertyNotImplementedException("TempComp", false);
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("TempCompAvailable Get", false.ToString());
|
||||
Tl.LogMessage("TempCompAvailable Get", false.ToString(), false);
|
||||
return false; // Temperature compensation is not available in this driver
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("Temperature Get", "Not implemented");
|
||||
Tl.LogMessage("Temperature Get", "Not implemented", false);
|
||||
throw new PropertyNotImplementedException("Temperature", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<ProjectConfiguration>
|
||||
<Settings>
|
||||
<HiddenComponentWarnings>
|
||||
<Value>CopyReferencedAssembliesToWorkspaceIsOn</Value>
|
||||
</HiddenComponentWarnings>
|
||||
<UseCPUArchitecture>x86</UseCPUArchitecture>
|
||||
</Settings>
|
||||
</ProjectConfiguration>
|
||||
@@ -3,6 +3,7 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using ASCOM.Meade.net.Wrapper;
|
||||
using ASCOM.Utilities;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
|
||||
namespace ASCOM.Meade.net
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace ASCOM.Meade.net
|
||||
/// <summary>
|
||||
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
|
||||
/// </summary>
|
||||
protected static TraceLogger Tl;
|
||||
protected static ITraceLogger Tl;
|
||||
|
||||
/// <summary>
|
||||
/// Driver description that displays in the ASCOM Chooser.
|
||||
@@ -32,9 +33,9 @@ namespace ASCOM.Meade.net
|
||||
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
|
||||
|
||||
@@ -79,7 +80,7 @@ namespace ASCOM.Meade.net
|
||||
public static void LogMessage(string identifier, string message, params object[] args)
|
||||
{
|
||||
var msg = string.Format(message, args);
|
||||
Tl.LogMessage(identifier, msg);
|
||||
Tl.LogMessage(identifier, msg, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,7 +92,7 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
Tl.LogMessage("Description Get", DriverDescription);
|
||||
Tl.LogMessage("Description Get", DriverDescription, false);
|
||||
return DriverDescription;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using ASCOM.DeviceInterface;
|
||||
@@ -80,12 +79,13 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
|
||||
//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)
|
||||
{
|
||||
SharedSerial.ClearBuffers();
|
||||
var encodedMessage = raw ? message : $"#:{message}#";
|
||||
traceLogger.LogMessage("SendBlind", $"Transmitting {encodedMessage}", false);
|
||||
SharedSerial.Transmit(encodedMessage);
|
||||
}
|
||||
}
|
||||
@@ -99,21 +99,25 @@ namespace ASCOM.Meade.net
|
||||
/// <param name="message"></param>
|
||||
/// <param name="raw"></param>
|
||||
/// <returns></returns>
|
||||
public static string SendString(string message, bool raw = false)
|
||||
public static string SendString(ITraceLogger traceLogger, string message, bool raw = false)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
SharedSerial.ClearBuffers();
|
||||
|
||||
var encodedMessage = raw ? message : $"#:{message}#";
|
||||
traceLogger.LogMessage("SendString", $"Transmitting {encodedMessage}", false);
|
||||
SharedSerial.Transmit(encodedMessage);
|
||||
|
||||
try
|
||||
{
|
||||
return SharedSerial.ReceiveTerminated("#").TrimEnd('#');
|
||||
var result = SharedSerial.ReceiveTerminated("#").TrimEnd('#');
|
||||
traceLogger.LogMessage("SendString", $"Received {result}", false);
|
||||
return result;
|
||||
}
|
||||
catch (COMException ex)
|
||||
{
|
||||
traceLogger.LogIssue("SendString", ex.Message);
|
||||
if (ex.Message.Contains("Timed out waiting for received data"))
|
||||
throw new TimeoutException(ex.Message, ex);
|
||||
|
||||
@@ -122,34 +126,41 @@ namespace ASCOM.Meade.net
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SendBool(string command, bool raw = false)
|
||||
public static bool SendBool(ITraceLogger traceLogger, string command, bool raw = false)
|
||||
{
|
||||
var result = SendChar(command, raw);
|
||||
var result = SendChar(traceLogger, command, raw);
|
||||
|
||||
return result == "1";
|
||||
}
|
||||
|
||||
public static string SendChar(string command, bool raw = false)
|
||||
public static string SendChar(ITraceLogger traceLogger, string command, bool raw = false)
|
||||
{
|
||||
return SendChars(command, raw, count: 1);
|
||||
return SendChars(traceLogger, command, raw, count: 1);
|
||||
}
|
||||
|
||||
public static string SendChars(string command, bool raw = false, int count = 1)
|
||||
public static string SendChars(ITraceLogger traceLogger, string command, bool raw = false, int count = 1)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
SharedSerial.ClearBuffers();
|
||||
|
||||
var encodedMessage = raw ? command : $"#:{command}#";
|
||||
traceLogger.LogMessage("SendChars", $"Transmitting {encodedMessage}", false);
|
||||
SharedSerial.Transmit(encodedMessage);
|
||||
|
||||
try
|
||||
{
|
||||
return SharedSerial.ReceiveCounted(count);
|
||||
var result = SharedSerial.ReceiveCounted(count);
|
||||
traceLogger.LogMessage("SendChars", $"Received {result}", false);
|
||||
return result;
|
||||
}
|
||||
catch (COMException ex) when (ex.Message.Contains("Timed out waiting for received data"))
|
||||
catch (COMException ex)
|
||||
{
|
||||
traceLogger.LogIssue("SendString", ex.Message);
|
||||
if (ex.Message.Contains("Timed out waiting for received data"))
|
||||
throw new TimeoutException(ex.Message, ex);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,7 +415,7 @@ namespace ASCOM.Meade.net
|
||||
//Test if communication is working.
|
||||
try
|
||||
{
|
||||
string utcOffSet = SendString("GG");
|
||||
string utcOffSet = SendString( traceLogger, "GG");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -433,7 +444,7 @@ namespace ASCOM.Meade.net
|
||||
//SendBlind($"SB{newSpeedIndex}");
|
||||
try
|
||||
{
|
||||
var speedChanged = SendChar($"SB{newSpeedIndex}");
|
||||
var speedChanged = SendChar(traceLogger, $"SB{newSpeedIndex}");
|
||||
if (speedChanged == "1")
|
||||
{
|
||||
SharedSerial.Connected = false;
|
||||
@@ -458,8 +469,8 @@ namespace ASCOM.Meade.net
|
||||
|
||||
try
|
||||
{
|
||||
ProductName = SendString("GVP");
|
||||
FirmwareVersion = SendString("GVN");
|
||||
ProductName = SendString(traceLogger, "GVP");
|
||||
FirmwareVersion = SendString(traceLogger, "GVN");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -479,7 +490,7 @@ namespace ASCOM.Meade.net
|
||||
|
||||
try
|
||||
{
|
||||
string utcOffSet = SendString("GG");
|
||||
string utcOffSet = SendString(traceLogger, "GG");
|
||||
//:GG# Get UTC offset time
|
||||
//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
|
||||
|
||||
@@ -23,14 +23,22 @@
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string LX200GPS = "LX2001";
|
||||
|
||||
public const string LX200GPS_42F = "4.2F";
|
||||
public const string LX200GPS_42F = "4.2f";
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string LX200GPS_42G = "4.2G";
|
||||
public const string LX200GPS_42G = "4.2g";
|
||||
#endregion
|
||||
|
||||
#region LX200EMC
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported!
|
||||
#endregion
|
||||
|
||||
#region RCX400
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public const string RCX400 = "RCX400";
|
||||
|
||||
public const string RCX400_22I = "2.2i";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
|
||||
string FirmwareVersion { get; }
|
||||
|
||||
string SendString(string message, bool raw = false);
|
||||
void SendBlind(string message, bool raw = false);
|
||||
bool SendBool(string command, bool raw = false);
|
||||
string SendChar(string message, bool raw = false);
|
||||
string SendChars(string message, bool raw = false, int count = 1);
|
||||
string SendString(ITraceLogger traceLogger, string message, bool raw = false);
|
||||
void SendBlind(ITraceLogger traceLogger, string message, bool raw = false);
|
||||
bool SendBool(ITraceLogger traceLogger, string command, bool raw = false);
|
||||
string SendChar(ITraceLogger traceLogger, string message, bool raw = false);
|
||||
string SendChars(ITraceLogger traceLogger, string message, bool raw = false, int count = 1);
|
||||
|
||||
string ReadTerminated();
|
||||
|
||||
@@ -66,29 +66,29 @@ namespace ASCOM.Meade.net.Wrapper
|
||||
|
||||
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(traceLogger, 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(traceLogger, 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(traceLogger, 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(traceLogger, message, raw, count);
|
||||
}
|
||||
|
||||
public string ReadTerminated()
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASCOM.Meade.net</RootNamespace>
|
||||
<AssemblyName>ASCOM.Meade.net.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
|
||||
Reference in New Issue
Block a user