Commit 1995e274 LN

上传结果后需要判断是否NG

1 个父辈 0cb31239
...@@ -759,11 +759,12 @@ namespace OnlineStore.AutoCountClient ...@@ -759,11 +759,12 @@ namespace OnlineStore.AutoCountClient
private void btnReturn_Click(object sender, EventArgs e) private void btnReturn_Click(object sender, EventArgs e)
{ {
int qty = FormUtil.GetIntValue(txtQty ) ; int qty = FormUtil.GetIntValue(txtQty);
string reelId = txtReelId.Text; string reelId = txtReelId.Text;
string pn = txtPN.Text; string pn = txtPN.Text;
int p = 0; int p = 0;
SServerManager.Return_Material ("测试按钮", pn + ";" + reelId, qty); string msg = SServerManager.Return_Material("测试按钮", pn + ";" + reelId, qty);
} }
} }
......
...@@ -33,6 +33,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -33,6 +33,7 @@ namespace OnlineStore.DeviceLibrary
public bool InXWork = false; public bool InXWork = false;
public int ThresholdValue = ConfigAppSettings.GetIntValue(Setting_Init.ThresholdValue); public int ThresholdValue = ConfigAppSettings.GetIntValue(Setting_Init.ThresholdValue);
private int ResultMinCount = 100;
private string path_XRAY = Application.StartupPath + @"\XRAY\"; private string path_XRAY = Application.StartupPath + @"\XRAY\";
private string path1_tif = Application.StartupPath + @"\XRAY\tif"; private string path1_tif = Application.StartupPath + @"\XRAY\tif";
...@@ -62,17 +63,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -62,17 +63,12 @@ namespace OnlineStore.DeviceLibrary
} }
private void XRayLoad() private void XRayLoad()
{ {
try try
{ {
//countImage = new CountImage("Count");
//countImage.SetDirectory(path1_tif, path2_out, path3_area);
//LogUtil.info(Name + "CountImage path1【" + path1_tif + "】");
//LogUtil.info(Name + "CountImage path2【" + path2_out + "】");
//LogUtil.info(Name + "CountImage path3【" + path3_area + "】");
//LogUtil.info(Name + "CountImage SetDirectory: 完成");
carerayImage = new CarerayImage("XRay"); carerayImage = new CarerayImage("XRay");
bool cResult = carerayImage.Open(); bool cResult = carerayImage.Open();
LogUtil.info(Name + "carerayImage.Open()=" + cResult); LogUtil.info(Name + "carerayImage.Open()=" + cResult);
...@@ -95,15 +91,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -95,15 +91,16 @@ namespace OnlineStore.DeviceLibrary
{ {
System.IO.Directory.CreateDirectory(path1_tif); System.IO.Directory.CreateDirectory(path1_tif);
} }
//if (!System.IO.Directory.Exists(path2_png))
//{
// System.IO.Directory.CreateDirectory(path2_png);
//}
if (!System.IO.Directory.Exists(path2_out)) if (!System.IO.Directory.Exists(path2_out))
{ {
System.IO.Directory.CreateDirectory(path2_out); System.IO.Directory.CreateDirectory(path2_out);
} }
LoadParamMap(); LoadParamMap();
ResultMinCount = ConfigAppSettings.GetIntValue(Setting_Init.ResultMinCount);
if (ResultMinCount <= 0)
{
ResultMinCount = 100;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -329,9 +329,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -329,9 +329,7 @@ namespace OnlineStore.DeviceLibrary
#endregion #endregion
#region 点料处理 #region 点料处理
private string lastFileName = ""; private string lastFileName = "";
//private int lastTh = 0;
//private int lastWSize = 0;
private CountParam lastParam = new CountParam(); private CountParam lastParam = new CountParam();
private void XW15_GetResult() private void XW15_GetResult()
{ {
...@@ -341,56 +339,81 @@ namespace OnlineStore.DeviceLibrary ...@@ -341,56 +339,81 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
MoveInfo.NextMoveStep(StepEnum.XW15_GetResult); MoveInfo.NextMoveStep(StepEnum.XW15_GetResult);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(180000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300000));
if (xRay.IsRayOpen) try
{ {
xRay.Stop(); if (xRay.IsRayOpen)
} {
int count = 99999; xRay.Stop();
//WorkLog("点料:开始调用 countImage.GetCount "); }
//bool result = countImage.GetCount(lastTh, out count); int count = 99999;
//WorkLog("点料:获取点料结果[" + lastTh + "]=【" + count + "】,result=" + result + ",保存并上传结果"); string fileP = path1_tif + @"\" + lastFileName;
int n = 0;
if (lastParam.Sign.Equals(0))
{
WorkLog("点料:开始调用 carerayImage.GetLocalCount ");
n = carerayImage.GetLocalCount(fileP, lastParam.Threshold, lastParam.WindowSize, out count, out Asa.API.EyemImage tpDstImg);
}
else
{
WorkLog("点料:开始调用 carerayImage.GetLocalCountHuge ");
n = carerayImage.GetLocalCountHuge(fileP, lastParam.Threshold, lastParam.WindowSize, out count, out Asa.API.EyemImage tpDstImg);
}
string fileP = path1_tif + @"\" + lastFileName; bool isNg = false;
int n = 0; string NgMsg = "";
if (lastParam.Sign.Equals(0))
{ if (count < ResultMinCount)
WorkLog("点料:开始调用 carerayImage.GetLocalCount "); {
n = carerayImage.GetLocalCount(fileP, lastParam.Threshold, lastParam.WindowSize, out count, out Asa.API.EyemImage tpDstImg); isNg = true;
} NgMsg = "NG:点料结果小于" + ResultMinCount;
else }
{ WorkLog("点料:获取点料结果 【" + count + "】 " + lastParam.ToStr() + ",n =" + n + ", " + NgMsg);
WorkLog("点料:开始调用 carerayImage.GetLocalCountHuge "); if (Work_ReelInfo.WareCount <= 0)
n = carerayImage.GetLocalCountHuge(fileP, lastParam.Threshold, lastParam.WindowSize, out count, out Asa.API.EyemImage tpDstImg); {
} MoveInfo.MoveParam.WareCount = count;
bool isNg = false; Work_ReelInfo.WareCount = count;
int ResultMinCount = ConfigAppSettings.GetIntValue(Setting_Init.ResultMinCount); }
if (ResultMinCount <= 0) InXWork = false;
{ if (!isNg && SServerManager.CanConnect())
ResultMinCount = 100; {
} // string msg = "暂不上传";
string result = "保存并上传结果"; string msg = SServerManager.Return_Material(Name, Work_ReelInfo.WareCode, Work_ReelInfo.WareCount);
if (count < ResultMinCount) if (!String.IsNullOrEmpty(msg))
{ {
result = "点料结果小于" + ResultMinCount + ",判断点料NG"; LogUtil.error(Name + "上传【" + Work_ReelInfo.ToStr() + "】点料结果失败:" + msg + ",更新状态为NG");
isNg = true; isNg = true;
} NgMsg = msg;
WorkLog("点料:获取点料结果 【" + count + "】 " + lastParam.ToStr() + ",n =" + n + ", " + result); }
if (Work_ReelInfo.WareCount <= 0) }
{
MoveInfo.MoveParam.WareCount = count;
Work_ReelInfo.WareCount = count;
if (isNg) if (isNg)
{ {
MoveInfo.MoveParam.IsNgReel = true; MoveInfo.MoveParam.IsNgReel = true;
Work_ReelInfo.IsNgReel = true; Work_ReelInfo.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = "点料结果小于" + ResultMinCount; MoveInfo.MoveParam.NgMsg = NgMsg;
Work_ReelInfo.NgMsg = "点料结果小于" + ResultMinCount; Work_ReelInfo.NgMsg = NgMsg;
} }
}
string outF = path2_out + lastFileName; string outF = path2_out + lastFileName;
if (!isNg)
{
ReadOutMsg(outF);
}
else
{
outF = NgMsg;
}
int c = RobotManager.robot.sQLite.Insert(Work_ReelInfo.WareCode, Work_ReelInfo.PlateW, Work_ReelInfo.PlateH, count, outF);
LogUtil.info("插入数据【" + Work_ReelInfo.WareCode + "】【" + count + "】结果:" + c + " ," + RobotManager.robot.sQLite.ErrInfo);
}
catch (Exception ex)
{
LogUtil.error("XW15_GetResult出错:"+ex.ToString());
}
MoveInfo.EndStepWait();
}
private bool ReadOutMsg(string outF)
{
try try
{ {
if (System.IO.File.Exists(outF)) if (System.IO.File.Exists(outF))
...@@ -398,31 +421,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -398,31 +421,19 @@ namespace OnlineStore.DeviceLibrary
WorkLog("点料:读取结果图片【" + outF + "】"); WorkLog("点料:读取结果图片【" + outF + "】");
Bitmap img = (Bitmap)Image.FromFile(outF).Clone(); Bitmap img = (Bitmap)Image.FromFile(outF).Clone();
GetImageEvent?.Invoke(img); GetImageEvent?.Invoke(img);
return true;
} }
else else
{ {
LogUtil.error("点料:未找到结果图片【" + outF + "】"); LogUtil.error("点料:未找到结果图片【" + outF + "】");
} }
int c = RobotManager.robot.sQLite.Insert(Work_ReelInfo.WareCode, Work_ReelInfo.PlateW, Work_ReelInfo.PlateH, count, outF);
LogUtil.info("插入数据【" + Work_ReelInfo.WareCode + "】【" + count + "】结果:" + c + " ," + RobotManager.robot.sQLite.ErrInfo);
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("读取结果图片【" + outF + "】出错:" + ex.ToString()); LogUtil.error("读取结果图片【" + outF + "】出错:" + ex.ToString());
} }
InXWork = false; return false;
if (!isNg)
{
// string msg = "暂不上传";
string msg = SServerManager.Return_Material(Name, Work_ReelInfo.WareCode, Work_ReelInfo.WareCount);
if (!String.IsNullOrEmpty(msg))
{
LogUtil.error(Name + "上传【" + Work_ReelInfo.ToStr() + "】点料结果失败:" + msg);
}
}
MoveInfo.EndStepWait();
} }
public string CapImage() public string CapImage()
{ {
try try
......
...@@ -110,8 +110,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -110,8 +110,14 @@ namespace OnlineStore.DeviceLibrary
return ""; return "";
} }
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Get(server); string resultStr = HttpHelper.Get(server);
//【<?xml version="1.0" encoding="utf-8"?>< string xmlns = "http://tempuri.org/" > NG 不可退料 厂别:ST </ string >】
LogUtil.info(deviceName + "Return_Material " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】"); LogUtil.info(deviceName + "Return_Material " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
if (resultStr.Contains("NG"))
{
msg = resultStr.Replace("<?xml version=\"1.0\" encoding=\"utf - 8\"?>< string xmlns = \"http://tempuri.org/\" >", "").Replace(" </ string >","");
}
} }
catch (Exception ex) catch (Exception ex)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!