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
+6 -5
View File
@@ -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;
}
}
+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.
public static void SendBlind(string message, bool raw = false)
public static void SendBlind(ITraceLogger traceLogger, string message, bool raw = false)
{
lock (LockObject)
{
+11 -11
View File
@@ -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,27 +66,27 @@ 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);
}
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);
}
public string SendChar(string message, bool raw = false)
public string SendChar(ITraceLogger traceLogger, string message, bool raw = false)
{
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);
}