public IStep OnNext() { ITelescope scope = null; if (string.IsNullOrEmpty(Settings1.Default.LastMountId)) { _state.ShowMessage("No telescope mount driver selected."); return(null); } try { scope = CreateScope(Settings1.Default.LastMountId); } catch (Exception e) { _state.ShowMessage("Cannot create ASCOM mount driver " + Settings1.Default.LastMount + "\r\nBecause : " + e.Message); return(null); } if (scope.AlignmentMode != AlignmentModes.algGermanPolar) { _state.ShowMessage(_state.AppName + " will only work with a German Equatorial style mount (as it needs the meridian flip to happen when swapping sides of the meridian)."); return(null); } try { scope.Connected = true; _state.Mount = scope; } catch (Exception ex) { _state.ShowMessage("Could not connect to scope driver : " + ex.Message); return(null); } return(new ScopePropertiesStep()); }
public void DisconnectTelescope(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedTelescope != null) { AssertTelescopeEngagement(clientId); ASCOMClient.Instance.DisconnectTelescope(m_ConnectedTelescope); m_ConnectedTelescope = null; } } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } OnTelescopeDisconnected(); return null; }, callType, callback, callbackUIControl); }
public void TryConnectTelescope(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedTelescope != null && m_ConnectedTelescope.ProgId != Settings.Default.ASCOMProgIdTelescope) { AssertTelescopeEngagement(clientId); ASCOMClient.Instance.DisconnectTelescope(m_ConnectedTelescope); m_ConnectedTelescope = null; } if (m_ConnectedTelescope == null && !string.IsNullOrEmpty(Settings.Default.ASCOMProgIdTelescope)) m_ConnectedTelescope = ASCOMClient.Instance.CreateTelescope(Settings.Default.ASCOMProgIdTelescope, Settings.Default.TelPulseSlowestRate, Settings.Default.TelPulseSlowRate, Settings.Default.TelPulseFasterRate); if (m_ConnectedTelescope != null) { if (!m_ConnectedTelescope.Connected) { OnTelescopeConnecting(); m_ConnectedTelescope.Connected = true; OnTelescopeConnected(); } else OnTelescopeConnected(); TelescopeCapabilities capabilities = m_ConnectedTelescope.GetTelescopeCapabilities(); OnTelescopeCapabilitiesKnown(capabilities); TelescopeState state = m_ConnectedTelescope.GetCurrentState(); OnTelescopeState(state); return state; } return null; } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }