Commit e8dc6ad0 张东亮

警告消息、图片保存

1 个父辈 15347405
...@@ -151,31 +151,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -151,31 +151,6 @@ namespace OnlineStore.DeviceLibrary
string r = ""; string r = "";
bool eyemNoCode = false; bool eyemNoCode = false;
//Task eyemtask = Task.Factory.StartNew(delegate {
// List<CodeInfo> tlci = EyemDecode.ModelDecoder(ref bmp);
// foreach (CodeInfo code in tlci)
// {
// //LogUtil.info(deviceName + " 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
// string str = CodeManager.ReplaceCode(code.CodeStr);
// if (!codeList.Contains(str))
// {
// codeList.Add(str);
// r = r + "##eyem|" + code.CodeType + "|" + str;
// if (!findRightCode)
// {
// findRightCode = HasRightCode(str);
// }
// }
// }
//});
////最多等待60秒
//bool taskResult = eyemtask.Wait(60000);
//if (!taskResult)
//{
// LogUtil.error(deviceName + " 【" + cameraName + "】eyem扫码超时");
// eyemNoCode = true;
//}
if (!isPreScan) if (!isPreScan)
{ {
if (!findRightCode) if (!findRightCode)
...@@ -214,38 +189,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -214,38 +189,6 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error(deviceName + " RemoteDecodeHelper扫码出错:" + ex.ToString()); LogUtil.error(deviceName + " RemoteDecodeHelper扫码出错:" + ex.ToString());
} }
//List<CodeInfo> cc = new List<CodeInfo>();
//eyemNoCode = true;
//foreach (string codeType in codeTypeList)
//{
// //判断是否是一维码
// if (codeType.ToLower().Equals("barcode"))
// {
// cc = HDCodeHelper.DecodeBarCode(ho_Image);
// }
// else
// {
// cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, timeOut);
// }
// foreach (CodeInfo c in cc)
// {
// string str = CodeManager.ReplaceCode(c.CodeStr);
// if (!codeList.Contains(str))
// {
// codeList.Add(str);
// r = r + "##halcon|" + codeType + "|" + str;
// if (!findRightCode)
// {
// findRightCode = HasRightCode(str);
// }
// }
// }
// if (findRightCodeBreak && findRightCode)
// {
// break;
// }
//}
} }
//if (!findRightCode && SaveErrorImageToFile.Equals(1)) //if (!findRightCode && SaveErrorImageToFile.Equals(1))
if ((!findRightCode) || eyemNoCode) if ((!findRightCode) || eyemNoCode)
...@@ -262,8 +205,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -262,8 +205,9 @@ namespace OnlineStore.DeviceLibrary
// nameStr = "eyemTimeOut"; // nameStr = "eyemTimeOut";
//} //}
SaveImageToFile(deviceName, cameraName + nameStr, bmp); SaveNGImageToFile(deviceName, cameraName + nameStr, bmp);
} }
SaveOKImageToFile(deviceName, cameraName, bmp);
} }
if (deviceName != "" || r != "") if (deviceName != "" || r != "")
{ {
...@@ -424,7 +368,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -424,7 +368,7 @@ namespace OnlineStore.DeviceLibrary
//if (codeList.Count() == 0) //if (codeList.Count() == 0)
//{ //{
bitmapfilename = SaveImageToFile("XLRClient", cameraName, bmp); bitmapfilename = SaveOKImageToFile("XLRClient", cameraName, bmp);
// } // }
LogUtil.info(" 【" + cameraName + "】" + " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】 :" + r); LogUtil.info(" 【" + cameraName + "】" + " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】 :" + r);
} }
...@@ -463,11 +407,35 @@ namespace OnlineStore.DeviceLibrary ...@@ -463,11 +407,35 @@ namespace OnlineStore.DeviceLibrary
} }
return (codeList, bitmapfilename); return (codeList, bitmapfilename);
} }
static int CntImgs = ConfigAppSettings.GetIntValue("SaveImgCnt", 100);
private static string SaveNGImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{
string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond;
string dire = @"\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\NG\";
string iamgeName = date + ".bmp";
try
{
Bitmap bit = (Bitmap)bitmap.Clone();
if (Directory.Exists(dire).Equals(false))
{
Directory.CreateDirectory(dire);
}
//deleteFiles(dire);
bit.Save(dire + iamgeName, ImageFormat.Bmp);
bit.Dispose();
LogUtil.info(deviceName + " 【" + cameraName + "】保存NG图片到【" + dire + iamgeName + "】成功");
private static string SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap) }
catch (Exception ex)
{
LogUtil.error("保存" + deviceName + " 【" + cameraName + "】NG图片到【" + dire + iamgeName + "】出错" + ex.ToString());
}
return dire + iamgeName;
}
private static string SaveOKImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{ {
string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond; string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond;
string dire = @"\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\"; string dire = @"\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\OK\";
string iamgeName = date + ".bmp"; string iamgeName = date + ".bmp";
try try
{ {
...@@ -476,17 +444,65 @@ namespace OnlineStore.DeviceLibrary ...@@ -476,17 +444,65 @@ namespace OnlineStore.DeviceLibrary
{ {
Directory.CreateDirectory(dire); Directory.CreateDirectory(dire);
} }
deleteFiles(dire);
bit.Save(dire + iamgeName, ImageFormat.Bmp); bit.Save(dire + iamgeName, ImageFormat.Bmp);
bit.Dispose(); bit.Dispose();
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成,保存图片到【" + dire + iamgeName + "】成功"); LogUtil.info(deviceName + " 【" + cameraName + "】保存OK图片到【" + dire + iamgeName + "】成功");
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("保存" + deviceName + " 【" + cameraName + "】图片到【" + dire + iamgeName + "】出错" + ex.ToString()); LogUtil.error("保存" + deviceName + " 【" + cameraName + "】OK图片到【" + dire + iamgeName + "】出错" + ex.ToString());
} }
return dire + iamgeName; return dire + iamgeName;
} }
static Task deleteTask = null;
static void deleteFiles(string dire)
{
if((deleteTask ==null)|| (deleteTask != null && deleteTask.IsCompleted))
{
deleteTask = Task.Factory.StartNew(() =>
{
try
{
string[] imgFiles = Directory.GetFiles(dire);
if (imgFiles.Length > CntImgs)
{
FileInfo fileInfo;
List<FileInfo> files = new List<FileInfo>();
foreach (var item in imgFiles)
{
fileInfo = new FileInfo(item);
files.Add(fileInfo);
}
do
{
FileInfo oldFile = files[0];
foreach (var item in files)
{
if((item.CreationTime-oldFile.CreationTime).Seconds<0)
{
oldFile=item;
}
}
oldFile?.Delete();
}
while (files.Count > CntImgs) ;
}
}
catch (Exception ex)
{
LogUtil.error("删除文件失败", ex);
}
});
}
else
{
LogUtil.info("延迟删除文件夹内的文件:"+dire);
}
}
public static void DelImg(string deviceName, string imgPath) public static void DelImg(string deviceName, string imgPath)
{ {
try try
......
...@@ -1391,6 +1391,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -1391,6 +1391,10 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 机器人报错 /// 机器人报错
/// </summary> /// </summary>
RobotError RobotError,
/// <summary>
/// 警告消息
/// </summary>
AlarmMsg,
} }
} }
...@@ -543,7 +543,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -543,7 +543,7 @@ namespace OnlineStore.DeviceLibrary
CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW); CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW);
} }
protected AlarmType alarmRedLedType = AlarmType.AxisAlarm; protected AlarmType alarmRedLedType = AlarmType.IoSingleTimeOut;
protected void LedProcess(object sender, ElapsedEventArgs e) protected void LedProcess(object sender, ElapsedEventArgs e)
{ {
try try
...@@ -773,6 +773,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -773,6 +773,12 @@ namespace OnlineStore.DeviceLibrary
{ {
SetWarnMsg(""); SetWarnMsg("");
} }
if (WarnMsg.Contains(msg) && alarmType.Equals(AlarmType.AlarmMsg))
{
LogUtil.info(Name + "清理异常消息报警【" + WarnMsg + "】 ");
alarmType = AlarmType.None;
SetWarnMsg("");
}
} }
protected void ClearTimeoutAlarm(string msg) protected void ClearTimeoutAlarm(string msg)
{ {
...@@ -786,6 +792,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -786,6 +792,12 @@ namespace OnlineStore.DeviceLibrary
alarmType = AlarmType.None; alarmType = AlarmType.None;
SetWarnMsg(""); SetWarnMsg("");
} }
if (WarnMsg.Contains(msg) && alarmType.Equals(AlarmType.AlarmMsg))
{
LogUtil.info(Name + "清理异常消息报警【" + WarnMsg + "】 ");
alarmType = AlarmType.None;
SetWarnMsg("");
}
} }
public Color GetShowColor() public Color GetShowColor()
{ {
......
...@@ -709,7 +709,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -709,7 +709,11 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.FeedA_ReelCheck).Equals(IO_VALUE.LOW) && BufferDataManager.AInStoreInfo != null) if (IOValue(IO_Type.FeedA_ReelCheck).Equals(IO_VALUE.LOW) && BufferDataManager.AInStoreInfo != null)
{ {
if (tsUppA.TotalSeconds > errSeconds) if (tsUppA.TotalSeconds > errSeconds)
{
SetWarnMsg("A上进料暂存区有料盘,但信号未亮"); SetWarnMsg("A上进料暂存区有料盘,但信号未亮");
Alarm(AlarmType.AlarmMsg);
}
} }
else else
{ {
...@@ -719,7 +723,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -719,7 +723,11 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.LineA_ReelInPlaceCheck).Equals(IO_VALUE.LOW) && BufferDataManager.AOutStoreInfo != null) if (IOValue(IO_Type.LineA_ReelInPlaceCheck).Equals(IO_VALUE.LOW) && BufferDataManager.AOutStoreInfo != null)
{ {
if (tsUnA.TotalSeconds > errSeconds) if (tsUnA.TotalSeconds > errSeconds)
{
Alarm(AlarmType.AlarmMsg);
SetWarnMsg("A下出料暂存区有料盘,但信号未亮"); SetWarnMsg("A下出料暂存区有料盘,但信号未亮");
}
} }
else else
{ {
...@@ -729,7 +737,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -729,7 +737,11 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.FeedB_ReelCheck).Equals(IO_VALUE.LOW) && BufferDataManager.BInStoreInfo != null) if (IOValue(IO_Type.FeedB_ReelCheck).Equals(IO_VALUE.LOW) && BufferDataManager.BInStoreInfo != null)
{ {
if (tsUppB.TotalSeconds > errSeconds) if (tsUppB.TotalSeconds > errSeconds)
{
Alarm(AlarmType.AlarmMsg);
SetWarnMsg("B上进料暂存区有料盘,但信号未亮"); SetWarnMsg("B上进料暂存区有料盘,但信号未亮");
}
} }
else else
{ {
...@@ -739,7 +751,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -739,7 +751,11 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.LineB_ReelInPlaceCheck).Equals(IO_VALUE.LOW) && BufferDataManager.BOutStoreInfo != null) if (IOValue(IO_Type.LineB_ReelInPlaceCheck).Equals(IO_VALUE.LOW) && BufferDataManager.BOutStoreInfo != null)
{ {
if (tsUnB.TotalSeconds > errSeconds) if (tsUnB.TotalSeconds > errSeconds)
{
Alarm(AlarmType.AlarmMsg);
SetWarnMsg("B下出料暂存区有料盘,但信号未亮"); SetWarnMsg("B下出料暂存区有料盘,但信号未亮");
}
} }
else else
{ {
......
...@@ -63,6 +63,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -63,6 +63,7 @@ namespace OnlineStore.DeviceLibrary
if (!param.PosInfo.CheckPosition()) if (!param.PosInfo.CheckPosition())
{ {
Alarm(AlarmType.AlarmMsg);
SetWarnMsg(Name + " 启动入库【" + param.PosInfo.ToStr() + "】出错,找不到库位信息"); SetWarnMsg(Name + " 启动入库【" + param.PosInfo.ToStr() + "】出错,找不到库位信息");
return false; return false;
} }
...@@ -76,6 +77,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -76,6 +77,7 @@ namespace OnlineStore.DeviceLibrary
if (!ReviceInStoreCMD(param.PosInfo.PosId, param.PosInfo.PlateH, param.PosInfo.PlateW, param.PosInfo.barcode)) if (!ReviceInStoreCMD(param.PosInfo.PosId, param.PosInfo.PlateH, param.PosInfo.PlateW, param.PosInfo.barcode))
{ {
SetWarnMsg($" 入库验证失败:{param.PosInfo.ToStr()}"); SetWarnMsg($" 入库验证失败:{param.PosInfo.ToStr()}");
Alarm(AlarmType.AlarmMsg);
return false; return false;
} }
else else
...@@ -86,6 +88,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -86,6 +88,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!ReviceInStoreCMD(param.PosInfoBack.PosId, param.PosInfoBack.PlateH, param.PosInfoBack.PlateW, param.PosInfoBack.barcode)) if (!ReviceInStoreCMD(param.PosInfoBack.PosId, param.PosInfoBack.PlateH, param.PosInfoBack.PlateW, param.PosInfoBack.barcode))
{ {
Alarm(AlarmType.AlarmMsg);
SetWarnMsg($" 入库验证失败:{param.PosInfoBack.ToStr()}"); SetWarnMsg($" 入库验证失败:{param.PosInfoBack.ToStr()}");
return false; return false;
} }
......
...@@ -280,6 +280,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -280,6 +280,7 @@ namespace OnlineStore.DeviceLibrary
} }
else if(MoveInfo.IsTimeOut(30)) else if(MoveInfo.IsTimeOut(30))
{ {
Alarm(AlarmType.AlarmMsg);
SetWarnMsg($"等待皮带线无料盘超时"); SetWarnMsg($"等待皮带线无料盘超时");
} }
break; break;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!