UCJoint.cs
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace JAKA
{
public partial class UCJoint : UserControl
{
public UCJoint()
{
InitializeComponent();
}
/// <summary>
/// 设置数据
/// </summary>
/// <param name="name">关节名称</param>
/// <param name="num">关节序列号</param>
/// <param name="enable">关节使能</param>
/// <param name="error">关节错误</param>
/// <param name="collision">关节碰撞</param>
/// <param name="position">关节位置</param>
/// <param name="speed">关节速度</param>
/// <param name="volt">关节伺服电压</param>
/// <param name="current">关节伺服电流</param>
/// <param name="force">关节力矩</param>
/// <param name="tempture">关节温度</param>
public void Set(string name, int num, int enable,int error,int collision,
float position,float speed,int volt,float current,float force,int tempture)
{
this.Invoke(new Action(() => {
lblName.Text = name;
lblSerial.Text = $"错误码:{num}";
if (enable == 1)
{
lblEnable.Text = "使能";
lblEnable.BackColor = Color.GreenYellow;
}
else
{
lblEnable.Text = "使能";
lblEnable.BackColor = Color.Red;
}
if (error == 1)
{
lblErrorState.Text = "错误";
lblErrorState.BackColor = Color.Red;
}
else
{
lblErrorState.Text = "错误";
lblErrorState.BackColor = Color.GreenYellow;
}
if (collision == 1)
{
lblCollision.Text = "碰撞";
lblCollision.BackColor = Color.Red;
}
else
{
lblCollision.Text = "碰撞";
lblCollision.BackColor = Color.GreenYellow;
}
lblPosition.Text = $"位置:{position.ToString("f3")}°";
lblSpeed.Text = $"速度:{speed.ToString("f3")}°/s";
lblVolt.Text = $"电压:{volt}V";
lblCurrent.Text = $"电流:{current.ToString("f3")}A";
lblForce.Text = $"力矩:{force.ToString("f3")}Nm";
lblTempture.Text = $"温度:{tempture}℃";
}));
}
}
}