FrmABB.cs
3.2 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
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 DoubleLine
{
public partial class FrmABB : Form
{
public FrmABB()
{
InitializeComponent();
}
private void FrmABB_Load(object sender, EventArgs e)
{
for (int i = 0; i < Common.ABB_Info.Length; i++)
DgvABB.Rows.Add(Common.ABB_Info[i].Name, Common.ABB_Info[i].IP, Common.ABB_Info[i].State, Common.ABB_Info[i].IsOpen.ToString());
CboAction.Items.Add(Common.ABB_MOVEGET);
CboAction.Items.Add(Common.ABB_MOVEPUT);
CboAction.Items.Add(Common.ABB_MOVEHOME);
CboAction.Items.Add(Common.ABB_MOVEP);
CboAction.SelectedIndex = 0;
CboType.Items.Add("C:双层线其他规格料格");
CboType.Items.Add("D:双层线7寸料格");
CboType.SelectedIndex = 0;
}
private void BtnMove1_Click(object sender, EventArgs e)
{
if (DgvABB.SelectedCells.Count == 0) return;
string command = CboAction.Text;
string point = "p" + NudPoint1.Value;
if (command == Common.ABB_MOVEPUT)
{
if (CboType.SelectedIndex == 0)
point = "cp" + NudPoint1.Value;
else
point = "dp" + NudPoint1.Value;
}
string movement = RdoMove1.Checked ? "L" : "J";
int speed = Convert.ToInt32(NudSpeed.Value);
string s = string.Format("{0},{1},{2},{3}", command, point, movement, speed);
int idx = DgvABB.SelectedCells[0].RowIndex;
Common.ABB.SendCommand(idx, s);
}
private void BtnMove2_Click(object sender, EventArgs e)
{
if (DgvABB.SelectedCells.Count == 0) return;
string command = CboAction.Text;
string point = "p{0}";
if (command == Common.ABB_MOVEPUT)
{
if (CboType.SelectedIndex == 0)
point = "cp{0}";
else
point = "dp{0}";
}
string movement = RdoMove1.Checked ? "L" : "J";
int speed = Convert.ToInt32(NudSpeed.Value);
string s = string.Format("{0},{1},{2},{3}", command, point, movement, speed);
int p1 = Convert.ToInt32(NudPoint1.Value);
int p2 = Convert.ToInt32(NudPoint2.Value);
string[] cmd = new string[Math.Abs(p1 - p2) + 1];
if (p1 < p2)
{
for (int i = 0; i < cmd.Length; i++)
cmd[i] = string.Format(s, p1 + i);
}
else
{
for (int i = 0; i < cmd.Length; i++)
cmd[i] = string.Format(s, p1 - i);
}
int idx = DgvABB.SelectedCells[0].RowIndex;
Common.ABB.Multitask(idx, cmd);
}
private void BtnStopMove_Click(object sender, EventArgs e)
{
Common.ABB.StopMultitask = true;
}
}
}