Skip to content

Commit 4659514

Browse files
OATControl V0.9.9.13 - Updates
- Improved detection of connection error conditions.
1 parent f18168e commit 4659514

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

Software/OpenAstroTracker ASCOM/OATControl/DlgChooseOat.xaml.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public DlgChooseOat(MountVM mountViewModel, Func<string, Task<string>> sendComma
8181
this.DataContext = this;
8282
InitializeComponent();
8383

84+
this.Result = false;
85+
8486
stateTimer.Start();
8587
}
8688

@@ -275,6 +277,9 @@ protected override void OnClosed(EventArgs e)
275277
base.OnClosed(e);
276278
}
277279

280+
public bool? Result { get; set; }
281+
282+
278283
private void AdvanceStateMachine()
279284
{
280285
switch (CurrentStep)
@@ -328,7 +333,7 @@ private void AdvanceStateMachine()
328333
break;
329334

330335
case Steps.Completed:
331-
this.DialogResult = true;
336+
this.Result = true;
332337
this.Close();
333338
break;
334339

@@ -345,11 +350,19 @@ private async void ProcessStateMachine(object sender, EventArgs e)
345350
break;
346351

347352
case Steps.CheckHardware:
348-
await _mountViewModel.ConnectToOat(SelectedDevice);
353+
var connectResult = await _mountViewModel.ConnectToOat(SelectedDevice);
349354

350355
ShowGPSStatus = false;
351356
GPSStatus = string.Empty;
352357

358+
if (!connectResult)
359+
{
360+
this.Result = null;
361+
this.Close();
362+
CurrentStep = Steps.WaitForConnect;
363+
return;
364+
}
365+
353366
if (_mountViewModel.IsAddonSupported("GYRO"))
354367
{
355368
CurrentStep = Steps.WaitForLevel;
@@ -446,7 +459,7 @@ private async void ProcessStateMachine(object sender, EventArgs e)
446459
break;
447460

448461
case Steps.Completed:
449-
this.DialogResult = true;
462+
this.Result = true;
450463
this.Close();
451464
return;
452465

Software/OpenAstroTracker ASCOM/OATControl/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("0.9.9.12")]
54+
[assembly: AssemblyVersion("0.9.9.13")]
5555
[assembly: AssemblyFileVersion("1.0.0.0")]

Software/OpenAstroTracker ASCOM/OATControl/ViewModels/MountVM.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ public MountVM()
135135
{
136136
XDocument doc = XDocument.Load(poiFile);
137137
_pointsOfInterest = doc.Element("PointsOfInterest").Elements("Object").Select(e => new PointOfInterest(e)).ToList();
138+
_pointsOfInterest.Sort((p1, p2) =>
139+
{
140+
if (p1.Name.StartsWith("Polaris")) return -1;
141+
if (p2.Name.StartsWith("Polaris")) return 1;
142+
return p1.Name.CompareTo(p2.Name);
143+
});
138144
_pointsOfInterest.Insert(0, new PointOfInterest("--- Select Target Object ---"));
139145
_selectedPointOfInterest = 0;
140146
Log.WriteLine("Mount: Successfully read {0} Points of Interest.", _pointsOfInterest.Count - 1);
@@ -514,10 +520,19 @@ private async void OnConnectToTelescope()
514520
MountConnected = true;
515521
Log.WriteLine("Mount: Successfully connected and configured!");
516522
}
523+
catch (FormatException fex)
524+
{
525+
ScopeName = string.Empty;
526+
ScopeHardware = string.Empty;
527+
Log.WriteLine("Mount: Failed to connect and configure OAT! {0}", fex.Message);
528+
MessageBox.Show("Connected to OpenAstroTracker, but protocol could not be established.\n\nIs the firmware compiled with DEBUG_LEVEL set to DEBUG_NONE?", "Protocol Error", MessageBoxButton.OK, MessageBoxImage.Error);
529+
}
517530
catch (Exception ex)
518531
{
532+
ScopeName = string.Empty;
533+
ScopeHardware = string.Empty;
519534
Log.WriteLine("Mount: Failed to connect and configure OAT! {0}", ex.Message);
520-
MessageBox.Show("Error trying to connect to OpenAstroTracker. " + ex.Message, "Connection Error", MessageBoxButton.OK, MessageBoxImage.Error);
535+
MessageBox.Show("Error trying to connect to OpenAstroTracker.\n\n" + ex.Message, "Connection Error", MessageBoxButton.OK, MessageBoxImage.Error);
521536
}
522537
finally
523538
{
@@ -646,14 +661,24 @@ private bool ChooseTelescope()
646661
var dlg = new DlgChooseOat(this, this.RunCustomOATCommandAsync) { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner };
647662

648663
Log.WriteLine("Mount: Showing OAT comms Chooser Wizard");
664+
dlg.ShowDialog();
649665

650-
var result = dlg.ShowDialog();
651-
652-
if (result == true)
666+
if (dlg.Result == true)
653667
{
654668
Log.WriteLine("OAT Connected!");
655669
return true;
656670
}
671+
else if (dlg.Result == null)
672+
{
673+
Log.WriteLine("Mount: Unable to connect");
674+
string extraMessage = "Is something else connected?";
675+
if (Process.GetProcesses().FirstOrDefault(d => d.ProcessName.Contains("ASCOM.OpenAstroTracker")) != null)
676+
{
677+
extraMessage = "Another process is connected via ASCOM.";
678+
}
679+
MessageBox.Show("Cannot connect to mount. " + extraMessage, "Connection Error", MessageBoxButton.OK, MessageBoxImage.Error);
680+
return false;
681+
}
657682

658683
RequeryCommands();
659684
Log.WriteLine("Mount: Chooser cancelled");

0 commit comments

Comments
 (0)