Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 927669a5
由
张东亮
编写于
2024-01-03 09:10:05 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
添加一维码检测料盘
1 个父辈
fa2cad7b
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
93 行增加
和
1 行删除
DeviceLibrary/DeviceLibrary/CodeManager.cs
DeviceLibrary/DeviceLibrary/CodeManager.cs
查看文件 @
927669a
...
...
@@ -263,6 +263,96 @@ namespace DeviceLibrary
string
logtxt
=
$
"【"
+
cameraName
+
"】开始取图片测试是否有料盘"
+
"\r\n"
;
DateTime
startTime
=
DateTime
.
Now
;
Bitmap
bmp
=
null
;
bool
usebarcode
=
ConfigHelper
.
Config
.
Get
(
"CamTestReel_useBarcode"
,
false
);
if
(
usebarcode
)
{
try
{
//bmp = new Bitmap(@"D:\logs\10-30-51-138.bmp");
bmp
=
Camera
.
_cam
.
GrabOne
(
cameraName
);
if
(
bmp
==
null
)
{
if
(
retrytime
>
2
)
return
null
;
retrytime
++;
Camera
.
_cam
.
Close
(
cameraName
);
//LoadCamera(true);
LogUtil
.
info
(
$
"bitmap为空重试第{retrytime}次"
);
Thread
.
Sleep
(
2000
);
goto
retry
;
}
logtxt
+=
$
"【"
+
cameraName
+
"】获取到图像"
+
"\r\n"
;
string
code
=
ConfigHelper
.
Config
.
Get
(
"CamTestReel_barcode"
,
"RW0000015"
);
int
codeThreshold
=
ConfigHelper
.
Config
.
Get
(
"CamTestReel_barcodeThreshold"
,
2
);
if
(
ConfigHelper
.
Config
.
Get
(
"CamTestReel_debug"
,
false
))
srcimg
=
SaveImageToFile
(
"test"
,
cameraName
,
bmp
);
bool
hasReel
=
false
;
RemoteDecodeHelper
.
RemoteDecodeParam
remoteDecodeParam
=
new
RemoteDecodeHelper
.
RemoteDecodeParam
{
codeTypeList
=
codeTypeList
.
ToArray
(),
codeCount
=
QRCodeCount
,
timeout
=
CodeTimeOut
};
List
<
CodeInfo
>
cc
=
RemoteDecodeHelper
.
DecodeRequest
(
bmp
,
remoteDecodeParam
);
int
count
=
0
;
if
(
cc
==
null
)
hasReel
=
true
;
else
{
var
res
=
cc
.
FindAll
(
s
=>
code
.
Equals
(
s
.
CodeStr
));
count
=
res
.
Count
();
if
(
res
==
null
||
count
<
codeThreshold
)
{
hasReel
=
true
;
}
}
string
r
=
""
;
if
(
cc
!=
null
&&
cc
.
Count
>
0
)
{
cc
.
ForEach
((
c
)
=>
{
c
.
CodeStr
=
CodeManager
.
ReplaceCode
(
c
.
CodeStr
);
r
+=
"#"
+
c
.
CodeStr
;
});
}
logtxt
+=
$
" 一维码扫描结果:{count}[{r}],设置可扫描到条码数量:{codeThreshold},result:{((count < codeThreshold)?"
有料
":"
无料
")}\r\n"
;
if
(
hasReel
!=
lastHasReel
)
{
lastHasReel
=
hasReel
;
}
else
if
(!
ConfigHelper
.
Config
.
Get
(
"CamTestReel_debug"
,
false
))
logtxt
=
""
;
if
(
ConfigHelper
.
Config
.
Get
(
"CamTestReel_debug"
,
false
)
||
(
TestHasRight
.
HasValue
&&
TestHasRight
.
Value
!=
hasReel
))
prcimg
=
SaveImageToFile
(
"test2"
,
cameraName
,
bmp
);
TestHasRight
=
null
;
return
hasReel
;
}
catch
(
AccessViolationException
e
)
{
LogUtil
.
error
(
" 扫码出现AccessViolationException异常,关闭相机【"
+
cameraName
+
"】:"
+
e
.
ToString
());
Camera
.
_cam
.
Close
(
cameraName
);
return
null
;
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
" 扫码出错:"
+
ex
.
ToString
());
return
null
;
}
finally
{
if
(
bmp
!=
null
)
bmp
.
Dispose
();
if
(!
string
.
IsNullOrEmpty
(
logtxt
))
LogUtil
.
error
(
logtxt
);
Monitor
.
Exit
(
testLocObj
);
}
}
else
{
try
{
//bmp = new Bitmap(@"D:\logs\10-30-51-138.bmp");
...
...
@@ -407,10 +497,12 @@ namespace DeviceLibrary
if
(
bmp
!=
null
)
bmp
.
Dispose
();
if
(!
string
.
IsNullOrEmpty
(
logtxt
))
LogUtil
.
error
(
logtxt
);
LogUtil
.
info
(
logtxt
);
Monitor
.
Exit
(
testLocObj
);
}
}
}
else
return
null
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论