From 2cbb1fb68c8d456be209a34927092872a1284ae3 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 22 Oct 2019 21:51:59 +0100 Subject: [PATCH] Code inspection cleanup --- Meade.net.Telescope/Telescope.cs | 30 ------- .../Properties/AssemblyInfo.cs | 1 - .../SharedResourcesUnitTests.cs | 15 ++-- Meade.net/ProfileFactory.cs | 1 - Meade.net/Wrapper/IProfileWrapper.cs | 80 +++++++++---------- TelescopeTestConsole/Program.cs | 14 ++-- 6 files changed, 54 insertions(+), 87 deletions(-) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 7dab9c8..c77994f 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1417,7 +1417,6 @@ namespace ASCOM.Meade.net } else { - string d = string.Empty; switch (direction) { case GuideDirections.guideEast: @@ -1441,35 +1440,6 @@ namespace ASCOM.Meade.net MoveAxis(TelescopeAxes.axisPrimary, 0); break; } - - - - //LogMessage("PulseGuide", "Using old pulse guiding technique"); - //_sharedResourcesWrapper.Lock(() => - //{ - // _sharedResourcesWrapper.SendBlind("#:RG#"); //Make sure we are at guide rate - // //:RG# Set Slew rate to Guiding Rate (slowest) - // //Returns: Nothing - // _sharedResourcesWrapper.SendBlind($"#:M{d}#"); - // //:Me# Move Telescope East at current slew rate - // //Returns: Nothing - // //:Mn# Move Telescope North at current slew rate - // //Returns: Nothing - // //:Ms# Move Telescope South at current slew rate - // //Returns: Nothing - // //:Mw# Move Telescope West at current slew rate - // //Returns: Nothing - // _utilities.WaitForMilliseconds(duration); - // _sharedResourcesWrapper.SendBlind($"#:Q{d}#"); - // //:Qe# Halt eastward Slews - // //Returns: Nothing - // //:Qn# Halt northward Slews - // //Returns: Nothing - // //:Qs# Halt southward Slews - // //Returns: Nothing - // //:Qw# Halt westward Slews - // //Returns: Nothing - //}); } var coordinatesAfterMove = GetTelescopeRaAndDec(); diff --git a/Meade.net.UnitTests/Properties/AssemblyInfo.cs b/Meade.net.UnitTests/Properties/AssemblyInfo.cs index 104173b..b8cda0e 100644 --- a/Meade.net.UnitTests/Properties/AssemblyInfo.cs +++ b/Meade.net.UnitTests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 13c040f..5710088 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -110,10 +110,11 @@ namespace Meade.net.UnitTests SharedResources.ProfileFactory = profileFactoryMock.Object; - var profileProperties = new ProfileProperties(); - profileProperties.TraceLogger = false; - profileProperties.ComPort = "TestComPort"; - + var profileProperties = new ProfileProperties + { + TraceLogger = false, + ComPort = "TestComPort" + }; SharedResources.WriteProfile(profileProperties); @@ -246,10 +247,8 @@ namespace Meade.net.UnitTests SharedResources.ProfileFactory = profileFactoryMock.Object; - string serialPortReturn = string.Empty; - - _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { serialPortReturn = ":GVP#"; }); - _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => { throw new Exception("Testerror"); }); + _serialMock.Setup(x => x.Transmit(":GVP#")).Callback(() => { }); + _serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => throw new Exception("Testerror")); var connectionResult = SharedResources.Connect(deviceId, string.Empty); diff --git a/Meade.net/ProfileFactory.cs b/Meade.net/ProfileFactory.cs index b80935f..8302324 100644 --- a/Meade.net/ProfileFactory.cs +++ b/Meade.net/ProfileFactory.cs @@ -1,5 +1,4 @@ using ASCOM.Meade.net.Wrapper; -using ASCOM.Utilities; namespace ASCOM.Meade.net { diff --git a/Meade.net/Wrapper/IProfileWrapper.cs b/Meade.net/Wrapper/IProfileWrapper.cs index f9b274a..ae9d434 100644 --- a/Meade.net/Wrapper/IProfileWrapper.cs +++ b/Meade.net/Wrapper/IProfileWrapper.cs @@ -14,59 +14,59 @@ namespace ASCOM.Meade.net.Wrapper { private readonly Profile _profile = new Profile(); - public ArrayList RegisteredDevices(string DeviceType) + public ArrayList RegisteredDevices(string deviceType) { - return _profile.RegisteredDevices(DeviceType); + return _profile.RegisteredDevices(deviceType); } - public bool IsRegistered(string DriverID) + public bool IsRegistered(string driverId) { - return _profile.IsRegistered(DriverID); + return _profile.IsRegistered(driverId); } - public void Register(string DriverID, string DescriptiveName) + public void Register(string driverId, string descriptiveName) { - _profile.Register(DriverID, DescriptiveName); + _profile.Register(driverId, descriptiveName); } - public void Unregister(string DriverID) + public void Unregister(string driverId) { - _profile.Unregister(DriverID); + _profile.Unregister(driverId); } - public string GetValue(string DriverID, string Name, string SubKey, string DefaultValue) + public string GetValue(string driverId, string name, string subKey, string defaultValue) { - return _profile.GetValue(DriverID, Name, SubKey, DefaultValue); + return _profile.GetValue(driverId, name, subKey, defaultValue); } - public void WriteValue(string DriverID, string Name, string Value, string SubKey) + public void WriteValue(string driverId, string name, string value, string subKey) { - _profile.WriteValue(DriverID, Name, Value); + _profile.WriteValue(driverId, name, value); } - public ArrayList Values(string DriverID, string SubKey) + public ArrayList Values(string driverId, string subKey) { - return _profile.Values(DriverID, SubKey); + return _profile.Values(driverId, subKey); } - public void DeleteValue(string DriverID, string Name, string SubKey) + public void DeleteValue(string driverId, string name, string subKey) { - _profile.DeleteValue(DriverID, Name, SubKey); + _profile.DeleteValue(driverId, name, subKey); } - public void CreateSubKey(string DriverID, string SubKey) + public void CreateSubKey(string driverId, string subKey) { - _profile.CreateSubKey(DriverID, SubKey); + _profile.CreateSubKey(driverId, subKey); } - public ArrayList SubKeys(string DriverID, string SubKey) + public ArrayList SubKeys(string driverId, string subKey) { - return _profile.SubKeys(DriverID, SubKey); + return _profile.SubKeys(driverId, subKey); } - public void DeleteSubKey(string DriverID, string SubKey) + public void DeleteSubKey(string driverId, string subKey) { - _profile.DeleteSubKey(DriverID, SubKey); + _profile.DeleteSubKey(driverId, subKey); } public string GetProfileXML(string deviceId) @@ -86,49 +86,49 @@ namespace ASCOM.Meade.net.Wrapper } public ArrayList RegisteredDeviceTypes => _profile.RegisteredDeviceTypes; - public void MigrateProfile(string CurrentPlatformVersion) + public void MigrateProfile(string currentPlatformVersion) { - _profile.MigrateProfile(CurrentPlatformVersion); + _profile.MigrateProfile(currentPlatformVersion); } - public void DeleteValue(string DriverID, string Name) + public void DeleteValue(string driverId, string name) { - _profile.DeleteValue(DriverID, Name); + _profile.DeleteValue(driverId, name); } - public string GetValue(string DriverID, string Name) + public string GetValue(string driverId, string name) { - return _profile.GetValue(DriverID, Name); + return _profile.GetValue(driverId, name); } - public string GetValue(string DriverID, string Name, string SubKey) + public string GetValue(string driverId, string name, string subKey) { - return _profile.GetValue(DriverID, Name, SubKey); + return _profile.GetValue(driverId, name, subKey); } - public ArrayList SubKeys(string DriverID) + public ArrayList SubKeys(string driverId) { - return _profile.SubKeys(DriverID); + return _profile.SubKeys(driverId); } - public ArrayList Values(string DriverID) + public ArrayList Values(string driverId) { - return _profile.Values(DriverID); + return _profile.Values(driverId); } - public void WriteValue(string DriverID, string Name, string Value) + public void WriteValue(string driverId, string name, string value) { - _profile.WriteValue(DriverID, Name, Value); + _profile.WriteValue(driverId, name, value); } - public ASCOMProfile GetProfile(string DriverId) + public ASCOMProfile GetProfile(string driverId) { - return _profile.GetProfile(DriverId); + return _profile.GetProfile(driverId); } - public void SetProfile(string DriverId, ASCOMProfile XmlProfileKey) + public void SetProfile(string driverId, ASCOMProfile xmlProfileKey) { - _profile.SetProfile(DriverId, XmlProfileKey); + _profile.SetProfile(driverId, xmlProfileKey); } public void Dispose() diff --git a/TelescopeTestConsole/Program.cs b/TelescopeTestConsole/Program.cs index 7b8c2d5..be621ea 100644 --- a/TelescopeTestConsole/Program.cs +++ b/TelescopeTestConsole/Program.cs @@ -58,26 +58,26 @@ namespace ASCOM.Meade.net var seconds = 10; - Console.WriteLine($"Slewing tests 10 second in each direction"); - Console.WriteLine($"test 1"); + Console.WriteLine("Slewing tests 10 second in each direction"); + Console.WriteLine("test 1"); device.MoveAxis(TelescopeAxes.axisPrimary, 4); Thread.Sleep(seconds * 1000); device.MoveAxis(TelescopeAxes.axisPrimary, 0); - Console.WriteLine($"test 2"); + Console.WriteLine("test 2"); device.MoveAxis(TelescopeAxes.axisPrimary, -4); Thread.Sleep(seconds * 1000); device.MoveAxis(TelescopeAxes.axisPrimary, 0); - Console.WriteLine($"test 3"); + Console.WriteLine("test 3"); device.MoveAxis(TelescopeAxes.axisSecondary, 4); Thread.Sleep(seconds * 1000); device.MoveAxis(TelescopeAxes.axisSecondary, 0); - Console.WriteLine($"test 4"); + Console.WriteLine("test 4"); device.MoveAxis(TelescopeAxes.axisSecondary, -4); Thread.Sleep(seconds * 1000); device.MoveAxis(TelescopeAxes.axisSecondary, 0); - Console.WriteLine($"Slewing tests complete"); + Console.WriteLine("Slewing tests complete"); seconds = 120; @@ -89,7 +89,7 @@ namespace ASCOM.Meade.net Console.WriteLine($"{direction.ToString()}"); device.PulseGuide(direction, seconds* 1000); } - Console.WriteLine($"Guiding Finished"); + Console.WriteLine("Guiding Finished");