Skip to content

Commit 183aa88

Browse files
Lunar tracking (#62)
* wip - tracking rates Authored-by: Christian Kardach <[email protected]>
1 parent fac464e commit 183aa88

File tree

3 files changed

+118
-2
lines changed

3 files changed

+118
-2
lines changed

OATControl/SettingsDialog.xaml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,35 @@
6969
<Setter Property="Foreground" Value="#F00" />
7070
<Setter Property="MaxWidth" Value="250" />
7171
</Style>
72+
<Style x:Key="ComboBoxStyle" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
73+
<Setter Property="Foreground" Value="Red" />
74+
<Setter Property="FontWeight" Value="Bold" />
75+
<Setter Property="BorderBrush" Value="#FF880000" />
76+
<Setter Property="FontSize" Value="14" />
77+
<Setter Property="HorizontalAlignment" Value="Left" />
78+
<Setter Property="ItemContainerStyle">
79+
<Setter.Value>
80+
<Style TargetType="ComboBoxItem">
81+
<Setter Property="FontSize" Value="14" />
82+
<Setter Property="Foreground" Value="Red" />
83+
<Setter Property="FontWeight" Value="Bold" />
84+
<Setter Property="Background" Value="#F600" />
85+
<Setter Property="BorderBrush" Value="#FF770000" />
86+
<Setter Property="BorderThickness" Value="1" />
87+
<Setter Property="Padding" Value="4" />
88+
<Style.Triggers>
89+
<Trigger Property="IsMouseOver" Value="True">
90+
<Setter Property="Background" Value="#FD00" />
91+
</Trigger>
92+
<Trigger Property="IsSelected" Value="True">
93+
<Setter Property="Background" Value="Black" />
94+
<Setter Property="Foreground" Value="#FFFF8888" />
95+
</Trigger>
96+
</Style.Triggers>
97+
</Style>
98+
</Setter.Value>
99+
</Setter>
100+
</Style>
72101
</Window.Resources>
73102
<Grid>
74103
<Grid.RowDefinitions>
@@ -344,7 +373,23 @@
344373
<TextBlock Grid.Row ="17" Grid.Column="3" Margin="0,0" HorizontalAlignment="Left" Text="Open the OATControl logfile folder" ToolTip="OATControl keeps logfiles from the last 6 sessions around in case you need to check something or the devs ask for them to debug a issue yopu might have." TextWrapping="Wrap" Style="{StaticResource SmallTextBlockLabel}" />
345374
<Button Grid.Row="17" Grid.Column="4" Margin="8,4" Padding="20,0" Content="Open Log Folder" HorizontalAlignment="Right" Style="{StaticResource CommandButtonStyle}" Command="{Binding ShowLogFolderCommand}"/>
346375

347-
<StackPanel Grid.Row="20" Grid.ColumnSpan="5" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,9.38,0,-0.38" Grid.RowSpan="2">
376+
<TextBlock Grid.Row ="18" Grid.Column="3" Margin="0,0" HorizontalAlignment="Left" Text="Tracking Rate" ToolTip="Change mount tracking rate" TextWrapping="Wrap" Style="{StaticResource SmallTextBlockLabel}" />
377+
<ComboBox Grid.Row="18" Grid.Column="4"
378+
ItemsSource="{Binding AvailableTrackingModes}"
379+
SelectedValue="{Binding SelectedTrackingMode}"
380+
Width="120"
381+
Height="24"
382+
Margin="10,4,0,0"
383+
FontSize="16"
384+
HorizontalAlignment="Left"
385+
Foreground="Red"
386+
FontWeight="Bold"
387+
BorderBrush="#FF880000"
388+
Style="{StaticResource ComboBoxStyle}"/>
389+
<!--<Button Grid.Row="18" Grid.Column="4" Margin="8,4" Padding="20,0" Content="SideReal" HorizontalAlignment="Right" Style="{StaticResource CommandButtonStyle}" Command="{Binding ChangeTrackingRateCommand}"/>-->
390+
391+
392+
<StackPanel Grid.Row="20" Grid.ColumnSpan="5" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,9.38,0,-0.38" Grid.RowSpan="2">
348393
<Button Margin="16,8" Padding="20,0" Content="Close" HorizontalAlignment="Right" Style="{StaticResource AccentedSquareButtonStyle}" IsCancel="True"/>
349394
</StackPanel>
350395
</Grid>

OATControl/ViewModels/AppSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ public string BaudRate
229229
set { this["BaudRate"] = value; }
230230
}
231231

232+
[DefaultValueAttribute("Sidereal")]
233+
public string TrackingRate
234+
{
235+
get { return this["TrackingRate"]; }
236+
set { this["TrackingRate"] = value; }
237+
}
238+
232239
[DefaultValueAttribute("False")]
233240
public bool KeepMiniControlOnTop
234241
{

OATControl/ViewModels/MountVM.cs

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public class MountVM : ViewModelBase
164164

165165
private ICommunicationHandler _commHandler;
166166
private string _serialBaudRate;
167+
private string _trackingMode;
167168

168169
private OatmealTelescopeCommandHandlers _oatMount;
169170
private PointsOfInterest _pointsOfInterest;
@@ -195,6 +196,7 @@ public class MountVM : ViewModelBase
195196
private DateTime _siderealTime;
196197
private DateTime _lastSiderealSync = DateTime.UtcNow - TimeSpan.FromMinutes(10);
197198

199+
198200
public float RASpeed
199201
{
200202
get; private set;
@@ -1524,6 +1526,7 @@ public void UpdateRealtimeParameters(bool editable)
15241526
string speed = string.Empty;
15251527
string network = string.Empty;
15261528
string hemisphere = string.Empty;
1529+
string trkMode = string.Empty;
15271530
bool failed = false;
15281531

15291532
if (_oatMount != null)
@@ -1534,7 +1537,8 @@ public void UpdateRealtimeParameters(bool editable)
15341537
this.SendOatCommand(":GG#,#", (a) => { utcOffset = a.Data; failed |= !a.Success; });
15351538
this.SendOatCommand(":GL#,#", (a) => { localTime = a.Data; failed |= !a.Success; });
15361539
this.SendOatCommand(":GC#,#", (a) => { localDate = a.Data; failed |= !a.Success; });
1537-
this.SendOatCommand(":XGH#,#", (a) => { ha = a.Data; failed |= !a.Success; });
1540+
this.SendOatCommand(":TZ#,#", (a) => { trkMode = a.Data; failed |= !a.Success; });
1541+
//this.SendOatCommand(":XGH#,#", (a) => { ha = a.Data; failed |= !a.Success; });
15381542
if (FirmwareVersion >= 11206)
15391543
{
15401544
this.SendOatCommand(":XGHS#,#", (a) => { hemisphere = a.Data.Substring(0, 1); failed |= !a.Success; });
@@ -1553,6 +1557,11 @@ public void UpdateRealtimeParameters(bool editable)
15531557
{
15541558
try
15551559
{
1560+
if(!string.IsNullOrEmpty(trkMode))
1561+
{
1562+
TrackingMode = trkMode;
1563+
}
1564+
15561565
if (localTime.Length == 8)
15571566
{
15581567
ScopeTime = localTime;
@@ -4030,6 +4039,12 @@ public PointsOfInterest AllPointsOfInterest
40304039
get { return _pointsOfInterest; }
40314040
}
40324041

4042+
public string TrackingMode
4043+
{
4044+
get { return _trackingMode; }
4045+
set { SetPropertyValue(ref _trackingMode, value); OnPropertyChanged("SelectedTrackingMode"); }
4046+
}
4047+
40334048
/// <summary>
40344049
/// Gets the string for the connect button
40354050
/// </summary>
@@ -4066,6 +4081,38 @@ public String SelectedBaudRate
40664081
}
40674082
}
40684083

4084+
public String SelectedTrackingMode
4085+
{
4086+
get { return _trackingMode; }
4087+
set
4088+
{
4089+
if (value == "Sidereal")
4090+
{
4091+
this.SendOatCommand(":TQ#,n", (a) => { });
4092+
}
4093+
else if (value == "Lunar")
4094+
{
4095+
this.SendOatCommand(":TL#,n", (a) => { });
4096+
}
4097+
else if (value == "Solar")
4098+
{
4099+
this.SendOatCommand(":TS#,n", (a) => { });
4100+
}
4101+
else if (value == "King")
4102+
{
4103+
this.SendOatCommand(":TK#,n", (a) => { });
4104+
}
4105+
else
4106+
{
4107+
this.SendOatCommand(":TQ#,n", (a) => { });
4108+
}
4109+
4110+
Log.WriteLine("MOUNT: Changing tracking rate to " + value);
4111+
_trackingMode = value;
4112+
AppSettings.Instance.TrackingRate = value;
4113+
}
4114+
}
4115+
40694116
public IEnumerable<String> AvailableBaudRates
40704117
{
40714118
get { return _baudRates; }
@@ -4085,6 +4132,23 @@ public IEnumerable<String> AvailableBaudRates
40854132
"1200",
40864133
"300",
40874134
};
4135+
4136+
/// <summary>
4137+
/// Gets or sets tracking modes
4138+
/// </summary>
4139+
public IEnumerable<String> AvailableTrackingModes
4140+
{
4141+
get { return _trackingModes; }
4142+
}
4143+
4144+
List<String> _trackingModes = new List<string>() {
4145+
"Sidereal",
4146+
"Lunar",
4147+
"Solar",
4148+
"King"
4149+
};
4150+
4151+
40884152
private string _autoHomeRaDirection;
40894153
private float _autoHomeRaDistance;
40904154
private string _autoHomeDecDirection;

0 commit comments

Comments
 (0)