Commit 1995e274 LN

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

1 个父辈 0cb31239
......@@ -759,11 +759,12 @@ namespace OnlineStore.AutoCountClient
private void btnReturn_Click(object sender, EventArgs e)
{
int qty = FormUtil.GetIntValue(txtQty ) ;
int qty = FormUtil.GetIntValue(txtQty);
string reelId = txtReelId.Text;
string pn = txtPN.Text;
int p = 0;
SServerManager.Return_Material ("测试按钮", pn + ";" + reelId, qty);
string msg = SServerManager.Return_Material("测试按钮", pn + ";" + reelId, qty);
}
}
......
......@@ -33,6 +33,7 @@ namespace OnlineStore.DeviceLibrary
public bool InXWork = false;
public int ThresholdValue = ConfigAppSettings.GetIntValue(Setting_Init.ThresholdValue);
private int ResultMinCount = 100;
private string path_XRAY = Application.StartupPath + @"\XRAY\";
private string path1_tif = Application.StartupPath + @"\XRAY\tif";
......@@ -62,17 +63,12 @@ namespace OnlineStore.DeviceLibrary
}
private void XRayLoad()
{
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");
bool cResult = carerayImage.Open();
LogUtil.info(Name + "carerayImage.Open()=" + cResult);
......@@ -95,15 +91,16 @@ namespace OnlineStore.DeviceLibrary
{
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))
{
System.IO.Directory.CreateDirectory(path2_out);
}
LoadParamMap();
ResultMinCount = ConfigAppSettings.GetIntValue(Setting_Init.ResultMinCount);
if (ResultMinCount <= 0)
{
ResultMinCount = 100;
}
}
catch (Exception ex)
{
......
......@@ -329,9 +329,7 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 点料处理
private string lastFileName = "";
//private int lastTh = 0;
//private int lastWSize = 0;
private string lastFileName = "";
private CountParam lastParam = new CountParam();
private void XW15_GetResult()
{
......@@ -341,56 +339,81 @@ namespace OnlineStore.DeviceLibrary
return;
}
MoveInfo.NextMoveStep(StepEnum.XW15_GetResult);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(180000));
if (xRay.IsRayOpen)
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300000));
try
{
xRay.Stop();
}
int count = 99999;
//WorkLog("点料:开始调用 countImage.GetCount ");
//bool result = countImage.GetCount(lastTh, out count);
//WorkLog("点料:获取点料结果[" + lastTh + "]=【" + count + "】,result=" + result + ",保存并上传结果");
if (xRay.IsRayOpen)
{
xRay.Stop();
}
int count = 99999;
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;
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);
}
bool isNg = false;
int ResultMinCount = ConfigAppSettings.GetIntValue(Setting_Init.ResultMinCount);
if (ResultMinCount <= 0)
{
ResultMinCount = 100;
}
string result = "保存并上传结果";
if (count < ResultMinCount)
{
result = "点料结果小于" + ResultMinCount + ",判断点料NG";
isNg = true;
}
WorkLog("点料:获取点料结果 【" + count + "】 " + lastParam.ToStr() + ",n =" + n + ", " + result);
if (Work_ReelInfo.WareCount <= 0)
{
MoveInfo.MoveParam.WareCount = count;
Work_ReelInfo.WareCount = count;
bool isNg = false;
string NgMsg = "";
if (count < ResultMinCount)
{
isNg = true;
NgMsg = "NG:点料结果小于" + ResultMinCount;
}
WorkLog("点料:获取点料结果 【" + count + "】 " + lastParam.ToStr() + ",n =" + n + ", " + NgMsg);
if (Work_ReelInfo.WareCount <= 0)
{
MoveInfo.MoveParam.WareCount = count;
Work_ReelInfo.WareCount = count;
}
InXWork = false;
if (!isNg && SServerManager.CanConnect())
{
// 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 + ",更新状态为NG");
isNg = true;
NgMsg = msg;
}
}
if (isNg)
{
MoveInfo.MoveParam.IsNgReel = true;
Work_ReelInfo.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = "点料结果小于" + ResultMinCount;
Work_ReelInfo.NgMsg = "点料结果小于" + ResultMinCount;
MoveInfo.MoveParam.NgMsg = NgMsg;
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
{
if (System.IO.File.Exists(outF))
......@@ -398,31 +421,19 @@ namespace OnlineStore.DeviceLibrary
WorkLog("点料:读取结果图片【" + outF + "】");
Bitmap img = (Bitmap)Image.FromFile(outF).Clone();
GetImageEvent?.Invoke(img);
return true;
}
else
{
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)
{
LogUtil.error("读取结果图片【" + outF + "】出错:" + ex.ToString());
}
InXWork = 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();
return false;
}
public string CapImage()
{
try
......
......@@ -110,8 +110,14 @@ namespace OnlineStore.DeviceLibrary
return "";
}
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 + "】");
if (resultStr.Contains("NG"))
{
msg = resultStr.Replace("<?xml version=\"1.0\" encoding=\"utf - 8\"?>< string xmlns = \"http://tempuri.org/\" >", "").Replace(" </ string >","");
}
}
catch (Exception ex)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!