Adding a catch so that when setting the precision, if one mode fails, try the other.

This commit is contained in:
2022-11-10 16:53:27 +00:00
parent 129fc23d83
commit cfa7e1d1cf
+24 -9
View File
@@ -3424,7 +3424,29 @@ namespace ASCOM.Meade.net
if (value < -90)
throw new InvalidValueException("Declination cannot be less than -90.");
var dms = SharedResourcesWrapper.IsLongFormat
string dms;
try
{
dms = SetTargetDeslination(value, SharedResourcesWrapper.IsLongFormat);
}
catch (InvalidOperationException)
{
dms = SetTargetDeslination(value, !SharedResourcesWrapper.IsLongFormat);
}
SharedResourcesWrapper.TargetDeclination = _utilities.DMSToDegrees(dms);
}
catch (Exception ex)
{
LogMessage("TargetDeclination Set", $"Error: {ex.Message}");
throw;
}
}
}
private string SetTargetDeslination(double value, bool useLongFormat)
{
var dms = useLongFormat
? _utilities.DegreesToDMS(value, "*", ":", ":", _digitsDe)
: _utilities.DegreesToDM(value, "*", "", _digitsDe);
@@ -3445,14 +3467,7 @@ namespace ASCOM.Meade.net
throw new InvalidOperationException("Target declination invalid");
}
SharedResourcesWrapper.TargetDeclination = _utilities.DMSToDegrees(dms);
}
catch (Exception ex)
{
LogMessage("TargetDeclination Set", $"Error: {ex.Message}");
throw;
}
}
return dms;
}
public double TargetRightAscension