Skip to content

Commit

Permalink
Prevent dome slaving calculations from sending NaN to the downstream …
Browse files Browse the repository at this point in the history
…dome driver.

Fixed AxisConverter unit tests
Bumped version to 6.5.1.5
  • Loading branch information
astroman133 committed May 17, 2021
1 parent ced8430 commit 89e68e5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
36 changes: 34 additions & 2 deletions DeviceHub/DeviceManagers/DomeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,40 @@ private void SlaveDomePointing( Point scopePosition, double localHourAngle, Pier

Point domeAltAz = GetDomeCoord( scopePosition, localHourAngle, sideOfPier );
double targetAzimuth = domeAltAz.X;
double targetAltitude = domeAltAz.Y;

bool targetsValid = true;

// Validate the calculated azimuth appears sane.
// If the scope position is NaN or any other input to the slaving calculation is NaN then
// the resultant targetAlt and targetAz could also be NaN. We do not want to send NaN to
// the dome, even though it should reject it.

if ( Double.IsNaN(targetAzimuth) || targetAzimuth < 0.0 || targetAzimuth > 360.0 )
{
targetsValid = false;
LogActivityLine( ActivityMessageTypes.Commands
, "An invalid azimuth value ({0:f2}) was calculated...short circuiting the slew"
, targetAzimuth );
}

// Validate the calculated altitude appears sane.
// Using 180 degrees for the upper limit for a clamshell type of dome that may be able to open to 180.

if ( Double.IsNaN( targetAltitude) || targetAltitude < 0.0 || targetAltitude > 180.0 )
{
targetsValid = false;
LogActivityLine( ActivityMessageTypes.Commands
, "An invalid altitude value ({0:f2}) was calculated...short circuiting the slew"
, targetAltitude );
}

// If either the target azimuth or altitude are invalid, return without slewing the dome!!!

if ( !targetsValid )
{
return;
}

LogActivityLine( ActivityMessageTypes.Commands, "The calculated dome position is Az: {0:f2}, Alt: {1:f2}."
, domeAltAz.X, domeAltAz.Y );
Expand All @@ -636,8 +670,6 @@ private void SlaveDomePointing( Point scopePosition, double localHourAngle, Pier
}, CancellationToken.None );
}

double targetAltitude = domeAltAz.Y;

if ( Capabilities.CanSetAltitude && Status.Altitude < targetAltitude )
{
LogActivityLine( ActivityMessageTypes.Commands
Expand Down
2 changes: 1 addition & 1 deletion Inno Setup/ASCOM Device Hub Setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
;

#define MyAppName "ASCOM.DeviceHub"
#define MyAppVersion "6.5.1.4"
#define MyAppVersion "6.5.1.5"
#define MyDestSubdirName "DeviceHub"
; #define MyPlatformRoot "D:\Github Repos\ASCOMPlatform\"
#define MyPlatformRoot "D:\My Projects\Visual Studio 2019\Ascom\"
Expand Down
2 changes: 1 addition & 1 deletion ProductAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "6.5.1.4" )]
[assembly: AssemblyVersion( "6.5.1.5" )]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AxisConvertersTests
private int _testRaHours = 12;
private int _testRaMinutes = 20;
private int _testRaSeconds = 44;
private string _testRaString = "12:20:44";
private string _testRaString = "+12:20:44";

private decimal _testValueRoundUp = 16.6499917m;
private int _testDegreesRoundUp = 16;
Expand Down

0 comments on commit 89e68e5

Please sign in to comment.