Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS200
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 6a7f63a0
由
刘韬
编写于
2026-02-11 09:01:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化日志贴标位置展示
1 个父辈
fd30d7b8
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
75 行增加
和
39 行删除
AutoScanAndLabel/Form1.cs
AutoScanAndLabel/Program.cs
AutoScanAndLabel/SettingControl.cs
DeviceLibrary/AutoScanAndLabel/Common.cs
DeviceLibrary/AutoScanAndLabel/MainMachine _LabelProcess.cs
DeviceLibrary/DeviceLibrary/CodeManager.cs
DeviceLibrary/DeviceLibrary/RemoteDecodeHelper.cs
AutoScanAndLabel/Form1.cs
查看文件 @
6a7f63a
...
@@ -491,7 +491,7 @@ namespace AutoScanAndLabel
...
@@ -491,7 +491,7 @@ namespace AutoScanAndLabel
MessageBox
.
Show
(
crc
.
GetString
(
"Res0019"
,
"正在执行料串释放"
));
MessageBox
.
Show
(
crc
.
GetString
(
"Res0019"
,
"正在执行料串释放"
));
return
;
return
;
}
}
else
if
(
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
<
MoveStep
.
L04
||
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
>
MoveStep
.
L30_LabelFinish
)
else
if
(
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
<
MoveStep
.
L04
||
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
>
MoveStep
.
L
20_WaitLabel
||
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
>
MoveStep
.
L
30_LabelFinish
)
{
{
MessageBox
.
Show
(
crc
.
GetString
(
"Res0083"
,
"左侧料串正在提升或下降, 不能释放"
));
MessageBox
.
Show
(
crc
.
GetString
(
"Res0083"
,
"左侧料串正在提升或下降, 不能释放"
));
return
;
return
;
...
...
AutoScanAndLabel/Program.cs
查看文件 @
6a7f63a
using
ConfigHelper
;
using
BLL
;
using
CodeLibrary
;
using
ConfigHelper
;
using
DeviceLibrary
;
using
log4net.Config
;
using
log4net.Config
;
using
Newtonsoft.Json
;
using
OnlineStore.Common
;
using
OnlineStore.Common
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Threading
;
using
System.Threading
;
...
@@ -24,21 +29,39 @@ namespace AutoScanAndLabel
...
@@ -24,21 +29,39 @@ namespace AutoScanAndLabel
Application
.
SetUnhandledExceptionMode
(
UnhandledExceptionMode
.
CatchException
);
Application
.
SetUnhandledExceptionMode
(
UnhandledExceptionMode
.
CatchException
);
Application
.
ThreadException
+=
new
System
.
Threading
.
ThreadExceptionEventHandler
(
Application_ThreadException
);
Application
.
ThreadException
+=
new
System
.
Threading
.
ThreadExceptionEventHandler
(
Application_ThreadException
);
AppDomain
.
CurrentDomain
.
UnhandledException
+=
new
UnhandledExceptionEventHandler
(
CurrentDomain_UnhandledException
);
AppDomain
.
CurrentDomain
.
UnhandledException
+=
new
UnhandledExceptionEventHandler
(
CurrentDomain_UnhandledException
);
//DeviceLibrary.LabelParam labelParam = new DeviceLibrary.LabelParam();
//labelParam.codeInfos = new List<CodeLibrary.CodeInfo>();
////##340093060037##01410000441770##012100000224##Q3000
SolidBrush
blue
=
new
SolidBrush
(
Color
.
BlueViolet
);
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Y38072732TLP785(D4GHTR6,F (C 2000A0132G0 2000ZUY0HG1U8501F2A Y0HG1U 2124 2124TWCN 69 T2", 0, 0));
SolidBrush
red
=
new
SolidBrush
(
Color
.
Red
);
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("[)>P1PTLV7022DGKR6P2PAQ25000V00333171T0557736ZEW4WTKYD210631T1032393ASH20LRFB21LUSA22LASH23LCHNEG43Z1/260C/UNLIM;//;022121L18087KN01", 0, 0));
SolidBrush
red2
=
new
SolidBrush
(
Color
.
MediumVioletRed
);
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("99700736000619EM6H38.125008625", 0, 0));
SolidBrush
yellow
=
new
SolidBrush
(
Color
.
Yellow
);
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("CK7T0H.125002115", 0, 0));
SolidBrush
AliceBlue
=
new
SolidBrush
(
Color
.
AliceBlue
);
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Y38073304TLP385(D4GREETRE (T 00003000A0149T 03000WT0HBGCC8210B3F-5595 2009 2009JPTH 00 67 91432487 02Q", 0, 0));
SolidBrush
Green
=
new
SolidBrush
(
Color
.
Green
);
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("01410000441770", 0, 0));
/*
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("012100000224", 0, 0));
Font font = new Font(FontFamily.GenericSansSerif, 60);
////labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("Q3000", 0, 0));
Pen Greenpen = new Pen(Color.Green, 7);
//labelParam.codeInfos.Add(new CodeLibrary.CodeInfo("340093060037", 0, 0, "Code 128"));
//Size pointsize = new Size(15, 15);
int pointsize = 16;
//DeviceLibrary.Common.codeProcess(labelParam, out string debugmsg);
//Console.WriteLine(debugmsg);
var codetxt = @"[{""CodeStr"":""1T0009938251"",""X"":1605,""Y"":2047,""CodeType"":""Code 128"",""Orientation"":35.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""10D2547"",""X"":1652,""Y"":1973,""CodeType"":""Code 128"",""Orientation"":34.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""1PCRCW0805249KFHEAP"",""X"":1852,""Y"":1909,""CodeType"":""Code 128"",""Orientation"":34.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""XA7IF 249KF "",""X"":2301,""Y"":1460,""CodeType"":""Code 39"",""Orientation"":43.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""Q5000"",""X"":1654,""Y"":1876,""CodeType"":""Code 128"",""Orientation"":39.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""4LIL"",""X"":1512,""Y"":2060,""CodeType"":""Code 128"",""Orientation"":38.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""701011124;0040;5000;CRCW0805249KFHEAP;BC COMP VISHAY;2547;1010025249;20260204;;0009938251"",""X"":1607,""Y"":1583,""CodeType"":""Data Matrix ECC 200"",""Orientation"":36.0,""LabelCenter"":""0, 0"",""LabelDistance"":0},{""CodeStr"":""CRCW0805249KFHEAP000993825111/21/25 202547IL 5000.00000329245390001 2547 61410010 50 9938251 5000 00041569040001 CRCW0805249KFHEAPCRCW0805-P 50 249K 1% ET1 B0R013674260"",""X"":2437,""Y"":1305,""CodeType"":""PDF417"",""Orientation"":0.0,""LabelCenter"":""0, 0"",""LabelDistance"":0}]";
var codelists= JsonConvert.DeserializeObject<List<CodeInfo>>(codetxt);
var bmp = new Bitmap(@"D:\logs\123\2026-02-09-16-24-3891.bmp");
var bmp2 = (Bitmap)bmp.Clone();
var result = RemoteDecodeHelper_mod.NeoSacnRequest(RemoteDecodeHelper_mod.BitmapToBase64(bmp), codelists, 7, 2059, 1755);
var labelPoint = new Point(result.positionAngle.X, result.positionAngle.Y);
Graphics graphics = Graphics.FromImage(bmp2);
graphics.FillEllipse(red, Common.EllipseCenter(new Point(2059, 1755), pointsize));
graphics.FillEllipse(red, Common.EllipseCenter(labelPoint, pointsize));
var l2 = Common.PointWithAngle(labelPoint, result.positionAngle.Angle, 200);
graphics.DrawLine(Greenpen, labelPoint, l2);
graphics.Save();
bmp2.Save(@"D:\logs\123\2026-02-09-16-24-3891_result.bmp");
return;
*/
_
=
new
Mutex
(
true
,
Application
.
ProductName
,
out
bool
ret
);
_
=
new
Mutex
(
true
,
Application
.
ProductName
,
out
bool
ret
);
if
(!
ret
)
if
(!
ret
)
{
{
...
...
AutoScanAndLabel/SettingControl.cs
查看文件 @
6a7f63a
...
@@ -127,7 +127,7 @@ namespace AutoScanAndLabel
...
@@ -127,7 +127,7 @@ namespace AutoScanAndLabel
private
void
btn_labelDebug_Click
(
object
sender
,
EventArgs
e
)
private
void
btn_labelDebug_Click
(
object
sender
,
EventArgs
e
)
{
{
LabelParam
la
=
new
LabelParam
();
LabelParam
la
=
new
LabelParam
();
Common
.
RenderedImage
(
la
,
new
Point
(
500
,
500
),
new
Point
(
1000
,
1000
));
Common
.
RenderedImage
(
la
,
new
Point
(
500
,
500
),
new
Point
(
1000
,
1000
)
,
0
);
//UnifiedDataHandler.RecordPrintNg(false,true,out string[] s);
//UnifiedDataHandler.RecordPrintNg(false,true,out string[] s);
//UnifiedDataHandler.RecordEmsData(false,"78945699999");
//UnifiedDataHandler.RecordEmsData(false,"78945699999");
//Dictionary<string, string> dic = new Dictionary<string, string>();
//Dictionary<string, string> dic = new Dictionary<string, string>();
...
...
DeviceLibrary/AutoScanAndLabel/Common.cs
查看文件 @
6a7f63a
...
@@ -18,6 +18,7 @@ using System.Threading.Tasks;
...
@@ -18,6 +18,7 @@ using System.Threading.Tasks;
using
System.Web
;
using
System.Web
;
using
System.Web.UI.WebControls
;
using
System.Web.UI.WebControls
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
using
ZXing
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
...
@@ -79,7 +80,10 @@ namespace DeviceLibrary
...
@@ -79,7 +80,10 @@ namespace DeviceLibrary
result
=
Math
.
Sqrt
((
p1
.
X
-
p2
.
X
)
*
(
p1
.
X
-
p2
.
X
)
+
(
p1
.
Y
-
p2
.
Y
)
*
(
p1
.
Y
-
p2
.
Y
));
result
=
Math
.
Sqrt
((
p1
.
X
-
p2
.
X
)
*
(
p1
.
X
-
p2
.
X
)
+
(
p1
.
Y
-
p2
.
Y
)
*
(
p1
.
Y
-
p2
.
Y
));
return
result
;
return
result
;
}
}
public
static
Rectangle
EllipseCenter
(
Point
p
,
int
size
)
{
return
new
Rectangle
(
p
.
X
-
size
/
2
,
p
.
Y
-
size
/
2
,
size
,
size
);
}
/// <summary>
/// <summary>
/// 以中心点旋转Angle角度
/// 以中心点旋转Angle角度
/// </summary>
/// </summary>
...
@@ -850,18 +854,19 @@ namespace DeviceLibrary
...
@@ -850,18 +854,19 @@ namespace DeviceLibrary
bitmap
.
Dispose
();
bitmap
.
Dispose
();
return
newxy
;
return
newxy
;
}
}
static
SolidBrush
blue
=
new
SolidBrush
(
Color
.
BlueViolet
);
public
static
void
RenderedImage
(
LabelParam
labelParam
,
Point
centrality
,
Point
point
)
static
SolidBrush
red
=
new
SolidBrush
(
Color
.
Red
);
static
SolidBrush
red2
=
new
SolidBrush
(
Color
.
MediumVioletRed
);
static
SolidBrush
yellow
=
new
SolidBrush
(
Color
.
Yellow
);
static
SolidBrush
AliceBlue
=
new
SolidBrush
(
Color
.
AliceBlue
);
static
SolidBrush
Green
=
new
SolidBrush
(
Color
.
Green
);
static
int
pointsize
=
16
;
static
Pen
Greenpen
=
new
Pen
(
Color
.
Green
,
7
);
public
static
void
RenderedImage
(
LabelParam
labelParam
,
Point
centrality
,
Point
point
,
int
angle
)
{
{
try
try
{
{
LogUtil
.
info
(
"labelParam:"
+
JsonConvert
.
SerializeObject
(
labelParam
));
LogUtil
.
info
(
"labelParam:"
+
JsonConvert
.
SerializeObject
(
labelParam
));
//标签位置
SolidBrush
blue
=
new
SolidBrush
(
Color
.
DarkBlue
);
//料盘中心点
SolidBrush
red
=
new
SolidBrush
(
Color
.
Red
);
//贴标位置
SolidBrush
yeelow
=
new
SolidBrush
(
Color
.
Yellow
);
Bitmap
srcbitmap
;
Bitmap
srcbitmap
;
if
(
File
.
Exists
(
labelParam
.
bitmapfilename
))
if
(
File
.
Exists
(
labelParam
.
bitmapfilename
))
{
{
...
@@ -873,15 +878,22 @@ namespace DeviceLibrary
...
@@ -873,15 +878,22 @@ namespace DeviceLibrary
}
}
Bitmap
bitmap
=
new
Bitmap
(
srcbitmap
);
Bitmap
bitmap
=
new
Bitmap
(
srcbitmap
);
Graphics
g
=
Graphics
.
FromImage
(
bitmap
);
Graphics
g
=
Graphics
.
FromImage
(
bitmap
);
Size
pointsize
=
new
Size
(
60
,
60
);
g
.
FillEllipse
(
red
,
new
Rectangle
(
centrality
,
pointsize
));
g
.
FillEllipse
(
red
,
Common
.
EllipseCenter
(
centrality
,
pointsize
));
int
idnex
=
0
;
int
idnex
=
0
;
labelParam
.
NewXYAngle
.
TryGetValue
(
"IsCodeUsed"
,
out
idnex
);
labelParam
.
NewXYAngle
.
TryGetValue
(
"IsCodeUsed"
,
out
idnex
);
Point
CalPoint
=
new
Point
(
point
.
X
,
point
.
Y
);
Point
CalPoint
=
new
Point
(
point
.
X
,
point
.
Y
);
if
(
idnex
>=
0
)
if
(
idnex
>=
0
)
CalPoint
=
new
Point
(
labelParam
.
codeInfos
[
idnex
].
X
,
labelParam
.
codeInfos
[
idnex
].
Y
);
CalPoint
=
new
Point
(
labelParam
.
codeInfos
[
idnex
].
X
,
labelParam
.
codeInfos
[
idnex
].
Y
);
g
.
FillEllipse
(
blue
,
new
Rectangle
(
CalPoint
,
pointsize
));
g
.
FillEllipse
(
blue
,
Common
.
EllipseCenter
(
CalPoint
,
pointsize
));
g
.
FillEllipse
(
yeelow
,
new
Rectangle
(
point
,
pointsize
));
g
.
FillEllipse
(
yellow
,
Common
.
EllipseCenter
(
point
,
pointsize
));
var
labelPoint
=
point
;
var
l2
=
Common
.
PointWithAngle
(
labelPoint
,
angle
,
200
);
g
.
DrawLine
(
Greenpen
,
labelPoint
,
l2
);
g
.
Save
();
g
.
Save
();
g
.
Dispose
();
g
.
Dispose
();
string
filepath
=
Application
.
StartupPath
+
"\\image\\Labeling\\"
;
string
filepath
=
Application
.
StartupPath
+
"\\image\\Labeling\\"
;
...
...
DeviceLibrary/AutoScanAndLabel/MainMachine _LabelProcess.cs
查看文件 @
6a7f63a
...
@@ -285,7 +285,7 @@ namespace DeviceLibrary
...
@@ -285,7 +285,7 @@ namespace DeviceLibrary
{
{
labelAngle
=
Angle
;
labelAngle
=
Angle
;
}
}
Common
.
RenderedImage
(
LabelMoveInfo
.
MoveParam
,
Right_Batch_Point
,
p
);
Common
.
RenderedImage
(
LabelMoveInfo
.
MoveParam
,
Right_Batch_Point
,
p
,
labelAngle
);
LogUtil
.
info
(
$
"NS200接收贴标位置{p};角度={labelAngle}"
);
LogUtil
.
info
(
$
"NS200接收贴标位置{p};角度={labelAngle}"
);
}
}
...
...
DeviceLibrary/DeviceLibrary/CodeManager.cs
查看文件 @
6a7f63a
...
@@ -17,6 +17,7 @@ using static RemoteDecodeHelper_mod;
...
@@ -17,6 +17,7 @@ using static RemoteDecodeHelper_mod;
using
System.Web
;
using
System.Web
;
using
log4net
;
using
log4net
;
using
OnlineStore.Common.util
;
using
OnlineStore.Common.util
;
using
Newtonsoft.Json
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
...
@@ -191,9 +192,9 @@ namespace DeviceLibrary
...
@@ -191,9 +192,9 @@ namespace DeviceLibrary
LogUtil
.
error
(
"扫码相机未扫描到任何条码!"
);
LogUtil
.
error
(
"扫码相机未扫描到任何条码!"
);
return
(
codeList
,
keyword
,
bitmapfilename
,
newpointanlge
);
return
(
codeList
,
keyword
,
bitmapfilename
,
newpointanlge
);
}
}
LogUtil
.
info
(
"识别条码为:"
+
JsonConvert
.
SerializeObject
(
codes
));
LogUtil
.
info
(
$
"开始请求ns100服务
:识别条码为:{string.Join("
##
", codes.Select(a=>a.CodeStr+$"
@
@x
:{
a
.
X
};
y
:{
a
.
Y
};
角度
{
a
.
Orientation
}
"))}
"
);
LogUtil
.
info
(
$
"开始请求ns100服务"
);
webResult
=
NeoSacnRequest
(
BitmapToBase64
(
bmp
),
codes
,
PlateW
);
webResult
=
NeoSacnRequest
(
BitmapToBase64
(
bmp
),
codes
,
PlateW
,
RobotManage
.
Config
.
Right_Batch_X
,
RobotManage
.
Config
.
Right_Batch_Y
);
}
}
else
else
{
{
...
@@ -288,7 +289,7 @@ namespace DeviceLibrary
...
@@ -288,7 +289,7 @@ namespace DeviceLibrary
{
{
moveInfo
.
log
(
$
"开始请求ns100服务:识别条码为:{string.Join("
##
", codeInfos.Select(a => a.CodeStr + $"
@
@x
:{
a
.
X
};
y
:{
a
.
Y
};
角度
{
a
.
Orientation
}
"))}"
);
moveInfo
.
log
(
$
"开始请求ns100服务:识别条码为:{string.Join("
##
", codeInfos.Select(a => a.CodeStr + $"
@
@x
:{
a
.
X
};
y
:{
a
.
Y
};
角度
{
a
.
Orientation
}
"))}"
);
webResult
=
NeoSacnRequest
(
bitmapBase64
,
codeInfos
,
PlateW
);
webResult
=
NeoSacnRequest
(
bitmapBase64
,
codeInfos
,
PlateW
,
RobotManage
.
Config
.
Right_Batch_X
,
RobotManage
.
Config
.
Right_Batch_Y
);
}
}
else
else
{
{
...
...
DeviceLibrary/DeviceLibrary/RemoteDecodeHelper.cs
查看文件 @
6a7f63a
...
@@ -94,7 +94,7 @@ public class RemoteDecodeHelper_mod
...
@@ -94,7 +94,7 @@ public class RemoteDecodeHelper_mod
}
}
#
region
扫码相机请求
ns100
方法
#
region
扫码相机请求
ns100
方法
public
static
WebResultCode
NeoSacnRequest
(
string
bitmapBase64
,
List
<
CodeLibrary
.
CodeInfo
>
codeInfos
,
int
PlateW
)
public
static
WebResultCode
NeoSacnRequest
(
string
bitmapBase64
,
List
<
CodeLibrary
.
CodeInfo
>
codeInfos
,
int
PlateW
,
int
center_x
,
int
center_y
)
{
{
WebResultCode
resultCode
=
null
;
WebResultCode
resultCode
=
null
;
try
try
...
@@ -126,8 +126,8 @@ public class RemoteDecodeHelper_mod
...
@@ -126,8 +126,8 @@ public class RemoteDecodeHelper_mod
});
});
bitmapData
.
ImageData
=
bitmapBase64
;
bitmapData
.
ImageData
=
bitmapBase64
;
bitmapData
.
BarCodeList
=
barcodeInfos
;
bitmapData
.
BarCodeList
=
barcodeInfos
;
bitmapData
.
X
=
RobotManage
.
Config
.
Right_Batch_X
;
bitmapData
.
X
=
center_x
;
bitmapData
.
Y
=
RobotManage
.
Config
.
Right_Batch_Y
;
bitmapData
.
Y
=
center_y
;
bitmapData
.
IsIDCamera
=
IsIDCamera
;
bitmapData
.
IsIDCamera
=
IsIDCamera
;
bitmapData
.
PlateW
=
PlateW
;
bitmapData
.
PlateW
=
PlateW
;
string
methodname
=
"NeoScan/ProcessBitmaps"
;
string
methodname
=
"NeoScan/ProcessBitmaps"
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论