Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS200
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2a28891c
由
刘韬
编写于
2024-06-23 13:12:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
添加相机日志, 优化设备报警
1 个父辈
27272119
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
120 行增加
和
45 行删除
AutoScanAndLabel/Properties/AssemblyInfo.cs
DeviceLibrary/AutoScanAndLabel/Common.cs
DeviceLibrary/AutoScanAndLabel/MainMachine _LabelProcess.cs
DeviceLibrary/AutoScanAndLabel/MainMachine _LedProcess.cs
DeviceLibrary/AutoScanAndLabel/MainMachine _MiddleProcess.cs
DeviceLibrary/AutoScanAndLabel/MainMachine.cs
DeviceLibrary/AutoScanAndLabel/RobotManage.cs
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/DeviceLibrary/CodeManager.cs
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
AutoScanAndLabel/Properties/AssemblyInfo.cs
查看文件 @
2a28891
...
@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
...
@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
// 与程序集关联的信息。
[assembly: AssemblyTitle("
自动扫码贴标机
")]
[assembly: AssemblyTitle("
NS200
")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("
上海挚锦科技有限公司
")]
[assembly: AssemblyCompany("
Neotel
")]
[assembly: AssemblyProduct("
自动扫码贴标机
")]
[assembly: AssemblyProduct("
NS200
")]
[assembly: AssemblyCopyright("Copyright © 202
1
")]
[assembly: AssemblyCopyright("Copyright © 202
4
")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyCulture("")]
...
...
DeviceLibrary/AutoScanAndLabel/Common.cs
查看文件 @
2a28891
...
@@ -943,7 +943,8 @@ namespace DeviceLibrary
...
@@ -943,7 +943,8 @@ namespace DeviceLibrary
public
enum
MsgLevel
public
enum
MsgLevel
{
{
warning
,
warning
,
info
info
,
alarm
}
}
public
class
IdWorker
public
class
IdWorker
{
{
...
...
DeviceLibrary/AutoScanAndLabel/MainMachine _LabelProcess.cs
查看文件 @
2a28891
...
@@ -43,24 +43,36 @@ namespace DeviceLibrary
...
@@ -43,24 +43,36 @@ namespace DeviceLibrary
break
;
break
;
case
MoveStep
.
Lbl_WaitPrint
:
case
MoveStep
.
Lbl_WaitPrint
:
string
version
=
ConfigHelper
.
Config
.
Get
(
"Hardwareversion"
,
"V2"
);
string
version
=
ConfigHelper
.
Config
.
Get
(
"Hardwareversion"
,
"V2"
);
bool
detectLabel
=
false
;
if
(
version
==
"V2"
)
if
(
version
==
"V2"
)
{
{
Thread
.
Sleep
(
1000
);
if
(
IOValue
(
IO_Type
.
HasPrinter
).
Equals
(
IO_VALUE
.
HIGH
))
if
(
IOValue
(
IO_Type
.
HasPrinter
).
Equals
(
IO_VALUE
.
HIGH
))
{
detectLabel
=
true
;
LabelMoveInfo
.
NextMoveStep
(
MoveStep
.
Lbl_Printted
);
Thread
.
Sleep
(
500
);
}
}
}
else
else
{
{
var
isPrinted
=
RobotManage
.
printerHelper
.
IsLabelOnPeeler
();
var
isPrinted
=
RobotManage
.
printerHelper
.
IsLabelOnPeeler
();
isPrinted
.
Wait
();
isPrinted
.
Wait
();
if
(
isPrinted
.
Result
.
Item1
)
if
(
isPrinted
.
Result
.
Item1
)
{
detectLabel
=
true
;
LabelMoveInfo
.
NextMoveStep
(
MoveStep
.
Lbl_Printted
);
}
Thread
.
Sleep
(
500
);
}
if
(
detectLabel
)
{
LabelMoveInfo
.
errlog
(
"标签打印完成"
);
LabelMoveInfo
.
NextMoveStep
(
MoveStep
.
Lbl_Printted
);
Thread
.
Sleep
(
500
);
}
//else if (LabelMoveInfo.IsTimeOut(15))
//{
// Msg.add("标签打印超时,请检查,取走标签后复位", MsgLevel.warning);
// LabelMoveInfo.errlog("标签打印超时");
// RobotManage.UserPause();
//}
else
{
Msg
.
add
(
"等待标签打印"
,
MsgLevel
.
info
);
LabelMoveInfo
.
log
(
"等待标签打印"
);
}
}
break
;
break
;
case
MoveStep
.
Lbl_Printted
:
case
MoveStep
.
Lbl_Printted
:
...
@@ -82,31 +94,26 @@ namespace DeviceLibrary
...
@@ -82,31 +94,26 @@ namespace DeviceLibrary
break
;
break
;
case
MoveStep
.
Lbl05
:
case
MoveStep
.
Lbl05
:
string
versions
=
ConfigHelper
.
Config
.
Get
(
"Hardwareversion"
,
"V2"
);
string
versions
=
ConfigHelper
.
Config
.
Get
(
"Hardwareversion"
,
"V2"
);
bool
IsLabelLeave
;
if
(
versions
==
"V2"
)
if
(
versions
==
"V2"
)
{
{
Thread
.
Sleep
(
1000
);
IsLabelLeave
=
IOValue
(
IO_Type
.
HasPrinter
).
Equals
(
IO_VALUE
.
LOW
);
if
(
IOValue
(
IO_Type
.
HasPrinter
).
Equals
(
IO_VALUE
.
LOW
))
{
LabelMoveInfo
.
NextMoveStep
(
MoveStep
.
Lbl06
);
}
else
{
Msg
.
add
(
crc
.
GetString
(
"Res0122.62c858d3"
,
"标签取起失败!"
),
MsgLevel
.
warning
);
}
}
}
else
else
{
{
var
ip
=
RobotManage
.
printerHelper
.
IsLabelOnPeeler
();
var
ip
=
RobotManage
.
printerHelper
.
IsLabelOnPeeler
();
ip
.
Wait
();
ip
.
Wait
();
var
r
=
ip
.
Result
;
IsLabelLeave
=
!
ip
.
Result
.
Item1
;
if
(
r
.
Item1
)
}
{
Msg
.
add
(
crc
.
GetString
(
"Res0122.62c858d3"
,
"标签取起失败!"
),
MsgLevel
.
warning
);
if
(
IsLabelLeave
)
}
{
else
LabelMoveInfo
.
NextMoveStep
(
MoveStep
.
Lbl06
);
{
LabelMoveInfo
.
log
(
"标签已经被取走"
);
LabelMoveInfo
.
NextMoveStep
(
MoveStep
.
Lbl06
);
}
}
else
{
Msg
.
add
(
crc
.
GetString
(
"Res0122.62c858d3"
,
"标签取起失败!"
),
MsgLevel
.
alarm
);
}
}
break
;
break
;
case
MoveStep
.
Lbl06
:
case
MoveStep
.
Lbl06
:
...
@@ -264,7 +271,7 @@ namespace DeviceLibrary
...
@@ -264,7 +271,7 @@ namespace DeviceLibrary
{
{
state
+=
crc
.
GetString
(
"Res0072"
,
"标签已打印,当前ReelID:"
)
+
LabelMoveInfo
.
MoveParam
.
WareCode
;
state
+=
crc
.
GetString
(
"Res0072"
,
"标签已打印,当前ReelID:"
)
+
LabelMoveInfo
.
MoveParam
.
WareCode
;
}
}
if
(
LabelMoveInfo
.
MoveStep
==
MoveStep
.
Lbl
01
)
if
(
LabelMoveInfo
.
MoveStep
==
MoveStep
.
Lbl
_WaitPrint
)
{
{
state
+=
crc
.
GetString
(
"Res0073"
,
"等待标签打印"
);
state
+=
crc
.
GetString
(
"Res0073"
,
"等待标签打印"
);
}
}
...
...
DeviceLibrary/AutoScanAndLabel/MainMachine _LedProcess.cs
查看文件 @
2a28891
...
@@ -42,7 +42,7 @@ namespace DeviceLibrary
...
@@ -42,7 +42,7 @@ namespace DeviceLibrary
// RunningLed.LedState = LedState.on;
// RunningLed.LedState = LedState.on;
//}
//}
if
(
alarmType
!=
AlarmType
.
None
)
if
(
alarmType
!=
AlarmType
.
None
||
IsAlarm
)
{
{
AlarmLed
.
LedState
=
LedState
.
on
;
AlarmLed
.
LedState
=
LedState
.
on
;
AlarmBuzzer
.
ON
();
AlarmBuzzer
.
ON
();
...
...
DeviceLibrary/AutoScanAndLabel/MainMachine _MiddleProcess.cs
查看文件 @
2a28891
...
@@ -71,11 +71,11 @@ namespace DeviceLibrary
...
@@ -71,11 +71,11 @@ namespace DeviceLibrary
{
{
if
(
MiddleMoveInfo
.
MoveParam
.
IsNg
)
if
(
MiddleMoveInfo
.
MoveParam
.
IsNg
)
{
{
Msg
.
add
(
crc
.
GetString
(
"Res0096"
,
"抓料失败请手动处理,请将料盘放入:NG箱,按右侧按钮继续"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0096"
,
"抓料失败请手动处理,请将料盘放入:NG箱,按右侧按钮继续"
),
MsgLevel
.
alarm
);
}
}
else
else
{
{
Msg
.
add
(
crc
.
GetString
(
"Res0097"
,
"抓料失败请手动处理,请将料盘放入: 左侧料串,按右侧按钮继续"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0097"
,
"抓料失败请手动处理,请将料盘放入: 左侧料串,按右侧按钮继续"
),
MsgLevel
.
alarm
);
}
}
if
(
IOValue
(
IO_Type
.
Right_BTN
).
Equals
(
IO_VALUE
.
HIGH
))
if
(
IOValue
(
IO_Type
.
Right_BTN
).
Equals
(
IO_VALUE
.
HIGH
))
...
@@ -186,7 +186,7 @@ namespace DeviceLibrary
...
@@ -186,7 +186,7 @@ namespace DeviceLibrary
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M09
);
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M09
);
MiddleMoveInfo
.
log
(
"等待夹爪放松"
);
MiddleMoveInfo
.
log
(
"等待夹爪放松"
);
}
}
Msg
.
add
(
crc
.
GetString
(
"Res0050"
,
"等待夹爪放松"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0050"
,
"等待夹爪放松"
),
MsgLevel
.
info
);
break
;
break
;
case
MoveStep
.
M10
:
case
MoveStep
.
M10
:
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M_ReturnToP1
);
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M_ReturnToP1
);
...
@@ -220,7 +220,7 @@ namespace DeviceLibrary
...
@@ -220,7 +220,7 @@ namespace DeviceLibrary
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M22
);
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M22
);
MiddleMoveInfo
.
log
(
"等待夹爪放松"
);
MiddleMoveInfo
.
log
(
"等待夹爪放松"
);
}
}
Msg
.
add
(
crc
.
GetString
(
"Res0050"
,
"等待夹爪放松"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0050"
,
"等待夹爪放松"
),
MsgLevel
.
info
);
break
;
break
;
case
MoveStep
.
M23
:
case
MoveStep
.
M23
:
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M_ReturnToP1
);
MiddleMoveInfo
.
NextMoveStep
(
MoveStep
.
M_ReturnToP1
);
...
...
DeviceLibrary/AutoScanAndLabel/MainMachine.cs
查看文件 @
2a28891
...
@@ -8,6 +8,7 @@ using System.Text;
...
@@ -8,6 +8,7 @@ using System.Text;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
using
static
System
.
Windows
.
Forms
.
VisualStyles
.
VisualStyleElement
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
...
@@ -67,6 +68,7 @@ namespace DeviceLibrary
...
@@ -67,6 +68,7 @@ namespace DeviceLibrary
/// 是否在急停中
/// 是否在急停中
/// </summary>
/// </summary>
public
bool
isInSuddenDown
=
false
;
public
bool
isInSuddenDown
=
false
;
public
bool
IsAlarm
=
false
;
public
ServerCommunication
ServerCM
;
public
ServerCommunication
ServerCM
;
...
@@ -197,8 +199,18 @@ namespace DeviceLibrary
...
@@ -197,8 +199,18 @@ namespace DeviceLibrary
}
}
finally
finally
{
{
ProcessMsgEvent
?.
Invoke
(
Msg
.
get
());
var
m
=
Msg
.
get
();
ProcessMsgEvent
?.
Invoke
(
m
);
ServerCM
.
ProcessMsg
(
m
);
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if
(
m
.
Find
((
aa
)
=>
aa
.
msgLevel
==
MsgLevel
.
alarm
)
==
null
)
{
IsAlarm
=
false
;
}
else
{
IsAlarm
=
true
;
}
Msg
.
clear
();
Msg
.
clear
();
}
}
}
}
...
@@ -354,7 +366,7 @@ namespace DeviceLibrary
...
@@ -354,7 +366,7 @@ namespace DeviceLibrary
}
}
if
(
IOValue
(
IO_Type
.
HasNgBox
).
Equals
(
IO_VALUE
.
LOW
))
if
(
IOValue
(
IO_Type
.
HasNgBox
).
Equals
(
IO_VALUE
.
LOW
))
{
{
Msg
.
add
(
crc
.
GetString
(
"Res0062"
,
"没有检测到NG料箱"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0062"
,
"没有检测到NG料箱"
),
MsgLevel
.
alarm
);
ok
=
false
;
ok
=
false
;
}
}
//if (IOValue(IO_Type.HasPrinter).Equals(IO_VALUE.LOW))
//if (IOValue(IO_Type.HasPrinter).Equals(IO_VALUE.LOW))
...
@@ -440,7 +452,7 @@ namespace DeviceLibrary
...
@@ -440,7 +452,7 @@ namespace DeviceLibrary
if
(
span
.
TotalSeconds
>
RobotManage
.
Config
.
AirCheckSeconds
)
if
(
span
.
TotalSeconds
>
RobotManage
.
Config
.
AirCheckSeconds
)
{
{
ok
=
false
;
ok
=
false
;
Msg
.
add
(
crc
.
GetString
(
"Res0068"
,
"气压不足"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0068"
,
"气压不足"
),
MsgLevel
.
alarm
);
}
}
}
}
else
else
...
@@ -457,7 +469,7 @@ namespace DeviceLibrary
...
@@ -457,7 +469,7 @@ namespace DeviceLibrary
{
{
if
(
AxisManager
.
GetAlarmStatus
(
configMoveAxis
.
DeviceName
,
configMoveAxis
.
GetAxisValue
())
==
1
)
if
(
AxisManager
.
GetAlarmStatus
(
configMoveAxis
.
DeviceName
,
configMoveAxis
.
GetAxisValue
())
==
1
)
{
{
Msg
.
add
(
$
"{configMoveAxis.Explain}:运动报警"
,
MsgLevel
.
warning
);
Msg
.
add
(
$
"{configMoveAxis.Explain}:运动报警"
,
MsgLevel
.
alarm
);
ok
=
false
;
ok
=
false
;
}
}
}
}
...
...
DeviceLibrary/AutoScanAndLabel/RobotManage.cs
查看文件 @
2a28891
...
@@ -38,6 +38,8 @@ namespace DeviceLibrary
...
@@ -38,6 +38,8 @@ namespace DeviceLibrary
Config
=
(
Robot_Config
)
CSVConfigReader
.
LoadConfig
(
Config
);
Config
=
(
Robot_Config
)
CSVConfigReader
.
LoadConfig
(
Config
);
CodeManager
.
LoadConfig
();
CodeManager
.
LoadConfig
();
IDHIKCamera
.
LibLogUtil
.
LogEvent
+=
LibLogUtil_LogEvent
;
clampTool
=
new
ClampTool
();
clampTool
=
new
ClampTool
();
if
(!
clampTool
.
Open
())
if
(!
clampTool
.
Open
())
{
{
...
@@ -70,6 +72,19 @@ namespace DeviceLibrary
...
@@ -70,6 +72,19 @@ namespace DeviceLibrary
LoadFinishEvent
?.
Invoke
(
false
,
ex
.
Message
);
LoadFinishEvent
?.
Invoke
(
false
,
ex
.
Message
);
}
}
}
}
private
static
void
LibLogUtil_LogEvent
(
IDHIKCamera
.
LibLogEventArg
libLogEventArg
)
{
if
(
libLogEventArg
.
Level
<=
IDHIKCamera
.
LibLogLevel
.
Warning
)
{
LogUtil
.
info
(
libLogEventArg
.
Msg
);
}
else
{
LogUtil
.
error
(
libLogEventArg
.
Msg
);
}
}
public
static
void
LoadDebug
()
public
static
void
LoadDebug
()
{
{
LoadFinishEvent
?.
Invoke
(
true
,
crc
.
GetString
(
"Res0190"
,
"打开配置模式"
));
LoadFinishEvent
?.
Invoke
(
true
,
crc
.
GetString
(
"Res0190"
,
"打开配置模式"
));
...
...
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
2a28891
...
@@ -49,6 +49,10 @@
...
@@ -49,6 +49,10 @@
<Reference Include="HuichuanLibrary">
<Reference Include="HuichuanLibrary">
<HintPath>..\dll\HuichuanLibrary.dll</HintPath>
<HintPath>..\dll\HuichuanLibrary.dll</HintPath>
</Reference>
</Reference>
<Reference Include="IDHIKCamera, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\IDHIKCamera.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
</Reference>
...
...
DeviceLibrary/DeviceLibrary/CodeManager.cs
查看文件 @
2a28891
...
@@ -168,13 +168,19 @@ namespace DeviceLibrary
...
@@ -168,13 +168,19 @@ namespace DeviceLibrary
Bitmap
bmp
=
null
;
Bitmap
bmp
=
null
;
try
try
{
{
int
retry
=
0
;
bool
nohalcon
=
true
;
bool
nohalcon
=
true
;
retry
:
_
=
Camera
.
_cam
.
CaptureOnImage
(
cameraName
,
out
bmp
,
out
List
<
CodeInfo
>
codes
,
nohalcon
);
_
=
Camera
.
_cam
.
CaptureOnImage
(
cameraName
,
out
bmp
,
out
List
<
CodeInfo
>
codes
,
nohalcon
);
if
(
bmp
==
null
)
if
(
bmp
==
null
)
{
{
LogUtil
.
error
(
" 【"
+
cameraName
+
"】取图片失败["
+
Camera
.
_cam
.
ErrInfo
+
"],关闭相机"
);
LogUtil
.
error
(
" 【"
+
cameraName
+
"】取图片失败["
+
Camera
.
_cam
.
ErrInfo
+
"],关闭相机,重试:"
+
retry
);
LoadCamera
(
true
);
Camera
.
_cam
.
CloseAll
();
continue
;
//LoadCamera(true);
retry
++;
if
(
retry
>
2
)
continue
;
goto
retry
;
}
}
bitmapfilename
=
SaveImageToFile
(
"Ns200"
,
cameraName
,
bmp
);
bitmapfilename
=
SaveImageToFile
(
"Ns200"
,
cameraName
,
bmp
);
WebResultCode
webResult
=
null
;
WebResultCode
webResult
=
null
;
...
...
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
查看文件 @
2a28891
...
@@ -58,6 +58,36 @@ namespace DeviceLibrary
...
@@ -58,6 +58,36 @@ namespace DeviceLibrary
return
;
return
;
SendLineStatus
();
SendLineStatus
();
}
}
public
void
ProcessMsg
(
List
<
Msg
>
msg
)
{
if
(
msg
==
null
)
return
;
WarnMsg
=
string
.
Join
(
"\r\n"
,
msg
.
Select
(
x
=>
{
if
(
x
.
msgLevel
==
MsgLevel
.
warning
||
x
.
msgLevel
==
MsgLevel
.
alarm
)
{
return
GetMsgPrefix
(
x
.
msgLevel
)
+
x
.
msgtxt
;
}
return
null
;
}
).
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
)));
}
string
GetMsgPrefix
(
MsgLevel
msgLevel
)
{
switch
(
msgLevel
)
{
case
MsgLevel
.
info
:
return
"I="
;
case
MsgLevel
.
warning
:
return
"W="
;
case
MsgLevel
.
alarm
:
return
"A="
;
}
return
""
;
}
public
void
StartConnectServer
()
public
void
StartConnectServer
()
{
{
serverConnectTimer
.
Enabled
=
true
;
serverConnectTimer
.
Enabled
=
true
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论