FrmMain.cs
25.9 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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
using BLL;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
public partial class FrmMain : Form
{
private bool exit = false;
private bool change;
private NotifyIcon notify;
private ContextMenuStrip notifyMenu;
private System.Timers.Timer showTimer;
private Label[] agvRunInfo;
//private string[] agvRunStep;
public FrmMain()
{
InitializeComponent();
showTimer = new System.Timers.Timer();
showTimer.Interval = 1000;
//showTimer.Enabled = true;
//showTimer.AutoReset = true;
showTimer.Elapsed += ShowTimer_Elapsed;
showTimer.Start();
Common.logTextBox = TxtLog;
agvRunInfo = new Label[] { label1, label2, label3, label4, label5, label6 };
}
private void ShowConfig()
{
int n;
//agvRunStep = new string[Common.agvInfo.Count];
for (int i = 0; i < Common.agvInfo.Count; i++)
{
Common.mir.Get_IO_Status(Common.agvInfo[i], out bool[] input, out bool[] output);
if (input != null && input.Length == 4)
Common.agvInfo[i].IsExistShelf = input[3];
n = DgvAgv.Rows.Add(Common.agvInfo[i].ToRow());
DgvAgv.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (i % 2 == 0)
DgvAgv.Rows[n].DefaultCellStyle.BackColor = Color.LightBlue;
if (!Common.agvInfo[i].IsCon)
DgvAgv.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
//agvRunStep[i] = Common.agvInfo[i].Msg;
//if (i % 2 == 0)
// agvRunInfo[i].BackColor = Color.LightBlue;
//else
// agvRunInfo[i].BackColor = Color.LightGray;
}
cmbBoxLineName.Items.Add("产线名称");
foreach (var item in Common.nodeInfo)
{
if (item.Name.StartsWith("A"))
continue;
cmbBoxLineName.Items.Add(item.AliceName);
}
cmbBoxLineName.SelectedIndex = 0;
for (int i = 0; i < Common.nodeInfo.Count; i++)
{
n = DgvNode.Rows.Add(Common.nodeInfo[i].ToRow());
DgvNode.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (i % 2 == 0)
DgvNode.Rows[n].DefaultCellStyle.BackColor = Color.LightBlue;
if (!Common.nodeInfo[i].Online)
DgvNode.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
}
LstAgvPlace.Items.Clear();
LstAgvPlace.Items.AddRange(Common.showNameMissionName.Keys.ToArray());
LstAgvPlace.SelectedIndex = 0;
}
private void Server_NodeChanged(int nodeIndex)
{
Invoke(new Action(() =>
{
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = Common.nodeInfo[nodeIndex].Online && Common.nodeInfo[nodeIndex].IsUse ? Color.Black : Color.Red;
DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void Server_NodeOnline(int nodeIndex)
{
Invoke(new Action(() =>
{
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = Common.nodeInfo[nodeIndex].Online ? Color.Black : Color.Red;
DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void Control_AgvChanged(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].DefaultCellStyle.ForeColor = Common.agvInfo[agvIndex].StateID.Equals(eAGVState.Error) ? Color.Red : Color.Black; }));
Invoke(new Action(() =>
{
DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow());
}));
System.GC.Collect();
}
private void MissionManager_MissionChanged()
{
ShowEmptyTask();
}
private void Control_AgvOnline(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].DefaultCellStyle.ForeColor = Common.agvInfo[agvIndex].IsCon ? Color.Black : Color.Red; }));
Invoke(new Action(() =>
{
DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow());
}));
GC.Collect();
}
private void ItemShow_Click(object sender, EventArgs e)
{
Show();
if (WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
private void ItemExit_Click(object sender, EventArgs e)
{
foreach (var item in Common.agvInfo)
{
Common.WriteIni(item.Name, SettingString.RFID, item.RFID);
}
notify.Dispose();
exit = true;
Close();
}
private void Notify_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
if (WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
private void FrmMain_Load(object sender, EventArgs e)
{
//托盘菜单
notifyMenu = new ContextMenuStrip();
ToolStripMenuItem itemShow = new ToolStripMenuItem("显示(&S)");
itemShow.Click += ItemShow_Click;
ToolStripMenuItem itemExit = new ToolStripMenuItem("退出(&X)");
itemExit.Click += ItemExit_Click;
notifyMenu.Items.Add(itemShow);
notifyMenu.Items.Add(itemExit);
//托盘控件
notify = new NotifyIcon { Icon = Icon, Visible = true, ContextMenuStrip = notifyMenu, Text = Text };
notify.MouseDoubleClick += Notify_MouseDoubleClick;
ShowConfig();
change = true;
//ChkAutoCharge.Checked = Common.chargeStatus.AutoCharge;
change = false;
Common.control.AgvChanged += Control_AgvChanged;
Common.control.AgvOnline += Control_AgvOnline;
Common.server.NodeChanged += Server_NodeChanged;
Common.server.NodeOnline += Server_NodeOnline;
Common.missionManager.MissionChanged += MissionManager_MissionChanged;
//foreach (var item in Common.agvInfo)
//{
// cmbBoxAGVName.Items.Add(item.Name);
//}
//cmbBoxAGVName.Items.Add("None");
//cmbBoxAGVName.SelectedIndex = Common.agvInfo.Count;
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (!exit)
{
e.Cancel = true;
Hide();
}
foreach (var item in Common.agvInfo)
{
Common.WriteIni(item.Name, SettingString.RFID, item.RFID);
}
//showTimer.Enabled = false;
showTimer.Stop();
Common.control.AgvChanged -= Control_AgvChanged;
Common.control.AgvOnline -= Control_AgvOnline;
Common.server.NodeChanged -= Server_NodeChanged;
Common.server.NodeOnline -= Server_NodeOnline;
}
private void DgvAgv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1) return;
if (e.ColumnIndex == 10) //调用
{
if (Common.agvInfo[e.RowIndex].IsUse.Equals(true))
{
if (Common.chargeStatus.charge3.Equals(Common.agvInfo[e.RowIndex].Name))
{
Common.chargeStatus.charge3 = "";
}
if (Common.chargeStatus.charge4.Equals(Common.agvInfo[e.RowIndex].Name))
{
Common.chargeStatus.charge4 = "";
}
Common.agvInfo[e.RowIndex].IsUse = false;
//Common.agvInfo[e.RowIndex].CurJob = null;
//Common.agvInfo[e.RowIndex].RFID = "";
// }
}
else
{
//清除4c临时待机位的占用
if (Common.agvInfo[e.RowIndex].Name.Equals(Common.StandbyStation.C4_Station1))
{
Common.StandbyStation.C4_Station1 = "";
}
else if (Common.agvInfo[e.RowIndex].Name.Equals(Common.StandbyStation.C4_Station2))
{
Common.StandbyStation.C4_Station2 = "";
}
Common.LogInfo(string.Format("手动开启小车自动模式,并清除上一次的自动模式的运行信息{0} {1}", Common.agvInfo[e.RowIndex].Name, Common.agvInfo[e.RowIndex].RunInfo()));
Common.agvInfo[e.RowIndex].CurJob = null;
Common.agvInfo[e.RowIndex].RFID = "";
// Common.agvInfo[e.RowIndex].Place = "";
Common.agvInfo[e.RowIndex].IsUse = true;
// }
//else
//{
// Common.agvInfo[e.RowIndex].IsUse = true;
// Common.LogInfo(string.Format("手动开启小车自动模式,并继续上一次的自动模式的运行信息{0} {1}", Common.agvInfo[e.RowIndex].Name, Common.agvInfo[e.RowIndex].RunInfo()));
//}
}
DgvAgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Common.agvInfo[e.RowIndex].IsUse.ToString();
Common.WriteIni(Common.agvInfo[e.RowIndex].Name, SettingString.IsUse, Common.agvInfo[e.RowIndex].IsUse.ToString());
Common.appConfig.Save();
DgvAgv.Rows[e.RowIndex].SetValues(Common.agvInfo[e.RowIndex].ToRow());
}
}
private void DgvNode_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1) return;
if (e.ColumnIndex == 7) //调用
{
Common.nodeInfo[e.RowIndex].IsUse = !Common.nodeInfo[e.RowIndex].IsUse;
DgvNode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Common.nodeInfo[e.RowIndex].IsUse.ToString();
Common.WriteIni(Common.nodeInfo[e.RowIndex].Name, SettingString.IsUse, Common.nodeInfo[e.RowIndex].IsUse.ToString());
Common.appConfig.Save();
DgvNode.Rows[e.RowIndex].SetValues(Common.nodeInfo[e.RowIndex].ToRow());
}
else if (e.ColumnIndex == 8) //清除缓存
{
//清除节点缓存
Common.LogInfo(string.Format("手动清除缓存,{0} {1}", Common.nodeInfo[e.RowIndex].AgvName, Common.nodeInfo[e.RowIndex].Name));
string name = Common.nodeInfo[e.RowIndex].AgvName;
Common.nodeInfo[e.RowIndex].AgvName = "";
DgvNode.Rows[e.RowIndex].Cells[5].Value = "";
Common.nodeInfo[e.RowIndex].RFID = "";
DgvNode.Rows[e.RowIndex].Cells[4].Value = "";
//清除小车缓存
int idx = Common.agvInfo.FindIndex(s => s.Name == name);
if (idx > -1)
{
Common.agvInfo[idx].Place = "";
Common.agvInfo[idx].RFID = "";
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
//添加Init任务
Common.mir.Add_Mission_Fleet(Common.agvInfo[idx], Common.agvMission["Init"]);
Common.mir.State_Ready(Common.agvInfo[idx]);
}
DgvNode.Rows[e.RowIndex].SetValues(Common.nodeInfo[e.RowIndex].ToRow());
}
}
private void BtnMissionReady_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
Common.mir.State_Ready(Common.agvInfo[idx]);
}
private void BtnMissionPause_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
Common.mir.State_Pause(Common.agvInfo[idx]);
Common.LogInfo("手动暂停:[" + Common.agvInfo[idx].Name + "]");
}
private void BtnMissionAdd_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
if (!Common.agvInfo[idx].IsUse)
//{
// if (MessageBox.Show("确定在自动模式下对小车手动分配任务?", Common.agvInfo[idx].Name, MessageBoxButtons.YesNo) == DialogResult.No)
// return;
// Common.agvInfo[idx].Resend();
// //Common.agvInfo[idx].TaskSend = LstAgvPlace.Text;
// Common.LogInfo("手动添加任务:[" + Common.agvInfo[idx].Name + "][" + Common.agvInfo[idx].CurTaskName + "]");
//}
//else
{
bool rtn = Common.mir.Add_Mission_Fleet(Common.agvInfo[idx], Common.agvMission[Common.showNameMissionName[LstAgvPlace.Text]]);
if (!rtn)
return;
if (LstAgvPlace.Text.StartsWith("Move"))
Common.agvInfo[idx].Place = LstAgvPlace.Text.Substring(4);
Common.LogInfo("手动添加任务:[" + Common.agvInfo[idx].Name + "][" + Common.agvInfo[idx].CurTaskName + "]");
}
////清除4c临时待机位的占用
//if (Common.agvInfo[idx].Name.Equals(Common.StandbyStation.C4_Station1))
//{
// Common.StandbyStation.C4_Station1 = "";
//}
//else if (Common.agvInfo[idx].Name.Equals(Common.StandbyStation.C4_Station2))
//{
// Common.StandbyStation.C4_Station2 = "";
//}
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
}
}
private void BtnClearError_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
Common.mir.Clear_Error(Common.agvInfo[idx]);
Common.LogInfo("手动清除错误:[" + Common.agvInfo[idx].Name + "]");
}
bool InShhow = false;
private void ShowTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//ShowEmptyTask();
if (InShhow)
return;
InShhow = true;
Invoke(new Action(() =>
{
for (int i = 0; i < Common.agvInfo.Count; i++)
{
try
{
agvRunInfo[i].Text = Common.agvInfo[i].RunInfo();
}
catch (Exception ex)
{
}
}
if (!Common.doubleLine_WO.Equals(""))
lblWO.Text = Common.doubleLine_WO;
if (!AGVManager.A6_Target.Equals(""))
lblDestInfo.Text = AGVManager.A6_Target;
lblCharge3.Text = "充电桩3:" + Common.chargeStatus.charge3;
lblCharge4.Text = "充电桩4:" + Common.chargeStatus.charge4;
lblStandy1.Text = "4C待机位1:" + Common.StandbyStation.C4_Station1;
lblStandy2.Text = "4C待机位2:" + Common.StandbyStation.C4_Station2;
}));
InShhow = false;
}
private void ShowEmptyTask()
{
if (dgvLineMission.InvokeRequired)
{
dgvLineMission.Invoke(new Action(() => ShowEmptyTask()));
return;
}
try
{
if (dgvLineMission.Rows.Count != 0)
dgvLineMission.Rows.Clear();
foreach (var item in Common.missionManager.missionList)
{
var key = Common.nodeInfo.Where(q => q.Name == item.NodeName).Select(q => q.AliceName);
if (key.ToList().Count > 0)
dgvLineMission.Rows.Add(item.CreateTime, key.ToList()[0]);
}
groupBox4.Text = "产线解绑信息:共" + Common.missionManager.EmptyMissionCount.ToString() + "个";
}
catch (Exception ex)
{
Common.log.Error(ex);
}
}
private void ChkAutoCharge_CheckedChanged(object sender, EventArgs e)
{
if (change) return;
//Common.chargeStatus.AutoCharge = ChkAutoCharge.Checked;
}
private void btnDeleteMission_Click(object sender, EventArgs e)
{
try
{
if (cmbBoxLineName.SelectedItem == null || cmbBoxLineName.SelectedIndex == 0)
{
return;
}
if (MessageBox.Show("确定删除产线任务[" + cmbBoxLineName.SelectedItem.ToString() + "]", "手动删除解绑任务", MessageBoxButtons.YesNo) == DialogResult.No)
return;
//int idx=Common.missionList.FindIndex(s => s.NodeName == Common.agvProductionLine[txtBoxMission.Text]);
int idx = Common.nodeInfo.FindIndex(s => s.AliceName.Equals(cmbBoxLineName.SelectedItem.ToString()));
if (idx > -1)
{
if (Common.DelEmptyShelfTask(Common.nodeInfo[idx].Name))
{
Common.LogInfo("手动删除任务成功:" + cmbBoxLineName.SelectedItem.ToString());
}
else
{
Common.LogInfo("手动删除任务失败");
}
}
}
catch (Exception ex)
{
Common.log.Error("手动删除任务失败:" + ex.Message);
}
}
private void btnAddMission_Click(object sender, EventArgs e)
{
try
{
if (cmbBoxLineName.SelectedItem == null || cmbBoxLineName.SelectedIndex == 0)
{
return;
}
if (cmbBoxLineName.SelectedItem.ToString().StartsWith("A"))
return;
if (MessageBox.Show("确定添加产线任务[" + cmbBoxLineName.SelectedItem.ToString() + "]", "手动1添加解绑", MessageBoxButtons.YesNo) == DialogResult.No)
return;
int idx = Common.nodeInfo.FindIndex(s => s.AliceName.Equals(cmbBoxLineName.SelectedItem.ToString()));
if (idx > -1)
{
if (Common.AddEmptyShelfTask(Common.nodeInfo[idx].Name))
{
Common.LogInfo("手动添加任务成功:" + cmbBoxLineName.SelectedItem.ToString());
}
else
{
Common.LogInfo("手动添加任务失败");
}
}
}
catch (Exception ex)
{
ShowEmptyTask();
Common.log.Error("手动添加任务失败:" + ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
Common.agvInfo[idx].IsExistShelf = !Common.agvInfo[idx].IsExistShelf;
Common.LogInfo("手动设置 " + Common.agvInfo[idx].Name + " 负载状态=" + Common.agvInfo[idx].IsExistShelf);
}
}
private void button1_Click_1(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
Common.agvInfo[idx].CurJob = new ChargeJob("");
return;
//Common.agvInfo[idx].TaskSend = LstAgvPlace.Text;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
Common.agvInfo[idx].CurJob = new EmptyAGVBackJob("");
return;
}
}
private void btnWO_Click(object sender, EventArgs e)
{
try
{
Task.Factory.StartNew(new Action(() =>
{
if (AGVManager.FindCurSO(out AGVManager.WOData woData))
{
if (Common.GetNodeNameByLineName(woData.line, out string loc))
{
Common.doubleLine_WO = "工单料信息:" + woData.ToTxt(loc);
Common.LogInfo(Common.doubleLine_WO);
}
}
}));
}
catch (Exception ex)
{
MessageBox.Show("查询失败:" + ex.Message + "\r\n" + ex.StackTrace);
}
}
/// <summary>
/// 出料查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button5_Click(object sender, EventArgs e)
{
try
{
Task.Factory.StartNew(() =>
{
int idx = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A6));
if (idx > -1)
{
AGVManager.FindFullShelfTarget(Common.nodeInfo[idx].RFID, out AGVManager.BoxDestInfo FullShelfDestInfo);
}
});
}
catch (Exception ex)
{
MessageBox.Show("查询失败:" + ex.Message + "\r\n" + ex.StackTrace);
}
}
private void button9_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
Common.agvInfo[idx].CurJob = null;
}
}
private void button1_Click_2(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
Common.CalculateNearNode(Common.agvInfo[idx], SettingString.D4_Name_Prefix);
}
private void btnUpdateStatus_Click(object sender, EventArgs e)
{
try
{
Task.Factory.StartNew(() =>
{
AGVManager.UpdateStatus(txtBoxRFID.Text.ToUpper(), txtBoxLineName.Text.ToUpper());
Common.LogInfo(string.Format("手动上报状态 产线{0} 物料状态更新成功[{1}]", txtBoxLineName.Text.ToUpper(), txtBoxRFID.Text.ToUpper()));
});
}
catch (Exception ex)
{
MessageBox.Show("手动上报状态失败:" + ex.Message + "\r\n" + ex.StackTrace);
}
}
private void dgvLineMission_Click(object sender, EventArgs e)
{
ShowEmptyTask();
}
private void btnClearC4StandyInfo_Click(object sender, EventArgs e)
{
Common.StandbyStation.C4_Station1 = "";
Common.StandbyStation.C4_Station2 = "";
}
private void btnReSendTask_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
if (Common.agvInfo[idx].IsUse)
{
if (MessageBox.Show("确定在自动模式下对小车重发任务?", Common.agvInfo[idx].Name, MessageBoxButtons.YesNo) == DialogResult.No)
return;
Common.agvInfo[idx].Resend();
Common.mir.State_Ready(Common.agvInfo[idx]);
//Common.agvInfo[idx].TaskSend = LstAgvPlace.Text;
Common.LogInfo("手动重发任务:[" + Common.agvInfo[idx].Name + "][" + Common.agvInfo[idx].CurTaskName + "]");
}
////清除4c临时待机位的占用
//if (Common.agvInfo[idx].Name.Equals(Common.StandbyStation.C4_Station1))
//{
// Common.StandbyStation.C4_Station1 = "";
//}
//else if (Common.agvInfo[idx].Name.Equals(Common.StandbyStation.C4_Station2))
//{
// Common.StandbyStation.C4_Station2 = "";
//}
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
}
}
}
}