Adding a catch so that when setting the precision, if one mode fails, try the other.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user