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
+30 -16
View File
@@ -3496,22 +3496,15 @@ 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;
? _utilities.HoursToHMS(value, ":", ":", ":", _digitsRa) try
: _utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',', '.'); {
hms = SetTargetRightAscension(value, SharedResourcesWrapper.IsLongFormat);
var command = $"Sr{hms}"; }
LogMessage("TargetRightAscension Set", $"{command}"); catch(InvalidOperationException)
var response = SharedResourcesWrapper.SendChar(Tl, command); {
//:SrHH:MM.T# hms = SetTargetRightAscension(value, !SharedResourcesWrapper.IsLongFormat);
//:SrHH:MM:SS# }
//Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting.
// Returns:
//0 - Invalid
//1 - Valid
if (response == "0")
throw new InvalidOperationException("Failed to set TargetRightAscension.");
SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms); SharedResourcesWrapper.TargetRightAscension = _utilities.HMSToHours(hms);
} }
@@ -3523,6 +3516,27 @@ namespace ASCOM.Meade.net
} }
} }
private string SetTargetRightAscension(double value, bool useLongFormat)
{
var hms = useLongFormat
? _utilities.HoursToHMS(value, ":", ":", ":", _digitsRa)
: _utilities.HoursToHM(value, ":", "", _digitsRa).Replace(',', '.');
var command = $"Sr{hms}";
LogMessage("TargetRightAscension Set", $"{command}");
var response = SharedResourcesWrapper.SendChar(Tl, command);
//:SrHH:MM.T#
//:SrHH:MM:SS#
//Set target object RA to HH:MM.T or HH: MM: SS depending on the current precision setting.
// Returns:
//0 - Invalid
//1 - Valid
if (response == "0")
throw new InvalidOperationException("Failed to set TargetRightAscension.");
return hms;
}
public bool Tracking public bool Tracking
{ {
get get