AxisControl.cs
3.6 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
using DeviceLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TheMachine
{
public partial class AxisControl : UserControl
{
public AxisControl()
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
if (DesignMode)
return;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
RobotManage_LoadFinishEvent(true, "");
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
if (this.InvokeRequired)
{
this.Invoke((EventHandler)delegate
{
RobotManage_LoadFinishEvent(state, msg);
});
return;
}
if (!state)
return;
axisMoveControl1.LoadData(AxisBean.List);
configControl1.Config = RobotManage.Config;
LogUtil.info("伺服面板加载完成.");
}
private void AxisControl_Load(object sender, EventArgs e)
{
}
volatile bool roateloop = false;
private void button2_Click(object sender, EventArgs e)
{
Task.Run(() => {
var p1 = RobotManage.mainMachine.Config.UpDown_P1;
var p1_speed = RobotManage.mainMachine.Config.UpDown_P1_speed;
var axis = RobotManage.mainMachine.UpDown_Axis;
roateloop = true;
while (roateloop)
{
axis.AbsMove(null, p1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
if (!roateloop)
break;
Task.Delay(500).Wait();
axis.AbsMove(null, 1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
Task.Delay(500).Wait();
}
});
Task.Run(() => {
var p1 = RobotManage.mainMachine.Config.Middle_P1;
var p1_speed = RobotManage.mainMachine.Config.Middle_P1_speed;
var axis = RobotManage.mainMachine.Middle_Axis;
roateloop = true;
while (roateloop)
{
axis.AbsMove(null, p1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
if (!roateloop)
break;
Task.Delay(500).Wait();
axis.AbsMove(null, 1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
Task.Delay(500).Wait();
}
});
}
private void button3_Click(object sender, EventArgs e)
{
roateloop = false;
}
}
}