Пример #1
0
        //
        private void _RunAll()
        {
            myGlobal.myTesting.StartButtonContent = "STOP";
            timer_scrollsystemlog.Start();

            Stopwatch st = new Stopwatch();

            st.Start();

            bool r        = false;
            int  idretry  = myGlobal.mySetting.GetIDRetry;
            int  comretry = myGlobal.mySetting.CommonRetry;

            //release device under test
            if (ProjectTestItem.DUT != null)
            {
                ProjectTestItem.DUT = null;
            }

            //init control
            myGlobal.myTesting.initValidating();


            //1 - Validate connection vs usb dongle
            if (myGlobal.myTesting.IsCheckConnection)
            {
                myGlobal.myTesting.ValidateConnection = "Waiting...";

                //check connection between DUT (module zigbee) vs PC
                if (ProjectTestItem.DUT == null || ProjectTestItem.DUT.IsConnected == false)
                {
                    r = ProjectTestItem.Is_DUT_Connected_To_Client_PC <TestingInformation, SettingInformation>(myGlobal.myTesting, myGlobal.mySetting, comretry);
                    if (!r)
                    {
                        myGlobal.myTesting.ValidateConnection = "Failed";
                        goto END;
                    }
                }
                //check connection between DUT (module zigbee) vs usb dongle
                string id = "";
                r = ProjectTestItem.Is_Module_ZigBee_Join_To_Network_D <TestingInformation>(myGlobal.myTesting, comretry, idretry, myGlobal.mySetting.DelayRetry, out id);
                myGlobal.myTesting.ValidateConnection = r == true ? "Passed" : "Failed";
                myGlobal.myTesting.ID = id;
                if (!r)
                {
                    goto END;
                }
            }

            //2 - Validate data transmission vs usb dongle
            if (myGlobal.myTesting.IsCheckTransmission)
            {
                myGlobal.myTesting.ValidateTransmission = "Waiting...";

                //check connection between DUT (module zigbee) vs PC
                if (ProjectTestItem.DUT == null || ProjectTestItem.DUT.IsConnected == false)
                {
                    r = ProjectTestItem.Is_DUT_Connected_To_Client_PC <TestingInformation, SettingInformation>(myGlobal.myTesting, myGlobal.mySetting, comretry);
                    if (!r)
                    {
                        myGlobal.myTesting.ValidateTransmission = "Failed";
                        goto END;
                    }
                }
                //check data transmission between DUT (module zigbee) vs usb dongle
                string cmd = string.Format("CHECK,{0},SMH_ZIGBEE,RF!", myGlobal.myTesting.ID);
                r = ProjectTestItem.Is_DUT_Transmitted_To_Node_RF_D <TestingInformation>(myGlobal.myTesting, comretry, myGlobal.mySetting.DelayRetry, cmd);
                myGlobal.myTesting.ValidateTransmission = r == true ? "Passed" : "Failed";
                if (!r)
                {
                    if (myGlobal.mySetting.StopTest.Equals("Yes"))
                    {
                        goto END;
                    }
                }
            }


            ////3 - Validate LED
            if (myGlobal.myTesting.IsCheckLED)
            {
                myGlobal.myTesting.ValidateLED = "Waiting...";

                //check connection between DUT (module zigbee) vs PC
                if (ProjectTestItem.DUT == null || ProjectTestItem.DUT.IsConnected == false)
                {
                    r = ProjectTestItem.Is_DUT_Connected_To_Client_PC <TestingInformation, SettingInformation>(myGlobal.myTesting, myGlobal.mySetting, comretry);
                    if (!r)
                    {
                        myGlobal.myTesting.ValidateLED = "Failed";
                        goto END;
                    }
                }
                //check led
                Dispatcher.Invoke(new Action(() => {
                    this.Opacity = 0.5;
                    myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA LED +++\r\n");
                    MultiLED window = new MultiLED(myGlobal.myTesting.ID, DeviceType.SMH_SW3);
                    window.ShowDialog();
                    r = window.Led1Result && window.Led2Result && window.Led3Result;
                    myGlobal.myTesting.ValidateLED = r ? "Passed" : "Failed";
                    string msg = string.Format(".........LED1 : {0}\r\n", window.Led1Result);
                    msg       += string.Format(".........LED2 : {0}\r\n", window.Led2Result);
                    msg       += string.Format(".........LED3 : {0}\r\n", window.Led3Result);
                    myGlobal.myTesting.LogSystem += msg;
                    myGlobal.myTesting.LogSystem += r ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n";
                    this.Opacity = 1;
                }));

                if (!r)
                {
                    if (myGlobal.mySetting.StopTest.Equals("Yes"))
                    {
                        goto END;
                    }
                }
            }

            //4 - Validate touch button
            if (myGlobal.myTesting.IsCheckTouchButton)
            {
                myGlobal.myTesting.ValidateTouchButton = "Waiting...";

                //check connection between DUT (module zigbee) vs PC
                if (ProjectTestItem.DUT == null || ProjectTestItem.DUT.IsConnected == false)
                {
                    r = ProjectTestItem.Is_DUT_Connected_To_Client_PC <TestingInformation, SettingInformation>(myGlobal.myTesting, myGlobal.mySetting, comretry);
                    if (!r)
                    {
                        myGlobal.myTesting.ValidateTouchButton = "Failed";
                        goto END;
                    }
                }
                //check touch button
                Dispatcher.Invoke(new Action(() => {
                    this.Opacity = 0.5;
                    myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA NÚT CẢM ỨNG +++\r\n");
                    MultiTouchButton window       = new MultiTouchButton(myGlobal.myTesting.ID);
                    window.ShowDialog();
                    r = window.TouchResult;
                    myGlobal.myTesting.ValidateTouchButton = r ? "Passed" : "Failed";
                    string msg = window.Message;
                    myGlobal.myTesting.LogSystem += msg;
                    myGlobal.myTesting.LogSystem += r ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n";
                    this.Opacity = 1;
                }));

                if (!r)
                {
                    if (myGlobal.mySetting.StopTest.Equals("Yes"))
                    {
                        goto END;
                    }
                }
            }

            //5 - Validate power switch
            if (myGlobal.myTesting.IsCheckPowerSwitch)
            {
                myGlobal.myTesting.ValidatePowerSwitch = "Waiting...";

                //check power switch
                Dispatcher.Invoke(new Action(() => {
                    this.Opacity = 0.5;
                    myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA POWER SWITCH +++\r\n");
                    PowerSwitch window            = new PowerSwitch();
                    window.ShowDialog();
                    r          = window.Lamp1Result && window.Lamp2Result && window.Lamp3Result;
                    string msg = string.Format(".........Power Switch1 : {0}\r\n", window.Lamp1Result);
                    msg       += string.Format(".........Power Switch2 : {0}\r\n", window.Lamp2Result);
                    msg       += string.Format(".........Power Switch3 : {0}\r\n", window.Lamp3Result);
                    myGlobal.myTesting.LogSystem          += msg;
                    myGlobal.myTesting.ValidatePowerSwitch = r ? "Passed" : "Failed";
                    myGlobal.myTesting.LogSystem          += r ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n";
                    this.Opacity = 1;
                }));

                if (!r)
                {
                    if (myGlobal.mySetting.StopTest.Equals("Yes"))
                    {
                        goto END;
                    }
                }
            }


            //6 - Save device info (id,type) to sql server
            if (myGlobal.myTesting.IsStorageInfoToSql)
            {
                myGlobal.myTesting.SaveInfoToSql = "Waiting...";

                myGlobal.myTesting.LogSystem += string.Format("\r\n+++ LƯU THÔNG TIN SẢN PHẨM (ID,TYPE) LÊN SQL SERVER +++\r\n");

                //check id valid or not
                r = !string.IsNullOrEmpty(myGlobal.myTesting.ID);
                if (!r)
                {
                    myGlobal.myTesting.SaveInfoToSql = "Failed";
                    myGlobal.myTesting.LogSystem    += ".........Kết quả: Failed\r\n";
                    myGlobal.myTesting.LogSystem    += ".........Thông tin lỗi: ID sản phẩm không đúng\r\n";
                    goto END;
                }
                //save device info to sql server
                string table_name = "ProductManagement";
                var    sqlServer  = new ProjectSqlServer(myGlobal.mySetting.SqlServerName, myGlobal.mySetting.SqlDatabase, myGlobal.mySetting.SqlUser, myGlobal.mySetting.SqlPassword);
                TableProductManagement deviceinfo = new TableProductManagement()
                {
                    DeviceID = myGlobal.myTesting.ID, DeviceType = DeviceType.SMH_SW3.ToString().ToUpper()
                };
                r = sqlServer.Insert_NewRow_To_SqlTable <TableProductManagement>(table_name, deviceinfo, "tb_ID");
                if (!r)
                {
                    myGlobal.myTesting.SaveInfoToSql = "Failed";
                    myGlobal.myTesting.LogSystem    += ".........Kết quả: Failed\r\n";
                    myGlobal.myTesting.LogSystem    += ".........Thông tin lỗi: không thể ghi dữ liệu lên sql server\r\n";
                    goto END;
                }

                myGlobal.myTesting.SaveInfoToSql = "Passed";
                myGlobal.myTesting.LogSystem    += ".........Kết quả: Passed\r\n";
            }

            //7 - Print the product id label
            if (myGlobal.myTesting.IsPrintLabel)
            {
                myGlobal.myTesting.PrintLabel = "Waiting...";

                //check id valid or not
                r = !string.IsNullOrEmpty(myGlobal.myTesting.ID);
                if (!r)
                {
                    myGlobal.myTesting.PrintLabel = "Failed";
                    goto END;
                }
                //print label
                string id_table_name  = "tb_ProductID";
                string log_table_name = "tb_DataLog";
                string report_name    = "ProductID";

                TableProductID id_info = new TableProductID()
                {
                    ProductID = myGlobal.myTesting.ID
                };
                TableDataLog ms_log_info = new TableDataLog()
                {
                    DateTimeCreated = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                    ErrorMessage    = "",
                    Factory         = "",
                    JigNumber       = "",
                    LineCode        = "",
                    ProductCode     = "",
                    ProductColor    = "",
                    ProductID       = id_info.ProductID,
                    ProductName     = "SMARTSWITCH",
                    ProductNumber   = "",
                    Station         = "PCBA-FUNCTION",
                    Worker          = "",
                    WorkOrder       = ""
                };

                r = ProjectTestItem.Print_DUT_ID_Labels <TestingInformation, TableProductID, TableDataLog>
                    (
                    myGlobal.myTesting,
                    myGlobal.myTesting.ID,
                    string.Format("{0}access_db\\{1}", AppDomain.CurrentDomain.BaseDirectory, myGlobal.mySetting.MSAccessFile),
                    id_table_name,
                    id_info,
                    log_table_name,
                    ms_log_info,
                    report_name
                    );
                myGlobal.myTesting.PrintLabel = r == true ? "Passed" : "Failed";
                if (!r)
                {
                    goto END;
                }
            }

END:
            st.Stop();
            timer_scrollsystemlog.Stop();

            myGlobal.myTesting.LogSystem += "\r\n+++ KẾT THÚC KIỂM TRA SẢN PHẨM +++\r\n";
            myGlobal.myTesting.LogSystem += string.Format(">>> Tổng thời gian kiểm tra: {0} ms\r\n", String.Format("{0:n0}", st.ElapsedMilliseconds));
            myGlobal.myTesting.LogSystem += string.Format(">>> Phán định sản phẩm: {0}\r\n", r == true ? "Passed" : "Failed");
            bool ___ = r == true?myGlobal.myTesting.initPassed() : myGlobal.myTesting.initFailed();

            myGlobal.myTesting.StartButtonContent = "START";

            //close device under test
            if (ProjectTestItem.DUT != null && ProjectTestItem.DUT.IsConnected == true)
            {
                ProjectTestItem.DUT.Close();
            }

            //save log
            string logdir = string.Format("{0}log", AppDomain.CurrentDomain.BaseDirectory);

            if (!Directory.Exists(logdir))
            {
                Directory.CreateDirectory(logdir); Thread.Sleep(100);
            }
            string pddir = string.Format("{0}\\smartswitch", logdir);

            if (!Directory.Exists(pddir))
            {
                Directory.CreateDirectory(pddir); Thread.Sleep(100);
            }
            string stdir = string.Format("{0}\\pcba", pddir);

            if (!Directory.Exists(stdir))
            {
                Directory.CreateDirectory(stdir); Thread.Sleep(100);
            }

            string lgsingle = string.Format("{0}\\logsingle", stdir);

            if (!Directory.Exists(lgsingle))
            {
                Directory.CreateDirectory(lgsingle); Thread.Sleep(100);
            }
            string lgtotal = string.Format("{0}\\logtotal", stdir);

            if (!Directory.Exists(lgtotal))
            {
                Directory.CreateDirectory(lgtotal); Thread.Sleep(100);
            }

            //log single
            string dedir = string.Format("{0}\\{1}", lgsingle, DateTime.Now.ToString("yyyyMMdd"));

            if (!Directory.Exists(dedir))
            {
                Directory.CreateDirectory(dedir); Thread.Sleep(100);
            }
            string file = string.Format("{0}\\{1}_{2}_{3}_{4}.txt", dedir, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), string.IsNullOrEmpty(myGlobal.myTesting.ID) ? "NULL" : myGlobal.myTesting.ID, myGlobal.myTesting.TotalResult);

            StreamWriter sw = new StreamWriter(file, true, Encoding.Unicode);

            sw.WriteLine(myGlobal.myTesting.LogSystem);
            sw.Close();

            //log total
            string _title   = "DateTimeCreate,ID,ConRF,TransRF,LED,TouchButton,PowerSwitch,PrintLabel,Total";
            string _content = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                                            DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                                            myGlobal.myTesting.ID,
                                            myGlobal.myTesting.ValidateConnection,
                                            myGlobal.myTesting.ValidateTransmission,
                                            myGlobal.myTesting.ValidateLED,
                                            myGlobal.myTesting.ValidateTouchButton,
                                            myGlobal.myTesting.ValidatePowerSwitch,
                                            myGlobal.myTesting.PrintLabel,
                                            myGlobal.myTesting.TotalResult);

            string ft = string.Format("{0}\\{1}.csv", lgtotal, DateTime.Now.ToString("yyyyMMdd"));

            if (!File.Exists(ft))
            {
                sw = new StreamWriter(ft, true, Encoding.Unicode);
                sw.WriteLine(_title);
            }
            else
            {
                sw = new StreamWriter(ft, true, Encoding.Unicode);
            }
            sw.WriteLine(_content);
            sw.Close();
        }
Пример #2
0
        //
        private void _RunAll(string _id)
        {
            myGlobal.myTesting.StartButtonContent = "STOP";
            timer_scrollsystemlog.Start();

            Stopwatch st = new Stopwatch();

            st.Start();

            bool r = false;

            //release device under test
            if (ProjectTestItem.DUT != null)
            {
                ProjectTestItem.DUT = null;
            }

            //init control
            myGlobal.myTesting.initValidating();
            myGlobal.myTesting.ID = _id;

            ////1 - Validate LED
            if (myGlobal.myTesting.IsCheckLED)
            {
                myGlobal.myTesting.ValidateLED = "Waiting...";

                //check connection between DUT (usb dongle) vs PC
                if (ProjectTestItem.DUT == null || ProjectTestItem.DUT.IsConnected == false)
                {
                    r = ProjectTestItem.Open_Device_USB_Dongle(myGlobal.myTesting, myGlobal.mySetting, 10);
                    if (!r)
                    {
                        myGlobal.myTesting.ValidateLED = "Failed";
                        goto END;
                    }
                }
                //check led
                Dispatcher.Invoke(new Action(() => {
                    this.Opacity = 0.5;
                    myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA LED +++\r\n");
                    MultiLED window = new MultiLED(myGlobal.myTesting.ID, DeviceType.SMH_SW3);
                    window.ShowDialog();
                    r = window.Led1Result && window.Led2Result && window.Led3Result;
                    myGlobal.myTesting.ValidateLED = r ? "Passed" : "Failed";
                    string msg = string.Format(".........LED1 : {0}\r\n", window.Led1Result);
                    msg       += string.Format(".........LED2 : {0}\r\n", window.Led2Result);
                    msg       += string.Format(".........LED3 : {0}\r\n", window.Led3Result);
                    myGlobal.myTesting.LogSystem += msg;
                    myGlobal.myTesting.LogSystem += r ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n";
                    this.Opacity = 1;
                }));

                if (!r)
                {
                    goto END;
                }
            }

            //2 - Validate touch button
            if (myGlobal.myTesting.IsCheckTouchButton)
            {
                myGlobal.myTesting.ValidateTouchButton = "Waiting...";

                //check connection between DUT (usb dongle) vs PC
                if (ProjectTestItem.DUT == null || ProjectTestItem.DUT.IsConnected == false)
                {
                    r = ProjectTestItem.Open_Device_USB_Dongle(myGlobal.myTesting, myGlobal.mySetting, 10);
                    if (!r)
                    {
                        myGlobal.myTesting.ValidateTouchButton = "Failed";
                        goto END;
                    }
                }
                //check touch button
                Dispatcher.Invoke(new Action(() => {
                    this.Opacity = 0.5;
                    myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA NÚT CẢM ỨNG +++\r\n");
                    MultiTouchButton window       = new MultiTouchButton(myGlobal.myTesting.ID);
                    window.ShowDialog();
                    r = window.TouchResult;
                    myGlobal.myTesting.ValidateTouchButton = r ? "Passed" : "Failed";
                    string msg = window.Message;
                    myGlobal.myTesting.LogSystem += msg;
                    myGlobal.myTesting.LogSystem += r ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n";
                    this.Opacity = 1;
                }));

                if (!r)
                {
                    goto END;
                }
            }


            //3 - Validate power switch
            if (myGlobal.myTesting.IsCheckPowerSwitch)
            {
                myGlobal.myTesting.ValidatePowerSwitch = "Waiting...";

                //check power switch
                Dispatcher.Invoke(new Action(() => {
                    this.Opacity = 0.5;
                    myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA POWER SWITCH +++\r\n");
                    PowerSwitch window            = new PowerSwitch();
                    window.ShowDialog();
                    r          = window.Lamp1Result && window.Lamp2Result && window.Lamp3Result;
                    string msg = string.Format(".........Power Switch1 : {0}\r\n", window.Lamp1Result);
                    msg       += string.Format(".........Power Switch2 : {0}\r\n", window.Lamp2Result);
                    msg       += string.Format(".........Power Switch3 : {0}\r\n", window.Lamp3Result);
                    myGlobal.myTesting.LogSystem          += msg;
                    myGlobal.myTesting.ValidatePowerSwitch = r ? "Passed" : "Failed";
                    myGlobal.myTesting.LogSystem          += r ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n";
                    this.Opacity = 1;
                }));

                if (!r)
                {
                    goto END;
                }
            }

END:
            st.Stop();
            timer_scrollsystemlog.Stop();

            myGlobal.myTesting.LogSystem += "\r\n+++ KẾT THÚC KIỂM TRA SẢN PHẨM +++\r\n";
            myGlobal.myTesting.LogSystem += string.Format(">>> Tổng thời gian sản phẩm: {0} mili giây\r\n", String.Format("{0:n0}", st.ElapsedMilliseconds));
            myGlobal.myTesting.LogSystem += string.Format(">>> Phán định sản phẩm: {0}\r\n", r == true ? "Passed" : "Failed");
            bool ___ = r == true?myGlobal.myTesting.initPassed() : myGlobal.myTesting.initFailed();

            myGlobal.myTesting.StartButtonContent = "START";

            //close device under test
            if (ProjectTestItem.DUT != null && ProjectTestItem.DUT.IsConnected == true)
            {
                ProjectTestItem.DUT.Close();
            }

            //save log
            string logdir = string.Format("{0}log", AppDomain.CurrentDomain.BaseDirectory);

            if (!Directory.Exists(logdir))
            {
                Directory.CreateDirectory(logdir); Thread.Sleep(100);
            }
            string pddir = string.Format("{0}\\smartswitch", logdir);

            if (!Directory.Exists(pddir))
            {
                Directory.CreateDirectory(pddir); Thread.Sleep(100);
            }
            string stdir = string.Format("{0}\\asm", pddir);

            if (!Directory.Exists(stdir))
            {
                Directory.CreateDirectory(stdir); Thread.Sleep(100);
            }

            string lgsingle = string.Format("{0}\\logsingle", stdir);

            if (!Directory.Exists(lgsingle))
            {
                Directory.CreateDirectory(lgsingle); Thread.Sleep(100);
            }
            string lgtotal = string.Format("{0}\\logtotal", stdir);

            if (!Directory.Exists(lgtotal))
            {
                Directory.CreateDirectory(lgtotal); Thread.Sleep(100);
            }

            //log single
            string dedir = string.Format("{0}\\{1}", lgsingle, DateTime.Now.ToString("yyyyMMdd"));

            if (!Directory.Exists(dedir))
            {
                Directory.CreateDirectory(dedir); Thread.Sleep(100);
            }
            string file = string.Format("{0}\\{1}_{2}_{3}_{4}.txt", dedir, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), string.IsNullOrEmpty(myGlobal.myTesting.ID) ? "NULL" : myGlobal.myTesting.ID, myGlobal.myTesting.TotalResult);

            StreamWriter sw = new StreamWriter(file, true, Encoding.Unicode);

            sw.WriteLine(myGlobal.myTesting.LogSystem);
            sw.Close();

            //log total
            string _title   = "DateTimeCreate,ID,LED,TouchButton,PowerSwitch,Total";
            string _content = string.Format("{0},{1},{2},{3},{4},{5}",
                                            DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                                            myGlobal.myTesting.ID,
                                            myGlobal.myTesting.ValidateLED,
                                            myGlobal.myTesting.ValidateTouchButton,
                                            myGlobal.myTesting.ValidatePowerSwitch,
                                            myGlobal.myTesting.TotalResult);

            string ft = string.Format("{0}\\{1}.csv", lgtotal, DateTime.Now.ToString("yyyyMMdd"));

            if (!File.Exists(ft))
            {
                sw = new StreamWriter(ft, true, Encoding.Unicode);
                sw.WriteLine(_title);
            }
            else
            {
                sw = new StreamWriter(ft, true, Encoding.Unicode);
            }
            sw.WriteLine(_content);
            sw.Close();
        }