public void Dispose() { ShutdownMonitorThread(); if (_focuser == null) { return; } try { _focuser.Link = false; } catch (Exception e) { Tracer.TraceException("Trying to unlink from focuser", e); } if (Marshal.IsComObject(_focuser)) { Marshal.ReleaseComObject(_focuser); } else if (_focuser is IDisposable) { (_focuser as IDisposable).Dispose(); } _focuser = null; }
public FocusAdaptor(string id, string name) { Tracer.TraceStart(LogLevel.Debug); _name = name; Tracer.Trace(LogLevel.Info, "Creating ASCOM Focuser of type {0} ('{1}')", id, name); object oFocuser = Activator.CreateInstance(Type.GetTypeFromProgID(id, true)); IFocuser focuser = oFocuser as IFocuser ?? new FocuserDispatchProxy(oFocuser); _focuser = focuser; Tracer.TraceEnd(LogLevel.Debug); }
public void DisconnectFocuser(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedFocuser != null) { AssertFocuserEngagement(clientId); ASCOMClient.Instance.DisconnectFocuser(m_ConnectedFocuser); m_ConnectedFocuser = null; } } catch (Exception ex) { OnFocuserErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } OnFocuserDisconnected(); return null; }, callType, callback, callbackUIControl); }
public void TryConnectFocuser(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedFocuser != null && m_ConnectedFocuser.ProgId != Settings.Default.ASCOMProgIdFocuser) { AssertFocuserEngagement(clientId); ASCOMClient.Instance.DisconnectFocuser(m_ConnectedFocuser); m_ConnectedFocuser = null; } if (m_ConnectedFocuser == null && !string.IsNullOrEmpty(Settings.Default.ASCOMProgIdFocuser)) { m_ConnectedFocuser = ASCOMClient.Instance.CreateFocuser( Settings.Default.ASCOMProgIdFocuser, Settings.Default.FocuserLargeStep, Settings.Default.FocuserSmallStep, Settings.Default.FocuserSmallestStep); } if (m_ConnectedFocuser != null) { if (!m_ConnectedFocuser.Connected) { OnFocuserConnecting(); m_ConnectedFocuser.Connected = true; OnFocuserConnected(); } else OnFocuserConnected(); FocuserState state = m_ConnectedFocuser.GetCurrentState(); OnFocuserState(state); return state; } return null; } catch (Exception ex) { OnFocuserErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
public TestableOvershootBacklashCompensationDecorator(IProfileService profileService, IFocuser focuser) : base(profileService, focuser) { }
public FocuserDecorator(IProfileService profileService, IFocuser focuser) { this.profileService = profileService; this.focuser = focuser; this.focuser.PropertyChanged += Focuser_PropertyChanged; }
public AbsoluteBacklashCompensationDecorator(IProfileService profileService, IFocuser focuser) : base(profileService, focuser) { }
public void DisconnectFocuser(IFocuser focuser) { try { if (TraceSwitchASCOMClient.TraceVerbose) Trace.WriteLine(string.Format("OccuRec: ASCOMClient::DisconnectFocuser('{0}')", focuser.UniqueId)); if (focuser.Connected) focuser.Connected = false; } catch (Exception ex) { if (TraceSwitchASCOMClient.TraceError) Trace.WriteLine(ex); } ReleaseDevice(focuser); }
private IFocuser GetBacklashCompensationFocuser(IProfileService profileService, IFocuser focuser) { switch (profileService.ActiveProfile.FocuserSettings.BacklashCompensationModel) { case Utility.Enum.BacklashCompensationModel.ABSOLUTE: return(new AbsoluteBacklashCompensationDecorator(profileService, focuser)); case Utility.Enum.BacklashCompensationModel.OVERSHOOT: return(new OvershootBacklashCompensationDecorator(profileService, focuser)); default: return(focuser); } }