ucCtuRunInfo.cs
6.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using CtuDeviceLib;
using DeviceLibrary.CtuService;
using Mushiny;
using OnlineStore.Common;
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace TheMachine
{
public partial class ucCtuRunInfo : UserControl
{
public ucCtuRunInfo(CTU ctu)
{
InitializeComponent();
curCtu = ctu;
}
CTU curCtu;
public void UpdateInfo()
{
if (!IsHandleCreated) return;
this.Invoke(new Action(() =>
{
try
{
groupBox1.Text = $"[{curCtu.Name}][{curCtu.IP}][{curCtu.SOC}%]";
lblRobotState.Text = curCtu.RobotState.ToString();
if (curCtu.Enabled)
{
lblEnabled.Text = "已启用";
}
else
{
lblEnabled.Text = "已关闭";
}
if (curCtu.RunState == RunState.Offline)
{
this.BackColor = Color.Red;
}
else if (curCtu.RunState == RunState.Online)
{
this.BackColor = Color.LightGreen;
}
else if (curCtu.RunState == RunState.Reset)
{
this.BackColor = Color.Yellow;
}
else if (curCtu.RunState == RunState.Executing)
{
this.BackColor = Color.LightBlue;
}
if (curCtu.FaultInfo?.HasFault ?? false)
{
lblError.BackColor = Color.Red;
}
listBox1.Items.Clear();
listBox1.Items.Add($"当前地码:{curCtu.CurLandMark} 当前角度:{curCtu.CurDir}°");
if (curCtu.RobotState == RobotState.空闲状态 && curCtu.CurLandMark == 10001)
{
listBox1.Items.Add($"CTU在辅助码上,请移动到维护的码上");
}
listBox1.Items.Add($"限制区域:{string.Join(",", curCtu.curLimitAreas)}");
listBox1.Items.Add($"占用地码:{string.Join(",", curCtu.UsedPoint)}");
curCtu.GetAllBaskets().ForEach(s =>
{
if (!string.IsNullOrEmpty(s.BoxCode))
{
string isShield = "";
if (s.Shield)
{
isShield = ",已屏蔽";
}
listBox1.Items.Add($"R{s.Row}:{s.BoxCode},{s.DstName},{(s.IsPutted ? "有料箱" : "无料箱")}{isShield}");
}
});
}
catch (Exception ex)
{
LogUtil.error($"【{curCtu.Name}】更新信息异常", ex);
}
}));
}
private void 清空所有背篓信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show($"是否清空背篓的所有信息?", curCtu?.Name, MessageBoxButtons.YesNo).Equals(DialogResult.No))
{
return;
}
for (byte i = 1; i <= CTUManager.basketCnt; i++)
{
curCtu?.ClearBasket(i);
}
LogUtil.info($"【{curCtu.Name}】手动清空所有背篓信息");
}
private void 启用ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (curCtu != null)
{
var lst = ConfigAppSettings.GetValue(Mushiny.Common.Mushiny_ + "EnabledCtus", new string[] { "" }).ToList();
if (!lst.Contains(curCtu.Name))
{
lst.Add(curCtu.Name);
ConfigAppSettings.SaveValue(Mushiny.Common.Mushiny_ + "EnabledCtus", lst.ToArray());
}
LogUtil.info($"【{curCtu.Name}】手动启用");
}
}
private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (curCtu != null)
{
var lst = ConfigAppSettings.GetValue(Mushiny.Common.Mushiny_ + "EnabledCtus", new string[] { "" }).ToList();
if (lst.Contains(curCtu.Name))
{
lst.Remove(curCtu.Name);
curCtu?.ClearUsedPoints();
ConfigAppSettings.SaveValue(Mushiny.Common.Mushiny_ + "EnabledCtus", lst.ToArray());
}
LogUtil.info($"【{curCtu.Name}】手动关闭");
string msg = $"[{curCtu.CtuTask?.Name}][{curCtu.CtuTask?.DstName}][{curCtu.CtuTask?.boxCode}]";
if (MessageBox.Show($"是否清空{curCtu.Name}当前执行的任务:{msg}", "", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
{
curCtu.CtuTask = null;
LogUtil.info($"【{curCtu.Name}】手动关闭时清空当前任务:{msg}");
}
}
}
private void 清空待机点ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void 清空占用路线点ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (curCtu != null)
{
curCtu.ClearUsedPoints();
LogUtil.info($"【{curCtu.Name}】手动清空待机点占用");
}
}
private void 清空当前任务ToolStripMenuItem_Click(object sender, EventArgs e)
{
string msg = $"[{curCtu.CtuTask?.Name}][{curCtu.CtuTask?.DstName}][{curCtu.CtuTask?.boxCode}]";
if (MessageBox.Show($"是否清空{curCtu.Name}当前执行的任务:{msg}", "", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
{
curCtu.CtuTask = null;
LogUtil.info($"【{curCtu.Name}】手动清空当前任务:{msg}");
}
}
private void 清空未放箱状态背篓ToolStripMenuItem_Click(object sender, EventArgs e)
{
curCtu.ClearUnPuttedBox();
LogUtil.info("手动清空未放箱状态背篓");
}
}
}