// 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) { goto END; } } //3 - Validate temperature sensor if (myGlobal.myTesting.IsCheckTemperature) { myGlobal.myTesting.ValidateTemperature = "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.ValidateTemperature = "Failed"; goto END; } } //check temperature sensor r = ProjectTestItem.Is_Sensor_Valid_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, SensorType.Temperature, myGlobal.mySetting.TemperatureValue, myGlobal.mySetting.TemperatureAccuracy, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateTemperature = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //4 - Validate humidity sensor if (myGlobal.myTesting.IsCheckHumidity) { myGlobal.myTesting.ValidateHumidity = "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.ValidateHumidity = "Failed"; goto END; } } //check humidity sensor r = ProjectTestItem.Is_Sensor_Valid_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, SensorType.Humidity, myGlobal.mySetting.HumidityValue, myGlobal.mySetting.HumidityAccuracy, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateHumidity = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //5 - Validate CO sensor if (myGlobal.myTesting.IsCheckCOSensor) { myGlobal.myTesting.ValidateCoSensor = "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.ValidateCoSensor = "Failed"; goto END; } } //check CO sensor r = ProjectTestItem.Is_Sensor_Valid_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, SensorType.CO, myGlobal.mySetting.CoValue, myGlobal.mySetting.CoAccuracy, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateCoSensor = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //6 - 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; } } Dispatcher.Invoke(new Action(() => { this.Opacity = 0.5; myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA LED +++\r\n"); SingleLED window = new SingleLED(myGlobal.myTesting.ID, DeviceType.SMH_CO); window.ShowDialog(); r = window.LedResult == "1"; myGlobal.myTesting.ValidateLED = window.LedResult == "1" ? "Passed" : "Failed"; myGlobal.myTesting.LogSystem += window.LedResult == "1" ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n"; switch (window.LedResult) { case "": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: Người thao tác chưa click chọn phán định trạng thái LED.\r\n"; break; } case "1": { break; } case "2": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: LED xanh không sáng.\r\n"; break; } case "3": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: LED đỏ không sáng.\r\n"; break; } case "4": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: Cả 2 LED đều không sáng.\r\n"; break; } } this.Opacity = 1; })); if (!r) { goto END; } } //7 - Validate speaker if (myGlobal.myTesting.IsCheckSpeaker) { myGlobal.myTesting.ValidateSpeaker = "Waiting..."; Thread.Sleep(3000); // //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.ValidateSpeaker = "Failed"; goto END; } } //check speaker Dispatcher.Invoke(new Action(() => { this.Opacity = 0.5; myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA CÒI BÁO ĐỘNG +++\r\n"); SingleSpeaker window = new SingleSpeaker(myGlobal.myTesting.ID, DeviceType.SMH_CO); window.ShowDialog(); r = window.SpeakerResult == "1"; myGlobal.myTesting.ValidateSpeaker = window.SpeakerResult == "1" ? "Passed" : "Failed"; myGlobal.myTesting.LogSystem += window.SpeakerResult == "1" ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n"; switch (window.SpeakerResult) { case "": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: người thao tác chưa click chọn phán định trạng thái còi báo động.\r\n"; break; } case "1": { break; } case "2": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: còi báo động không kêu.\r\n"; break; } } this.Opacity = 1; })); if (!r) { goto END; } } //8 - 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 = "CO DETECTOR", 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; } } //10. Switch firmware to user mode if (myGlobal.myTesting.IsSwitchFirmwareMode) { myGlobal.myTesting.SwitchFirmwareMode = "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.SwitchFirmwareMode = "Failed"; goto END; } } //switch firmware to user mode r = ProjectTestItem.Switch_Firmware_To_User_Mode <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, "111", 3); myGlobal.myTesting.SwitchFirmwareMode = 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}\\codetector", 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,Temperature,Humidity,CO,LED,Speaker,PrintLabel,SwitchFW,Total"; string _content = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), myGlobal.myTesting.ID, myGlobal.myTesting.ValidateConnection, myGlobal.myTesting.ValidateTransmission, myGlobal.myTesting.ValidateTemperature, myGlobal.myTesting.ValidateHumidity, myGlobal.myTesting.ValidateCoSensor, myGlobal.myTesting.ValidateLED, myGlobal.myTesting.ValidateSpeaker, myGlobal.myTesting.PrintLabel, myGlobal.myTesting.SwitchFirmwareMode, 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(); }
// private void _RunAll(string id, string sn) { myGlobal.myTesting.StartButtonContent = "STOP"; timer_scrollsystemlog.Start(); Stopwatch st = new Stopwatch(); st.Start(); bool r = false; int comretry = myGlobal.mySetting.CommonRetry; //release device under test if (ProjectTestItem.DUT != null) { ProjectTestItem.DUT = null; } //init control myGlobal.myTesting.initValidating(); myGlobal.myTesting.ID = id; myGlobal.myTesting.SerialNumber = sn; //1 - validate product id if (myGlobal.myTesting.IsVerifyID) { myGlobal.myTesting.ValidateID = "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, comretry); if (!r) { myGlobal.myTesting.ValidateID = "Failed"; return; } } //validate ID r = ProjectTestItem.Validate_ID_Value_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateID = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //2 - validate firmware version if (myGlobal.myTesting.IsVerifyFW) { myGlobal.myTesting.ValidateFirmware = "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, comretry); if (!r) { myGlobal.myTesting.ValidateFirmware = "Failed"; return; } } //validate firmware version r = ProjectTestItem.Validate_Firmware_Version_Value_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, myGlobal.mySetting.FirmwareVersion, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateFirmware = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //3 - validate model if (myGlobal.myTesting.IsVerifyModel) { myGlobal.myTesting.ValidateModel = "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, comretry); if (!r) { myGlobal.myTesting.ValidateModel = "Failed"; return; } } //validate model r = ProjectTestItem.Validate_Model_Value_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, myGlobal.mySetting.Model, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateModel = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //4 - write serial number if (myGlobal.myTesting.IsWriteSN) { myGlobal.myTesting.WriteSerialNumber = "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, comretry); if (!r) { myGlobal.myTesting.WriteSerialNumber = "Failed"; return; } } //write serial number r = ProjectTestItem.Write_SerialNumber_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, myGlobal.myTesting.SerialNumber, comretry, myGlobal.mySetting.DelayRetry); if (!r) { myGlobal.myTesting.WriteSerialNumber = "Failed"; goto END; } //validate serial number r = ProjectTestItem.Validate_SerialNumber_Value_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, myGlobal.myTesting.SerialNumber, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.WriteSerialNumber = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //5 - Validate temperature sensor if (myGlobal.myTesting.IsCheckTemperature) { myGlobal.myTesting.ValidateTemperature = "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, comretry); if (!r) { myGlobal.myTesting.ValidateTemperature = "Failed"; return; } } //check temperature sensor r = ProjectTestItem.Is_Sensor_Valid_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, SensorType.Temperature, myGlobal.mySetting.TemperatureValue, myGlobal.mySetting.TemperatureAccuracy, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateTemperature = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //6 - Validate humidity sensor if (myGlobal.myTesting.IsCheckHumidity) { myGlobal.myTesting.ValidateHumidity = "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, comretry); if (!r) { myGlobal.myTesting.ValidateTemperature = "Failed"; return; } } //check humidity sensor r = ProjectTestItem.Is_Sensor_Valid_D <TestingInformation>(myGlobal.myTesting, myGlobal.myTesting.ID, DeviceType.SMH_CO, SensorType.Humidity, myGlobal.mySetting.HumidityValue, myGlobal.mySetting.HumidityAccuracy, comretry, myGlobal.mySetting.DelayRetry); myGlobal.myTesting.ValidateHumidity = r == true ? "Passed" : "Failed"; if (!r) { goto END; } } //7 - 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, comretry); if (!r) { myGlobal.myTesting.ValidateTemperature = "Failed"; return; } } //check led Dispatcher.Invoke(new Action(() => { this.Opacity = 0.5; myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA LED +++\r\n"); SingleLED window = new SingleLED(myGlobal.myTesting.ID, DeviceType.SMH_CO); window.ShowDialog(); r = window.LedResult == "1"; myGlobal.myTesting.ValidateLED = window.LedResult == "1" ? "Passed" : "Failed"; myGlobal.myTesting.LogSystem += window.LedResult == "1" ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n"; switch (window.LedResult) { case "": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: Người thao tác chưa click chọn phán định trạng thái LED.\r\n"; break; } case "1": { break; } case "2": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: LED xanh không sáng.\r\n"; break; } case "3": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: LED đỏ không sáng.\r\n"; break; } case "4": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: Cả 2 LED đều không sáng.\r\n"; break; } } this.Opacity = 1; })); if (!r) { goto END; } } //8 - Validate speaker if (myGlobal.myTesting.IsCheckSpeaker) { myGlobal.myTesting.ValidateSpeaker = "Waiting..."; Thread.Sleep(3000); // //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, comretry); if (!r) { myGlobal.myTesting.ValidateTemperature = "Failed"; return; } } //check speaker Dispatcher.Invoke(new Action(() => { this.Opacity = 0.5; myGlobal.myTesting.LogSystem += string.Format("\r\n+++ KIỂM TRA CÒI BÁO ĐỘNG +++\r\n"); SingleSpeaker window = new SingleSpeaker(myGlobal.myTesting.ID, DeviceType.SMH_CO); window.ShowDialog(); r = window.SpeakerResult == "1"; myGlobal.myTesting.ValidateSpeaker = window.SpeakerResult == "1" ? "Passed" : "Failed"; myGlobal.myTesting.LogSystem += window.SpeakerResult == "1" ? ".........Kết quả: Passed\r\n" : ".........Kết quả: Failed\r\n"; switch (window.SpeakerResult) { case "": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: người thao tác chưa click chọn phán định trạng thái còi báo động.\r\n"; break; } case "1": { break; } case "2": { myGlobal.myTesting.LogSystem += ".........Thông tin lỗi: còi báo động không kêu.\r\n"; break; } } 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 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}\\codetector", 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,SN,ConfID,ConfFW,ConfModel,WriteSN,Temperature,Humidity,LED,Speaker,Total"; string _content = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), myGlobal.myTesting.ID, myGlobal.myTesting.SerialNumber, myGlobal.myTesting.ValidateID, myGlobal.myTesting.ValidateFirmware, myGlobal.myTesting.ValidateModel, myGlobal.myTesting.WriteSerialNumber, myGlobal.myTesting.ValidateTemperature, myGlobal.myTesting.ValidateHumidity, myGlobal.myTesting.ValidateLED, myGlobal.myTesting.ValidateSpeaker, 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(); }