CT.cs
15.4 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using UserFromControl;
namespace OnlineStore.XLRStore.useControl
{
public partial class CT : UserControl
{
private InputEquip inputEquip;
private BoxEquip boxBean;
private BatchMoveBean moveBean;
public CT()
{
InitializeComponent();
StoreManager.Loadfinishevent += StoreManager_Loadfinishevent;
this.Enabled = false;
}
private void StoreManager_Loadfinishevent(object sender, bool e)
{
inputEquip = StoreManager.XLRStore.inputEquip;
boxBean = StoreManager.XLRStore.boxEquip;
timer1.Enabled = true;
this.Enabled = true;
axisMoveControl1.LoadData(StoreManager.XLRStore.inputEquip, new AxisBean[] { inputEquip.BatchMove_A.BatchAxis, inputEquip.BatchMove_B.BatchAxis });
boxBean.cttime += BoxBean_cttime;
inputEquip.cttime += InputEquip_cttime;
LoadIOList();
}
private void InputEquip_cttime(object sender, double e)
{
var cc = DateTime.Now - cttime;
lbl_t1.Text = $"CT:{cc.TotalSeconds:F2}";
}
private void BoxBean_cttime(object sender, double e)
{
lbl_t2.Text = $"CT:{e:F2}";
}
DateTime cttime;
private void btn_ct_Click(object sender, EventArgs e)
{
if (StoreManager.XLRStore.runStatus != RunStatus.Runing)
{
MessageBox.Show("请先启动设备");
return;
}
if (StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UpperArea_Check_A).Equals(IO_VALUE.LOW)
|| StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UpperArea_Check_B).Equals(IO_VALUE.LOW))
{
MessageBox.Show("请在出库缓存位上放上料盘");
return;
}
if (StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UnderArea_Check_A).Equals(IO_VALUE.HIGH)
|| StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UnderArea_Check_B).Equals(IO_VALUE.HIGH))
{
MessageBox.Show("请清空入库缓存上的料盘");
return;
}
BoxPosition posiiton = CSVPositionReader<BoxPosition>.GetPositon(PosIDManger.APosList.DRAWER[1][0].PosID);
InOutParam param = new InOutParam(new InOutPosInfo("InstoreSTEST", posiiton.PositionNum, posiiton.BagHigh, posiiton.BagWidth));
param.ShelfType = 1;
LogUtil.info("点击 CT测试");
cttime = DateTime.Now;
inputEquip.StartInstore(param);
}
private void timer1_Tick(object sender, EventArgs e)
{
lblMoveInfo.Text = inputEquip.GetMoveStr();
lblMoveInfo2.Text = boxBean.GetMoveStr();
ReadIOList();
}
private void CT_Load(object sender, EventArgs e)
{
for (int i = 1; i <= 13; i++)
{
// 创建按钮
Button button = new Button();
button.Text = "位置 " + i; // 设置按钮文本
button.Tag = i; // 设置按钮的Tag属性
button.Click += new EventHandler(Button_Click); // 为按钮添加点击事件
button.Width = 100;
button.Height = 40;
// 将按钮添加到FlowLayoutPanel
flowLayoutPanel1.Controls.Add(button);
}
}
private void Button_Click(object sender, EventArgs e)
{
// 获取触发事件的按钮
Button clickedButton = sender as Button;
// 检查Tag属性并显示提示
if (clickedButton != null && clickedButton.Tag is int tag)
{
btn_auto_Click(tag);
}
}
private void btn_auto_Click(int drawerindex)
{
if (StoreManager.XLRStore.runStatus != RunStatus.Runing)
{
MessageBox.Show("请先启动设备");
return;
}
if (StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UpperArea_Check_A).Equals(IO_VALUE.HIGH)
|| StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UpperArea_Check_B).Equals(IO_VALUE.HIGH))
{
MessageBox.Show("请清空出库缓存位上的料盘");
return;
}
if (StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UnderArea_Check_A).Equals(IO_VALUE.LOW)
|| StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UnderArea_Check_B).Equals(IO_VALUE.LOW))
{
MessageBox.Show("请在入库缓存位上放上料盘");
return;
}
//int drawerindex = int.Parse(cb_poslist.SelectedItem.ToString());
string apos = "", bpos = "", aout = "", bout = "";
//if (drawerindex == 20)
//{
// apos = "01AA15060420";
// bpos = "01BB14050401";
//}
//else
PosIDManger.GetDarwerPoslist(drawerindex, out apos, out bpos, out aout, out bout);
if (string.IsNullOrEmpty(apos))
{
MessageBox.Show($"位置{drawerindex} A侧没有可用库位");
return;
}
if (string.IsNullOrEmpty(bpos))
{
MessageBox.Show($"位置{drawerindex} B侧没有可用库位");
return;
}
if (PosIDManger.GetPosHasReel(apos))
{
MessageBox.Show($"库位{apos} 已有物料,不能入库");
return;
}
if (PosIDManger.GetPosHasReel(bpos))
{
MessageBox.Show($"库位{bpos} 已有物料,不能入库");
return;
}
LogUtil.info($"工作库位: apos:{apos}, bpos:{bpos}, aout:{aout}, bout:{bout}");
InOutParam inp;
if (apos.IndexOf("AA") > 0)
{
BufferDataManager.AInStoreInfo = new InOutPosInfo("STEST", apos, 7, 8);
BufferDataManager.BInStoreInfo = new InOutPosInfo("STEST", bpos, 7, 8);
inp = new InOutParam() { PosInfo = BufferDataManager.AInStoreInfo, PosInfoBack = BufferDataManager.BInStoreInfo };
if (!string.IsNullOrEmpty(aout))
inp.AOutPosInfo = new InOutPosInfo("STEST", aout, 7, 8);
if (!string.IsNullOrEmpty(bout))
inp.BOutPosInfo = new InOutPosInfo("STEST", bout, 7, 8);
}
else
{
BufferDataManager.AInStoreInfo = new InOutPosInfo("STEST", bpos, 7, 8);
BufferDataManager.BInStoreInfo = new InOutPosInfo("STEST", apos, 7, 8);
inp = new InOutParam() { PosInfo = BufferDataManager.BInStoreInfo, PosInfoBack = BufferDataManager.AInStoreInfo };
if (!string.IsNullOrEmpty(bout))
inp.AOutPosInfo = new InOutPosInfo("STEST", bout, 7, 8);
if (!string.IsNullOrEmpty(aout))
inp.BOutPosInfo = new InOutPosInfo("STEST", aout, 7, 8);
}
if (!StoreManager.XLRStore.boxEquip.StartInstore(inp))
{
MessageBox.Show("启动失败");
return;
}
//LogUtil.info("手动入库测试...");
//string apos = PosIDManger.APosList.DRAWER[selindex][0].PosID;
//string aout = PosIDManger.APosList.DRAWER[selindex][1].PosID;
//string bpos = PosIDManger.BPosList.DRAWER[selindex][0].PosID;
//string bout = PosIDManger.BPosList.DRAWER[selindex][1].PosID;
//LogUtil.info($"工作库位: apos:{apos}, bpos:{bpos}, aout:{aout}, bout:{bout}");
//BufferDataManager.AInStoreInfo = new InOutPosInfo("STEST", apos, 7, 8);
//BufferDataManager.BInStoreInfo = new InOutPosInfo("STEST", bpos, 7, 8);
//var inp = new InOutParam() { PosInfo = BufferDataManager.AInStoreInfo, PosInfoBack = BufferDataManager.BInStoreInfo };
//if (!string.IsNullOrEmpty(aout))
// inp.AOutPosInfo = new InOutPosInfo("STEST", aout, 7, 8);
//if (!string.IsNullOrEmpty(bout))
// inp.BOutPosInfo = new InOutPosInfo("STEST", bout, 7, 8);
//if (!StoreManager.XLRStore.boxEquip.StartInstore(inp))
//{
// MessageBox.Show("启动失败");
// return;
//}
//else
//{
// StoreManager.XLRStore.boxEquip.MoveInfo.NextMoveStep(StepEnum.SO_15_ToBufferArea);
// LogUtil.info($"直接前往缓存放料");
//}
}
private void chbMoveStop_CheckedChanged(object sender, EventArgs e)
{
boxBean.MoveStop = chbMoveStop.Checked;
inputEquip.MoveStop = chbMoveStop.Checked;
LogUtil.info(inputEquip.Name + "用户切换是否暂停: " + inputEquip.MoveStop);
}
private void btnStop_Click(object sender, EventArgs e)
{
StoreManager.XLRStore.StopRun();
LogUtil.info("手动停止");
}
private void lbl_t1_Click(object sender, EventArgs e)
{
}
private void btn_ttin_Click(object sender, EventArgs e)
{
if (StoreManager.XLRStore.runStatus != RunStatus.Runing)
{
MessageBox.Show("请先启动设备");
return;
}
if (StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UnderArea_Check_A).Equals(IO_VALUE.LOW)
|| StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UnderArea_Check_B).Equals(IO_VALUE.LOW))
{
MessageBox.Show("请在入库缓存位上放上料盘");
return;
}
//int drawerindex = int.Parse(cb_poslist.SelectedItem.ToString());
string apos = "01AA15060420", bpos = "01BB14050401", aout = "", bout = "";
if (PosIDManger.GetPosHasReel(apos))
{
MessageBox.Show($"库位{apos} 已有物料,不能入库");
apos = "";
}
if (PosIDManger.GetPosHasReel(bpos))
{
MessageBox.Show($"库位{bpos} 已有物料,不能入库");
bpos = "";
}
if (apos == "" && bpos == "")
return;
LogUtil.info($"工作库位: apos:{apos}, bpos:{bpos}, aout:{aout}, bout:{bout}");
InOutParam inp;
BufferDataManager.AInStoreInfo = apos == "" ? null : new InOutPosInfo("STEST", apos, 7, 8);
BufferDataManager.BInStoreInfo = bpos == "" ? null : new InOutPosInfo("STEST", bpos, 7, 8);
if (BufferDataManager.AInStoreInfo != null)
inp = new InOutParam() { PosInfo = BufferDataManager.AInStoreInfo, PosInfoBack = BufferDataManager.BInStoreInfo };
else
inp = new InOutParam() { PosInfo = BufferDataManager.BInStoreInfo };
if (!StoreManager.XLRStore.boxEquip.StartInstore(inp))
{
MessageBox.Show("启动失败");
return;
}
}
private void btn_ttout_Click(object sender, EventArgs e)
{
if (StoreManager.XLRStore.runStatus != RunStatus.Runing)
{
MessageBox.Show("请先启动设备");
return;
}
if (StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UpperArea_Check_A).Equals(IO_VALUE.HIGH)
|| StoreManager.XLRStore.boxEquip.IOValue(IO_Type.UpperArea_Check_B).Equals(IO_VALUE.HIGH))
{
MessageBox.Show("请清空出库缓存位上的料盘");
return;
}
//int drawerindex = int.Parse(cb_poslist.SelectedItem.ToString());
string apos = "", bpos = "", aout = "01AA15060420", bout = "01BB14050401";
if (!PosIDManger.GetPosHasReel(aout))
{
MessageBox.Show($"库位{aout} 没有物料,不能出库");
aout = "";
//return;
}
if (!PosIDManger.GetPosHasReel(bout))
{
MessageBox.Show($"库位{bout} 没有物料,不能出库");
bout = "";
//return;
}
if (aout == "" && bout == "")
return;
LogUtil.info($"工作库位: apos:{apos}, bpos:{bpos}, aout:{aout}, bout:{bout}");
InOutParam inp;
BufferDataManager.AInStoreInfo = new InOutPosInfo("OUTSTEST", aout, 7, 8);
BufferDataManager.BInStoreInfo = new InOutPosInfo("OUTSTEST", bout, 7, 8);
inp = new InOutParam();
if (!string.IsNullOrEmpty(aout))
{
inp.AOutPosInfo = new InOutPosInfo("STEST", aout, 7, 8);
inp.PosInfo = BufferDataManager.AInStoreInfo;
}
if (!string.IsNullOrEmpty(bout))
{
inp.BOutPosInfo = new InOutPosInfo("STEST", bout, 7, 8);
inp.PosInfo = BufferDataManager.BInStoreInfo;
}
if (!string.IsNullOrEmpty(aout) && !string.IsNullOrEmpty(bout))
inp = new InOutParam() { PosInfo = BufferDataManager.AInStoreInfo, PosInfoBack = BufferDataManager.BInStoreInfo };
if (!StoreManager.XLRStore.boxEquip.StartInstore(inp))
{
MessageBox.Show("启动失败");
return;
}
}
protected Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
protected void ReadIOList()
{
foreach (string key in DIControlList.Keys)
{
IOTextControl control = DIControlList[key];
int iov = (int)IOManager.IOValue(key, inputEquip.DeviceID);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
}
private void LoadIOList()
{
int maxCount = 20;
int roleindex = 0;
this.tableLayoutPanel1.RowStyles.Clear();
this.tableLayoutPanel1.RowCount = maxCount;
//this.tableLayoutPanel3.RowStyles.Clear();
//this.tableLayoutPanel3.RowCount = maxCount;
int i = 0;
foreach (ConfigIO ioValue in inputEquip.Config.DIList.Values)
{
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
{
// 为每个控件添加一个新的行样式
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
// 计算列索引,每两个控件换一行
int columnIndex = i % 2;
// 将控件添加到正确的列和行
this.tableLayoutPanel1.Controls.Add(control, columnIndex, i / 2);
}
roleindex++;
i++;
DIControlList.Add(ioValue.ProName, control);
}
this.SuspendLayout(); //此处为不闪屏,一定要有的!
}
}
}