Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
HuichuanLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 4eb33448
由
LN
编写于
2023-02-24 10:23:12 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
负载率功能修改
1 个父辈
11c81d5d
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
123 行增加
和
7 行删除
HuichuanLibrary/FrmHuiChuanTest.Designer.cs
HuichuanLibrary/FrmHuiChuanTest.cs
HuichuanLibrary/HCBoardManager_Axis.cs
HuichuanLibrary/FrmHuiChuanTest.Designer.cs
查看文件 @
4eb3344
此文件的差异被折叠,
点击展开。
HuichuanLibrary/FrmHuiChuanTest.cs
查看文件 @
4eb3344
...
@@ -38,7 +38,7 @@ namespace HuichuanLibrary
...
@@ -38,7 +38,7 @@ namespace HuichuanLibrary
DILabelList
.
Add
(
lblDI13
);
DILabelList
.
Add
(
lblDI13
);
DILabelList
.
Add
(
lblDI14
);
DILabelList
.
Add
(
lblDI14
);
DILabelList
.
Add
(
lblDI15
);
DILabelList
.
Add
(
lblDI15
);
for
(
int
i
=
0
;
i
<
DILabelList
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
DILabelList
.
Count
;
i
++)
{
{
DILabelList
[
i
].
Text
=
"DI_"
+
i
;
DILabelList
[
i
].
Text
=
"DI_"
+
i
;
}
}
...
@@ -87,7 +87,7 @@ namespace HuichuanLibrary
...
@@ -87,7 +87,7 @@ namespace HuichuanLibrary
FormStatus
(
false
);
FormStatus
(
false
);
timerIO
.
Start
();
timerIO
.
Start
();
timerMain
.
Start
();
timerMain
.
Start
();
lblAdSts
.
Text
=
"状态说明:\r\n"
+
lblAdSts
.
Text
=
"状态说明:\r\n"
+
"Bit0 ,负载电压故障,0:正常,1:未接入外部电源\r\n"
+
"Bit0 ,负载电压故障,0:正常,1:未接入外部电源\r\n"
+
"Bit1 ,模拟芯片连接错误,0:正常,1:数字版与模拟板通讯错误\r\n"
+
"Bit1 ,模拟芯片连接错误,0:正常,1:数字版与模拟板通讯错误\r\n"
+
"Bit2:通道故障\r\n"
+
"Bit2:通道故障\r\n"
+
...
@@ -99,7 +99,77 @@ namespace HuichuanLibrary
...
@@ -99,7 +99,77 @@ namespace HuichuanLibrary
HCLogUtil
.
logBox
=
richTextBox1
;
HCLogUtil
.
logBox
=
richTextBox1
;
axisTimer
=
new
System
.
Timers
.
Timer
();
axisTimer
.
Interval
=
200
;
axisTimer
.
AutoReset
=
true
;
axisTimer
.
Enabled
=
false
;
axisTimer
.
Elapsed
+=
AxisTimer_Elapsed
;
txtMaxFuzai
.
Text
=
MaxFuZai
.
ToString
();
groupBox12
.
Text
=
"最大负载率="
+
MaxFuZai
;
}
private
void
AxisTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
//200毫秒检测一次运动轴,如果负载率超过指定值,直接停止
//如果停止运动,从集合移除;
List
<
short
>
axiss
=
new
List
<
short
>(
moveAxisNoList
);
foreach
(
short
axisNo
in
axiss
)
{
AxisSts
sts
=
HCBoardManager
.
GetAxisSts
(
axisNo
);
if
(
sts
.
ServoOn
<=
0
)
{
HCLogUtil
.
error
(
$
"AxisTimer_Elapsed 轴号{axisNo} 伺服已关闭,removeMoveAxis"
);
removeMoveAxis
(
axisNo
);
}
//判断是否再运动中
if
(
sts
.
BUSY
<=
0
)
{
HCLogUtil
.
error
(
$
"AxisTimer_Elapsed 轴号{axisNo} 已停止运动,removeMoveAxis"
);
removeMoveAxis
(
axisNo
);
}
float
currFuzai
=
HCBoardManager
.
GetAxisLoadRate
(
axisNo
);
if
(
currFuzai
>
MaxFuZai
)
{
HCLogUtil
.
error
(
$
"AxisTimer_Elapsed 轴号{axisNo} 当前负载率{currFuzai}大于最大负载率{MaxFuZai},停止运动,removeMoveAxis"
);
HCBoardManager
.
AxisStop
(
axisNo
);
removeMoveAxis
(
axisNo
);
}
}
}
private
void
removeMoveAxis
(
short
axisNo
)
{
try
{
HCLogUtil
.
info
(
$
"removeMoveAxis{axisNo}"
);
moveAxisNoList
.
Remove
(
axisNo
);
}
catch
(
Exception
ex
)
{
}
}
private
void
addMoveAxis
(
short
axisNo
)
{
try
{
if
(!
moveAxisNoList
.
Contains
(
axisNo
))
{
HCLogUtil
.
info
(
$
"addMoveAxis{axisNo}"
);
moveAxisNoList
.
Add
(
axisNo
);
}
}
}
catch
(
Exception
ex
)
{
}
}
private
List
<
short
>
moveAxisNoList
=
new
List
<
short
>();
private
System
.
Timers
.
Timer
axisTimer
;
private
float
MaxFuZai
=
10
;
private
void
btnInitBoard_Click
(
object
sender
,
EventArgs
e
)
private
void
btnInitBoard_Click
(
object
sender
,
EventArgs
e
)
{
{
bool
result
=
HCBoardManager
.
OpenCard
(
1
);
bool
result
=
HCBoardManager
.
OpenCard
(
1
);
...
@@ -242,6 +312,12 @@ namespace HuichuanLibrary
...
@@ -242,6 +312,12 @@ namespace HuichuanLibrary
double
ptpPos
=
Convert
.
ToDouble
(
txtPtpPos
.
Text
);
double
ptpPos
=
Convert
.
ToDouble
(
txtPtpPos
.
Text
);
HCBoardManager
.
AbsMove
(
axisNo
,
ptpPos
,
ptpVel
,
ptpAcc
,
ptpDec
);
HCBoardManager
.
AbsMove
(
axisNo
,
ptpPos
,
ptpVel
,
ptpAcc
,
ptpDec
);
addMoveAxis
(
axisNo
);
if
(!
axisTimer
.
Enabled
)
{
HCLogUtil
.
info
(
"启动axisTimer"
);
axisTimer
.
Start
();
}
}
}
private
void
btnRelMove_Click
(
object
sender
,
EventArgs
e
)
private
void
btnRelMove_Click
(
object
sender
,
EventArgs
e
)
...
@@ -255,6 +331,12 @@ namespace HuichuanLibrary
...
@@ -255,6 +331,12 @@ namespace HuichuanLibrary
double
ptpPos
=
Convert
.
ToDouble
(
txtPtpPos
.
Text
);
double
ptpPos
=
Convert
.
ToDouble
(
txtPtpPos
.
Text
);
HCBoardManager
.
RelMove
(
axisNo
,
ptpPos
,
ptpVel
,
ptpAcc
,
ptpDec
);
HCBoardManager
.
RelMove
(
axisNo
,
ptpPos
,
ptpVel
,
ptpAcc
,
ptpDec
);
addMoveAxis
(
axisNo
);
if
(!
axisTimer
.
Enabled
)
{
HCLogUtil
.
info
(
"启动axisTimer"
);
axisTimer
.
Start
();
}
}
}
private
void
btnAxisStop_Click
(
object
sender
,
EventArgs
e
)
private
void
btnAxisStop_Click
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -298,8 +380,15 @@ namespace HuichuanLibrary
...
@@ -298,8 +380,15 @@ namespace HuichuanLibrary
{
{
if
(
value
.
Equals
(
1
))
if
(
value
.
Equals
(
1
))
{
{
if
(
lbl
.
Text
.
Equals
(
"ALM"
))
{
lbl
.
BackColor
=
Color
.
Red
;
}
else
{
lbl
.
BackColor
=
Color
.
Lime
;
lbl
.
BackColor
=
Color
.
Lime
;
}
}
}
else
if
(
value
.
Equals
(
0
))
else
if
(
value
.
Equals
(
0
))
{
{
lbl
.
BackColor
=
Color
.
LightGray
;
lbl
.
BackColor
=
Color
.
LightGray
;
...
@@ -674,7 +763,7 @@ namespace HuichuanLibrary
...
@@ -674,7 +763,7 @@ namespace HuichuanLibrary
private
void
btnSearch_Click
(
object
sender
,
EventArgs
e
)
private
void
btnSearch_Click
(
object
sender
,
EventArgs
e
)
{
{
short
axisNo
=
GetAxisNo
();
short
axisNo
=
GetAxisNo
();
//
txtFuzai.Text = HCBoardManager.GetAxisLoadRate(axisNo).ToString();
txtFuzai
.
Text
=
HCBoardManager
.
GetAxisLoadRate
(
axisNo
).
ToString
();
}
}
private
void
btnSearchNj_Click
(
object
sender
,
EventArgs
e
)
private
void
btnSearchNj_Click
(
object
sender
,
EventArgs
e
)
...
@@ -682,5 +771,30 @@ namespace HuichuanLibrary
...
@@ -682,5 +771,30 @@ namespace HuichuanLibrary
short
axisNo
=
GetAxisNo
();
short
axisNo
=
GetAxisNo
();
txtNuiju
.
Text
=
HCBoardManager
.
GetAxActTorq
(
axisNo
).
ToString
();
txtNuiju
.
Text
=
HCBoardManager
.
GetAxActTorq
(
axisNo
).
ToString
();
}
}
private
void
btnSaveMaxFuzai_Click
(
object
sender
,
EventArgs
e
)
{
float
v
=
0
;
try
{
v
=
(
float
)
Convert
.
ToDecimal
(
txtMaxFuzai
.
Text
);
}
catch
(
Exception
ex
)
{
}
if
(
v
>
0
)
{
MaxFuZai
=
v
;
MessageBox
.
Show
(
"已设置最大负载率="
+
MaxFuZai
);
}
else
{
MessageBox
.
Show
(
"设置失败"
);
}
groupBox12
.
Text
=
"最大负载率="
+
MaxFuZai
;
}
}
}
}
}
HuichuanLibrary/HCBoardManager_Axis.cs
查看文件 @
4eb3344
...
@@ -905,7 +905,7 @@ namespace HuichuanLibrary
...
@@ -905,7 +905,7 @@ namespace HuichuanLibrary
/// </summary>
/// </summary>
/// <param name="axisNo"></param>
/// <param name="axisNo"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
GetAxisLoadRate
(
short
axisNo
)
public
static
float
GetAxisLoadRate
(
short
axisNo
)
{
{
short
pPhyStation_Id
=
0
;
short
pPhyStation_Id
=
0
;
short
pPhySlot_id
=
0
;
short
pPhySlot_id
=
0
;
...
@@ -913,6 +913,7 @@ namespace HuichuanLibrary
...
@@ -913,6 +913,7 @@ namespace HuichuanLibrary
ushort
index
=
0x200b
;
ushort
index
=
0x200b
;
ushort
subindex
=
13
;
ushort
subindex
=
13
;
//扭矩 3;
uint
targetsize
=
2
;
uint
targetsize
=
2
;
int
datasize
=
2
;
int
datasize
=
2
;
uint
resultSize
=
0
;
uint
resultSize
=
0
;
...
@@ -931,14 +932,15 @@ namespace HuichuanLibrary
...
@@ -931,14 +932,15 @@ namespace HuichuanLibrary
}
}
int
value
=
Convert
.
ToInt32
(
str
.
Trim
().
Replace
(
" "
,
""
),
16
);
int
value
=
Convert
.
ToInt32
(
str
.
Trim
().
Replace
(
" "
,
""
),
16
);
HCLogUtil
.
info
(
$
"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize}, str={str},value={value}"
);
float
v
=
(
float
)
value
/
2560
;
return
value
.
ToString
();
HCLogUtil
.
info
(
$
"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize}, str={str},value={value},v={v}"
);
return
v
;
}
}
else
else
{
{
HCLogUtil
.
info
(
$
"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize},"
);
HCLogUtil
.
info
(
$
"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize},"
);
}
}
return
""
;
return
0
;
}
}
/// <summary>
/// <summary>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论