WinTest.xaml.cs
19.1 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
using XingYe_ACS.BaseStruct;
using XingYe_ACS.Business;
using XingYe_ACS.Common;
using XingYe_ACS.WebApi;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace XingYe_ACS.UI
{
/// <summary>
/// WinTest.xaml 的交互逻辑
/// </summary>
public partial class WinTest : Window
{
public WinTest()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
foreach (Config_TaskSplit task in App.Config_TaskSplitList)
{
if (Enum.IsDefined(typeof(EnumMsg.TaskType), task.taskID))
{
if (!ComBox_TaskTypeList.Items.Contains(task.taskID))
{
ComBox_TaskTypeList.Items.Add(task.taskID);
}
}
}
foreach (Station st in App.StationList.FindAll(a=>a.stationType>EnumMsg.StationType.充电桩))
{
ComBox_StartList.Items.Add(st.strStationNo);
ComBox_EndList.Items.Add(st.strStationNo);
}
}
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
//重写Closing方法
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
this.Hide();
e.Cancel = true;
}
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
/// <summary>
/// 单个出库测试
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_TaskSend_Click(object sender, RoutedEventArgs e)
{
//try
//{
// string strResult = TaskManage.CheackWareTask(EnumMsg.TaskType.配送出库, TBox_ShelfOri.Text, TBox_WsNo.Text, EnumMsg.OriType.X正方向);
// if (strResult != "1")
// {
// MessageBox.Show("建立出库任务失败");
// }
// else
// {
// MessageBox.Show("建立出库任务成功");
// }
//}
//catch (Exception Ex)
//{
// MessageBox.Show("建立出库任务失败" + Ex.ToString());
//}
}
/// <summary>
/// 整体出库测试
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_DoubleTaskSend_Click(object sender, RoutedEventArgs e)
{
}
/// <summary>
/// 单个回库任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_MoveBack_Click(object sender, RoutedEventArgs e)
{
}
private void Btn_OK_Click(object sender, RoutedEventArgs e)
{
try
{
if (ComBox_TaskType.Text == "") return;
string[] Data = ComBox_TaskType.Text.Split('|');
BaseStruct.Point StratPoint = App.PointList.Find(a => a.strBarcode == Tbox_Spoint.Text);
BaseStruct.Point EndPoint = App.PointList.Find(a => a.strBarcode == Tbox_Epoint.Text);
BaseStruct.Point agvPoint = App.PointList.Find(a => a.strBarcode == App.AgvList.First(b => b.strAgvNo == Tbox_Agv.Text).strBarcode);
if (StratPoint == null)
{
StratPoint = agvPoint;
}
if (Data[1] == "2" || Data[1] == "3" || Data[1] == "6")
{
StratPoint = agvPoint;
EndPoint = agvPoint;
}
#pragma warning disable CS0219 // 变量“oriDail”已被赋值,但从未使用过它的值
EnumMsg.OriDial oriDail = EnumMsg.OriDial.角度0;
#pragma warning restore CS0219 // 变量“oriDail”已被赋值,但从未使用过它的值
if (Data[1] == "4" && Tbox_Spoint.Text == "1") oriDail = EnumMsg.OriDial.角度90;
else if (Data[1] == "4" && Tbox_Spoint.Text == "2") oriDail = EnumMsg.OriDial.角度180;
else if (Data[1] == "4" && Tbox_Spoint.Text == "3") oriDail = EnumMsg.OriDial.角度270;
//手动充电任务
if (Data[1].ToString() == "充电")
{
Agv agv = App.AgvList.FirstOrDefault(a => a.strAgvNo == Tbox_Agv.Text);
Station station = App.StationList.FirstOrDefault(a => a.strBarcode == Tbox_Epoint.Text);
agv.strChooseStation = station.strStationNo;
station.isLocked = true;
bool updateAgvResult = UpdateManage.UpdateAgvMsg(agv);
bool updateAtationResult = UpdateManage.UpdateStation(station);
}
bool isResult = TaskManage.TaskBuild(Data[0].ToString(), "PCBA", "", 1, Tbox_Agv.Text, "", StratPoint, EndPoint, "");
//bool isResult = TaskManage.TaskBuild("回家-1", "PCBA", "", 1, Tbox_Agv.Text, "", StratPoint, EndPoint, "");
if (isResult)
{
MessageBox.Show("建立成功!");
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
private void Btn_WalkOK_Click(object sender, RoutedEventArgs e)
{
App.StartWalk = 1;
App.AgvNo.Add(Tbox_WalkAgv.Text);
App.EndPoint.Add(Tbox_WalkEpoint.Text);
BaseStruct.Point point = App.PointList.Find(a => a.strBarcode == App.AgvList.FirstOrDefault(b => b.strAgvNo == Tbox_WalkAgv.Text).strBarcode);
App.StartPoint.Add(point.strBarcode);
//Business.TaskManage.WalkTasks();
}
private void Btn_Close_Click(object sender, RoutedEventArgs e)
{
App.StartWalk = 0;
for (int i = 0; i < App.AgvNo.Count; i++)
{
Agv agv = App.AgvList.FirstOrDefault(b => b.strAgvNo == App.AgvNo[i]);
if (agv.strAgvNo == Tbox_WalkAgv.Text)
{
App.AgvNo.Remove(App.AgvNo[i]);
App.EndPoint.Remove(App.EndPoint[i]);
App.StartPoint.Remove(App.StartPoint[i]);
}
}
}
private void Btn_Off_Click(object sender, RoutedEventArgs e)
{
try
{
if (Combo_offType.Text == "")
{
MessageBox.Show("请选择关机小车!");
}
else
{
App.offAgv = 1;
App.offTime = DateTime.Now;
App.offAgvNo.Clear();
if (Combo_offType.Text == "单独关机")
{
Agv getAgv = App.AgvList.FirstOrDefault(a => a.strAgvNo == TBox_offAgvNo.Text);
if (getAgv != null)
{
App.offAgvNo.Add(TBox_offAgvNo.Text);
}
}
else if (Combo_offType.Text == "全部关机")
{
foreach (Agv agv in App.AgvList)
{
if (agv.isEnable == true && agv.isOnline == true)
{
App.offAgvNo.Add(agv.strAgvNo);
}
else
{
continue;
}
}
}
}
}
catch (Exception Ex)
{
App.ExFile.MessageLog("ToWebTaskRefresh", "WEB返回的数据(ToWebTaskRefresh)," + Ex.ToString() + "\r");
}
}
/// <summary>
/// 建立单个移库任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_SingleMoveTaskSend_Click(object sender, RoutedEventArgs e)
{
try
{
//不需要修改货架方向
//string isResult = TaskManage.CheackWareTask(EnumMsg.TaskType.配送移库, TBox_MoveShelfNo.Text, TBox_MoveEndBarcode.Text, 0);
//if (isResult == "1")
//{
// MessageBox.Show("建立移库任务成功!");
//}
}
catch (Exception Ex)
{
MessageBox.Show("建立移库任务失败" + Ex.ToString());
}
}
/// <summary>
/// 整列移库
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_MoveTaskSend_Click(object sender, RoutedEventArgs e)
{
}
/// <summary>
/// 整列回库
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_MoveBackTaskSend_Click(object sender, RoutedEventArgs e)
{
}
//测试托盘
private void TuoPan_SingleMoveTaskSend_Click(object sender, RoutedEventArgs e)
{
}
private void Btn_UpdateShelfOri_Click(object sender, RoutedEventArgs e)
{
}
private void TBox_CurrentShelf_KeyDown(object sender, KeyEventArgs e)
{
}
private void Btn_RototeTask_Click(object sender, RoutedEventArgs e)
{
}
private void TBox_ChangeShelfOri_KeyDown(object sender, KeyEventArgs e)
{
}
private void TuoPan_GoHomeTaskSend_Click(object sender, RoutedEventArgs e)
{
try
{
string taskID = ComBox_TaskTypeList.SelectedItem.ToString();
BaseStruct.Point startPoint = App.PointList.Find(b => b.strBarcode == App.StationList.Find(a => a.strStationNo == ComBox_StartList.Text).strBarcode);
BaseStruct.Point endPoint = App.PointList.Find(b => b.strBarcode == App.StationList.Find(a => a.strStationNo == ComBox_EndList.Text).strBarcode);
TaskManage.TaskBuild(taskID, "配送", "", 5, "", "", startPoint, endPoint, "");
}
catch (Exception Ex)
{
MessageBox.Show(Ex.StackTrace);
}
MessageBox.Show("成功!!");
}
/// <summary>
/// 移库的回库任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_SingleMoveBackTaskSend_Click(object sender, RoutedEventArgs e)
{
}
private void TuoPan_SingleYMoveTaskSend_Click(object sender, RoutedEventArgs e)
{
}
private void Btn_SendTask_Click(object sender, RoutedEventArgs e)
{
}
private void SendCargoTask(object sender, RoutedEventArgs e)
{
}
private void SendTestTask(object sender, RoutedEventArgs e)
{
}
private void SendPickTask(object sender, RoutedEventArgs e)
{
}
private void Btn_WalktaskStart_Click(object sender, RoutedEventArgs e)
{
try
{
App.StartWalk = 1;
App.AgvNo.Add(TBox_AgvNo.Text);
App.EndPoint.Add(TBox_EndPoint.Text);
BaseStruct.Point point = App.PointList.Find(a => a.strBarcode == App.AgvList.FirstOrDefault(b => b.strAgvNo == TBox_AgvNo.Text).strBarcode);
App.StartPoint.Add(point.strBarcode);
}
catch (Exception ex)
{
MessageBox.Show("建立失败" + ex.ToString());
}
}
private void Btn_WalktaskEnd_Click(object sender, RoutedEventArgs e)
{
App.StartWalk = 0;
for (int i = 0; i < App.AgvNo.Count; i++)
{
Agv agv = App.AgvList.FirstOrDefault(b => b.strAgvNo == App.AgvNo[i]);
if (agv.strAgvNo == TBox_AgvNo.Text)
{
App.AgvNo.Remove(App.AgvNo[i]);
App.EndPoint.Remove(App.EndPoint[i]);
App.StartPoint.Remove(App.StartPoint[i]);
}
}
}
private void Btn_RotateStart_Click(object sender, RoutedEventArgs e)
{
try
{
App.RotateTask = 1;
App.RotateAgvNo.Add(TBox_RotateAgv.Text);
BaseStruct.Point point = App.PointList.Find(a => a.strBarcode == App.AgvList.FirstOrDefault(b => b.strAgvNo == TBox_RotateAgv.Text).strBarcode);
App.RotateStartPoint.Add(point.strBarcode);
}
catch (Exception ex)
{
MessageBox.Show("建立失败" + ex.ToString());
}
}
private void Btn_RotateEnd_Click(object sender, RoutedEventArgs e)
{
App.RotateTask = 0;
for (int i = 0; i < App.AgvNo.Count; i++)
{
Agv agv = App.AgvList.FirstOrDefault(b => b.strAgvNo == App.RotateAgvNo[i]);
if (agv.strAgvNo == TBox_RotateAgv.Text)
{
App.RotateAgvNo.Remove(App.RotateAgvNo[i]);
App.RotateStartPoint.Remove(App.RotateStartPoint[i]);
}
}
}
private void Btn_LiftStart_Click(object sender, RoutedEventArgs e)
{
try
{
App.LiftTask = 1;
App.LiftAgvNo.Add(TBox_LiftAgv.Text);
BaseStruct.Point point = App.PointList.Find(a => a.strBarcode == App.AgvList.FirstOrDefault(b => b.strAgvNo == TBox_LiftAgv.Text).strBarcode);
App.LiftStartPoint.Add(point.strBarcode);
}
catch (Exception ex)
{
MessageBox.Show("建立失败" + ex.ToString());
}
}
private void Btn_LiftEnd_Click(object sender, RoutedEventArgs e)
{
App.LiftTask = 0;
for (int i = 0; i < App.LiftAgvNo.Count; i++)
{
Agv agv = App.AgvList.FirstOrDefault(b => b.strAgvNo == App.LiftAgvNo[i]);
if (agv.strAgvNo == TBox_LiftAgv.Text)
{
App.LiftAgvNo.Remove(App.LiftAgvNo[i]);
App.LiftStartPoint.Remove(App.LiftStartPoint[i]);
}
}
}
private void Btn_PalletStart_Click(object sender, RoutedEventArgs e)
{
try
{
App.PalletTask = 1;
App.PalletAgvNo.Add(TBox_PalletAgv.Text);
BaseStruct.Point point = App.PointList.Find(a => a.strBarcode == App.AgvList.FirstOrDefault(b => b.strAgvNo == TBox_PalletAgv.Text).strBarcode);
App.PalletStartPoint.Add(point.strBarcode);
}
catch (Exception ex)
{
MessageBox.Show("建立失败" + ex.ToString());
}
}
private void Btn_PalletEnd_Click(object sender, RoutedEventArgs e)
{
App.PalletTask = 0;
for (int i = 0; i < App.PalletAgvNo.Count; i++)
{
Agv agv = App.AgvList.FirstOrDefault(b => b.strAgvNo == App.PalletAgvNo[i]);
if (agv.strAgvNo == TBox_PalletAgv.Text)
{
App.PalletAgvNo.Remove(App.PalletAgvNo[i]);
App.PalletStartPoint.Remove(App.PalletStartPoint[i]);
}
}
}
private void Btn_ChargeStart_Click(object sender, RoutedEventArgs e)
{
App.ChargeTask = 1;
}
private void Btn_ChargeEnd_Click(object sender, RoutedEventArgs e)
{
App.ChargeTask = 0;
}
private void Btn_CurveStart_Click(object sender, RoutedEventArgs e)
{
try
{
Agv agv = App.AgvList.FirstOrDefault(a => a.strAgvNo == TBox_CurveAgv.Text);
BaseStruct.Point startPoint = App.PointList.Find(a =>a.strBarcode == TBox_CurveStartPoint.Text);
BaseStruct.Point endPoint = App.PointList.Find(a =>a.strBarcode == TBox_CurveEndPoint.Text);
bool result = TaskManage.TaskBuild("弧线行走任务", "", "", 1, agv.strAgvNo, "", startPoint, endPoint, "");
if (result) MessageBox.Show("建立成功");
}
catch (Exception ex)
{
MessageBox.Show("建立失败" + ex.ToString());
}
}
private void Border_Canv_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss fff"));
//Agv agv = App.AgvList.Find(a=>a.strAgvNo == Tbox_SingleAgv.Text);
//agv.link = EnumMsg.LinkState.待连接;
//agv.action = int.Parse(Tbox_SingleTask.Text);
if (!App.SingleControlList.Exists(a => a.agvNo == Tbox_SingleAgv.Text))
{
SingleControl singleAgv = new SingleControl();
singleAgv.agvNo = Tbox_SingleAgv.Text;
singleAgv.agvAction = int.Parse(Tbox_SingleTask.Text);
App.SingleControlList.Add(singleAgv);
}
else
{
SingleControl singleAgv = App.SingleControlList.Find(a => a.agvNo == Tbox_SingleAgv.Text);
singleAgv.agvAction = int.Parse(Tbox_SingleTask.Text);
}
}
private void Border_Canv_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Released)
{
//MessageBox.Show("左键弹起");
SingleControl singleAgv = App.SingleControlList.Find(a => a.agvNo == Tbox_SingleAgv.Text);
singleAgv.agvAction = 0;
//App.SingleControlList.RemoveAll(a => a.agvNo == Tbox_SingleAgv.Text);
}
}
private void Btn_SendLift_Click(object sender, RoutedEventArgs e)
{
//if (ComBox_LiftAddress.Text == "") return;
//string[] Data = ComBox_LiftAddress.Text.Split('|');
////轮询电梯状态,操控电梯
//ComnMethod.ChangeDoor(3, 0, Data[1]);
//App.ExFile.MessageLog("SingelLift", "服务器发送关门信号");
}
private void Btn_TaskStart_Click(object sender, RoutedEventArgs e)
{
var hoist = App.HoisterList.First();
hoist.read_isFull = true;
}
}
}