public static FocuserSettings FromProfile() { string focuserID; double temperatureOffset; bool loggerEnabled; double fastUpdatePeriod; using (Profile profile = new Profile()) { profile.DeviceType = "Focuser"; focuserID = profile.GetValue(DriverID, _focuserIDProfileName, String.Empty, _focuserIDDefault); temperatureOffset = Convert.ToDouble(profile.GetValue(DriverID, _temperatureOffsetProfileName, String.Empty, _temperatureOffsetDefault), CultureInfo.InvariantCulture); loggerEnabled = Convert.ToBoolean(profile.GetValue(DriverID, _traceStateProfileName, String.Empty, _traceStateDefault)); fastUpdatePeriod = Convert.ToDouble(profile.GetValue(DriverID, _fastUpdateProfileName, String.Empty, _fastUpdateDefault), CultureInfo.InvariantCulture); } // Prevent the user from circumventing the valid fast update by setting the value in the profile store directly. fastUpdatePeriod = Math.Max(Globals.FOCUSER_FAST_UPDATE_MIN, Math.Min(fastUpdatePeriod, Globals.FOCUSER_FAST_UPDATE_MAX)); FocuserSettings settings = new FocuserSettings { FocuserID = focuserID, TemperatureOffset = temperatureOffset, IsLoggingEnabled = loggerEnabled, FastUpdatePeriod = fastUpdatePeriod }; return(settings); }
private void SaveFocuserSettings() { FocuserSettings settings = FocuserSettings.FromProfile(); settings.FocuserID = FocuserManager.FocuserID; settings.TemperatureOffset = Globals.FocuserTemperatureOffset; settings.ToProfile(); }
/// <summary> /// Write the device configuration to the ASCOM Profile store /// </summary> internal void SaveProfile() { FocuserSettings settings = new FocuserSettings { FocuserID = FocuserManager.FocuserID, TemperatureOffset = Globals.FocuserTemperatureOffset, IsLoggingEnabled = _logger.Enabled }; settings.ToProfile(); }
private static void LoadDeviceSettings() { TelescopeSettings scopeSettings = TelescopeSettings.FromProfile(); TelescopeManager.SetTelescopeID(scopeSettings.TelescopeID); DomeSettings domeSettings = DomeSettings.FromProfile(); DomeManager.SetDomeID(domeSettings.DomeID); Globals.DomeLayout = domeSettings.DomeLayout; Globals.DomeAzimuthAdjustment = domeSettings.AzimuthAdjustment; Globals.UsePOTHDomeSlaveCalculation = domeSettings.UsePOTHDomeSlaveCalculation; Globals.FindDomeHomeAtStartup = domeSettings.FindDomeHomeAtStartup; FocuserSettings focuserSettings = FocuserSettings.FromProfile(); FocuserManager.SetFocuserID(focuserSettings.FocuserID); Globals.FocuserTemperatureOffset = focuserSettings.TemperatureOffset; }
public static FocuserSettings FromProfile() { string focuserID; double temperatureOffset; bool loggerEnabled; using (Profile profile = new Profile()) { profile.DeviceType = "Focuser"; focuserID = profile.GetValue(DriverID, _focuserIDProfileName, String.Empty, _focuserIDDefault); temperatureOffset = Convert.ToDouble(profile.GetValue(DriverID, _temperatureOffsetProfileName, String.Empty, _temperatureOffsetDefault), CultureInfo.InvariantCulture); loggerEnabled = Convert.ToBoolean(profile.GetValue(DriverID, _traceStateProfileName, String.Empty, _traceStateDefault)); } FocuserSettings settings = new FocuserSettings { FocuserID = focuserID, TemperatureOffset = temperatureOffset, IsLoggingEnabled = loggerEnabled }; return(settings); }
/// <summary> /// Read the device configuration from the ASCOM Profile store /// </summary> internal void ReadProfile() { FocuserSettings settings = FocuserSettings.FromProfile(); _logger.Enabled = settings.IsLoggingEnabled; }