Added attempt to set the TargetRightAscension using the other format if one fails.
This commit is contained in:
@@ -3496,7 +3496,29 @@ namespace ASCOM.Meade.net
|
|||||||
if (value >= 24)
|
if (value >= 24)
|
||||||
throw new InvalidValueException("Right ascension value cannot be greater than 23:59:59");
|
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.HoursToHMS(value, ":", ":", ":", _digitsRa)
|
||||||
: _utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',', '.');
|
: _utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',', '.');
|
||||||
|
|
||||||
@@ -3512,15 +3534,7 @@ namespace ASCOM.Meade.net
|
|||||||
|
|
||||||
if (response == "0")
|
if (response == "0")
|
||||||
throw new InvalidOperationException("Failed to set TargetRightAscension.");
|
throw new InvalidOperationException("Failed to set TargetRightAscension.");
|
||||||
|
return hms;
|
||||||
SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogMessage("TargetRightAscension Set", $"Error: {ex.Message}");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Tracking
|
public bool Tracking
|
||||||
|
|||||||
Reference in New Issue
Block a user