Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            sserialPort.Close();
            NCdrillForm PhotoEditor = new NCdrillForm();

            PhotoEditor.ShowDialog();
            PhotoEditor.Dispose();
        }
Example #2
0
        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 button7_Click(object sender, EventArgs e)
        {
            AutoClosingMessageBox.Show("Wait please...", "Message", 500);

            Kordinate TMPP = new Kordinate(0, 0);

            NCdrillForm.OdrediBrojeveKoraka(TMPP);

            try
            {
                Form1.sserialPort.Write("MA" + NCdrillForm.MotorABrojKoraka.ToString().PadLeft(5, '0') + textBox1.Text.PadLeft(3,'0') + NCdrillForm.SmerMotoraA + NCdrillForm.MotorBBrojKoraka.ToString().PadLeft(5, '0') + textBox1.Text.PadLeft(3, '0') + NCdrillForm.SmerMotoraB + "//");
                NCdrillForm.FizickaDuzinaSajleA =NCdrillForm.TrenutnaDuzinaSajleA;
                NCdrillForm.FizickaDuzinaSajleB = NCdrillForm.TrenutnaDuzinaSajleB;
                Form1.Pozicija = 1;
            }
            catch
            {
               AutoClosingMessageBox.Show("Error", "Error", 1000);
            }
        }
 private void FormPosition_MouseDown(object sender, MouseEventArgs e)
 {
     NCdrillForm.PocetneKordinate(NCdrillForm.TrenutnaDuzinaSajleA, NCdrillForm.TrenutnaDuzinaSajleB);
     KoordX.Text = NCdrillForm.PocetnaKoordinataX.ToString();
     KoordY.Text = NCdrillForm.PocetnaKoordinataY.ToString();
 }