private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { DataSerial = true; Resive = sserialPort.ReadExisting(); Console.WriteLine("__" + Resive + "__"); if (Resive == "READY") { if (Pozicija == 1) { NCdrillForm.PocetneKordinate(NCdrillForm.FizickaDuzinaSajleA, NCdrillForm.FizickaDuzinaSajleB); } if (NCdrillForm.KomandeBool) { switch (Pozicija) { case 0: Form1.sserialPort.Write(NCdrillForm.KomandeLista[0].GetKomanda()); NCdrillForm.FizickaDuzinaSajleA = NCdrillForm.KomandeLista[0].GetDuzinaA(); NCdrillForm.FizickaDuzinaSajleB = NCdrillForm.KomandeLista[0].GetDuzinaB(); NCdrillForm.IzbuseneRupe.Add(NCdrillForm.KomandeLista[0]); NCdrillForm.KomandeLista.RemoveAt(0); Pozicija = 1; break; case 1: int Value = Convert.ToInt32(NCdrillForm.brzinamotora.Split('%')[0]) + 100; // if (Value > 99 && Value < 201) // Form1.sserialPort.Write("GLM" + Value.ToString().PadLeft(3, '0') + "//"); // Slepi obe komande u jednu .... Form1.sserialPort.Write("ZO" + SPDOWN.ToString().PadLeft(2, '0') + "//"); // Spust burgiju Console.WriteLine("SpustiBurgiju"); Pozicija = 2; break; case 2: Form1.sserialPort.Write("ZO" + SPUP.ToString().PadLeft(2, '0') + "//"); // Podigni burgiju Pozicija = 0; if (NCdrillForm.KomandeLista.Count == 0) { NCdrillForm.KomandeBool = false; Form1.sserialPort.Write("GLM101//"); } break; } } } }
private void FormPosition_MouseDown(object sender, MouseEventArgs e) { NCdrillForm.PocetneKordinate(NCdrillForm.TrenutnaDuzinaSajleA, NCdrillForm.TrenutnaDuzinaSajleB); KoordX.Text = NCdrillForm.PocetnaKoordinataX.ToString(); KoordY.Text = NCdrillForm.PocetnaKoordinataY.ToString(); }