From a2fcaac2a90a8f1640a7c51fe7dc235d3a845f94 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 3 Sep 2020 20:28:32 +0100 Subject: [PATCH] Code inspections --- Meade.net.Telescope/Telescope.cs | 30 ++++++++++++------------ Meade.net.focuser/Focuser.cs | 12 +++++----- Meade.net/MeadeTelescopeBase.cs | 40 ++++++++++++++++---------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index a0ccfe8..6feade6 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -64,7 +64,7 @@ namespace ASCOM.Meade.net /// Initializes a new instance of the class. /// Must be public for COM registration. /// - public Telescope() : base() + public Telescope() { try { @@ -373,11 +373,11 @@ namespace ASCOM.Meade.net { ReadProfile(); - LogMessage("Connected Set", "Connecting to port {0}", _comPort); + LogMessage("Connected Set", "Connecting to port {0}", ComPort); var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl); try { - LogMessage("Connected Set", $"Connected to port {_comPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}"); + LogMessage("Connected Set", $"Connected to port {ComPort}. Product: {_sharedResourcesWrapper.ProductName} Version:{_sharedResourcesWrapper.FirmwareVersion}"); _userNewerPulseGuiding = IsNewPulseGuidingSupported(); _targetDeclination = InvalidParameter; @@ -396,7 +396,7 @@ namespace ASCOM.Meade.net if (CanSetGuideRates) { - SetNewGuideRate(_guideRate, "Connect"); + SetNewGuideRate(GuideRate, "Connect"); } SetTelescopePrecision("Connect"); @@ -417,12 +417,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", _comPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", _comPort); + LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); _sharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -431,7 +431,7 @@ namespace ASCOM.Meade.net private void SetTelescopePrecision(string propertyName) { - switch (_precision.ToLower()) + switch (Precision.ToLower()) { case "high": TelescopePointingPrecision(true); @@ -449,7 +449,7 @@ namespace ASCOM.Meade.net public bool IsNewPulseGuidingSupported() { - switch (_guidingStyle) + switch (GuidingStyle) { case "guide rate slew": return false; @@ -1181,7 +1181,7 @@ namespace ASCOM.Meade.net //info from RickB says that 15.04107 is a better value for - _guideRate = value; + GuideRate = value; WriteProfile(); } @@ -1200,8 +1200,8 @@ namespace ASCOM.Meade.net { get { - var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); - LogMessage("GuideRateDeclination Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate); + LogMessage("GuideRateDeclination Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1215,8 +1215,8 @@ namespace ASCOM.Meade.net { get { - double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); - LogMessage("GuideRateRightAscension Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate); + LogMessage("GuideRateRightAscension Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -2321,8 +2321,8 @@ namespace ASCOM.Meade.net var profileProperties = new ProfileProperties { TraceLogger = _tl.Enabled, - ComPort = _comPort, - GuideRateArcSecondsPerSecond = _guideRate + ComPort = ComPort, + GuideRateArcSecondsPerSecond = GuideRate }; _sharedResourcesWrapper.WriteProfile(profileProperties); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index 5e9f23e..b797dcd 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -48,7 +48,7 @@ namespace ASCOM.Meade.net /// Initializes a new instance of the class. /// Must be public for COM registration. /// - public Focuser() : base() + public Focuser() { //todo move this out to IOC var util = new Util(); //Initialise util object @@ -169,12 +169,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", _comPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", _comPort); + LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); _sharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -287,13 +287,13 @@ namespace ASCOM.Meade.net return; var direction = position > 0; - if (_reverseFocusDirection) + if (ReverseFocusDirection) direction = !direction; _sharedResourcesWrapper.Lock(() => { //backlash compensation. - var backlashCompensationSteps = direction ? Math.Abs(_backlashCompensation) : 0; + var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0; var steps = Math.Abs(position) + backlashCompensationSteps; @@ -317,7 +317,7 @@ namespace ASCOM.Meade.net private void DynamicBreaking(bool directionOut) { - if (!_useDynamicBreaking) + if (!UseDynamicBreaking) return; _tl.LogMessage("Move", "Applying dynamic breaking"); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index 43b0b59..f34ac52 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -19,13 +19,13 @@ namespace ASCOM.Meade.net /// protected static readonly string DriverDescription = "Meade Generic"; - protected static string _comPort; // Variables to hold the currrent device configuration - protected static int _backlashCompensation; - protected static bool _reverseFocusDirection; - protected static bool _useDynamicBreaking; - protected double _guideRate; - protected string _precision; - protected string _guidingStyle; + protected static string ComPort; // Variables to hold the currrent device configuration + protected static int BacklashCompensation; + protected static bool ReverseFocusDirection; + protected static bool UseDynamicBreaking; + protected double GuideRate; + protected string Precision; + protected string GuidingStyle; protected readonly ISharedResourcesWrapper _sharedResourcesWrapper; @@ -60,21 +60,21 @@ namespace ASCOM.Meade.net { var profileProperties = _sharedResourcesWrapper.ReadProfile(); _tl.Enabled = profileProperties.TraceLogger; - _comPort = profileProperties.ComPort; - _backlashCompensation = profileProperties.BacklashCompensation; - _reverseFocusDirection = profileProperties.ReverseFocusDirection; - _useDynamicBreaking = profileProperties.DynamicBreaking; - _guideRate = profileProperties.GuideRateArcSecondsPerSecond; - _precision = profileProperties.Precision; - _guidingStyle = profileProperties.GuidingStyle.ToLower(); + ComPort = profileProperties.ComPort; + BacklashCompensation = profileProperties.BacklashCompensation; + ReverseFocusDirection = profileProperties.ReverseFocusDirection; + UseDynamicBreaking = profileProperties.DynamicBreaking; + GuideRate = profileProperties.GuideRateArcSecondsPerSecond; + Precision = profileProperties.Precision; + GuidingStyle = profileProperties.GuidingStyle.ToLower(); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); - LogMessage("ReadProfile", $"Com Port: {_comPort}"); - LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); - LogMessage("ReadProfile", $"Dynamic breaking: {_useDynamicBreaking}"); - LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); - LogMessage("ReadProfile", $"Precision: {_precision}"); - LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}"); + LogMessage("ReadProfile", $"Com Port: {ComPort}"); + LogMessage("ReadProfile", $"Backlash Steps: {BacklashCompensation}"); + LogMessage("ReadProfile", $"Dynamic breaking: {UseDynamicBreaking}"); + LogMessage("ReadProfile", $"Guide Rate: {GuideRate}"); + LogMessage("ReadProfile", $"Precision: {Precision}"); + LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}"); } ///