//kiem tra wifi qua cong UART public bool excuteUart() { bool ret = false; var prop_wifiresult = testingInfo.GetType().GetProperty("wifiResult"); prop_wifiresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } int count = 0; RE: count++; string data = camera.getWlanInterface(); log_value += data; prop_logsystem.SetValue(testingInfo, log_value); if (data != null) { ret = data.ToUpper().Contains(std_value.ToUpper()); } if (!ret) { if (count < retry_time) { goto RE; } } } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_wifiresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
//kiem tra sd card qua cong UART public bool excuteUart(Grid grid_container) { bool ret = false; var prop_buttonresult = testingInfo.GetType().GetProperty("buttonResult"); prop_buttonresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } Thread.Sleep(500); Application.Current.Dispatcher.Invoke(new Action(() => { uc_button = new UI.ucButton(30); grid_container.Children.Clear(); grid_container.Children.Add(uc_button); })); RE: string data = camera.captureLog(); log_value += data; prop_logsystem.SetValue(testingInfo, log_value); if (data != null) { ret = data.ToUpper().Contains(std_value.ToUpper()); } if (!ret) { if (uc_button.timeOut > 0) { Thread.Sleep(500); goto RE; } } goto END; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_buttonresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
//Kiem tra ir led qua cong telnet public bool excuteTelnet(Grid grid_container) { bool ret = false; var prop_irledresult = testingInfo.GetType().GetProperty("irLedResult"); prop_irledresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } camera.initRGBLedControl(); //led red camera.turnIRLedOn(); Application.Current.Dispatcher.Invoke(new Action(() => { uc_irled = new UI.ucIRLed(30); grid_container.Children.Clear(); grid_container.Children.Add(uc_irled); })); RE: ret = uc_irled.ledResult != -1; if (!ret) { if (uc_irled.timeOut > 0) { Thread.Sleep(100); goto RE; } } ret = uc_irled.ledResult == 0; camera.turnIRLedOff(); log_value += string.Format("...IR LED: \"{0}\"\n", ret ? "sáng màu đỏ" : "không sáng"); prop_logsystem.SetValue(testingInfo, log_value); } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_irledresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
//kiem tra ethernet qua cong UART public bool excuteUart() { bool ret = false; var prop_imagesensorresult = testingInfo.GetType().GetProperty("imageSensorResult"); prop_imagesensorresult.SetValue(testingInfo, "Waiting..."); try { if (!camera.IsConnected()) { goto END; } //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); int count = 0; RE: count++; string data = camera.getImageSensorInterface(); log_value += data; prop_logsystem.SetValue(testingInfo, log_value); bool r = data.ToUpper().Contains(std_value.ToUpper()); if (!r) { if (count < retry_time) { goto RE; } } ret = r; } catch { goto END; } END: prop_imagesensorresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
bool _loginToCamera(string ip, string user, string pass, ref Dut.IPCamera <U> camera) { bool ret = false; int count = 0; RE: count++; camera = new Dut.IPCamera <U>(uploadInfo, ip, user, pass); camera.Login(); ret = camera.IsConnected(); if (!ret) { if (count < 3) { goto RE; } } return(ret); }
//ghi hw ver qua cong telnet public bool excuteTelnet() { bool ret = false; var prop_hardwareresult = testingInfo.GetType().GetProperty("hardwareResult"); prop_hardwareresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } int count = 0; RE: count++; //set hw ver log_value += string.Format("...ghi hardware version \"{0}\" vào camera.\n", std_value); prop_logsystem.SetValue(testingInfo, log_value); ret = camera.setHardwareVersion(std_value); if (!ret) { if (count < retry_time) { goto RE; } else { goto END; } } //verify hw ver after set ret = false; log_value += string.Format("...đọc giá trị hardware version sau khi ghi\n"); prop_logsystem.SetValue(testingInfo, log_value); string data = camera.getHardwareVersion(); log_value += data; prop_logsystem.SetValue(testingInfo, log_value); if (data != null) { ret = data.ToUpper().Contains(std_value.ToUpper()); } if (!ret) { if (count < retry_time) { goto RE; } } } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_hardwareresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
//kiem tra light sensor qua cong UART public bool excuteUart(Grid grid_container) { bool ret = false; bool ret_darkmode = false; bool ret_lightmode = false; var prop_ligthsensorresult = testingInfo.GetType().GetProperty("lightSensorResult"); prop_ligthsensorresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } //dark mode Application.Current.Dispatcher.Invoke(new Action(() => { uc_darkmode = new UI.ucLightSensorDarkMode(30); grid_container.Children.Clear(); grid_container.Children.Add(uc_darkmode); })); RE_DARK: int dark_value = camera.getLightSensorValue(); ret_darkmode = dark_value > dark_lowerlimit && dark_value < dark_upperlimit; if (!ret_darkmode) { if (uc_darkmode.timeOut > 0) { Thread.Sleep(500); goto RE_DARK; } } //wait Application.Current.Dispatcher.Invoke(new Action(() => { grid_container.Children.Clear(); })); Thread.Sleep(500); //light mode Application.Current.Dispatcher.Invoke(new Action(() => { uc_lightmode = new UI.ucLightSensorLightMode(30); grid_container.Children.Clear(); grid_container.Children.Add(uc_lightmode); })); RE_LIGHT: int light_value = camera.getLightSensorValue(); ret_lightmode = light_value > light_lowerlimit; if (!ret_lightmode) { if (uc_lightmode.timeOut > 0) { Thread.Sleep(500); goto RE_LIGHT; } } log_value += string.Format("...Chế độ tối: \"{0}\", \"{1}\"\n", dark_value, ret_darkmode ? "Passed" : "Failed"); log_value += string.Format("...Chế độ sáng: \"{0}\", \"{1}\"\n", light_value, ret_lightmode ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); ret = ret_darkmode && ret_lightmode; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_ligthsensorresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
//kiem tra rgb led qua cong UART public bool excuteUart(Grid grid_container) { bool ret = false; bool ret_ledred = false; bool ret_ledgreen = false; var prop_rgbledresult = testingInfo.GetType().GetProperty("rgbLedResult"); prop_rgbledresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } camera.initRGBLedControl(); //led red camera.turnRGBLedRedOn(); Application.Current.Dispatcher.Invoke(new Action(() => { uc_ledred = new UI.ucRGBLedRed(30); grid_container.Children.Clear(); grid_container.Children.Add(uc_ledred); })); RE_RED: ret_ledred = uc_ledred.ledResult == 0 || uc_ledred.ledResult == 1 || uc_ledred.timeOut == 0; if (!ret_ledred) { Thread.Sleep(100); goto RE_RED; } if (uc_ledred.ledResult != 0) { ret_ledred = false; } camera.turnRGBLedRedOff(); //wait Application.Current.Dispatcher.Invoke(new Action(() => { grid_container.Children.Clear(); })); Thread.Sleep(500); //led green camera.turnRGBLedGreenOn(); Application.Current.Dispatcher.Invoke(new Action(() => { uc_ledgreen = new UI.ucRGBLedGreen(30); grid_container.Children.Clear(); grid_container.Children.Add(uc_ledgreen); })); RE_GREEN: ret_ledgreen = uc_ledgreen.ledResult == 0 || uc_ledgreen.ledResult == 1 || uc_ledgreen.timeOut == 0; if (!ret_ledgreen) { Thread.Sleep(100); goto RE_GREEN; } if (uc_ledgreen.ledResult != 0) { ret_ledgreen = false; } camera.turnRGBLedGreenOff(); log_value += string.Format("...RGB LED đỏ: \"{0}\"\n", ret_ledred ? "sáng" : "không sáng"); log_value += string.Format("...RGB LED xanh: \"{0}\"\n", ret_ledgreen ? "sáng" : "không sáng"); prop_logsystem.SetValue(testingInfo, log_value); ret = ret_ledred && ret_ledgreen; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_rgbledresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
//Nap fw thuong mai qua cong telnet public bool excuteTelnet() { bool ret = false; bool flag_check = false; var prop_rebootresult = uploadInfo.GetType().GetProperty("rebootResult"); prop_rebootresult.SetValue(uploadInfo, "Passed"); //get logsytem var prop_logsystem = uploadInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(uploadInfo); Dut.IPCamera <U> camera = null; try { //login to camera //###############################################################// log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, Login to ip camera\n", DateTime.Now); prop_logsystem.SetValue(uploadInfo, log_value); string camera_ip = (string)uploadInfo.GetType().GetProperty("ipAddress").GetValue(uploadInfo); string telnet_user = (string)settingInfo.GetType().GetProperty("cameraTelnetUser").GetValue(settingInfo); string telnet_pass = (string)settingInfo.GetType().GetProperty("cameraTelnetPassword").GetValue(settingInfo); ret = _loginToCamera(camera_ip, telnet_user, telnet_pass, ref camera); log_value = (string)prop_logsystem.GetValue(uploadInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(uploadInfo, log_value); if (!ret) { goto END; } //check firmware build time //###############################################################// flag_check = (bool)settingInfo.GetType().GetProperty("IsCheckFirmwareBuildTime").GetValue(settingInfo); if (flag_check) { var prop_fwresult = uploadInfo.GetType().GetProperty("firmwareResult"); prop_fwresult.SetValue(uploadInfo, "Waiting..."); log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, check firmware business build time\n", DateTime.Now); prop_logsystem.SetValue(uploadInfo, log_value); string fw_buildtime = (string)settingInfo.GetType().GetProperty("firmwareBuildTime").GetValue(settingInfo); log_value += string.Format("...tiêu chuẩn: {0}\n", fw_buildtime); log_value += string.Format("...thực tế:\n"); prop_logsystem.SetValue(uploadInfo, log_value); string act_buildtime = ""; ret = _checkFWBuildTime(camera, fw_buildtime, out act_buildtime); log_value = (string)prop_logsystem.GetValue(uploadInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(uploadInfo, log_value); prop_fwresult.SetValue(uploadInfo, ret ? "Passed" : "Failed"); uploadInfo.GetType().GetProperty("firmwareBuildTime").SetValue(uploadInfo, act_buildtime); if (!ret) { goto END; } } //check mac address //###############################################################// flag_check = (bool)settingInfo.GetType().GetProperty("IsCheckMacEthernet").GetValue(settingInfo); if (flag_check) { var prop_macresult = uploadInfo.GetType().GetProperty("macResult"); prop_macresult.SetValue(uploadInfo, "Waiting..."); log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, check mac ethernet\n", DateTime.Now); prop_logsystem.SetValue(uploadInfo, log_value); string mac_header = (string)settingInfo.GetType().GetProperty("vnptMacHeader").GetValue(settingInfo); ret = _checkMacEthernet(camera, mac_header); log_value = (string)prop_logsystem.GetValue(uploadInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(uploadInfo, log_value); prop_macresult.SetValue(uploadInfo, ret ? "Passed" : "Failed"); if (!ret) { goto END; } } //check serial number //###############################################################// flag_check = (bool)settingInfo.GetType().GetProperty("IsCheckSerialNumber").GetValue(settingInfo); if (flag_check) { var prop_serialresult = uploadInfo.GetType().GetProperty("serialResult"); prop_serialresult.SetValue(uploadInfo, "Waiting..."); log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, check serial number\n", DateTime.Now); prop_logsystem.SetValue(uploadInfo, log_value); string vnpt_productnumber = (string)settingInfo.GetType().GetProperty("vnptProductNumber").GetValue(settingInfo); string vnpt_maccode = (string)settingInfo.GetType().GetProperty("productMacCode").GetValue(settingInfo); string act_serial = ""; ret = _checkSerialNumber(camera, vnpt_productnumber, vnpt_maccode, out act_serial); log_value = (string)prop_logsystem.GetValue(uploadInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(uploadInfo, log_value); prop_serialresult.SetValue(uploadInfo, ret ? "Passed" : "Failed"); uploadInfo.GetType().GetProperty("serialNumber").SetValue(uploadInfo, act_serial); if (!ret) { goto END; } } //check uid //###############################################################// flag_check = (bool)settingInfo.GetType().GetProperty("IsCheckUID").GetValue(settingInfo); if (flag_check) { var prop_uidresult = uploadInfo.GetType().GetProperty("uidResult"); prop_uidresult.SetValue(uploadInfo, "Waiting..."); log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, check uid\n", DateTime.Now); prop_logsystem.SetValue(uploadInfo, log_value); string vnpt_uidheader = (string)settingInfo.GetType().GetProperty("vnptUidHeader").GetValue(settingInfo); string act_uid = ""; ret = _checkUIDCode(camera, vnpt_uidheader, out act_uid); log_value = (string)prop_logsystem.GetValue(uploadInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(uploadInfo, log_value); prop_uidresult.SetValue(uploadInfo, ret ? "Passed" : "Failed"); uploadInfo.GetType().GetProperty("uidCode").SetValue(uploadInfo, act_uid); if (!ret) { goto END; } } //check hardware version //###############################################################// flag_check = (bool)settingInfo.GetType().GetProperty("IsCheckHardwareVersion").GetValue(settingInfo); if (flag_check) { var prop_hwresult = uploadInfo.GetType().GetProperty("hardwareResult"); prop_hwresult.SetValue(uploadInfo, "Waiting..."); log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, check hardware version\n", DateTime.Now); prop_logsystem.SetValue(uploadInfo, log_value); string hw_version = (string)settingInfo.GetType().GetProperty("hardwareVersion").GetValue(settingInfo); log_value += string.Format("...tiêu chuẩn: {0}\n", hw_version); log_value += string.Format("...thực tế:\n"); prop_logsystem.SetValue(uploadInfo, log_value); string act_hw_ver = ""; ret = _checkHardwareVersion(camera, hw_version, out act_hw_ver); log_value = (string)prop_logsystem.GetValue(uploadInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(uploadInfo, log_value); prop_hwresult.SetValue(uploadInfo, ret ? "Passed" : "Failed"); uploadInfo.GetType().GetProperty("hardwareVersion").SetValue(uploadInfo, act_hw_ver); if (!ret) { goto END; } } } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(uploadInfo, log_value); goto END; } END: if (camera != null && camera.IsConnected()) { camera.Close(); } return(ret); }
//kiem tra ir cut qua cong UART public bool excuteUart(Grid grid_container) { bool ret = false; var prop_ircutresult = testingInfo.GetType().GetProperty("irCutResult"); prop_ircutresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } Thread.Sleep(500); //show form confirm log_value += "...hiển thị giao diện xác nhận trạng thái khối ir cut.\n"; prop_logsystem.SetValue(testingInfo, log_value); Application.Current.Dispatcher.Invoke(new Action(() => { uc_ircut = new UI.ucIRCut(); grid_container.Children.Clear(); grid_container.Children.Add(uc_ircut); })); //play ir cut log_value += "...thiết lập camera giả lập ir cut.\n"; prop_logsystem.SetValue(testingInfo, log_value); camera.virtualIRCut(); RE: if (uc_ircut.isTryAgain) { camera.virtualIRCut(); uc_ircut.isTryAgain = false; } ret = uc_ircut.ircutResult != -1; if (!ret) { Thread.Sleep(100); goto RE; } if (uc_ircut.ircutResult != 0) { ret = false; } //phán định log_value += string.Format("...\n"); log_value += string.Format("... ===> \"{0}\" <===\n", uc_ircut.ircutMessage); log_value += string.Format("...\n"); prop_logsystem.SetValue(testingInfo, log_value); //stop ir cut log_value += "...thiết lập camera dừng giả lập ir cut.\n"; prop_logsystem.SetValue(testingInfo, log_value); camera.switchCameraMode(false); goto END; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_ircutresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
public bool excuteTelnet() { bool ret = false; //get setting string rtsp_link = (string)settingInfo.GetType().GetProperty("cameraRtspLink").GetValue(settingInfo); double std_sharpness = (double)settingInfo.GetType().GetProperty("sharpnessStandard").GetValue(settingInfo); double std_tolerance = (double)settingInfo.GetType().GetProperty("toleranceSharpness").GetValue(settingInfo); string areatest = (string)settingInfo.GetType().GetProperty("areaTestChart").GetValue(settingInfo); double scale = 0; //get testing var prop_macethernet = testingInfo.GetType().GetProperty("macEthernet"); var prop_totalresult = testingInfo.GetType().GetProperty("TotalResult"); var prop_imagesource = testingInfo.GetType().GetProperty("imageSource"); var prop_imagecrop = testingInfo.GetType().GetProperty("imageCrop"); var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { //login to camera log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, Login to ip camera\n", DateTime.Now); prop_logsystem.SetValue(testingInfo, log_value); string camera_ip = (string)settingInfo.GetType().GetProperty("cameraIP").GetValue(settingInfo); string telnet_user = (string)settingInfo.GetType().GetProperty("cameraTelnetUser").GetValue(settingInfo); string telnet_pass = (string)settingInfo.GetType().GetProperty("cameraTelnetPassword").GetValue(settingInfo); ret = _loginToCamera(camera_ip, telnet_user, telnet_pass, ref camera); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //get mac ethernet log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, Đọc địa chỉ mac ethernet\n", DateTime.Now); prop_logsystem.SetValue(testingInfo, log_value); string mac_ethernet = ""; ret = _getMacEthernet(camera, out mac_ethernet); prop_macethernet.SetValue(testingInfo, mac_ethernet); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //stream video and judgement log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, Stream và phán định độ nét hình ảnh camera\n", DateTime.Now); log_value += string.Format("...Tiêu chuẩn: > {0}\n", std_sharpness - std_tolerance); prop_logsystem.SetValue(testingInfo, log_value); capture = new VideoCapture(rtsp_link); if (!capture.IsOpened) { ret = false; log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); goto END; } isStreaming = true; int count = 0; RE: Mat m = new Mat(); if (capture != null) { capture.Read(m); } if (!m.IsEmpty) { Image <Bgr, Byte> img = m.ToImage <Bgr, Byte>(); int iw = img.Width; int ih = img.Height; string[] buffer = areatest.Split(','); int rect_left = (int)double.Parse(buffer[0]); int rect_top = (int)double.Parse(buffer[1]); int rect_width = (int)double.Parse(buffer[2]); int rect_height = (int)double.Parse(buffer[3]); var rect = new System.Drawing.Rectangle(rect_left, rect_top, rect_width, rect_height); //show rectangle CvInvoke.Rectangle(m, rect, new MCvScalar(0, 0, 255), 3, LineType.AntiAlias); //crop image by rectangle Image <Gray, byte> image_crop = globalUtility.CropFromImage(img, rect); //calculate sharpness int s = globalUtility.getSharpnessValueFromImage(image_crop); int pixel = image_crop.Width * image_crop.Height; scale = s / (pixel * 1.0); //judgement double ll_value = std_sharpness - std_tolerance; ret = scale >= ll_value; prop_totalresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); count++; //thoi gian CvInvoke.PutText(m, string.Format("Now is {0}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")), new System.Drawing.Point(30, 50), FontFace.HersheySimplex, 1, ret ? new MCvScalar(0, 255, 0) : new MCvScalar(0, 0, 255), 2, LineType.AntiAlias); //do net tieu chuan CvInvoke.PutText(m, string.Format("Standard value: {0}", ll_value), new System.Drawing.Point(30, 100), FontFace.HersheySimplex, 1, ret ? new MCvScalar(0, 255, 0) : new MCvScalar(0, 0, 255), 2, LineType.AntiAlias); //do net thuc te CvInvoke.PutText(m, string.Format("Actual value: {0}", Math.Round(scale, 5)), new System.Drawing.Point(30, 150), FontFace.HersheySimplex, 1, ret ? new MCvScalar(0, 255, 0) : new MCvScalar(0, 0, 255), 2, LineType.AntiAlias); //ket qua CvInvoke.PutText(m, string.Format("{0}", ret ? "Passed" : "Failed"), new System.Drawing.Point(30, 350), FontFace.HersheySimplex, 4, ret ? new MCvScalar(0, 255, 0) : new MCvScalar(0, 0, 255), 2, LineType.AntiAlias); //mac address CvInvoke.PutText(m, string.Format("{0}:{1}:{2}:{3}:{4}:{5}", mac_ethernet.Substring(0, 2), mac_ethernet.Substring(2, 2), mac_ethernet.Substring(4, 2), mac_ethernet.Substring(6, 2), mac_ethernet.Substring(8, 2), mac_ethernet.Substring(10, 2) ), new System.Drawing.Point(30, 650), FontFace.HersheySimplex, 2, new MCvScalar(0, 0, 255), 2, LineType.AntiAlias); //show image var bi = globalUtility.ToBitmapSource(m.Bitmap); bi.Freeze(); prop_imagesource.SetValue(testingInfo, bi); //show crop var ci = globalUtility.Bitmap2BitmapImage(image_crop.Bitmap); ci.Freeze(); prop_imagecrop.SetValue(testingInfo, ci); } Thread.Sleep(10); if (isStreaming) { goto RE; } log_value += string.Format("...kết quả: {0}, {1}\n", scale, ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: if (capture != null) { capture.Dispose(); } if (camera != null && camera.IsConnected()) { camera.Close(); } return(ret); }
//Kiem tra night vision qua cong telnet public bool excuteTelnet(Grid grid_container) { bool ret = false; var prop_nightvisionresult = testingInfo.GetType().GetProperty("nightVisionResult"); prop_nightvisionresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); string rtsp_link = (string)settingInfo.GetType().GetProperty("cameraRtspLink").GetValue(settingInfo); int rgb_diffvalue = (int)settingInfo.GetType().GetProperty("toleranceRGBNightVision").GetValue(settingInfo); string mac_ethernet = (string)testingInfo.GetType().GetProperty("macFromBarcode").GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } //chuyen camera sang mode night vision camera.switchCameraMode(true); Application.Current.Dispatcher.Invoke(new Action(() => { uc_nightvision = new UI.ucNightVision(13, rgb_diffvalue, rtsp_link, mac_ethernet); })); Thread.Sleep(3000); Application.Current.Dispatcher.Invoke(new Action(() => { grid_container.Children.Clear(); grid_container.Children.Add(uc_nightvision); })); Thread.Sleep(1000); RE: ret = uc_nightvision.nightResult != -1 || uc_nightvision.timeOut == 0; if (!ret) { Thread.Sleep(100); goto RE; } if (uc_nightvision.nightResult != 0) { ret = false; } //close stream uc_nightvision.Dispose(); //chuyen camera ve mode normal camera.switchCameraMode(false); Thread.Sleep(1000); log_value += uc_nightvision.nightMessage; prop_logsystem.SetValue(testingInfo, log_value); goto END; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_nightvisionresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); if (uc_nightvision.nightInfo.imageSource != null) { testingInfo.GetType().GetProperty("imageNightVision").SetValue(testingInfo, uc_nightvision.nightInfo.imageSource); } return(ret); }
//kiem tra sd card qua cong UART public bool excuteUart(Grid grid_container) { bool ret = false; var prop_audioresult = testingInfo.GetType().GetProperty("audioResult"); prop_audioresult.SetValue(testingInfo, "Waiting..."); //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); try { if (!camera.IsConnected()) { goto END; } //set camera record audio log_value += "...thiết lập camera thu âm thanh từ mic\n"; prop_logsystem.SetValue(testingInfo, log_value); camera.captureAudio(); //play audio log_value += "...phát file âm thanh sound.wav ra loa máy tính.\n"; prop_logsystem.SetValue(testingInfo, log_value); IO.Speaker speaker = new IO.Speaker(string.Format("{0}sound.wav", AppDomain.CurrentDomain.BaseDirectory)); speaker.Play(); RE_WAIT: bool r = speaker.IsPlaying(); if (r) { Thread.Sleep(100); goto RE_WAIT; } //stop record log_value += "...thiết lập camera dừng thu âm.\n"; prop_logsystem.SetValue(testingInfo, log_value); camera.stopCaptureAudio(); //play sound log_value += "...thiết lập camera phát file âm thanh vừa thu ra loa.\n"; prop_logsystem.SetValue(testingInfo, log_value); camera.playBackAudio(); //show form confirm log_value += "...hiển thị giao diện xác nhận trạng thái khối audio.\n"; prop_logsystem.SetValue(testingInfo, log_value); Application.Current.Dispatcher.Invoke(new Action(() => { uc_audio = new UI.ucAudio(); grid_container.Children.Clear(); grid_container.Children.Add(uc_audio); })); RE: if (uc_audio.isPlayBack) { camera.playBackAudio(); uc_audio.isPlayBack = false; } ret = uc_audio.audioResult != -1; if (!ret) { Thread.Sleep(100); goto RE; } if (uc_audio.audioResult != 0) { ret = false; } //phán định log_value += string.Format("...\n"); log_value += string.Format("... ===> \"{0}\" <===\n", uc_audio.audioMessage); log_value += string.Format("...\n"); prop_logsystem.SetValue(testingInfo, log_value); //stop play back log_value += "...thiết lập camera dừng phát âm thanh.\n"; prop_logsystem.SetValue(testingInfo, log_value); camera.stopPlayBack(); goto END; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: prop_audioresult.SetValue(testingInfo, ret ? "Passed" : "Failed"); return(ret); }
public bool excuteUart() { bool ret = false; //get logsytem var prop_logsystem = testingInfo.GetType().GetProperty("logSystem"); string log_value = (string)prop_logsystem.GetValue(testingInfo); string mac_ethernet = (string)testingInfo.GetType().GetProperty("macEthernet").GetValue(testingInfo); log_value += string.Format("\n-------------------------------\n"); log_value += string.Format("{0}, Nhập mac từ barcode reader\n", DateTime.Now); log_value += string.Format("...{0}\n", mac_ethernet); prop_logsystem.SetValue(testingInfo, log_value); try { //check mac address ret = _isVnptMacAddress(mac_ethernet); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //open serial port string serial_port = (string)testingInfo.GetType().GetProperty("serialPortName").GetValue(testingInfo); ret = _openSerialPort(serial_port); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //login to uboot (wait 30s) ret = _loginToUboot(30); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //set mac ethernet ret = _setMacEthernet(mac_ethernet); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); testingInfo.GetType().GetProperty("setMacResult").SetValue(testingInfo, ret ? "Passed" : "Failed"); if (!ret) { goto END; } //upload firmware basic string camera_ip = (string)testingInfo.GetType().GetProperty("ipAddress").GetValue(testingInfo); string file_firmware = (string)settingInfo.GetType().GetProperty("fileFirmware").GetValue(settingInfo); ret = _uploadFirmwareBasic(camera_ip, file_firmware, 90); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); testingInfo.GetType().GetProperty("uploadResult").SetValue(testingInfo, ret ? "Passed" : "Failed"); if (!ret) { goto END; } //reboot camera and wait camera reboot complete ret = _rebootCamera(); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //wait camera reboot complete ret = _waitCameraRebootComplete(60); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); if (!ret) { goto END; } //set static ip string static_ip = (string)settingInfo.GetType().GetProperty("cameraStaticIP").GetValue(settingInfo); ret = _setStaticIP(static_ip); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); testingInfo.GetType().GetProperty("setIpResult").SetValue(testingInfo, ret ? "Passed" : "Failed"); if (!ret) { goto END; } //write uid string uid_header = (string)settingInfo.GetType().GetProperty("vnptUidHeader").GetValue(settingInfo); string uid_code = "";; ret = _setUidCode(uid_header, mac_ethernet, out uid_code); log_value = (string)prop_logsystem.GetValue(testingInfo); log_value += string.Format("...kết quả {0}\n", ret ? "Passed" : "Failed"); prop_logsystem.SetValue(testingInfo, log_value); testingInfo.GetType().GetProperty("uidCode").SetValue(testingInfo, uid_code); goto END; } catch (Exception ex) { log_value += ex.ToString(); prop_logsystem.SetValue(testingInfo, log_value); goto END; } END: if (camera != null && camera.IsConnected()) { camera.Close(); } return(ret); }