Code inspections

This commit is contained in:
2020-09-03 20:28:32 +01:00
parent da4e4fd81a
commit a2fcaac2a9
3 changed files with 41 additions and 41 deletions
+15 -15
View File
@@ -64,7 +64,7 @@ namespace ASCOM.Meade.net
/// Initializes a new instance of the <see cref="Meade.net"/> class. /// Initializes a new instance of the <see cref="Meade.net"/> class.
/// Must be public for COM registration. /// Must be public for COM registration.
/// </summary> /// </summary>
public Telescope() : base() public Telescope()
{ {
try try
{ {
@@ -373,11 +373,11 @@ namespace ASCOM.Meade.net
{ {
ReadProfile(); ReadProfile();
LogMessage("Connected Set", "Connecting to port {0}", _comPort); LogMessage("Connected Set", "Connecting to port {0}", ComPort);
var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl); var connectionInfo = _sharedResourcesWrapper.Connect("Serial", DriverId, _tl);
try 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(); _userNewerPulseGuiding = IsNewPulseGuidingSupported();
_targetDeclination = InvalidParameter; _targetDeclination = InvalidParameter;
@@ -396,7 +396,7 @@ namespace ASCOM.Meade.net
if (CanSetGuideRates) if (CanSetGuideRates)
{ {
SetNewGuideRate(_guideRate, "Connect"); SetNewGuideRate(GuideRate, "Connect");
} }
SetTelescopePrecision("Connect"); SetTelescopePrecision("Connect");
@@ -417,12 +417,12 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) 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 else
{ {
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort); LogMessage("Connected Set", "Disconnecting from port {0}", ComPort);
_sharedResourcesWrapper.Disconnect("Serial", DriverId); _sharedResourcesWrapper.Disconnect("Serial", DriverId);
IsConnected = false; IsConnected = false;
} }
@@ -431,7 +431,7 @@ namespace ASCOM.Meade.net
private void SetTelescopePrecision(string propertyName) private void SetTelescopePrecision(string propertyName)
{ {
switch (_precision.ToLower()) switch (Precision.ToLower())
{ {
case "high": case "high":
TelescopePointingPrecision(true); TelescopePointingPrecision(true);
@@ -449,7 +449,7 @@ namespace ASCOM.Meade.net
public bool IsNewPulseGuidingSupported() public bool IsNewPulseGuidingSupported()
{ {
switch (_guidingStyle) switch (GuidingStyle)
{ {
case "guide rate slew": case "guide rate slew":
return false; return false;
@@ -1181,7 +1181,7 @@ namespace ASCOM.Meade.net
//info from RickB says that 15.04107 is a better value for //info from RickB says that 15.04107 is a better value for
_guideRate = value; GuideRate = value;
WriteProfile(); WriteProfile();
} }
@@ -1200,8 +1200,8 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate);
LogMessage("GuideRateDeclination Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); LogMessage("GuideRateDeclination Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second");
return degreesPerSecond; return degreesPerSecond;
} }
set set
@@ -1215,8 +1215,8 @@ namespace ASCOM.Meade.net
{ {
get get
{ {
double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_guideRate); double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate);
LogMessage("GuideRateRightAscension Get", $"{_guideRate} arc seconds / second = {degreesPerSecond} degrees per second"); LogMessage("GuideRateRightAscension Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second");
return degreesPerSecond; return degreesPerSecond;
} }
set set
@@ -2321,8 +2321,8 @@ namespace ASCOM.Meade.net
var profileProperties = new ProfileProperties var profileProperties = new ProfileProperties
{ {
TraceLogger = _tl.Enabled, TraceLogger = _tl.Enabled,
ComPort = _comPort, ComPort = ComPort,
GuideRateArcSecondsPerSecond = _guideRate GuideRateArcSecondsPerSecond = GuideRate
}; };
_sharedResourcesWrapper.WriteProfile(profileProperties); _sharedResourcesWrapper.WriteProfile(profileProperties);
+6 -6
View File
@@ -48,7 +48,7 @@ namespace ASCOM.Meade.net
/// Initializes a new instance of the <see cref="Meade.net"/> class. /// Initializes a new instance of the <see cref="Meade.net"/> class.
/// Must be public for COM registration. /// Must be public for COM registration.
/// </summary> /// </summary>
public Focuser() : base() public Focuser()
{ {
//todo move this out to IOC //todo move this out to IOC
var util = new Util(); //Initialise util object var util = new Util(); //Initialise util object
@@ -169,12 +169,12 @@ namespace ASCOM.Meade.net
} }
catch (Exception ex) 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 else
{ {
LogMessage("Connected Set", "Disconnecting from port {0}", _comPort); LogMessage("Connected Set", "Disconnecting from port {0}", ComPort);
_sharedResourcesWrapper.Disconnect("Serial", DriverId); _sharedResourcesWrapper.Disconnect("Serial", DriverId);
IsConnected = false; IsConnected = false;
} }
@@ -287,13 +287,13 @@ namespace ASCOM.Meade.net
return; return;
var direction = position > 0; var direction = position > 0;
if (_reverseFocusDirection) if (ReverseFocusDirection)
direction = !direction; direction = !direction;
_sharedResourcesWrapper.Lock(() => _sharedResourcesWrapper.Lock(() =>
{ {
//backlash compensation. //backlash compensation.
var backlashCompensationSteps = direction ? Math.Abs(_backlashCompensation) : 0; var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0;
var steps = Math.Abs(position) + backlashCompensationSteps; var steps = Math.Abs(position) + backlashCompensationSteps;
@@ -317,7 +317,7 @@ namespace ASCOM.Meade.net
private void DynamicBreaking(bool directionOut) private void DynamicBreaking(bool directionOut)
{ {
if (!_useDynamicBreaking) if (!UseDynamicBreaking)
return; return;
_tl.LogMessage("Move", "Applying dynamic breaking"); _tl.LogMessage("Move", "Applying dynamic breaking");
+20 -20
View File
@@ -19,13 +19,13 @@ namespace ASCOM.Meade.net
/// </summary> /// </summary>
protected static readonly string DriverDescription = "Meade Generic"; protected static readonly string DriverDescription = "Meade Generic";
protected static string _comPort; // Variables to hold the currrent device configuration protected static string ComPort; // Variables to hold the currrent device configuration
protected static int _backlashCompensation; protected static int BacklashCompensation;
protected static bool _reverseFocusDirection; protected static bool ReverseFocusDirection;
protected static bool _useDynamicBreaking; protected static bool UseDynamicBreaking;
protected double _guideRate; protected double GuideRate;
protected string _precision; protected string Precision;
protected string _guidingStyle; protected string GuidingStyle;
protected readonly ISharedResourcesWrapper _sharedResourcesWrapper; protected readonly ISharedResourcesWrapper _sharedResourcesWrapper;
@@ -60,21 +60,21 @@ namespace ASCOM.Meade.net
{ {
var profileProperties = _sharedResourcesWrapper.ReadProfile(); var profileProperties = _sharedResourcesWrapper.ReadProfile();
_tl.Enabled = profileProperties.TraceLogger; _tl.Enabled = profileProperties.TraceLogger;
_comPort = profileProperties.ComPort; ComPort = profileProperties.ComPort;
_backlashCompensation = profileProperties.BacklashCompensation; BacklashCompensation = profileProperties.BacklashCompensation;
_reverseFocusDirection = profileProperties.ReverseFocusDirection; ReverseFocusDirection = profileProperties.ReverseFocusDirection;
_useDynamicBreaking = profileProperties.DynamicBreaking; UseDynamicBreaking = profileProperties.DynamicBreaking;
_guideRate = profileProperties.GuideRateArcSecondsPerSecond; GuideRate = profileProperties.GuideRateArcSecondsPerSecond;
_precision = profileProperties.Precision; Precision = profileProperties.Precision;
_guidingStyle = profileProperties.GuidingStyle.ToLower(); GuidingStyle = profileProperties.GuidingStyle.ToLower();
LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}"); LogMessage("ReadProfile", $"Trace logger enabled: {_tl.Enabled}");
LogMessage("ReadProfile", $"Com Port: {_comPort}"); LogMessage("ReadProfile", $"Com Port: {ComPort}");
LogMessage("ReadProfile", $"Backlash Steps: {_backlashCompensation}"); LogMessage("ReadProfile", $"Backlash Steps: {BacklashCompensation}");
LogMessage("ReadProfile", $"Dynamic breaking: {_useDynamicBreaking}"); LogMessage("ReadProfile", $"Dynamic breaking: {UseDynamicBreaking}");
LogMessage("ReadProfile", $"Guide Rate: {_guideRate}"); LogMessage("ReadProfile", $"Guide Rate: {GuideRate}");
LogMessage("ReadProfile", $"Precision: {_precision}"); LogMessage("ReadProfile", $"Precision: {Precision}");
LogMessage("ReadProfile", $"Guiding Style: {_guidingStyle}"); LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}");
} }
/// <summary> /// <summary>