private void OnFocuserState(FocuserState state) { EventHelper.RaiseEvent(FocuserStateUpdated, state); }
public void FocuserStateUpdated(FocuserState state) { m_LastFocuserState = state; UpdateConnectedDevicesState(); #if DEBUG Trace.WriteLine(state.AsSerialized().OuterXml); #endif }
public FocuserState GetCurrentState() { var rv = new FocuserState(); var sw = new Stopwatch(); try { sw.Start(); rv.TempCompAvailable = m_Focuser.TempCompAvailable; try { rv.Temperature = m_Focuser.Temperature; } catch (PropertyNotImplementedException) { rv.Temperature = double.NaN; } rv.IsMoving = m_Focuser.IsMoving; rv.MaxIncrement = m_Focuser.MaxIncrement; rv.MaxStep = m_Focuser.MaxStep; rv.Absolute = m_Focuser.Absolute; try { rv.StepSize = m_Focuser.StepSize; } catch (PropertyNotImplementedException) { rv.StepSize = double.NaN; } rv.TempComp = m_Focuser.TempComp; try { if (rv.Absolute) rv.Position = m_Focuser.Position; else rv.Position = 0; } catch (PropertyNotImplementedException) { rv.Position = 0; } } finally { sw.Stop(); Trace.WriteLine(string.Format("Focuser.GetCurrentState() took {0} ms", (int)sw.ElapsedMilliseconds)); } return rv; }
public void FocuserConnectionChanged(ASCOMConnectionState state) { RefreshASCOMStatusControls(state, tssASCOMFocuser); if (state == ASCOMConnectionState.Connected || state == ASCOMConnectionState.Ready) { tsbFocControl.Text = "Control Focuser"; tsbFocControl.Enabled = true; } else if (state == ASCOMConnectionState.Disconnected || state == ASCOMConnectionState.Engaged) { tsbFocControl.Text = "Connect to Focuser"; tsbFocControl.Enabled = true; m_LastFocuserState = null; UpdateConnectedDevicesState(); } else { tsbFocControl.Enabled = false; } }
private void UpdateFocuserState(FocuserState state) { if (state != null) { Trace.WriteLine(state.AsXmlString()); DisableEnableControls(true); if (!state.TempCompAvailable) { cbxTempComp.Visible = false; m_SettingTempCompValue = true; try { cbxTempComp.Checked = false; } finally { m_SettingTempCompValue = false; } } else { cbxTempComp.Visible = true; m_SettingTempCompValue = true; try { cbxTempComp.Checked = state.TempComp; } finally { m_SettingTempCompValue = false; } } Text = "Focuser: " + state.Position.ToString(); pnlFocuserControls.Enabled = true; gbxTargetControl.Enabled = true; } else { pnlFocuserControls.Enabled = false; gbxTargetControl.Enabled = false; } }