Skip to content

Commit a5e3df7

Browse files
committed
Telescope - Fix Set RightAscensionRate and DeclinationRate to throw InvalidOperationExceptions when the telescope is tracking at other than sidereal rate.
1 parent 98213bc commit a5e3df7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

TelescopeSimulator/TelescopeHardware.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ private static void MoveAxes()
727727
// In addition, the sense of required rate corrections is inverted when in the southern hemisphere compared to the northern hemisphere
728728
if (SouthernHemisphere) // Southern hemisphere
729729
{
730-
change.Y += (SideOfPier == PointingState.Normal? -rateRaDecOffsetInternal.Y : +rateRaDecOffsetInternal.Y) * timeInSecondsSinceLastUpdate; // Add or subtract declination rate depending on pointing state
730+
change.Y += (SideOfPier == PointingState.Normal ? -rateRaDecOffsetInternal.Y : +rateRaDecOffsetInternal.Y) * timeInSecondsSinceLastUpdate; // Add or subtract declination rate depending on pointing state
731731
}
732732
else // Northern hemisphere
733733
{
@@ -1413,8 +1413,15 @@ public static double DeclinationRate
14131413
get { return rateRaDecOffsetExternal.Y; }
14141414
set
14151415
{
1416-
rateRaDecOffsetExternal.Y = value; // Save the provided rate to be returned through the Get property
1417-
rateRaDecOffsetInternal.Y = value * ARCSECONDS_TO_DEGREES; // Save the rate in the internal units that the simulator uses
1416+
// Setting DeclinationRate is only valid when tracking at sidereal rate. At other tracking rates the set must be rejected.
1417+
if (!(TrackingRate == DriveRate.Sidereal)) // We are not tracking at sidereal rate
1418+
throw new InvalidOperationException($"DeclinationRate can only be set when tracking at sidereal rate. The current tracking rate is: {TrackingRate}.");
1419+
1420+
// Save the provided rate to be returned through the Get property
1421+
rateRaDecOffsetExternal.Y = value;
1422+
1423+
// Save the rate in the internal units that the simulator uses
1424+
rateRaDecOffsetInternal.Y = value * ARCSECONDS_TO_DEGREES;
14181425
}
14191426
}
14201427

@@ -1513,6 +1520,10 @@ public static double RightAscensionRate
15131520
get { return rateRaDecOffsetExternal.X; }
15141521
set
15151522
{
1523+
// Setting RightAscensionRate is only valid when tracking at sidereal rate. At other tracking rates the set must be rejected.
1524+
if (!(TrackingRate == DriveRate.Sidereal)) // We are not tracking at sidereal rate
1525+
throw new InvalidOperationException($"RightAscensionRate can only be set when tracking at sidereal rate. The current tracking rate is: {TrackingRate}.");
1526+
15161527
// Save the provided rate (seconds of RA per sidereal second) to be returned through the Get property
15171528
rateRaDecOffsetExternal.X = value;
15181529

0 commit comments

Comments
 (0)