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)); }
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(); }
private void cmdOK_Click(object sender, EventArgs e) { Properties.Settings.Default.ip_addr = ipaddr.Text; using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Dome"; p.WriteValue(Dome.driverID, "ip_addr222", (string)ipaddr.Text); } Close(); }
private void cmdOK_Click(object sender, EventArgs e) { Properties.Settings.Default.ip_addr = ipaddr.Text; using(ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Dome"; p.WriteValue(Dome.driverID, "ip_addr222", (string)ipaddr.Text); } Close(); }
private void cmdOK_Click(object sender, EventArgs e) { using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Telescope"; p.WriteValue(Telescope.driverID, "Comport", (string)comboBox1.SelectedItem); } // Properties.Settings.Default.CommPort = comboBox1.SelectedItem.ToString(); Dispose(); Close(); }
public void IsSingleton() { //Telescope.RegisterASCOM(typeof(Telescope)); Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; Assert.That(theProfile.IsRegistered(Telescope.ProgId)); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation != null); Assert.That(theLocation, Is.SameAs(ObservationLocation.Location)); }
public void WriteProfile() { using (ASCOM.Utilities.Profile p = new Utilities.Profile() { DeviceType = "Telescope" }) { if (!p.IsRegistered(Const.wiseTelescopeDriverID)) { p.Register(Const.wiseTelescopeDriverID, "Wise40 global settings"); } p.WriteValue(Const.wiseTelescopeDriverID, "SiteDebugLevel", Level.ToString()); } }
private void CmdOkClick(object sender, EventArgs e) { using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "FilterWheel"; p.WriteValue(FilterWheel.driverId, "ComPort", (string)portsSeries.SelectedItem); p.WriteValue(FilterWheel.driverId, "Position1", (string)textBox1.Text); p.WriteValue(FilterWheel.driverId, "Position2", (string)textBox2.Text); p.WriteValue(FilterWheel.driverId, "Position3", (string)textBox3.Text); p.WriteValue(FilterWheel.driverId, "Position4", (string)textBox4.Text); p.WriteValue(FilterWheel.driverId, "Position5", (string)textBox5.Text); } Dispose(); }
private void CmdOkClick(object sender, EventArgs e) { using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Focuser"; p.WriteValue(Focuser.driverId, "ComPort",(string)cbComPort.SelectedItem); p.WriteValue(Focuser.driverId, "SetPos", (string)checkSetPos.Checked.ToString()); p.WriteValue(Focuser.driverId, "RPM", textBoxRpm.Text); if (checkSetPos.Checked) { p.WriteValue(Focuser.driverId, "Pos", (string)textPos.Text.ToString()); } p.WriteValue(Focuser.driverId, "TempDisp", radioCelcius.Checked ? "C" : "F"); } Dispose(); }
private void CmdOkClick(object sender, EventArgs e) { using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Focuser"; p.WriteValue(Focuser.driverId, "ComPort", (string)cbComPort.SelectedItem); p.WriteValue(Focuser.driverId, "SetPos", (string)checkSetPos.Checked.ToString()); p.WriteValue(Focuser.driverId, "RPM", textBoxRpm.Text); if (checkSetPos.Checked) { p.WriteValue(Focuser.driverId, "Pos", (string)textPos.Text.ToString()); } p.WriteValue(Focuser.driverId, "TempDisp", radioCelcius.Checked ? "C" : "F"); } Dispose(); }
private void cmdOK_Click(object sender, EventArgs e) // OK button event handler { if (textBox2.Text == "") { MessageBox.Show("You must specify a value for Steps per Degree"); return; } else { using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Rotator"; p.WriteValue(Rotator.driverID, "ComPort", (string)comboBoxComPort.SelectedItem); p.WriteValue(Rotator.driverID, "SetPos", checkBox1.Checked.ToString()); // 6-16-16 added 2 lines below // p.WriteValue(Rotator.driverID, "Reverse", reverseCheckBox1.Checked.ToString()); // motor sitting shaft up turns clockwise with increasing numbers if NOT reversed p.WriteValue(Rotator.driverID, "ContHold", checkBox2.Checked.ToString()); p.WriteValue(Rotator.driverID, "StepsPerDegree", textBox2.Text.ToString()); // p.WriteValue(Focuser.driverID, "RPM", textBoxRpm.Text); if (checkBox1.Checked) { p.WriteValue(Rotator.driverID, "Pos", textBox1.Text.ToString()); } // p.WriteValue(Focuser.driverID, "TempDisp", radioCelcius.Checked ? "C" : "F"); } Dispose(); // Place any validation constraint checks here // Update the state variables with results from the dialogue Rotator.comPort = (string)comboBoxComPort.SelectedItem; Rotator.traceState = chkTrace.Checked; } // Place any validation constraint checks here // Update the state variables with results from the dialogue //Rotator.comPort = (string)comboBoxComPort.SelectedItem; //Rotator.tl.Enabled = chkTrace.Checked; }
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; } } } }
// // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // private static void RegUnregASCOM(bool bRegister) { Utilities.Profile P = new Utilities.Profile(); P.DeviceType = "Telescope"; // Requires Helper 5.0.3 or later if (bRegister) { P.Register(s_csDriverID, s_csDriverDescription); } else { P.Unregister(s_csDriverID); } try // In case Helper becomes native .NET { Marshal.ReleaseComObject(P); } catch (Exception) { } P = null; }
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 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); } }
// // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // private static void RegUnregASCOM(bool bRegister) { //Helper.Profile P = new Helper.Profile(); Utilities.Profile P = new Utilities.Profile(); P.DeviceType = "Focuser"; if (bRegister) P.Register(s_csDriverID, s_csDriverDescription); else P.Unregister(s_csDriverID); try { Marshal.ReleaseComObject(P); } catch (Exception) { } P = null; }
private void cmdOK_Click_1(object sender, EventArgs e) { if (textBox2.Text == "") { MessageBox.Show("You must specify a value for Steps per Degree"); return; } else { using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Rotator"; p.WriteValue(driverID, "ComPort", (string)comboBoxComPort.SelectedItem); // p.WriteValue(driverID, "SetPos", checkBox1.Checked.ToString()); //p.WriteValue(driverID, "SetPos", "false"); //leave this false so needs to be check everytime used // 6-16-16 added 2 lines below // p.WriteValue(Rotator.driverID, "Reverse", reverseCheckBox1.Checked.ToString()); // motor sitting shaft up turns clockwise with increasing numbers if NOT reversed p.WriteValue(driverID, "ContHold", checkBox2.Checked.ToString()); p.WriteValue(driverID, "StepsPerDegree", textBox2.Text.ToString()); // p.WriteValue(Focuser.driverID, "RPM", textBoxRpm.Text); if (checkBox1.Checked) { p.WriteValue(driverID, "Pos", textBox1.Text.ToString()); } // p.WriteValue(Focuser.driverID, "TempDisp", radioCelcius.Checked ? "C" : "F"); } // Dispose(); // Place any validation constraint checks here // Update the state variables with results from the dialogue // Rotator.comPort = (string)comboBoxComPort.SelectedItem; comPort = (string)comboBoxComPort.SelectedItem; // Rotator.traceState = chkTrace.Checked; traceState = chkTrace.Checked; stepsPerDegree = Convert.ToInt32(textBox2.Text.ToString()); if (checkBox1.Checked) { setPosition = float.Parse(textBox1.Text.ToString()); } // stepsPerDegree = 150; } ASCOM.scopefocusServer.Properties.Settings.Default.stepsPerDegree = stepsPerDegree; ASCOM.scopefocusServer.Properties.Settings.Default.COMPort = comPort; ASCOM.scopefocusServer.Properties.Settings.Default.traceState = traceState; ASCOM.scopefocusServer.Properties.Settings.Default.ContHold = checkBox2.Checked; ASCOM.scopefocusServer.Properties.Settings.Default.SetPos = checkBox1.Checked; ASCOM.scopefocusServer.Properties.Settings.Default.SetPosValue = setPosition; ASCOM.scopefocusServer.Properties.Settings.Default.Save(); // Place any validation constraint checks here // Update the state variables with results from the dialogue //Rotator.comPort = (string)comboBoxComPort.SelectedItem; //Rotator.tl.Enabled = chkTrace.Checked; }
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); }
// // Register or unregister driver for ASCOM. This is harmless if already // registered or unregistered. // private static void RegUnregASCOM(bool bRegister) { Utilities.Profile P = new Utilities.Profile(); P.DeviceType = "Telescope"; // Requires Helper 5.0.3 or later if (bRegister) P.Register(s_csDriverID, s_csDriverDescription); else P.Unregister(s_csDriverID); try // In case Helper becomes native .NET { Marshal.ReleaseComObject(P); } catch (Exception) { } P = null; }
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)); }
void saveParametersImpl(int port, bool traceState) { this.tcpPort = port; this.traceState = traceState; using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = deviceType; p.WriteValue(this.driverId, Focuser.tcpPortProfileName, "" + port); p.WriteValue(this.driverId, Focuser.traceStateProfileName, "" + traceState); } }
// OK button event handler private void cmdOK_Click(object sender, EventArgs e) { // Place any validation constraint checks here Focuser.comPort = comboBoxComPort.Text; // Update the state variables with results from the dialogue Focuser.traceState = chkTrace.Checked; // If a new initial position entered pass it to focuser if (!String.IsNullOrEmpty(txtInitialPosition.Text)) { Focuser.newInitialPosition = Int32.Parse(txtInitialPosition.Text); } else { Focuser.newInitialPosition = 0; } using (ASCOM.Utilities.Profile p = new Utilities.Profile()) { p.DeviceType = "Focuser"; p.WriteValue(Focuser.driverID, "ComPort", (string)comboBoxComPort.Text); } }