AxisJogControl.cs
4.3 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System;
using System.Drawing;
using System.Windows.Forms;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using DeviceLib;
namespace OnlineStore.TinPasteStore.useControl
{
public partial class AxisJogControl : UserControl
{
public AxisJogControl()
{
InitializeComponent();
}
public void SetParam(string conText, string addText, string delText, ConfigMoveAxis moveAxis)
{
this.ConText = conText;
this.AddText = addText;
this.DelText = delText;
this.AxisInfo = moveAxis;
this.SpeedValue = 2;
}
public string ConText
{
set { this.label1.Text = value; }
get { return this.label1.Text; }
}
public string AddText
{
set { this.btnMove.Text = value; }
get { return this.btnMove.Text; }
}
public string DelText
{
set { this.btnMovej.Text = value; }
get { return this.btnMovej.Text; }
}
public ConfigMoveAxis AxisInfo { get; set; }
private int speedValue = 2;
public int SpeedValue
{
set
{
speedValue = value;
if (AxisInfo != null)
{
this.txtSpeed.Text = (AxisInfo.TargetSpeed * speedValue / 10).ToString();
}
}
get { return speedValue; }
}
private void btnMCopy_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(txtPosition.Text, true);
}
/// <summary>
/// 判断进出轴是否在P1点
/// </summary>
private bool InOutIsIsP1()
{
return true;
}
private void AxisMove(int speed)
{
LogUtil.debug("点动:[" + AxisInfo.DeviceName + "_" + AxisInfo.GetAxisValue() + "],speed=" + speed);
ACServerManager.SpeedMove(AxisInfo.DeviceName, AxisInfo.GetAxisValue(), speed);
}
public void UpdatePosition()
{
int position = ACServerManager.GetTargetPosition(AxisInfo.DeviceName, AxisInfo.GetAxisValue());
if (!txtPosition.Text.Equals(position.ToString()))
{
txtPosition.Text = position.ToString();
}
}
private void btnMove_MouseDown(object sender, MouseEventArgs e)
{
if (!InOutIsIsP1())
{
return;
}
if (btnMove.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtSpeed);
if (speed <= 0)
{
MessageBox.Show("提示", "请先输入正确的速度");
return;
}
btnMove.BackColor = Color.Green;
AxisMove(speed);
}
}
private void btnMove_MouseUp(object sender, MouseEventArgs e)
{
if (btnMove.BackColor == Color.Green)
{
btnMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(AxisInfo.DeviceName, AxisInfo.GetAxisValue());
UpdatePosition();
}
}
private void btnMovej_MouseDown(object sender, MouseEventArgs e)
{
if (!InOutIsIsP1())
{
return;
}
if (btnMovej.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtSpeed);
if (speed <= 0)
{
MessageBox.Show("提示", "请先输入正确的速度");
return;
}
btnMovej.BackColor = Color.Green;
AxisMove(- speed);
}
}
private void btnMovej_MouseUp(object sender, MouseEventArgs e)
{
if (btnMovej.BackColor == Color.Green)
{
btnMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(AxisInfo.DeviceName, AxisInfo.GetAxisValue());
UpdatePosition();
}
}
}
}