From 19da00146e856c266f6dbabccac94d7c2e627008 Mon Sep 17 00:00:00 2001 From: "xhm\\HP" <1173131411@qq.com> Date: Mon, 8 Jul 2024 16:29:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BB=E7=A0=81=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HisenceYoloDetection/MainForm.cs | 73 ++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/HisenceYoloDetection/MainForm.cs b/HisenceYoloDetection/MainForm.cs index ab627d6..d596bd2 100644 --- a/HisenceYoloDetection/MainForm.cs +++ b/HisenceYoloDetection/MainForm.cs @@ -73,6 +73,8 @@ namespace HisenceYoloDetection bool PLC548 = false; string m_sKEYENCEBar; + string Oldm_sKEYENCEBar; + string OcrBar = "";//洗衣机编号 string IfChangeLanguage = "";//是否换洗衣机的型号 bool bTriger = true;//是否可以触发检测 bool bBarTriger = false;//第一个地址完成后才能触发第二个位置 @@ -85,6 +87,7 @@ namespace HisenceYoloDetection Mat Cam2ImgShowBar = new Mat();//实时相机2的照片 用来识别条码 XKHisence xKNow;//数据库中的洗衣机数据 + XKHisence Old_xKNow;//数据库中的洗衣机数据 XK_HisenceWord xK_HisenceSQLWord = new XK_HisenceWord(); bool bOn = false; //////////////////////////// @@ -347,7 +350,7 @@ namespace HisenceYoloDetection string startTime = starttime; string EndTime = starttime; - string lineBody = "ZZ-P5"; + string lineBody = "ZZ-P"; string MaterialDescripts = "制冷器"; string MaterialDescripts2 = "工艺管"; JObject patientinfo = new JObject(); @@ -766,15 +769,15 @@ namespace HisenceYoloDetection { myLog("Cam1相机启动", DateTime.Now); } - Cam2.Start("Cam2"); - if (Cam2.IfSuccess) - { - myLog("Cam2相机启动", DateTime.Now); - } + //Cam2.Start("Cam2"); + //if (Cam2.IfSuccess) + //{ + // myLog("Cam2相机启动", DateTime.Now); + //} Cam1.OnHImageOutput -= OnCameraMatOutPut; Cam1.OnHImageOutput += OnCameraMatOutPut; - Cam2.OnHImageOutput -= OnCameraMatOutPut2; - Cam2.OnHImageOutput += OnCameraMatOutPut2; + //Cam2.OnHImageOutput -= OnCameraMatOutPut2; + // Cam2.OnHImageOutput += OnCameraMatOutPut2; OKOrNGShow.Image = OKbitmap; //初始化扫码枪 @@ -1179,16 +1182,62 @@ namespace HisenceYoloDetection { _runHandleBefore.WaitOne(); //这里改成和海信的对接需求 + + // if(Oldm_sKEYENCEBar!= m_sKEYENCEBar) + { + // Oldm_sKEYENCEBar= m_sKEYENCEBar; + //获取请求 + //报警地址 + string url = "https://inner-apisix.hisense.com/mes-plus/api/Fcc/GetWorkOrderBOMlnfo?user_key=k7gzo1fsfcami7n5hmpxtybyluf9xeue"; + // string url = "https://echo.hoppscotch.io"; + string PostUrl = url; + DateTime dt = DateTime.Now; + string starttime = string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017 + + string startTime = starttime; + string EndTime = starttime; + string lineBody = "ZZ-P";//线体 + string MaterialDescripts = "制冷器"; + string MaterialDescripts2 = "工艺管"; + JObject patientinfo = new JObject(); + JArray ids = new JArray(); + ids.Add(MaterialDescripts); + ids.Add(MaterialDescripts2); + patientinfo["startTime"] = startTime; + patientinfo["EndTime"] = EndTime; + patientinfo["lineBody"] = lineBody; + patientinfo["MaterialDescripts"] = ids; + string sendData = JsonConvert.SerializeObject(patientinfo); + //eg: 发送Url需要的格式:sendData={"ids":[123],"Name":小黑} + string resultData = Post(sendData, PostUrl); + resultData = "{\r\n\t\"Result\": [],\r\n\t\"success\": false,\r\n\t\"ReturnMsg\": \"参数-starttime 不正确!\"\r\n}"; + JObject jo = (JObject)JsonConvert.DeserializeObject(resultData); + string sucessIf = jo["success"].ToString(); + if (sucessIf.ToLower() == "true") + { + string ProductType = jo["ProductType"].ToString(); + string FinalDefIo = jo["FinalDefIo"].ToString(); + //WEBAPI得到条码 + xKNow = GetModeFromBar(ProductType);//从数据库中查询到这个条码的四轴的值 + //解析字段 + } + } //xKNow = GetModeFromBar("VWJ070633V0WW80F0120356");//从数据库中查询到这个条码的四轴的值 - xKNow = GetModeFromBar(m_sKEYENCEBar);//从数据库中查询到这个条码的四轴的值 + + if(xKNow==null) { myLog("数据库没有条码匹配" + m_sKEYENCEBar, DateTime.Now); break; } + //if(xKNow.OcrBar!= Old_xKNow.OcrBar) + //{ + + //} if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$")) { + // Old_xKNow = xKNow; myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now); bBarTriger = true; //MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴 @@ -1288,7 +1337,7 @@ namespace HisenceYoloDetection } if (iNum1 >= 2) { -#if false +#if true if (bBarTriger)//证明读码器读到东西 { @@ -1330,8 +1379,8 @@ namespace HisenceYoloDetection Cam1.SnapshotCount = 0; Cam1.Snapshot(); - Cam2.SnapshotCount = 0; - Cam2.Snapshot(); + //Cam2.SnapshotCount = 0; + //Cam2.Snapshot(); myLog("第二次采集图像", DateTime.Now); //if (xKNow != null)