Skip to content

Commit 336d8f0

Browse files
committed
Added ability to restore expanded panels at startup
Fixed issue with dome slewing interruption Changed Activity Log to not show icon on the Taskbar Fixed Activity Log format error for SlewToCoofdinatesAsync Bumped Device Hub version to 6.6.0.11
1 parent 03a9b8b commit 336d8f0

12 files changed

Lines changed: 157 additions & 55 deletions

File tree

ConformanceTests/DomeDriverConformance.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ private string ParkTheDome( ref string status )
485485
if ( Dome.CanPark )
486486
{
487487
Dome.Park();
488-
timedOut = WaitForSlewToComplete( 60.0 );
488+
timedOut = WaitForSlewToComplete( 70.0 );
489489

490490
if ( timedOut )
491491
{
@@ -516,13 +516,13 @@ private void TestFindHome()
516516
string status = _error;
517517
bool timedOut;
518518
Exception except;
519-
519+
520520
try
521521
{
522522
if ( Dome.CanFindHome )
523523
{
524524
Dome.FindHome();
525-
timedOut = WaitForSlewToComplete( 60.0 );
525+
timedOut = WaitForSlewToComplete( 70.0 );
526526

527527
if ( timedOut )
528528
{
@@ -770,7 +770,7 @@ private void TestSlewToAzimuth( int target, bool expectException = false )
770770
{
771771
double azimuth = (double)target;
772772
Dome.SlewToAzimuth( azimuth );
773-
timedOut = WaitForSlewToComplete( 60.0 );
773+
timedOut = WaitForSlewToComplete( 70.0 );
774774

775775
if ( timedOut )
776776
{

DeviceHub/Business Object Classes/AppSettingsManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public static void CreateInitialAppSettings()
1919
settings.ActivityWindowSize = new System.Windows.Point( 480.0, 540.0 );
2020
settings.RegistryVersion = Globals.RegistryVersion;
2121
settings.AlwaysOnTop = false;
22+
settings.IsDomeExpanded = false;
23+
settings.IsFocuserExpanded = false;
2224

2325
svc.SaveSettings( settings );
2426
}
@@ -38,6 +40,8 @@ public static void LoadAppSettings()
3840
Globals.UseCustomTheme = settings.UseCustomTheme;
3941
Globals.UseExpandedScreenLayout = settings.UseExpandedScreenLayout;
4042
Globals.UseCompositeSlewingFlag = settings.UseCompositeSlewingFlag;
43+
Globals.IsDomeExpanded = settings.IsDomeExpanded;
44+
Globals.IsFocuserExpanded = settings.IsFocuserExpanded;
4145
}
4246

4347
public static void LoadMainWindowSettings()
@@ -51,6 +55,8 @@ public static void LoadMainWindowSettings()
5155
Globals.UseCustomTheme = settings.UseCustomTheme;
5256
Globals.UseExpandedScreenLayout = settings.UseExpandedScreenLayout;
5357
Globals.AlwaysOnTop = settings.AlwaysOnTop;
58+
Globals.IsDomeExpanded = settings.IsDomeExpanded;
59+
Globals.IsFocuserExpanded = settings.IsFocuserExpanded;
5460
}
5561

5662
public static void SaveAppSettings()
@@ -65,7 +71,9 @@ public static void SaveAppSettings()
6571
UseCustomTheme = Globals.UseCustomTheme,
6672
UseExpandedScreenLayout = Globals.UseExpandedScreenLayout,
6773
AlwaysOnTop = Globals.AlwaysOnTop,
68-
UseCompositeSlewingFlag = Globals.UseCompositeSlewingFlag
74+
UseCompositeSlewingFlag = Globals.UseCompositeSlewingFlag,
75+
IsDomeExpanded = Globals.IsDomeExpanded,
76+
IsFocuserExpanded = Globals.IsFocuserExpanded
6977
};
7078

7179
ServiceContainer.Instance.GetService<IAppSettingsService>().SaveSettings( settings );

DeviceHub/Business Object Classes/ApplicationSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public ApplicationSettings()
4646
public bool UseExpandedScreenLayout { get; set; }
4747
public bool AlwaysOnTop { get; set; }
4848
public bool UseCompositeSlewingFlag { get; set; }
49+
public bool IsDomeExpanded { get; set; }
50+
public bool IsFocuserExpanded { get; set; }
4951

5052
#endregion Public Properties
5153

DeviceHub/Business Object Classes/Globals.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ static Globals()
4545
public static double ActivityWindowHeight { get; set; }
4646
public static double ActivityWindowWidth { get; set; }
4747
public static bool AlwaysOnTop { get; set; }
48+
public static bool IsDomeExpanded { get; set; }
49+
public static bool IsFocuserExpanded { get; set; }
4850

4951
public static DomeLayoutSettings DomeLayout { get; set; }
5052

DeviceHub/DeviceManagers/DomeManager.cs

Lines changed: 72 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Windows;
55

66
using ASCOM.DeviceInterface;
7+
using ASCOM.Astrometry.Exceptions;
78
using ASCOM.Astrometry.Transform;
89

910
using ASCOM.DeviceHub.MvvmMessenger;
@@ -456,7 +457,13 @@ private void PollDomeTask( CancellationToken token )
456457
if ( Service.DeviceAvailable )
457458
{
458459
UpdateDomeStatusTask();
459-
SlewTheSlavedDome( ref nextSlaveAdjustmentTime );
460+
461+
if ( !Status.Slewing )
462+
{
463+
SlewTheSlavedDome( ref nextSlaveAdjustmentTime );
464+
UpdateDomeStatusTask();
465+
}
466+
460467
bool shutterMoving = Status.ShutterStatus == ShutterState.shutterOpening
461468
|| Status.ShutterStatus == ShutterState.shutterClosing;
462469

@@ -515,6 +522,7 @@ private void PollDomeTask( CancellationToken token )
515522

516523
private void SlewTheSlavedDome( ref DateTime nextAdjustmentTime )
517524
{
525+
ActivityMessageTypes msgType = ActivityMessageTypes.Commands;
518526
DateTime returnTime = nextAdjustmentTime;
519527

520528
if ( Globals.IsDomeSlaved )
@@ -523,32 +531,33 @@ private void SlewTheSlavedDome( ref DateTime nextAdjustmentTime )
523531
// We need to slew there immediately. We will get another message when the slew has finished, but
524532
// until then we need to suspend normal slaved adjustments.
525533

526-
if ( SlavedSlewState.IsSlewInProgress ) // The telescope is being slewed.
534+
SlewInProgressMessage slewState = SlavedSlewState;
535+
536+
if ( slewState != null && slewState.IsSlewInProgress ) // The telescope is being slewed.
527537
{
528538
if ( !Status.Slewing || Globals.UseCompositeSlewingFlag )
529539
{
530540
// The telescope is slewing and we are slaved but not slewing so initiate a dome slew
531541
// to the telescope's target position.
532542

533-
LogActivityLine( ActivityMessageTypes.Commands
534-
, "Dome position recalculation due to telescope slew-in-progress." );
543+
LogActivityLine( msgType, "Dome position recalculation due to telescope slew-in-progress." );
544+
545+
Transform xform = new Transform();
546+
xform.SiteElevation = TelescopeParameters.SiteElevation;
547+
xform.SiteLatitude = TelescopeParameters.SiteLatitude;
548+
xform.SiteLongitude = TelescopeParameters.SiteLongitude;
549+
550+
EquatorialCoordinateType coordinateType = TelescopeParameters.EquatorialSystem;
535551

536552
try
537553
{
538-
Transform xform = new Transform
539-
{
540-
SiteElevation = TelescopeParameters.SiteElevation,
541-
SiteLatitude = TelescopeParameters.SiteLatitude,
542-
SiteLongitude = TelescopeParameters.SiteLongitude
543-
};
544-
545-
if ( TelescopeParameters.EquatorialSystem == EquatorialCoordinateType.equJ2000 )
554+
if ( coordinateType == EquatorialCoordinateType.equJ2000 )
546555
{
547-
xform.SetJ2000( SlavedSlewState.RightAscension, SlavedSlewState.Declination );
556+
xform.SetJ2000( slewState.RightAscension, slewState.Declination );
548557
}
549-
else
558+
else // Assume JNOW
550559
{
551-
xform.SetTopocentric( SlavedSlewState.RightAscension, SlavedSlewState.Declination );
560+
xform.SetTopocentric( slewState.RightAscension, slewState.Declination );
552561
}
553562

554563
Point scopeTargetPosition = new Point( xform.AzimuthTopocentric, xform.ElevationTopocentric );
@@ -559,13 +568,28 @@ private void SlewTheSlavedDome( ref DateTime nextAdjustmentTime )
559568

560569
SlaveDomePointing( scopeTargetPosition, localHourAngle, SlavedSlewState.SideOfPier );
561570
}
571+
catch ( TransformUninitialisedException xcp )
572+
{
573+
LogActivityLine( msgType, "Attempting to calculate the slaved dome azimuth. Details follow:" );
574+
LogActivityLine( msgType, xcp.Message );
575+
LogActivityLine( msgType, $"Transform Error site location: latitude = {xform.SiteLatitude:F5}, longitude = {xform.SiteLongitude:F5}, elevation = {xform.SiteElevation:F0}" );
576+
LogActivityLine( msgType, $"Transform Error coordinate system: coordinateType = {coordinateType}" );
577+
LogActivityLine( msgType, $"Transform Error target position: RA = {slewState.RightAscension}, Dec = {slewState.Declination}" );
578+
}
562579
catch ( Exception xcp )
563580
{
564-
LogActivityLine( ActivityMessageTypes.Commands, "Attempting to calculate a new dome slave position due to telescope "
581+
LogActivityLine( msgType, "Attempting to calculate a new dome slave position due to telescope "
565582
+ "slew caught an exception. Details follow:" );
566-
LogActivityLine( ActivityMessageTypes.Commands, xcp.Message );
583+
LogActivityLine( msgType, xcp.Message );
567584
}
568585
}
586+
else
587+
{
588+
// If we get here we need to slew to a new target because of a telescope slew, but the dome is already slewing.
589+
// We want to test again quickly and slew the dome again as soon as it has stopped from the current slew.
590+
591+
returnTime = DateTime.Now.AddMilliseconds( 250.0 );
592+
}
569593
}
570594
else if ( DateTime.Now > nextAdjustmentTime )
571595
{
@@ -654,10 +678,15 @@ private void SlaveDomePointing( Point scopePosition, double localHourAngle, Pier
654678

655679
if ( Double.IsNaN( targetAltitude) || targetAltitude < 0.0 || targetAltitude > 180.0 )
656680
{
657-
targetsValid = false;
658-
LogActivityLine( ActivityMessageTypes.Commands
659-
, "An invalid altitude value ({0:f2}) was calculated...short circuiting the slew"
660-
, targetAltitude );
681+
// Don't report a bad altitude if we are not going to set it anyway.
682+
683+
if ( Capabilities.CanSetAltitude )
684+
{
685+
targetsValid = false;
686+
LogActivityLine( ActivityMessageTypes.Commands
687+
, "An invalid altitude value ({0:f2}) was calculated...short circuiting the slew"
688+
, targetAltitude );
689+
}
661690
}
662691

663692
// If either the target azimuth or altitude are invalid, return without slewing the dome!!!
@@ -670,6 +699,8 @@ private void SlaveDomePointing( Point scopePosition, double localHourAngle, Pier
670699
LogActivityLine( ActivityMessageTypes.Commands, "The calculated dome position is Az: {0:f2}, Alt: {1:f2}."
671700
, domeAltAz.X, domeAltAz.Y );
672701

702+
bool moving = false;
703+
673704
if ( IsInRange( targetAzimuth, Status.Azimuth, Globals.DomeLayout.AzimuthAccuracy ) )
674705
{
675706
LogActivityLine( ActivityMessageTypes.Commands
@@ -680,23 +711,33 @@ private void SlaveDomePointing( Point scopePosition, double localHourAngle, Pier
680711
LogActivityLine( ActivityMessageTypes.Commands
681712
, "Slaving dome to target azimuth of {0:f2} degrees.", targetAzimuth );
682713

683-
Task task = Task.Run( () =>
684-
{
685-
SlewToAzimuth( targetAzimuth );
686-
Status.Slewing = true;
687-
SetFastPolling();
688-
}, CancellationToken.None );
714+
//Task task = Task.Run( () =>
715+
//{
716+
// SlewToAzimuth( targetAzimuth );
717+
// Status.Slewing = true;
718+
// SetFastPolling();
719+
//}, CancellationToken.None );
720+
SlewToAzimuth( targetAzimuth );
721+
moving = true;
689722
}
690723

691724
if ( Capabilities.CanSetAltitude && Status.Altitude < targetAltitude )
692725
{
693726
LogActivityLine( ActivityMessageTypes.Commands
694727
, "Synchronizing dome to target altitude of {0:f2} degrees.", targetAltitude );
695728

696-
Task task = Task.Run( () =>
697-
{
698-
SlewToAltitude( targetAltitude );
699-
}, CancellationToken.None );
729+
//Task task = Task.Run( () =>
730+
//{
731+
// SlewToAltitude( targetAltitude );
732+
//}, CancellationToken.None );
733+
SlewToAzimuth( targetAltitude );
734+
moving = true;
735+
}
736+
737+
if ( moving )
738+
{
739+
Status = new DevHubDomeStatus( this );
740+
SetFastPolling();
700741
}
701742
}
702743

DeviceHub/DeviceManagers/TelescopeManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public void DoSlewToTarget( bool useSynchronousMethodCall = true )
483483
{
484484
// In case the dome is slaved to us, send it a message to start moving.
485485

486-
SendSlewMessage( Status.TargetRightAscension, Status.TargetDeclination );
486+
SendSlewMessage( TargetRightAscension, TargetDeclination );
487487

488488
if ( useSynchronousMethodCall )
489489
{
@@ -530,7 +530,7 @@ public void BeginSlewToTargetAsync()
530530
{
531531
// In case the dome is slaved to us, send it a message to start moving.
532532

533-
SendSlewMessage( Status.TargetRightAscension, Status.Declination );
533+
SendSlewMessage( TargetRightAscension, TargetDeclination );
534534
SlewToTargetAsync();
535535
slewed = true;
536536

DeviceHub/DeviceManagers/TelescopeManagerAccess.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ public void SlewToCoordinatesAsync( double rightAscension, double declination )
10591059
RightAscensionConverter raConverter = new RightAscensionConverter( (decimal)rightAscension );
10601060
DeclinationConverter decConverter = new DeclinationConverter( (decimal)declination );
10611061

1062-
LogActivityLine( msgType, "SlewToCoordinatesAsync - RA = {raConverter}, Dec {decConverter}: {msgEnd}" );
1062+
LogActivityLine( msgType, $"SlewToCoordinatesAsync - RA = {raConverter}, Dec {decConverter}: {msgEnd}" );
10631063

10641064
if ( except != null )
10651065
{

DeviceHub/View Classes/ActivityLogView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib"
77
mc:Ignorable="d"
88
Background="{DynamicResource WindowBackgroundBrush}"
9-
Title="Device Hub Activity Log" MinHeight="540" MinWidth="480" Height="540" Width="480" WindowStyle="ThreeDBorderWindow" Loaded="Window_Loaded" LocationChanged="Window_LocationChanged" Icon="/ASCOM.DeviceHub;component/Images/ASCOM.ico" SizeChanged="Window_SizeChanged" ResizeMode="CanResizeWithGrip" >
9+
Title="Device Hub Activity Log" MinHeight="540" MinWidth="480" Height="540" Width="480" WindowStyle="ThreeDBorderWindow" Loaded="Window_Loaded" LocationChanged="Window_LocationChanged" Icon="/ASCOM.DeviceHub;component/Images/ASCOM.ico" SizeChanged="Window_SizeChanged" ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" >
1010
<Window.Resources>
1111
<Style x:Key="DevLabel" TargetType="{x:Type Label}">
1212
<Setter Property="HorizontalAlignment" Value="Left" />

DeviceHub/View Classes/MainWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
<!-- Expanded Screen Layout -->
9191

92-
<Grid Grid.Row="1" Visibility="{Binding UseExpandedScreenLayout, Converter={StaticResource BoolVisConverter}, FallbackValue=Collapsed}">
92+
<Grid Grid.Row="1" Name="_expandedViewGrid" Visibility="{Binding UseExpandedScreenLayout, Converter={StaticResource BoolVisConverter}, FallbackValue=Collapsed}">
9393
<Grid.RowDefinitions>
9494
<RowDefinition Height="Auto" />
9595
<RowDefinition Height="Auto" />
@@ -105,7 +105,7 @@
105105
<ContentControl Content="{Binding TelescopeVm}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="6,0" Padding="0" Height="Auto" />
106106
</GroupBox>
107107
<Expander x:Name="_domeControl" Grid.Row="1" Grid.Column="1" ExpandDirection="Right" Margin="0,10"
108-
Foreground="{DynamicResource NormalTextBrush}" Expanded="Expander_Expanded"
108+
Foreground="{DynamicResource NormalTextBrush}"
109109
ToolTip="Use Ctrl-Click to expand without collapsing other expanders.">
110110
<Expander.Header>
111111
<TextBlock Text="Dome Control" TextOptions.TextFormattingMode="Display">
@@ -128,7 +128,7 @@
128128
</Grid>
129129
</Expander>
130130
<Expander x:Name="_focuserControl" Grid.Row="1" Grid.Column="2" ExpandDirection="Right" Margin="0,10"
131-
Foreground="{DynamicResource NormalTextBrush}" Expanded="Expander_Expanded"
131+
Foreground="{DynamicResource NormalTextBrush}"
132132
ToolTip="Use Ctrl-Click to expand without collapsing other expanders.">
133133
<Expander.Header>
134134
<TextBlock Text="Focuser Control" TextOptions.TextFormattingMode="Display" Foreground="{DynamicResource NormalTextBrush}">

0 commit comments

Comments
 (0)