//================================================================================================================================================ Lacznosc public void tryConnect() { Debug.WriteLine("tryConnect():"); // Połącz z laserem ------------------------------------------------------------------------------------------------------------------------ POLACZ if (laserStatus == LaserStatus.Disconnected) { // Jesli sterownik zainstalowany if (__isDriverInstalled) { Debug.WriteLine("\t-> Sterownik: Zainstalowany"); PortFinder portFinder = new PortFinder(); if (portFinder.Status == PortFinder.PortFinderStatus.PortFound) { } switch (portFinder.Status) { case PortFinder.PortFinderStatus.PortFound: { Debug.WriteLine("\t-> PortFinder: Urzadzenie podlaczone"); SetLaserConnected(portFinder.PortNameFound); setSerialPort(portFinder.PortNameFound); OpenSerialPort(); // break; } case PortFinder.PortFinderStatus.PortNotFound: { Debug.WriteLine("\t-> PortFinder: Urzadzenie nie jest podlaczone"); setStatusBarMessage(DateTime.Now + " Urzadzenie nie jest podlaczone"); setStatusBoxStatus(StatusBoxStatus.ConnectionError, null); DialogResult installDriverDialog = MessageBox.Show("Urzadzenie nie zostalo wykryte. Czy kabel zostal poprawnie podpiety?", "Nie wykryto urzadzenia", MessageBoxButtons.OK, MessageBoxIcon.Warning ); // break; } case PortFinder.PortFinderStatus.PortMatchError: { Debug.WriteLine("\t-> PortFinder: PortMatchError"); DialogResult installDriverDialog = MessageBox.Show("PortMatchError: Nie wykryto poprawnie urzadzenia", "PortMatchError", MessageBoxButtons.OK, MessageBoxIcon.Error ); // break; } case PortFinder.PortFinderStatus.ManagementSearcherError: { Debug.WriteLine("\t-> PortFinder: ManagementSearchError"); DialogResult installDriverDialog = MessageBox.Show("ManagementSearchError: Nie wykryto poprawnie urzadzenia", "ManagementSearchError", MessageBoxButtons.OK, MessageBoxIcon.Error ); // break; } } } else { Debug.WriteLine("\n\t-> Sterownik: Nie zainstalowany!"); } } // Połącz z laserem ------------------------------------------------------------------------------------------------------------------------ POLACZ // // // // Rozlacz z laserem ------------------------------------------------------------------------------------------------------------------------ ROZLACZ else { CloseSerialPort(); SetLaserDisconnected(); Debug.WriteLine("\t-> Status: Rozlaczono"); } // Rozlacz z laserem ------------------------------------------------------------------------------------------------------------------------ ROZLACZ }
public EngravingForm(string __fileName, List <string> __gcode) { /* * WarningForm tak jak jest w projekcie */ WarningForm warningForm = new WarningForm() { MinimizeBox = false, MaximizeBox = false, }; warningForm.ShowDialog(); if (!warningForm.OK) { this.Close(); } else { InitializeComponent(); fileName = __fileName; originalInstructions = __gcode; try { //Proboj nawiazac polaczenie z urzadzeniem PortFinder pf = new PortFinder(); if (pf.Status == PortFinder.PortFinderStatus.PortFound) { SetSerialPort(pf.PortNameFound); OpenSerialPort(); } else { DialogResult portFinderErrorDialog = MessageBox.Show("Wystapil blad podczas wykrywania urzadzenia.", "Nie wykryto urzadzenia", MessageBoxButtons.OK, MessageBoxIcon.Error ); } // Wszystkie instrukcje queuedInstructions = new Queue <string>(); // Nastepne instrukcje nextInstructions = new Queue <string>(); // Przygotuj progress bar progressBar.Maximum = originalInstructions.Count; // Przygotuj labelTitle labelTitle.Text = $"Grawerowanie {Path.GetFileName(fileName)}..."; // Przenies instrukcje z argumentow konstruktora EngravingForm do queuedInstructions foreach (string line in originalInstructions) { queuedInstructions.Enqueue(line); } // Inicjalizacja Listy<int> instructionTimes instructionTimes = new List <int>(); // Zacznij mierzyc czas stopwatch = Stopwatch.StartNew(); // Rozpocznij dodawanie instrukcji PopulateNextInstructions(1); // Aktywuj proces ActivateInstructionTimer(); ActivateSecondsTimer(); } catch { DialogResult portFinderErrorDialog = MessageBox.Show("Wystapil blad podczas grawerowania.", "Blad", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } }