Пример #1
0
        private void ClearQR_Click(object sender, EventArgs e)
        {
            QR_code.BackColor = Color.Black;
            QR_code.Clear();

            QR_code.Focus();
        }
Пример #2
0
        private void jig_close_VisibleChanged(object sender, EventArgs e)
        {
            if (jig_close.Visible == true)
            {
                jig_open.Visible = false;
                Start_dowload();
            }
            else
            {
                try
                {
                    jig_open.Visible = true;
                    QR_code.Clear();

                    MB.WriteSingleRegister(ModbusRTU.ADD_CLR, 1);
                }
                catch
                {
                }
            }
        }
Пример #3
0
        void Logfiletxt()
        {
            if ((Status_PGFP6.Text == "PASS" || Status_PGFP6.Text == "ERROR") && QR_code.Text != "")
            {
                //Logfile.addDataToExcel(Logfile.Rownumber.ToString(),QR_code.Text, Status_PGFP6.Text, DateTime.Now.ToString("MM-dd-yyyy-HH:mm:ss"), " ");

                string pathTotal = PG_FP6_UI.Properties.Settings.Default.pathLogfile;
                string path_Day  = DateTime.Now.ToString("MM-dd-yyyy").ToString();

                string Full_path         = Path.Combine(pathTotal, path_Day);
                string Full_path_OK      = Path.Combine(Full_path, "OK");
                string Full_path_NG      = Path.Combine(Full_path, "NG");
                string Full_path_OK_file = Path.Combine(Full_path_OK, QR_code.Text + ".txt");
                string Full_path_NG_file = Path.Combine(Full_path_NG, QR_code.Text + ".txt");
                //=====================================txt========================================================C:\Users\MEIKO\Desktop\PGFP6_DATA
                // string txtpath = System.IO.Path.Combine(@"" + PG_FP6_UI.Properties.Settings.Default.pathLogfile, "PGFP6-" + DateTime.Now.ToString("MM-dd-yyyy") + ".xls");
                //string OK_path = System.IO.Path.Combine(@"C:\Users\MEIKO\Desktop\PGFP6_DATA\OK", QR_code.Text + DateTime.Now.ToString("MM-dd-yyyy") + ".txt");
                //string NG_path = System.IO.Path.Combine(@"C:\Users\MEIKO\Desktop\PGFP6_DATA\NG", QR_code.Text + DateTime.Now.ToString("MM-dd-yyyy") + ".txt");
                string T_path;
                if (Status_PGFP6.Text == "PASS")
                {
                    T_path = Full_path_OK_file;
                }
                else
                {
                    T_path = Full_path_NG_file;
                }
                using (FileStream fileStream = File.Create(T_path))
                    using (StreamWriter writer = new StreamWriter(fileStream))
                    {
                        writer.WriteLine(QR_code.Text + "___" + checksumMCU.Text + "___" + Filename.Text + "___" + DateTime.Now.ToString("MM-dd-yyyy-HH:mm:ss"));
                    }
                //================================================================================================

                this.QR_code.TextChanged += new System.EventHandler(this.QR_code_TextChanged);
                QR_code.Focus();
            }
        }
Пример #4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //Data = new Data(this);
            CodeModel_setup.Text = Data.Code_model.Text;


            if (LED_MCU.BackColor == Color.Red)
            {
                LED_MCU.BackColor = Color.DodgerBlue;
            }
            else
            {
                LED_MCU.BackColor = Color.Red;
            }

            if (ModbusRTU.Status_CONN == 1)
            {
            }
            if (ModbusRTU.Status_BUSY == 1)
            {
                Status_PGFP6.BackColor = Color.Yellow;
            }
            else if (ModbusRTU.Status_ERROR == 1)
            {
                Status_PGFP6.BackColor = Color.Red;
            }
            else if (ModbusRTU.Status_PASS == 1)
            {
                Status_PGFP6.BackColor = Color.Lime;
            }
            else
            {
                Status_PGFP6.BackColor = Color.Black;
            }
            //-----------------------------TRANG THAI JIG----------------------------
            if (ModbusRTU.Status_CTHT == 0)
            {
                jig_close.Visible = false;
            }
            else
            {
                jig_close.Visible = true;
            }

            //---------------------- CHECK FILENAME ------------------
            if (PG_FP6_RS232.Req_Filename > 0)
            {
                PG_FP6_RS232.Req_Filename++;
                if (PG_FP6_RS232.Req_Filename > 10)
                {
                    PG_FP6_RS232.Req_Filename = 0;
                    try
                    {
                        check_Filename();
                    }
                    catch
                    {
                        MessageBox.Show("Check filename error!");
                    }

                    req_checksum_file();
                }
            }
            //--------------------- CHECKSHUM_FILE -------------------
            if (PG_FP6_RS232.Req_Filename == 0 && PG_FP6_RS232.Req_checksum_file > 0)
            {
                PG_FP6_RS232.Req_checksum_file++;
                if (PG_FP6_RS232.Req_checksum_file > 10)
                {
                    PG_FP6_RS232.Req_checksum_file = 0;
                    try
                    {
                        check_sum_file();
                        QR_code.Focus();
                        try
                        {
                            MB.WriteSingleRegister(ModbusRTU.ADD_CLR, 1);
                        }
                        catch
                        { }
                    }
                    catch
                    {
                        MessageBox.Show("Checksum file error!!");
                    }


                    Start.Enabled = true;
                    CLR.Enabled   = true;
                }
            }
            //-------------------- checksum MCU ----------------------
            if (PG_FP6_RS232.Req_checksum_MCU == 1 && (Status_PGFP6.Text == "PASS" || Status_PGFP6.Text == "ERROR"))
            {
                PG_FP6_RS232.Req_checksum_MCU = 0;
                if (Status_PGFP6.Text == "PASS")
                {
                    checksum_MCU();
                }
                if (Status_PGFP6.Text == "ERROR") // NG
                {
                    PG_FP6_RS232.num_ERROR++;
                    Box_NG.Text = PG_FP6_RS232.num_ERROR.ToString();
                }
                //--------------dem so luot NG OK
                PG_FP6_RS232.num_Sum = PG_FP6_RS232.num_ERROR + PG_FP6_RS232.num_Pass;
                Box_Sum.Text         = PG_FP6_RS232.num_Sum.ToString();
            }
            //--------------------------------------------------------------
            if (Status_PGFP6.Text == "BUSY")
            {
                Start.Enabled = false;
            }
            else
            {
                Start.Enabled = true;
            }
        }