Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
SO1057-XLRStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 66068c21
由
张东亮
编写于
2024-12-19 10:45:34 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
扫码使用服务
1 个父辈
3a0334d4
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
148 行增加
和
8 行删除
source/Common/Common.csproj
source/Common/Setting_Init.cs
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/deviceLibrary/halcon/CodeManager.cs
source/XLRStoreClient/FrmXLRStore.cs
source/XLRStoreClient/XLRStore.csproj
source/Common/Common.csproj
查看文件 @
66068c2
...
...
@@ -33,6 +33,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ConfigHelper">
<HintPath>..\XLRStoreClient\bin\Debug\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\..\packages\log4net.2.0.12\lib\net40\log4net.dll</HintPath>
</Reference>
...
...
source/Common/Setting_Init.cs
查看文件 @
66068c2
using
System
;
using
ConfigHelper
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -125,5 +126,9 @@ namespace OnlineStore.Common
public
static
string
Device_HumidityLimited
=
"Device_HumidityLimited"
;
public
static
string
Device_TemptureAdjust
=
"Device_TemptureAdjust"
;
public
static
string
Device_TemptureLimited
=
"Device_TemptureLimited"
;
[
MyConfigComment
(
"筛选条码数量"
)]
public
static
MyConfig
<
int
>
Camera_QRCodeCount
=
3
;
[
MyConfigComment
(
"解码的超时时间"
)]
public
static
MyConfig
<
int
>
Camera_CodeTimeOut
=
1000
;
}
}
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
66068c2
...
...
@@ -48,8 +48,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\Client.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
<Reference Include="CodeLibrary, Version=1.0.8787.29577, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Standalone\MIMO_G2\DLL\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="ConfigHelper">
<HintPath>..\..\..\..\SharedRefDll\Neotel\ConfigHelper.dll</HintPath>
...
...
source/DeviceLibrary/deviceLibrary/halcon/CodeManager.cs
查看文件 @
66068c2
...
...
@@ -20,7 +20,8 @@ namespace OnlineStore.DeviceLibrary
public
static
List
<
string
>
codeTypeList
=
new
List
<
string
>();
public
static
List
<
string
>
balserNameList
=
new
List
<
string
>();
public
static
List
<
string
>
hikNameList
=
new
List
<
string
>();
private
static
int
QRCodeCount
=
Setting_Init
.
Camera_QRCodeCount
;
private
static
int
CodeTimeOut
=
Setting_Init
.
Camera_CodeTimeOut
;
private
static
char
spiltChar
=
'#'
;
/// <summary>
/// 初始化摄像机名称和二维码类型
...
...
@@ -104,11 +105,140 @@ namespace OnlineStore.DeviceLibrary
public
static
List
<
string
>
CameraScan
(
string
cameraName
,
string
deviceName
,
bool
findRightCodeBreak
=
false
,
int
timeOut
=
1500
)
{
List
<
string
>
nameList
=
new
List
<
string
>()
{
cameraName
};
return
CameraScan
(
nameList
,
deviceName
,
findRightCodeBreak
,
timeOut
);
return
CameraScan
(
nameList
,
deviceName
);
}
private
static
int
ScanCount
=
0
;
private
static
int
codeCount
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
CodeCount
);
[
HandleProcessCorruptedStateExceptions
]
public
static
List
<
CodeInfo
>
CameraScan
(
List
<
string
>
cameraNameList
)
{
HashSet
<
string
>
codestr
=
new
HashSet
<
string
>();
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
// string bitmapfilename = "";
if
(
cameraNameList
==
null
||
cameraNameList
.
Count
<=
0
)
{
throw
new
Exception
(
"CameraScan方法没有传入相机名称."
);
}
try
{
Task
[]
cameraTask
=
new
Task
[
cameraNameList
.
Count
()];
for
(
int
ii
=
0
;
ii
<
cameraNameList
.
Count
();
ii
++)
{
var
cameraName
=
cameraNameList
[
ii
];
var
idx
=
ii
;
cameraTask
[
ii
]
=
Task
.
Run
(
new
Action
(()
=>
{
int
retrytime
=
0
;
retry
:
LogUtil
.
info
(
$
"【"
+
cameraName
+
"】开始取图片"
);
if
(
cameraName
.
Trim
().
Equals
(
""
))
{
return
;
}
DateTime
startTime
=
DateTime
.
Now
;
HalconDotNet
.
HObject
ho_Image
=
null
;
Bitmap
bmp
=
null
;
try
{
bool
nohalcon
=
true
;
ho_Image
=
Camera
.
_cam
.
CaptureOnImage
(
cameraName
,
out
bmp
,
nohalcon
);
if
(
bmp
==
null
)
{
if
(
retrytime
>
2
)
return
;
retrytime
++;
LoadCamera
(
true
);
LogUtil
.
info
(
$
"bitmap为空重试第{retrytime}次"
);
Task
.
Delay
(
1500
).
Wait
();
goto
retry
;
}
//HalconDotNet.HOperatorSet.RotateImage()
if
(
ho_Image
==
null
&&
!
nohalcon
)
{
LogUtil
.
error
(
" 【"
+
cameraName
+
"】取图片失败["
+
Camera
.
_cam
.
ErrInfo
+
"],关闭相机"
);
LoadCamera
(
true
);
return
;
}
// if (idx == 0)
// camera_event?.Invoke(null, bmp);
LogUtil
.
info
(
" 【"
+
cameraName
+
"】取图片完成,开始扫码"
);
string
r
=
""
;
RemoteDecodeHelper
.
RemoteDecodeParam
remoteDecodeParam
=
new
RemoteDecodeHelper
.
RemoteDecodeParam
{
codeTypeList
=
codeTypeList
.
ToArray
(),
codeCount
=
QRCodeCount
,
timeout
=
CodeTimeOut
};
List
<
CodeInfo
>
cc
=
new
List
<
CodeInfo
>();
cc
=
RemoteDecodeHelper
.
DecodeRequest
(
bmp
,
remoteDecodeParam
);
if
(
cc
!=
null
&&
cc
.
Count
>
0
)
{
lock
(
codeList
)
{
cc
.
ForEach
((
c
)
=>
{
c
.
CodeStr
=
CodeManager
.
ReplaceCode
(
c
.
CodeStr
);
if
(!
codestr
.
Contains
(
c
.
CodeStr
))
{
codeList
.
Add
(
c
);
codestr
.
Add
(
c
.
CodeStr
);
r
+=
"##"
+
c
.
CodeStr
;
}
});
}
}
else
{
SaveImageToFile
(
"mimo"
,
cameraName
,
bmp
);
}
LogUtil
.
info
(
" 【"
+
cameraName
+
"】"
+
" 扫码完成【"
+
FormUtil
.
GetSpanStr
(
DateTime
.
Now
-
startTime
)
+
"】 :"
+
r
);
}
catch
(
AccessViolationException
e
)
{
LogUtil
.
error
(
" 扫码出现AccessViolationException异常,关闭相机【"
+
cameraName
+
"】:"
+
e
.
ToString
());
Camera
.
_cam
.
Close
(
cameraName
);
// GC.Collect();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
" 扫码出错:"
+
ex
.
ToString
());
}
finally
{
if
(
ho_Image
!=
null
)
{
ho_Image
.
Dispose
();
}
if
(
bmp
!=
null
)
bmp
.
Dispose
();
}
}));
Task
.
Delay
(
ii
*
700
).
Wait
();
}
while
(!
cameraTask
[
0
].
IsCompleted
||
!
cameraTask
[
1
].
IsCompleted
)
{
Application
.
DoEvents
();
Thread
.
Sleep
(
100
);
}
}
catch
(
AccessViolationException
e
)
{
LogUtil
.
error
(
" 扫码出现AccessViolationException异常:"
+
e
.
ToString
());
//throw new Exception("扫码出现AccessViolationException异常");
// GC.Collect();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
" 扫码出错:"
+
ex
.
ToString
());
//throw new Exception("扫码出错");
}
return
codeList
;
}
[
HandleProcessCorruptedStateExceptions
]
public
static
List
<
string
>
CameraScan
(
List
<
string
>
cameraList
,
string
deviceName
,
bool
findRightCodeBreak
=
false
,
int
timeOut
=
1500
)
{
bool
isPreScan
=
deviceName
.
EndsWith
(
"预扫码"
);
...
...
source/XLRStoreClient/FrmXLRStore.cs
查看文件 @
66068c2
...
...
@@ -600,7 +600,7 @@ namespace OnlineStore.XLRStore
{
Camera
.
_cam
.
CloseAll
();
}
CodeLibrary
.
FrmCodeDecode
frm
=
new
CodeLibrary
.
FrmCodeDecode
(
false
);
CodeLibrary
.
FrmCodeDecode
frm
=
new
CodeLibrary
.
FrmCodeDecode
();
frm
.
ShowDialog
();
frm
.
Dispose
();
}
...
...
source/XLRStoreClient/XLRStore.csproj
查看文件 @
66068c2
...
...
@@ -63,8 +63,9 @@
<Reference Include="Client">
<HintPath>..\..\dll\Client.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
<Reference Include="CodeLibrary, Version=1.0.8182.32076, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Standalone\MIMO_G2\DLL\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="ConfigHelper, Version=1.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论