diff --git a/LynxAstro.DewController.Switch/Switch.cs b/LynxAstro.DewController.Switch/Switch.cs index 35573e3..82bf5a4 100644 --- a/LynxAstro.DewController.Switch/Switch.cs +++ b/LynxAstro.DewController.Switch/Switch.cs @@ -74,7 +74,7 @@ namespace ASCOM.LynxAstro.DewController { get { - Tl.LogMessage("SupportedActions Get", "Returning empty arraylist"); + LogMessage("SupportedActions Get", "Returning empty arraylist"); return new ArrayList(); } } @@ -183,7 +183,7 @@ namespace ASCOM.LynxAstro.DewController get { string name = "LynxAstro.DewController"; - Tl.LogMessage("Name Get", name); + LogMessage("Name Get", 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. //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; } } @@ -230,7 +230,10 @@ namespace ASCOM.LynxAstro.DewController Validate("GetSwitchName", id); ReadProfile(); - return switchNames.Count > id ? switchNames[id] : string.Empty; + var switchName = switchNames.Count > id ? switchNames[id] : string.Empty; + + LogMessage("GetSwitchName", $"{id}: {switchName}"); + return switchName; } /// @@ -246,6 +249,8 @@ namespace ASCOM.LynxAstro.DewController while (id > switchNames.Count) switchNames.Add(string.Empty); + + LogMessage("SetSwitchName", $"{id}: \"{switchNames[id]}\" to \"{name}\""); switchNames[id] = name; WriteSwitchNames(); @@ -259,7 +264,11 @@ namespace ASCOM.LynxAstro.DewController public string GetSwitchDescription(short id) { Validate("GetSwitchDescription", id); - return $"Channel {ChannelToLetter(id)}"; + + var channel= $"Channel {ChannelToLetter(id)}"; + + LogMessage("GetSwitchDescription", channel); + return channel; } /// @@ -276,7 +285,8 @@ namespace ASCOM.LynxAstro.DewController { Validate("CanWrite", id); // default behavour is to report true - Tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - default true", id)); + + LogMessage("CanWrite", $"CanWrite({id}) - default true"); return true; // implementation should report the correct behaviour //tl.LogMessage("CanWrite", string.Format("CanWrite({0}) - not implemented", id)); @@ -296,7 +306,11 @@ namespace ASCOM.LynxAstro.DewController public bool GetSwitch(short id) { var value = GetSwitchValue(id); - return value > 0; + + var switchIsOn = value > 0; + + LogMessage("GetSwitch", $"{id}: {switchIsOn} ({value})"); + return switchIsOn; } /// @@ -316,7 +330,11 @@ namespace ASCOM.LynxAstro.DewController Tl.LogMessage("SetSwitch", str); throw new MethodNotImplementedException(str); } - SetSwitchValue(id, state ? 1023 : 0); + + var switchIsOn = state ? 1023 : 0; + + LogMessage("SetSwitch", $"{id}: {state} ({switchIsOn})"); + SetSwitchValue(id, switchIsOn); } #endregion @@ -389,6 +407,8 @@ namespace ASCOM.LynxAstro.DewController var encoded = SharedResourcesWrapper.SendString($":GC{channel}#"); var decoded = DecodeResult(":GC", encoded); + LogMessage("GetSwitchValue", $"{id}: {channel} - {decoded}"); + return double.Parse(decoded.TrimStart(channel)); //Command: :GCX# where X is the channel A, B, C or D to retrieve. //Purpose: Get the current power setting for a specific channel. @@ -431,8 +451,10 @@ namespace ASCOM.LynxAstro.DewController //Possible Errors //:ER4# = Not enough data received - make sure you zero pad the power level. //:ER5# = Channel or power level out of range, e.g. channel B on a 1 channel device or power above 1023. - - var channel = ChannelToLetter(id); + + var channel = ChannelToLetter(id); + + LogMessage("SetSwitchValue", $"{id}: {channel} - {value}"); var encoded = SharedResourcesWrapper.SendString($":SC{channel}{value:0000}#"); var decoded = DecodeResult(":SC", encoded); @@ -441,6 +463,7 @@ namespace ASCOM.LynxAstro.DewController { throw new InvalidValueException($"Unable to set switch {{id}} to value {value}"); } + //return double.Parse(decoded.TrimStart(channel)); } diff --git a/LynxAstro.DewController/AscomDriverBase.cs b/LynxAstro.DewController/AscomDriverBase.cs index 3330a33..e8b2ed2 100644 --- a/LynxAstro.DewController/AscomDriverBase.cs +++ b/LynxAstro.DewController/AscomDriverBase.cs @@ -16,7 +16,7 @@ namespace ASCOM.LynxAstro.DewController /// /// Driver description that displays in the ASCOM Chooser. /// - 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 @@ -34,7 +34,7 @@ namespace ASCOM.LynxAstro.DewController 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 @@ -78,7 +78,7 @@ namespace ASCOM.LynxAstro.DewController { get { - Tl.LogMessage("Description Get", DriverDescription); + LogMessage("Description Get", DriverDescription); return DriverDescription; } } diff --git a/LynxAstro.DewController/SharedResources.cs b/LynxAstro.DewController/SharedResources.cs index 51cd224..06b0193 100644 --- a/LynxAstro.DewController/SharedResources.cs +++ b/LynxAstro.DewController/SharedResources.cs @@ -147,6 +147,8 @@ namespace ASCOM.LynxAstro.DewController driverProfile.DeviceType = "Switch"; driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); + + //todo write the switch names } } }