Duplicate reconcile

This commit is contained in:
2019-10-01 21:16:47 +01:00
parent babb2a7492
commit 2a56cfa700
+17 -19
View File
@@ -552,12 +552,7 @@ namespace ASCOM.Meade.net
public void SelectSite(int site) public void SelectSite(int site)
{ {
CheckConnected("SelectSite"); CheckConnectedAndValidateSite(site, "SelectSite");
if (site < 1)
throw new ArgumentOutOfRangeException(nameof(site),site,Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
if (site > 4)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
_sharedResourcesWrapper.SendBlind($"#:W{site}#"); _sharedResourcesWrapper.SendBlind($"#:W{site}#");
//:W<n># //:W<n>#
@@ -565,14 +560,21 @@ namespace ASCOM.Meade.net
//Returns: Nothing //Returns: Nothing
} }
private void SetSiteName(int site, string sitename) private void CheckConnectedAndValidateSite(int site, string message)
{ {
CheckConnected("SetSiteName"); CheckConnected(message);
if (site < 1) if (site < 1)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); throw new ArgumentOutOfRangeException(nameof(site), site,
Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
if (site > 4) if (site > 4)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); throw new ArgumentOutOfRangeException(nameof(site), site,
Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
}
private void SetSiteName(int site, string sitename)
{
CheckConnectedAndValidateSite(site, "SetSiteName");
string command = String.Empty; string command = String.Empty;
switch (site) switch (site)
@@ -609,7 +611,8 @@ namespace ASCOM.Meade.net
//0 Invalid //0 Invalid
//1 - Valid //1 - Valid
break; break;
default:
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range);
} }
var result = _sharedResourcesWrapper.SendChar(command); var result = _sharedResourcesWrapper.SendChar(command);
@@ -621,12 +624,7 @@ namespace ASCOM.Meade.net
private string GetSiteName(int site) private string GetSiteName(int site)
{ {
CheckConnected("GetSiteName"); CheckConnectedAndValidateSite(site, "GetSiteName");
if (site < 1)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1);
if (site > 4)
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4);
switch (site) switch (site)
{ {
@@ -650,10 +648,10 @@ namespace ASCOM.Meade.net
//:GP# Get Site 4 Name //:GP# Get Site 4 Name
//Returns: <string># //Returns: <string>#
//A # terminated string with the name of the requested site. //A # terminated string with the name of the requested site.
} default:
throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range); throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range);
} }
}
public string Description public string Description
{ {