Added attempt to set the TargetRightAscension using the other format if one fails.

This commit is contained in:
2022-11-10 14:34:10 +00:00
parent e851fd0e01
commit 1e5bb04817
+24 -10
View File
@@ -3496,7 +3496,29 @@ namespace ASCOM.Meade.net
if (value >= 24)
throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59");
var hms = SharedResourcesWrapper.IsLongFormat
string hms;
try
{
hms = SetTargetRightAscension(value, SharedResourcesWrapper.IsLongFormat);
}
catch(InvalidOperationException)
{
hms = SetTargetRightAscension(value, !SharedResourcesWrapper.IsLongFormat);
}
SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms);
}
catch (Exception ex)
{
LogMessage("TargetRightAscension Set", $"Error: {ex.Message}");
throw;
}
}
}
private string SetTargetRightAscension(double value, bool useLongFormat)
{
var hms = useLongFormat
? _utilities.HoursToHMS(value, ":", ":", ":", _digitsRa)
: _utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',', '.');
@@ -3512,15 +3534,7 @@ namespace ASCOM.Meade.net
if (response == "0")
throw new InvalidOperationException("Failed to set TargetRightAscension.");
SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms);
}
catch (Exception ex)
{
LogMessage("TargetRightAscension Set", $"Error: {ex.Message}");
throw;
}
}
return hms;
}
public bool Tracking