Commit 188f217a LN

托盘检测优化。扫码增加验证。

1 个父辈 6c44dde4
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<!--摄像机名称列表配置,用#分割--> <!--摄像机名称列表配置,用#分割-->
<add key="CameraName" value="GigE:MV-CE100-30GC (00C69898519)#GigE:MV-CE100-30GC (00C95305929)" /> <add key="CameraName" value="GigE:MV-CE100-30GC (00C69898519)#GigE:MV-CE100-30GC (00C95305929)" />
<!--二维码类型列表配置,用#分割,一维码=Barcode 二维码: QR Code#Data Matrix ECC 200#Micro QR Code--> <!--二维码类型列表配置,用#分割,一维码=Barcode 二维码: QR Code#Data Matrix ECC 200#Micro QR Code-->
<add key="CodeType" value="QR Code#Data Matrix ECC 200" /> <add key="CodeType" value="Data Matrix ECC 200#QR Code" />
<!--<add key="CodeType" value="Data Matrix ECC 200"/>--> <!--<add key="CodeType" value="Data Matrix ECC 200"/>-->
<add key="ACBaudRate" value="115200" /> <add key="ACBaudRate" value="115200" />
<!--二维码参数文件所在路径,文件名与二维码类型名一样--> <!--二维码参数文件所在路径,文件名与二维码类型名一样-->
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
<add key="DefaultTrayNum" value="0" /> <add key="DefaultTrayNum" value="0" />
<add key="NeedScanCode" value="1" /> <add key="NeedScanCode" value="1" />
<add key="Agv_Log_Open" value="0" /> <add key="Agv_Log_Open" value="0" />
<add key="NeedCheckTray" value="0" />
</appSettings> </appSettings>
<!-- <log4net> --> <!-- <log4net> -->
<!-- <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> --> <!-- <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> -->
......
 20200317
1.托盘检测的还会报警。
2.伺服问题?测高不准确。
3.条码扫一种类型后,判断有有效条码则不再扫码。
......
...@@ -247,13 +247,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -247,13 +247,13 @@ namespace OnlineStore.DeviceLibrary
protected override void BaseTimerProcess() protected override void BaseTimerProcess()
{ {
if (IOValue(IO_Type.DLine_SuddenStop).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.DLine_SuddenStop).Equals(IO_VALUE.LOW) && (!isInSuddenDown))
{ {
LogUtil.error(Name + "收到急停信号,等待300后再次验证急停"); LogUtil.error(Name + "收到急停信号,等待300后再次验证急停");
Task.Factory.StartNew(delegate Task.Factory.StartNew(delegate
{ {
Thread.Sleep(300); Thread.Sleep(300);
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.DLine_SuddenStop).Equals(IO_VALUE.LOW))
{ {
SetWarnMsg(Name + "收到急停信号,急停报警"); SetWarnMsg(Name + "收到急停信号,急停报警");
Alarm(LineAlarmType.SuddenStop); Alarm(LineAlarmType.SuddenStop);
......
...@@ -422,19 +422,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -422,19 +422,6 @@ namespace OnlineStore.DeviceLibrary
if (!wait.IsEnd) if (!wait.IsEnd)
{ {
//if (wait.IoType.Equals(IO_Type.ClampCylinder_Slack) && wait.IoValue.Equals(IO_VALUE.HIGH) && span.TotalMilliseconds > 6000)
//{
// LogInfo("未检测到:ClampCylinder_Slack=HIGH,超过6秒钟,默认下一步骤");
// wait.IsEnd = true;
//}
//else if (wait.IoType.Equals(IO_Type.SL_MoveCylinder_Tighten) && wait.IoValue.Equals(IO_VALUE.HIGH) && span.TotalMilliseconds > 6000)
//{
// LogInfo("未检测到:SL_MoveCylinder_Tighten=HIGH,超过6秒钟,默认下一步骤");
// wait.IsEnd = true;
//}
//else
//{
TimeSpan rwSpan = DateTime.Now - preRWTime; TimeSpan rwSpan = DateTime.Now - preRWTime;
//一分钟还未检测到 //一分钟还未检测到
if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && alarmType <= LineAlarmType.IoSingleTimeOut) if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && alarmType <= LineAlarmType.IoSingleTimeOut)
...@@ -468,10 +455,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -468,10 +455,14 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(msg); LogUtil.error(msg);
} }
} }
if (!moveInfo.OneWaitCanEndStep)
{
isOk = false; isOk = false;
break; break;
} }
} }
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time)) else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{ {
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds); wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
......
...@@ -326,13 +326,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -326,13 +326,13 @@ namespace OnlineStore.DeviceLibrary
protected override void BaseTimerProcess() protected override void BaseTimerProcess()
{ {
if (IOValue(IO_Type.SL_SuddenStop_BTN).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.SL_SuddenStop_BTN).Equals(IO_VALUE.LOW) && (!isInSuddenDown))
{ {
LogUtil.error(Name + "收到急停信号,等待300后再次验证急停"); LogUtil.error(Name + "收到急停信号,等待300后再次验证急停");
Task.Factory.StartNew(delegate Task.Factory.StartNew(delegate
{ {
Thread.Sleep(300); Thread.Sleep(300);
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.SL_SuddenStop_BTN).Equals(IO_VALUE.LOW))
{ {
SetWarnMsg(Name + "收到急停信号,急停报警"); SetWarnMsg(Name + "收到急停信号,急停报警");
if (isInSuddenDown.Equals(false)) if (isInSuddenDown.Equals(false))
......
...@@ -129,10 +129,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -129,10 +129,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(msg); LogUtil.error(msg);
} }
} }
if (!checkWaitInfo.OneWaitCanEndStep)
{
isOk = false; isOk = false;
break; break;
} }
} }
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time)) else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{ {
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds); wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
......
...@@ -412,6 +412,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -412,6 +412,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error("第" + i + "次获取" + portName + "_" + slvAddr + "的实时位置" + result); LogUtil.error("第" + i + "次获取" + portName + "_" + slvAddr + "的实时位置" + result);
} }
Thread.Sleep(100);
} }
return result; return result;
} }
......
...@@ -93,34 +93,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -93,34 +93,13 @@ namespace OnlineStore.DeviceLibrary
} }
public static void CloseAllCamera() public static void CloseAllCamera()
{ {
//BaslerCamera.Instance.Close();
//HIKCamera.Instance.Close();
Camera._cam.CloseAll(); Camera._cam.CloseAll();
} }
//public static Bitmap GetCamerImage(string cameraName)
//{
// Bitmap bitm = null;
// try
// {
// bitm= Camera._cam.GrabOneImage(cameraName);
// //Camera._cam.Close(cameraName);
// }
// catch (Exception ex)
// {
// LogUtil.error(" 【" + cameraName + "】获取图片出错:", ex);
// }
// return bitm;
//}
private static int ScanCount = 0; private static int ScanCount = 0;
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount); private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(List<string> cameraList, string deviceName, bool isSaveImg = false) public static List<string> CameraScan(List<string> cameraList, string deviceName, bool isSaveImg = false)
{ {
//if (codeCount < 1)
//{
// codeCount = 1;
//}
List<string> codeList = new List<string>(); List<string> codeList = new List<string>();
if (cameraList == null || cameraList.Count <= 0) if (cameraList == null || cameraList.Count <= 0)
{ {
...@@ -137,9 +116,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -137,9 +116,9 @@ namespace OnlineStore.DeviceLibrary
ScanCount++; ScanCount++;
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
LogUtil.info(deviceName + " 【" + cameraName + "】开始取图片"); LogUtil.info(deviceName + " 【" + cameraName + "】开始取图片");
//using (Bitmap bitmap = GetCamerImage(cameraName))
//{
HalconDotNet.HObject ho_Image = null; HalconDotNet.HObject ho_Image = null;
bool findRightCode = false;
try try
{ {
ho_Image = Camera._cam.CaptureOnImage(cameraName); ho_Image = Camera._cam.CaptureOnImage(cameraName);
...@@ -149,10 +128,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -149,10 +128,7 @@ namespace OnlineStore.DeviceLibrary
CloseCamera(cameraName); CloseCamera(cameraName);
continue; continue;
} }
//LogUtil.info(deviceName + " 【" + cameraName + "】取图片完成,开始转换并扫码");
//bit = new Bitmap(bitmap);
//LogUtil.info(deviceName + " 【" + cameraName + "】new Bitmap(bitmap);完成");
//ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bit);
LogUtil.info(deviceName + " 【" + cameraName + "】取图片完成,开始扫码"); LogUtil.info(deviceName + " 【" + cameraName + "】取图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>(); List<CodeInfo> cc = new List<CodeInfo>();
string r = ""; string r = "";
...@@ -174,14 +150,23 @@ namespace OnlineStore.DeviceLibrary ...@@ -174,14 +150,23 @@ namespace OnlineStore.DeviceLibrary
{ {
codeList.Add(str); codeList.Add(str);
r = r + "##" + str; r = r + "##" + str;
if (!findRightCode)
{
findRightCode = IsRightCode(str);
} }
} }
} }
if (findRightCode)
{
break;
}
}
if (String.IsNullOrEmpty(r)) if (String.IsNullOrEmpty(r))
{ {
// SaveImageToFile(deviceName, cameraName, bit); // SaveImageToFile(deviceName, cameraName, bit);
} }
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】" + ScanCount + " :" + r); LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】["+ findRightCode + "]" + ScanCount + " :" + r);
} }
catch (AccessViolationException e) catch (AccessViolationException e)
{ {
...@@ -195,21 +180,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -195,21 +180,12 @@ namespace OnlineStore.DeviceLibrary
} }
finally finally
{ {
//if (bitmap != null)
//{
// bitmap.Dispose();
//}
//if (bit != null)
//{
// bit.Dispose();
//}
if (ho_Image != null) if (ho_Image != null)
{ {
ho_Image.Dispose(); ho_Image.Dispose();
} }
} }
} }
//}
} }
catch (AccessViolationException e) catch (AccessViolationException e)
{ {
...@@ -244,6 +220,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -244,6 +220,29 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("保存" + deviceName + " 【" + cameraName + "】的图片到【" + dire + iamgeName + "】出错" + ex.ToString()); LogUtil.error("保存" + deviceName + " 【" + cameraName + "】的图片到【" + dire + iamgeName + "】出错" + ex.ToString());
} }
} }
private static bool IsRightCode(string code)
{
//分号分割后长度=4,L,E,B,R
try
{
string[] strarray = code.Split(';');
if (strarray.Length == 4)
{
if (strarray[0].StartsWith("L") &&
strarray[1].StartsWith("E") &&
strarray[2].StartsWith("B") &&
strarray[3].StartsWith("R"))
{
return true;
}
}
}
catch (Exception ex)
{
}
return false;
}
public static string GetCodeParamFilePath(string codePath) public static string GetCodeParamFilePath(string codePath)
{ {
string appPath = Application.StartupPath; string appPath = Application.StartupPath;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!