Code inspection cleanup

This commit is contained in:
2019-09-28 22:20:21 +01:00
parent b962420b94
commit e782ac36fb
15 changed files with 184 additions and 187 deletions
+5 -4
View File
@@ -9,7 +9,7 @@ namespace ASCOM.Meade.net.AstroMaths
//returns the decimal hour angle for given right ascension on a given datetime for a given logitude.
public double RightAscensionToHourAngle(DateTime utcDateTime, double longitude, double rightAscension)
{
var ut = DateTimeToDecimalHours( utcDateTime);
//var ut = DateTimeToDecimalHours( utcDateTime);
var gst = UTtoGst( utcDateTime);
var lst = GsTtoLst( gst, longitude);
var raHours = rightAscension;
@@ -82,10 +82,11 @@ namespace ASCOM.Meade.net.AstroMaths
var upperA = Math.Atan2(y, x);
var upperB = RadiansToDegrees(upperA);
var horizonCoordinates = new HorizonCoordinates();
horizonCoordinates.Altitude = RadiansToDegrees(Math.Asin(sinA));
var horizonCoordinates = new HorizonCoordinates
{
Altitude = RadiansToDegrees(Math.Asin(sinA)), Azimuth = upperB
};
horizonCoordinates.Azimuth = upperB;
if (upperB < 0)
{
+14 -18
View File
@@ -19,17 +19,14 @@ namespace ASCOM.Meade.net
[ComVisible(true)]
public class Rate : IRate
{
private double _maximum = 0;
private double _minimum = 0;
//
// Default constructor - Internal prevents public creation
// of instances. These are values for AxisRates.
//
internal Rate(double minimum, double maximum)
{
_maximum = maximum;
_minimum = minimum;
Maximum = maximum;
Minimum = minimum;
}
#region Implementation of IRate
@@ -39,17 +36,9 @@ namespace ASCOM.Meade.net
// TODO Add any required object cleanup here
}
public double Maximum
{
get => _maximum;
set => _maximum = value;
}
public double Maximum { get; set; }
public double Minimum
{
get => _minimum;
set => _minimum = value;
}
public double Minimum { get; set; }
#endregion
}
@@ -152,7 +141,7 @@ namespace ASCOM.Meade.net
private readonly DriveRates[] _trackingRates;
// this is used to make the index thread safe
private readonly ThreadLocal<int> _pos = new ThreadLocal<int>(() => { return -1; });
private readonly ThreadLocal<int> _pos = new ThreadLocal<int>(() => -1);
private static readonly object LockObj = new object();
//
@@ -176,7 +165,11 @@ namespace ASCOM.Meade.net
public IEnumerator GetEnumerator()
{
_pos.Value = -1;
lock (LockObj)
{
_pos.Value = -1;
}
return this as IEnumerator;
}
@@ -220,7 +213,10 @@ namespace ASCOM.Meade.net
public void Reset()
{
_pos.Value = -1;
lock (LockObj)
{
_pos.Value = -1;
}
}
#endregion
}
+27 -31
View File
@@ -98,9 +98,7 @@ namespace ASCOM.Meade.net
}
private double _guideRate;
private const double SIDRATE = 0.9972695677; //synodic/solar seconds per sidereal second
private void Initialise()
{
//todo move the TraceLogger out to a factory class.
@@ -152,9 +150,7 @@ namespace ASCOM.Meade.net
get
{
LogMessage("SupportedActions Get", "Returning empty arraylist");
var supportedActions = new ArrayList();
supportedActions.Add("handbox");
supportedActions.Add("site");
var supportedActions = new ArrayList {"handbox", "site"};
return supportedActions;
}
}
@@ -540,9 +536,9 @@ namespace ASCOM.Meade.net
CheckConnected("SelectSite");
if (site < 1)
throw new ArgumentOutOfRangeException("site",site,"Site cannot be lower than 1");
throw new ArgumentOutOfRangeException(nameof(site),site,"Site cannot be lower than 1");
else if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4");
_sharedResourcesWrapper.SendBlind($":W{site}#");
//:W<n>#
@@ -555,9 +551,9 @@ namespace ASCOM.Meade.net
CheckConnected("SetSiteName");
if (site < 1)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1");
else if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4");
string command = String.Empty;
switch (site)
@@ -609,9 +605,9 @@ namespace ASCOM.Meade.net
CheckConnected("GetSiteName");
if (site < 1)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be lower than 1");
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1");
else if (site > 4)
throw new ArgumentOutOfRangeException("site", site, "Site cannot be higher than 4");
throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4");
switch (site)
{
@@ -637,7 +633,7 @@ namespace ASCOM.Meade.net
//A # terminated string with the name of the requested site.
}
throw new ArgumentOutOfRangeException("site", site, "Site out of range");
throw new ArgumentOutOfRangeException(nameof(site), site, "Site out of range");
}
public string Description
@@ -874,7 +870,7 @@ namespace ASCOM.Meade.net
}
}
private bool _atPark = false;
private bool _atPark;
public bool AtPark
{
@@ -1162,10 +1158,10 @@ namespace ASCOM.Meade.net
if (!value.InRange(0, 15.0417))
{
throw new InvalidValueException(propertyName, value.ToString(), "0 to 15.0417”/sec");
throw new InvalidValueException(propertyName, value.ToString(CultureInfo.CurrentCulture), $"{0.ToString(CultureInfo.CurrentCulture)} to {15.0417.ToString(CultureInfo.CurrentCulture)}”/sec");
}
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString()} arc seconds/second ({value.ToString()} degrees/second)");
LogMessage($"{propertyName} Set", $"Setting new guiderate {value.ToString(CultureInfo.CurrentCulture)} arc seconds/second ({value.ToString(CultureInfo.CurrentCulture)} degrees/second)");
_sharedResourcesWrapper.SendBlind($":Rg{value:00.0}#");
//:RgSS.S#
//Set guide rate to +/ -SS.S to arc seconds per second.This rate is added to or subtracted from the current tracking
@@ -1708,10 +1704,8 @@ namespace ASCOM.Meade.net
throw new InvalidValueException("Azimuth cannot be less than 0.");
LogMessage("SlewToAltAzAsync", $"Az={azimuth} Alt={altitude}");
HorizonCoordinates altAz = new HorizonCoordinates();
altAz.Azimuth = azimuth;
altAz.Altitude = altitude;
HorizonCoordinates altAz = new HorizonCoordinates {Azimuth = azimuth, Altitude = altitude};
var utcDateTime = UTCDate;
var latitude = SiteLatitude;
@@ -2128,18 +2122,20 @@ namespace ASCOM.Meade.net
LogMessage("UTCDate", "Get started");
TelescopeDateDetails telescopeDateDetails = _sharedResourcesWrapper.Lock(() =>
var telescopeDateDetails = _sharedResourcesWrapper.Lock(() =>
{
TelescopeDateDetails tdd = new TelescopeDateDetails();
tdd.TelescopeDate = _sharedResourcesWrapper.SendString(":GC#");
//:GC# Get current date.
//Returns: MM/DD/YY#
//The current local calendar date for the telescope.
tdd.TelescopeTime = _sharedResourcesWrapper.SendString(":GL#");
//:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS#
//The Local Time in 24 - hour Format
tdd.UtcCorrection = GetUtcCorrection();
var tdd = new TelescopeDateDetails
{
TelescopeDate = _sharedResourcesWrapper.SendString(":GC#"),
//:GC# Get current date.
//Returns: MM/DD/YY#
//The current local calendar date for the telescope.
TelescopeTime = _sharedResourcesWrapper.SendString(":GL#"),
//:GL# Get Local Time in 24 hour format
//Returns: HH:MM:SS#
//The Local Time in 24 - hour Format
UtcCorrection = GetUtcCorrection()
};
return tdd;
});