private void Parcheggia() { try { timer_refresh.Stop(); if (Messaggi.YesNo("ATTENZIONE!! In fase di parcheggio non è possibile agire sulla cupola e sulla montatura. Continuare?") == DialogResult.Yes) { label_azimut.Text = "---"; label_altezza.Text = "---"; label_posizione_montatura.Text = "---"; label_posizione_cupola.Text = "---"; RiceviDatiMONT(":KA#:KA#"); ARDU.WriteLine("Q"); richTextBoxCommunication.Text += Environment.NewLine + "Send Q to Arduino. N.:17"; Funzioni.Wait(90000, progressBar); Messaggi.Show("Parcheggio avvenuto con successo"); } else { Messaggi.ShowWarning("La montatura non è parcheggiata"); } timer_refresh.Start(); evento_parcheggia = false; } catch (Exception ex) { Messaggi.ShowException("Errore al parcheggia", ex); } }
public static void CheckForAnotherIstance() { if (System.Diagnostics.Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Count() > 1) { Messaggi.ShowWarning("Un altra istanza del programma è già in esecuzione"); Application.Exit(); } }
private void AccendiMontatura() { try { if (Funzioni.GetStatus("MONTATURA").Equals("OFF")) { ARDU.WriteLine("A"); if (Messaggi.YesNo("Ricerca satelliti in corso, non sarà possibile agire sul programma...") == DialogResult.Yes) { Funzioni.Wait(90000, progressBar); } else { return; } Funzioni.SetStatus("MONTATURA", "ON"); button_accendi_pannello.Visible = false; Messaggi.ShowWarning("ATTENZIONE!! Settare la porta seriale della montatura da tastierino.\n\t- Menù\n\t- Impostazioni\n\t- Porta GPS\n\t- Seriale\n\t- OK"); ARDU.WriteLine("VG"); richTextBoxCommunication.Text += Environment.NewLine + "Send VG to Arduino. N.:9"; button_accendi.Text = "Spegni montatura"; button_accendi.BackColor = Color.Green; button_muovi.Visible = true; button_cupola.Visible = true; button_piu.Visible = true; button_insegui.Visible = true; button_meno.Visible = true; button_parcheggia.Visible = true; } else if (Funzioni.GetStatus("MONTATURA").Equals("ON")) { if (Messaggi.YesNo("ATTENZIONE!! Settare la porta GPS della montatura da tastierino.\n\t- Menù\n\t- Impostazioni\n\t- Porta GPS\n\t- GPS\n\t- OK\n\nE' stato fatto?") == DialogResult.Yes) { ARDU.WriteLine("A"); richTextBoxCommunication.Text += Environment.NewLine + "Send A to Arduino. N.:10"; Messaggi.Show("Spegnimento montatura, non sarà possibile agire sul programma..."); Funzioni.Wait(20000, progressBar); ARDU.WriteLine("g"); richTextBoxCommunication.Text += Environment.NewLine + "Send g to Arduino. N.:11"; Funzioni.SetStatus("MONTATURA", "OFF"); button_accendi_pannello.Visible = true; button_accendi.Text = "Accendi montatura"; button_accendi.BackColor = Color.Red; } } } catch (Exception ex) { Messaggi.ShowException("Errore all'accensione della montatura", ex); } }
public static void CheckForInternetConnection() { try { Ping myPing = new Ping(); String host = "google.com"; byte[] buffer = new byte[32]; int timeout = 2000; PingOptions pingOptions = new PingOptions(); PingReply reply = myPing.Send(host, timeout, buffer, pingOptions); connection = reply.Status == IPStatus.Success; } catch { connection = false; Messaggi.ShowWarning("Connessione a internet assente"); } }
private void ComboBox_porta_montatura_SelectedIndexChanged(object sender, EventArgs e) { try { if (ComboBox_porta_montatura.SelectedItem.Equals(ComboBox_porta_arduino.SelectedItem)) { Messaggi.ShowWarning("Montatura e cupola settati sulla medesima porta"); } if (checkBox_default_montatura.Checked) { Funzioni.SetStatus("COM_MONTATURA", ComboBox_porta_montatura.SelectedItem.ToString()); } } catch (Exception ex) { Messaggi.ShowException("Errore in ComboBox_porta_montatura_SelectedIndexChanged", ex); } }