Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
SO1057-XLRStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit c3abc9bf
由
张东亮
编写于
2024-03-25 17:27:31 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
视觉检测料盘、最后一盘自增可配置
1 个父辈
b0174c0e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
93 行增加
和
6 行删除
source/DeviceLibrary/deviceLibrary/halcon/CodeManager.cs
source/DeviceLibrary/storeBean/inputBean/BatchMoveBean.cs
source/DeviceLibrary/storeBean/inputBean/BatchMoveBean_Partial.cs
source/DeviceLibrary/deviceLibrary/halcon/CodeManager.cs
查看文件 @
c3abc9b
using
CodeLibrary
;
using
CodeLibrary
;
using
log4net.Util
;
using
OnlineStore.Common
;
using
OnlineStore.Common
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -268,6 +269,84 @@ namespace OnlineStore.DeviceLibrary
...
@@ -268,6 +269,84 @@ namespace OnlineStore.DeviceLibrary
}
}
return
codeList
;
return
codeList
;
}
}
[
HandleProcessCorruptedStateExceptions
]
public
static
bool
CameraCheckHeight
(
List
<
string
>
cameraList
,
string
deviceName
,
bool
findRightCodeBreak
=
false
,
int
timeOut
=
1500
)
{
bool
isPreScan
=
deviceName
.
EndsWith
(
"预扫码"
);
isPreScan
=
false
;
List
<
string
>
codeList
=
new
List
<
string
>();
if
(
cameraList
==
null
||
cameraList
.
Count
<=
0
)
{
return
false
;
}
try
{
foreach
(
string
cameraName
in
cameraList
)
{
if
(
cameraName
.
Trim
().
Equals
(
""
))
{
continue
;
}
ScanCount
++;
DateTime
startTime
=
DateTime
.
Now
;
if
(
deviceName
!=
""
)
{
LogUtil
.
info
(
deviceName
+
" 【"
+
cameraName
+
"】开始取图片"
);
}
Bitmap
bmp
=
null
;
HalconDotNet
.
HObject
ho_Image
=
null
;
try
{
ho_Image
=
Camera
.
_cam
.
CaptureOnImage
(
cameraName
,
out
bmp
);
if
(
ho_Image
==
null
)
{
LogUtil
.
error
(
deviceName
+
" 【"
+
cameraName
+
"】取图片失败["
+
Camera
.
_cam
.
ErrInfo
+
"],关闭相机"
);
CloseCamera
(
cameraName
);
continue
;
}
else
{
LogUtil
.
info
(
deviceName
+
" 【"
+
cameraName
+
"】取图片完成"
);
return
true
;
}
}
catch
(
AccessViolationException
e
)
{
LogUtil
.
error
(
deviceName
+
" 扫码出现AccessViolationException异常,关闭相机【"
+
cameraName
+
"】:"
+
e
.
ToString
());
Camera
.
_cam
.
Close
(
cameraName
);
// GC.Collect();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
deviceName
+
" 扫码出错:"
+
ex
.
ToString
());
}
finally
{
if
(
ho_Image
!=
null
)
{
ho_Image
.
Dispose
();
ho_Image
=
null
;
}
// GC.Collect();
Task
.
Delay
(
10
);
}
}
}
catch
(
AccessViolationException
e
)
{
LogUtil
.
error
(
deviceName
+
" 扫码出现AccessViolationException异常,关闭所有相机:"
+
e
.
ToString
());
Camera
.
_cam
.
CloseAll
();
//GC.Collect();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
deviceName
+
" 扫码出错:"
+
ex
.
ToString
());
}
return
false
;
}
private
static
int
SaveErrorImageToFile
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
SaveErrorImageToFile
);
private
static
int
SaveErrorImageToFile
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
SaveErrorImageToFile
);
//private static void SaveImageToFile(string deviceName, string cameraName, HalconDotNet.HObject bitmap)
//private static void SaveImageToFile(string deviceName, string cameraName, HalconDotNet.HObject bitmap)
...
...
source/DeviceLibrary/storeBean/inputBean/BatchMoveBean.cs
查看文件 @
c3abc9b
...
@@ -61,7 +61,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -61,7 +61,7 @@ namespace OnlineStore.DeviceLibrary
Config
.
LoadIO
(
ioAdd
);
Config
.
LoadIO
(
ioAdd
);
MoveInfo
=
new
DeviceMoveInfo
(
Name
);
MoveInfo
=
new
DeviceMoveInfo
(
Name
);
cames
=
ConfigHelper
.
Config
.
Get
<
string
[
]>
(
$
"{Name}_HeightCams"
);
}
}
public
void
TimerProcess
()
public
void
TimerProcess
()
{
{
...
...
source/DeviceLibrary/storeBean/inputBean/BatchMoveBean_Partial.cs
查看文件 @
c3abc9b
...
@@ -400,7 +400,8 @@ namespace OnlineStore.DeviceLibrary
...
@@ -400,7 +400,8 @@ namespace OnlineStore.DeviceLibrary
//else
//else
if
(
isScan
)
if
(
isScan
)
{
{
WorkLog
(
"料盘移栽 :开始扫码"
);
WorkLog
(
"料盘移栽 :开始扫码,并采集抓取前测高图片"
);
CodeManager
.
CameraCheckHeight
(
cames
?.
ToList
(),
Name
);
MoveInfo
.
OneWaitCanEndStep
=
true
;
MoveInfo
.
OneWaitCanEndStep
=
true
;
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitFeedScanCode
());
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitFeedScanCode
());
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
60000
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
60000
));
...
@@ -556,8 +557,12 @@ namespace OnlineStore.DeviceLibrary
...
@@ -556,8 +557,12 @@ namespace OnlineStore.DeviceLibrary
public
int
StartMovePosition
=
0
;
public
int
StartMovePosition
=
0
;
public
int
EndMovePosition
=
0
;
public
int
EndMovePosition
=
0
;
internal
int
LastHeight
=
0
;
internal
int
LastHeight
=
0
;
string
[]
cames
;
public
int
GetHeight
()
public
int
GetHeight
()
{
{
CodeManager
.
CameraCheckHeight
(
cames
?.
ToList
(),
Name
);
LogUtil
.
info
(
$
"{Name} 采集料盘抓走后的图片,开始计算高度"
);
int
lastReelAddVal
=
ConfigHelper
.
Config
.
Get
(
$
"{Name}_lastReelSelfAddVal"
,
4
);
LastHeight
=
0
;
LastHeight
=
0
;
int
AxisChangeValue
=
Robot
.
Config
.
Height_ChangeValue
;
int
AxisChangeValue
=
Robot
.
Config
.
Height_ChangeValue
;
//计算高度
//计算高度
...
@@ -572,8 +577,8 @@ namespace OnlineStore.DeviceLibrary
...
@@ -572,8 +577,8 @@ namespace OnlineStore.DeviceLibrary
string
buchongStr
=
""
;
string
buchongStr
=
""
;
if
(
isLast
)
if
(
isLast
)
{
{
buchongStr
=
"(最后一盘料)加4
"
;
buchongStr
=
$
"(最后一盘料)加{lastReelAddVal}
"
;
height
+=
4
;
height
+=
lastReelAddVal
;
}
}
//如果检测出<=15,都按照8计算
//如果检测出<=15,都按照8计算
...
@@ -608,8 +613,11 @@ namespace OnlineStore.DeviceLibrary
...
@@ -608,8 +613,11 @@ namespace OnlineStore.DeviceLibrary
}
}
if
(
LastHeight
<=
8
)
{
LastHeight
=
8
;
}
if
(
LastHeight
<=
8
)
{
LastHeight
=
8
;
}
string
code
=
CodeManager
.
ProcessCode
(
LastCodeList
);
string
code
=
CodeManager
.
ProcessCode
(
LastCodeList
);
string
msg
=
Name
+
" 计算盘高:上升前 ["
+
StartMovePosition
+
"]实时[ "
+
EndMovePosition
+
"]差值["
+
(
EndMovePosition
-
StartMovePosition
)
+
"]系数["
+
AxisChangeValue
+
"] 计算后"
+
buchongStr
+
"["
+
height
+
"]"
+
",归类为【"
+
LastHeight
+
"mm】条码【"
+
code
+
"】"
;
Thread
.
Sleep
(
500
);
string
msg
=
$
"{Name} 上升前 [{StartMovePosition}]实时[{ EndMovePosition}]差值[{(EndMovePosition - StartMovePosition)}]"
+
$
"系数[{AxisChangeValue}] 计算后{buchongStr}[{height}]条码【{code}】"
;
LogUtil
.
info
(
msg
);
LogUtil
.
info
(
msg
);
LogUtil
.
info
(
$
"{Name} 视觉计算的盘高结果:{height}mm,归类为{LastHeight}mm"
);
return
LastHeight
;
return
LastHeight
;
}
}
#
endregion
#
endregion
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论