1
0
mirror of https://bitbucket.org/cjdskunkworks/lynxastrodewcontroller.git synced 2026-05-03 17:28:52 +00:00

Redone the log messages

This commit is contained in:
2021-02-24 16:06:35 +00:00
parent a13c6e8f1e
commit 7e19f47246
3 changed files with 38 additions and 13 deletions
+31 -8
View File
@@ -74,7 +74,7 @@ namespace ASCOM.LynxAstro.DewController
{ {
get get
{ {
Tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); LogMessage("SupportedActions Get", "Returning empty arraylist");
return new ArrayList(); return new ArrayList();
} }
} }
@@ -183,7 +183,7 @@ namespace ASCOM.LynxAstro.DewController
get get
{ {
string name = "LynxAstro.DewController"; string name = "LynxAstro.DewController";
Tl.LogMessage("Name Get", name); LogMessage("Name Get", name);
return name; return name;
} }
} }
@@ -213,7 +213,7 @@ namespace ASCOM.LynxAstro.DewController
//Purpose: Get the device type, i.e.the number of channels the dew controller has. //Purpose: Get the device type, i.e.the number of channels the dew controller has.
//Response: :GDX# where X is either 1 or 4 depending on the number of channels this device has //Response: :GDX# where X is either 1 or 4 depending on the number of channels this device has
Tl.LogMessage("MaxSwitch Get", numSwitch.ToString()); LogMessage("MaxSwitch Get", numSwitch.ToString());
return this.numSwitch; return this.numSwitch;
} }
} }
@@ -230,7 +230,10 @@ namespace ASCOM.LynxAstro.DewController
Validate("GetSwitchName", id); Validate("GetSwitchName", id);
ReadProfile(); ReadProfile();
return switchNames.Count > id ? switchNames[id] : string.Empty; var switchName = switchNames.Count > id ? switchNames[id] : string.Empty;
LogMessage("GetSwitchName", $"{id}: {switchName}");
return switchName;
} }
/// <summary> /// <summary>
@@ -246,6 +249,8 @@ namespace ASCOM.LynxAstro.DewController
while (id > switchNames.Count) while (id > switchNames.Count)
switchNames.Add(string.Empty); switchNames.Add(string.Empty);
LogMessage("SetSwitchName", $"{id}: \"{switchNames[id]}\" to \"{name}\"");
switchNames[id] = name; switchNames[id] = name;
WriteSwitchNames(); WriteSwitchNames();
@@ -259,7 +264,11 @@ namespace ASCOM.LynxAstro.DewController
public string GetSwitchDescription(short id) public string GetSwitchDescription(short id)
{ {
Validate("GetSwitchDescription", id); Validate("GetSwitchDescription", id);
return $"Channel {ChannelToLetter(id)}";
var channel= $"Channel {ChannelToLetter(id)}";
LogMessage("GetSwitchDescription", channel);
return channel;
} }
/// <summary> /// <summary>
@@ -276,7 +285,8 @@ namespace ASCOM.LynxAstro.DewController
{ {
Validate("CanWrite", id); Validate("CanWrite", id);
// default behavour is to report true // default behavour is to report true
Tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - default true", id));
LogMessage("CanWrite", $"CanWrite({id}) - default true");
return true; return true;
// implementation should report the correct behaviour // implementation should report the correct behaviour
//tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - not implemented", id)); //tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - not implemented", id));
@@ -296,7 +306,11 @@ namespace ASCOM.LynxAstro.DewController
public bool GetSwitch(short id) public bool GetSwitch(short id)
{ {
var value = GetSwitchValue(id); var value = GetSwitchValue(id);
return value > 0;
var switchIsOn = value > 0;
LogMessage("GetSwitch", $"{id}: {switchIsOn} ({value})");
return switchIsOn;
} }
/// <summary> /// <summary>
@@ -316,7 +330,11 @@ namespace ASCOM.LynxAstro.DewController
Tl.LogMessage("SetSwitch", str); Tl.LogMessage("SetSwitch", str);
throw new MethodNotImplementedException(str); throw new MethodNotImplementedException(str);
} }
SetSwitchValue(id, state ? 1023 : 0);
var switchIsOn = state ? 1023 : 0;
LogMessage("SetSwitch", $"{id}: {state} ({switchIsOn})");
SetSwitchValue(id, switchIsOn);
} }
#endregion #endregion
@@ -389,6 +407,8 @@ namespace ASCOM.LynxAstro.DewController
var encoded = SharedResourcesWrapper.SendString($":GC{channel}#"); var encoded = SharedResourcesWrapper.SendString($":GC{channel}#");
var decoded = DecodeResult(":GC", encoded); var decoded = DecodeResult(":GC", encoded);
LogMessage("GetSwitchValue", $"{id}: {channel} - {decoded}");
return double.Parse(decoded.TrimStart(channel)); return double.Parse(decoded.TrimStart(channel));
//Command: :GCX# where X is the channel A, B, C or D to retrieve. //Command: :GCX# where X is the channel A, B, C or D to retrieve.
//Purpose: Get the current power setting for a specific channel. //Purpose: Get the current power setting for a specific channel.
@@ -434,6 +454,8 @@ namespace ASCOM.LynxAstro.DewController
var channel = ChannelToLetter(id); var channel = ChannelToLetter(id);
LogMessage("SetSwitchValue", $"{id}: {channel} - {value}");
var encoded = SharedResourcesWrapper.SendString($":SC{channel}{value:0000}#"); var encoded = SharedResourcesWrapper.SendString($":SC{channel}{value:0000}#");
var decoded = DecodeResult(":SC", encoded); var decoded = DecodeResult(":SC", encoded);
@@ -441,6 +463,7 @@ namespace ASCOM.LynxAstro.DewController
{ {
throw new InvalidValueException($"Unable to set switch {{id}} to value {value}"); throw new InvalidValueException($"Unable to set switch {{id}} to value {value}");
} }
//return double.Parse(decoded.TrimStart(channel)); //return double.Parse(decoded.TrimStart(channel));
} }
+3 -3
View File
@@ -16,7 +16,7 @@ namespace ASCOM.LynxAstro.DewController
/// <summary> /// <summary>
/// Driver description that displays in the ASCOM Chooser. /// Driver description that displays in the ASCOM Chooser.
/// </summary> /// </summary>
protected static readonly string DriverDescription = "Meade Generic"; protected static readonly string DriverDescription = "LynxAstro.DewController";
protected static string ComPort; // Variables to hold the currrent device configuration protected static string ComPort; // Variables to hold the currrent device configuration
@@ -34,7 +34,7 @@ namespace ASCOM.LynxAstro.DewController
protected void Initialise(string className) protected void Initialise(string className)
{ {
Tl = new TraceLogger("", $"Meade.Generic.{className}"); Tl = new TraceLogger("", $"LynxAstro.DewController.{className}");
ReadProfile(); // Read device configuration from the ASCOM Profile store ReadProfile(); // Read device configuration from the ASCOM Profile store
@@ -78,7 +78,7 @@ namespace ASCOM.LynxAstro.DewController
{ {
get get
{ {
Tl.LogMessage("Description Get", DriverDescription); LogMessage("Description Get", DriverDescription);
return DriverDescription; return DriverDescription;
} }
} }
@@ -147,6 +147,8 @@ namespace ASCOM.LynxAstro.DewController
driverProfile.DeviceType = "Switch"; driverProfile.DeviceType = "Switch";
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
//todo write the switch names
} }
} }
} }