Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS200
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 6aec9051
由
刘韬
编写于
2026-02-12 15:58:30 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化料串测高
1 个父辈
b833e3a7
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
31 行删除
DeviceLibrary/AutoScanAndLabel/AxisBean.cs
DeviceLibrary/AutoScanAndLabel/AxisBean.cs
查看文件 @
6aec905
...
@@ -3,10 +3,7 @@ using OnlineStore.Common;
...
@@ -3,10 +3,7 @@ using OnlineStore.Common;
using
OnlineStore.LoadCSVLibrary
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
...
@@ -22,7 +19,7 @@ namespace DeviceLibrary
...
@@ -22,7 +19,7 @@ namespace DeviceLibrary
/// <summary>
/// <summary>
/// 干涉检测回调 from, to
/// 干涉检测回调 from, to
/// </summary>
/// </summary>
public
event
Func
<
int
,
int
,(
bool
,
string
)>
interference
;
public
event
Func
<
int
,
int
,
(
bool
,
string
)>
interference
;
public
string
AxisName
;
public
string
AxisName
;
public
AxisBean
(
ConfigMoveAxis
axisConfig
,
string
deviceName
)
public
AxisBean
(
ConfigMoveAxis
axisConfig
,
string
deviceName
)
{
{
...
@@ -126,7 +123,7 @@ namespace DeviceLibrary
...
@@ -126,7 +123,7 @@ namespace DeviceLibrary
else
else
{
{
AxisManager
.
ServoOff
(
portName
,
slvAddr
);
AxisManager
.
ServoOff
(
portName
,
slvAddr
);
msg
=
crc
.
GetString
(
"Res0117.2bf5c941"
,
"打开轴"
)
+
Config
.
Explain
+
crc
.
GetString
(
"Res0118.33d2a704"
,
"失败 "
);
msg
=
crc
.
GetString
(
"Res0117.2bf5c941"
,
"打开轴"
)
+
Config
.
Explain
+
crc
.
GetString
(
"Res0118.33d2a704"
,
"失败 "
);
LogUtil
.
info
(
AxisName
+
msg
);
LogUtil
.
info
(
AxisName
+
msg
);
return
false
;
return
false
;
}
}
...
@@ -192,7 +189,7 @@ namespace DeviceLibrary
...
@@ -192,7 +189,7 @@ namespace DeviceLibrary
int
isAlarm
=
AxisManager
.
GetAlarmStatus
(
deviceName
,
axisNo
);
int
isAlarm
=
AxisManager
.
GetAlarmStatus
(
deviceName
,
axisNo
);
if
(
isAlarm
.
Equals
(
1
))
if
(
isAlarm
.
Equals
(
1
))
{
{
clearMsg
=
crc
.
GetString
(
"Res0119.cbd5d752"
,
"清理报警,"
);
clearMsg
=
crc
.
GetString
(
"Res0119.cbd5d752"
,
"清理报警,"
);
AxisManager
.
AlarmClear
(
deviceName
,
axisNo
);
AxisManager
.
AlarmClear
(
deviceName
,
axisNo
);
Thread
.
Sleep
(
200
);
Thread
.
Sleep
(
200
);
AxisManager
.
ServoOn
(
deviceName
,
axisNo
);
AxisManager
.
ServoOn
(
deviceName
,
axisNo
);
...
@@ -204,7 +201,7 @@ namespace DeviceLibrary
...
@@ -204,7 +201,7 @@ namespace DeviceLibrary
AxisManager
.
SuddenStop
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
AxisManager
.
SuddenStop
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
Thread
.
Sleep
(
100
);
Thread
.
Sleep
(
100
);
}
}
LogUtil
.
error
(
$
"{
MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr}目标位置{targetPosition}当前位置{outCount},误差过大,{clearMsg}重新开始运动,剩余{MoveInfo.CanWhileCount}次"
);
LogUtil
.
error
(
$
"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr}目标位置{targetPosition}当前位置{outCount},误差过大,{clearMsg}重新开始运动,剩余{MoveInfo.CanWhileCount}次"
);
AxisManager
.
AbsMove
(
axis
.
DeviceName
,
axis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
,
targetSpeed
*
4
,
targetSpeed
*
4
);
// , axis.AddSpeed, axis.DelSpeed);
AxisManager
.
AbsMove
(
axis
.
DeviceName
,
axis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
,
targetSpeed
*
4
,
targetSpeed
*
4
);
// , axis.AddSpeed, axis.DelSpeed);
MoveInfo
.
CanWhileCount
--;
MoveInfo
.
CanWhileCount
--;
Thread
.
Sleep
(
200
);
Thread
.
Sleep
(
200
);
...
@@ -239,7 +236,7 @@ namespace DeviceLibrary
...
@@ -239,7 +236,7 @@ namespace DeviceLibrary
}
}
else
else
{
{
msg
=
MoveInfo
.
Name
+
" "
+
MoveInfo
.
MoveStep
+
axis
.
DisplayStr
+
crc
.
GetString
(
"Res0120.405c5a9e"
,
",收到原点完成信号,当前位置["
)
+
outCount
+
crc
.
GetString
(
"Res0121.6658614e"
,
"],误差过大,需要报警"
);
msg
=
MoveInfo
.
Name
+
" "
+
MoveInfo
.
MoveStep
+
axis
.
DisplayStr
+
crc
.
GetString
(
"Res0120.405c5a9e"
,
",收到原点完成信号,当前位置["
)
+
outCount
+
crc
.
GetString
(
"Res0121.6658614e"
,
"],误差过大,需要报警"
);
LogUtil
.
error
(
msg
);
LogUtil
.
error
(
msg
);
}
}
}
}
...
@@ -292,62 +289,76 @@ namespace DeviceLibrary
...
@@ -292,62 +289,76 @@ namespace DeviceLibrary
/// 判断轴运动是否安全
/// 判断轴运动是否安全
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
bool
IsSafe
(
int
Targetpos
,
out
string
msg
){
public
bool
IsSafe
(
int
Targetpos
,
out
string
msg
)
{
msg
=
""
;
msg
=
""
;
if
(
interference
==
null
)
if
(
interference
==
null
)
return
true
;
return
true
;
bool
result
;
bool
result
;
(
result
,
msg
)
=
interference
.
Invoke
(
GetAclPosition
(),
Targetpos
);
(
result
,
msg
)
=
interference
.
Invoke
(
GetAclPosition
(),
Targetpos
);
return
!
result
;
return
!
result
;
}
}
#
region
匀速上升处理
#
region
匀速上升处理
private
System
.
Timers
.
Timer
axisCheckTimer
=
null
;
//
private System.Timers.Timer axisCheckTimer = null;
internal
string
TargetIoType
=
""
;
internal
string
TargetIoType
;
internal
IO_VALUE
TargetIoValue
=
IO_VALUE
.
HIGH
;
internal
IO_VALUE
TargetIoValue
=
IO_VALUE
.
HIGH
;
public
bool
BatchAxisStartCheck
(
string
targetIo
,
IO_VALUE
value
=
IO_VALUE
.
HIGH
)
public
bool
BatchAxisStartCheck
(
string
targetIo
,
IO_VALUE
value
=
IO_VALUE
.
HIGH
)
{
{
if
(
String
.
IsNullOrEmpty
(
targetIo
))
{
targetIo
=
""
;
}
if
(
axisCheckTimer
==
null
)
{
axisCheckTimer
=
new
System
.
Timers
.
Timer
();
axisCheckTimer
.
AutoReset
=
true
;
axisCheckTimer
.
Interval
+=
15
;
axisCheckTimer
.
Elapsed
+=
CheckTimer_Elapsed
;
axisCheckTimer
.
Enabled
=
false
;
}
TargetIoValue
=
value
;
TargetIoValue
=
value
;
TargetIoType
=
targetIo
;
TargetIoType
=
targetIo
;
axisCheckTimer
.
Start
();
IsInProcess
=
true
;
new
Thread
(()
=>
{
CheckTimer_Elapsed
();
})
{
IsBackground
=
true
}
// 按需设成后台线程
.
Start
();
return
true
;
return
true
;
}
}
public
bool
StopAxisCheckMove
()
public
bool
StopAxisCheckMove
()
{
{
if
(!(
axisCheckTimer
==
null
))
IsInProcess
=
false
;
{
axisCheckTimer
.
Stop
();
}
return
true
;
return
true
;
}
}
private
void
CheckTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
private
bool
IsInProcess
=
false
;
private
void
CheckTimer_Elapsed
()
{
{
while
(
IsInProcess
)
{
Thread
.
Sleep
(
1
);
try
try
{
{
if
(
TargetIoValue
==
IO_VALUE
.
HIGH
)
{
if
(
IOManager
.
IOValue
(
TargetIoType
).
Equals
(
TargetIoValue
))
if
(
IOManager
.
IOValue
(
TargetIoType
).
Equals
(
TargetIoValue
))
{
{
SuddenStop
();
SuddenStop
();
StopAxisCheckMove
();
LogUtil
.
info
(
AxisName
+
"上料轴,检测到 "
+
TargetIoType
+
"="
+
TargetIoValue
+
",停止运动"
);
LogUtil
.
info
(
AxisName
+
"上料轴,检测到 "
+
TargetIoType
+
"="
+
TargetIoValue
+
",停止运动"
);
StopAxisCheckMove
();
break
;
}
}
}
else
{
if
(
IOManager
.
IOValue
(
TargetIoType
).
Equals
(
TargetIoValue
))
{
SuddenStop
();
LogUtil
.
info
(
AxisName
+
"上料轴,检测到 ="
+
TargetIoValue
+
",停止运动"
);
StopAxisCheckMove
();
break
;
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
"CheckTimer_Elapsed出错:"
,
ex
);
LogUtil
.
error
(
"CheckTimer_Elapsed出错:"
,
ex
);
IsInProcess
=
false
;
}
}
}
}
}
#
endregion
#
endregion
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论