private void InitUI() { chkTrace.Checked = Rotator.traceState; // set the list of com ports to those that are currently available comboBoxComPort.Items.Clear(); comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); // use System.IO because it's static // select the current port if possible if (comboBoxComPort.Items.Contains(Rotator.comPort)) { comboBoxComPort.SelectedItem = Rotator.comPort; } using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Rotator"; textBox2.Text = p.GetValue(Rotator.driverID, "StepsPerDegree"); if (p.GetValue(Rotator.driverID, "ContHold") == "True") { checkBox2.Checked = true; } else { checkBox2.Checked = false; } } if (!checkBox1.Checked) { textBox1.Enabled = false; } checkTextBox(); }
public ObservationLocation() { iProfile = new Utilities.Profile(); iProfile.DeviceType = "Telescope"; iHelper = new Utilities.Util(); iProgID = Telescope.ProgId; if (iProfile.IsRegistered(Telescope.ProgId)) { String storedLongitude; storedLongitude = iProfile.GetValue(iProgID, "Longitude", ""); if (storedLongitude.Length != 0) { iLongitude = Convert.ToDouble(storedLongitude); } else { iLongitude = 0; } } else { iLongitude = 0; } }
public void TestProfile() { Telescope.RegisterASCOM(typeof(Telescope)); Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; Assert.That(theProfile.IsRegistered(Telescope.ProgId)); ObservationLocation.Reset(); try { theProfile.DeleteValue(Telescope.ProgId, "Longitude", ""); } catch (Exception) {} ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(0.0)); theProfile.WriteValue(Telescope.ProgId, "Longitude", Convert.ToString(4.12345), ""); double longitude = Convert.ToDouble(theProfile.GetValue(Telescope.ProgId, "Longitude", "")); Assert.That(longitude, Is.EqualTo(4.12345)); ObservationLocation.Reset(); theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(4.12345)); ObservationLocation.Reset(); theProfile.DeleteValue(Telescope.ProgId, "Longitude", ""); theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(0.0)); }
// Constructor - Must be public for COM registration! /// <summary> /// Constructor /// </summary> public Telescope() { sysLog.Enabled = true; sysLog.LogMessage("Telescope", "Creating Telescope"); m_AxisRates = new AxisRates[2]; m_AxisRates[0] = new AxisRates(TelescopeAxes.axisPrimary); m_AxisRates[1] = new AxisRates(TelescopeAxes.axisSecondary); m_TrackingRates = new TrackingRates(); Serial theSerial = null; if (_profile.IsRegistered(s_csDriverID)) { _profile.CreateSubKey(s_csDriverID, s_SerialSubKey); string portname = _profile.GetValue(s_csDriverID, "Port", s_SerialSubKey); string baudRate = _profile.GetValue(s_csDriverID, "Baud", s_SerialSubKey); if (portname.Length != 0 && baudRate.Length != 0) { theSerial = new Serial(); theSerial.Port = Convert.ToInt16(portname); theSerial.Speed = (ASCOM.Utilities.SerialSpeed)Convert.ToInt16(baudRate); theSerial.Connected = true; } } else { RegUnregASCOM(true); } Controller = new BoxdorferConnect(theSerial); m_Axes = new Axis.AxisControl[] { new Axis.RaAxisControl(Controller), //new Axis.DecAxisController(Controller); }; RaAxis = m_Axes[0]; }
public void ReadProfile() { using (ASCOM.Utilities.Profile p = new Utilities.Profile() { DeviceType = "Telescope" }) { if (p.IsRegistered(Const.wiseTelescopeDriverID)) { DebugLevel d; if (Enum.TryParse <DebugLevel>(p.GetValue(Const.wiseTelescopeDriverID, "SiteDebugLevel", string.Empty, DebugLevel.DebugDefault.ToString()), out d)) { _currentLevel = d; } } } }
public SetupDialogForm(ASCOM.DeviceInterface.IFocuserV2 f, string uniqueDriverId, string syncUnits) { InitializeComponent(); SyncUnits = syncUnits; myFocuser = f; driverId = uniqueDriverId; NVC.NewVersionDetected += new EventHandler(NVC_NewVersionDetected); Utilities.Profile pro = new Utilities.Profile(); pro.DeviceType = "Focuser"; bool check = bool.Parse(pro.GetValue(driverId, "Check for Updates", "", true.ToString())); if (check) { NVC.CheckForNewVersion(System.Reflection.Assembly.GetExecutingAssembly(), "GeminiSoftware", false, Properties.Resources.FocusLynx); } }
public void TestLongitude() { Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; theProfile.WriteValue(Telescope.ProgId, "Longitude", Convert.ToString(4.12345), ""); ObservationLocation.Reset(); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(4.12345).Within(0.00001)); NotifyHandler theHandler = new NotifyHandler(theLocation); theLocation.Longitude = 12.54321; double storedLongitude = Convert.ToDouble(theProfile.GetValue(Telescope.ProgId, "Longitude", "")); Assert.That(theLocation.Longitude, Is.EqualTo(12.54321).Within(0.00001)); Assert.That(storedLongitude, Is.EqualTo(12.54321).Within(0.00001)); Assert.That(theHandler.nLongitudeChanges, Is.EqualTo(1)); }
public void TestProfile() { Telescope.RegisterASCOM(typeof(Telescope)); Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; Assert.That(theProfile.IsRegistered(Telescope.ProgId)); ObservationLocation.Reset(); try { theProfile.DeleteValue(Telescope.ProgId, "Longitude", ""); } catch(Exception) {} ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(0.0)); theProfile.WriteValue(Telescope.ProgId, "Longitude", Convert.ToString(4.12345), ""); double longitude = Convert.ToDouble(theProfile.GetValue(Telescope.ProgId, "Longitude", "")); Assert.That(longitude, Is.EqualTo(4.12345)); ObservationLocation.Reset(); theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(4.12345)); ObservationLocation.Reset(); theProfile.DeleteValue(Telescope.ProgId, "Longitude", ""); theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(0.0)); }
public void TestLongitude() { Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; theProfile.WriteValue(Telescope.ProgId, "Longitude", Convert.ToString(4.12345), ""); ObservationLocation.Reset(); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(4.12345).Within(0.00001)); NotifyHandler theHandler = new NotifyHandler(theLocation); theLocation.Longitude = 12.54321; double storedLongitude = Convert.ToDouble(theProfile.GetValue(Telescope.ProgId, "Longitude", "")); Assert.That(theLocation.Longitude, Is.EqualTo(12.54321).Within(0.00001)); Assert.That(storedLongitude,Is.EqualTo(12.54321).Within(0.00001)); Assert.That(theHandler.nLongitudeChanges, Is.EqualTo(1)); }
static SharedResources() { EventLogger.LogMessage("Creating FocusLynx Shared Resources", System.Diagnostics.TraceLevel.Info); // Get the stored TraceLevel from the ASCOM Profile and convert it to a usable type. Utilities.Profile p = new Utilities.Profile(); p.DeviceType = "Focuser"; string level = p.GetValue(SharedProfileDriverID, "Trace Level", "", System.Diagnostics.TraceLevel.Info.ToString()); System.Diagnostics.TraceLevel traceLevel = (System.Diagnostics.TraceLevel)Enum.Parse(typeof(System.Diagnostics.TraceLevel), level); try { EventLogger.LoggingLevel = traceLevel; } catch { // This means someone keyed in an invalid value for trace level. Fix the problem p.WriteValue(SharedProfileDriverID, "Trace Level", System.Diagnostics.TraceLevel.Error.ToString()); EventLogger.LoggingLevel = System.Diagnostics.TraceLevel.Warning; EventLogger.LogMessage("Invalid Trace Level string found in settings profile. Value was: " + level + ". Trace Level has been automatically set to Warning now. Problem automatically resolved!", System.Diagnostics.TraceLevel.Warning); } //myFocuserManager = FocuserManager.GetInstance(); // Focuser Manager is implemented as a singleton just so that // there is no chance of creating multiple instances of it. hubFocuser1 = HubFocuserRev2.Instance1; hubFocuser2 = HubFocuserRev2.Instance2; EventLogger.LogMessage("myFocuserManager Created Successfully!", System.Diagnostics.TraceLevel.Info); }