Init.cs
34.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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
using XingYe_ACS.BaseStruct;
using XingYe_ACS.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XingYe_ACS.Business
{
public class Init
{
public static void InitData(ref string ErrMsg)
{
DownPoint(ref ErrMsg);
if (ErrMsg != "") return;
DownTask(ref ErrMsg);
if (ErrMsg != "") return;
DownStation(ref ErrMsg);
if (ErrMsg != "") return;
DownSonTask(ref ErrMsg);
if (ErrMsg != "") return;
DownAgv(ref ErrMsg);
if (ErrMsg != "") return;
DownPath(ref ErrMsg);
if (ErrMsg != "") return;
DownConfig(ref ErrMsg);
if (ErrMsg != "") return;
DownErrMsg(ref ErrMsg);
if (ErrMsg != "") return;
DownTaskAgvGroup(ref ErrMsg);
if (ErrMsg != "") return;
KeyValue(ref ErrMsg);
if (ErrMsg != "") return;
DownConfigPoint(ref ErrMsg);
if (ErrMsg != "") return;
DownHoister(ref ErrMsg);
if (ErrMsg != "") return;
}
/// <summary>
/// 下载点位信息
/// </summary>
/// <param name="errMsg"></param>
public static void DownPoint(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Base_Point");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Point point = new Point();
point.strBarcode = dr["strBarcode"].ToString();
point.AreaType = dr["pointAreaType"].ToString();
point.pointType = (EnumMsg.PointType)int.Parse(dr["pointType"].ToString());
point.intX = int.Parse(dr["intX"].ToString());
point.intY = 1000 - int.Parse(dr["intY"].ToString());
point.isXPos = dr["isXPos"].ToString() == "0" ? false : true;
point.isXNeg = dr["isXNeg"].ToString() == "0" ? false : true;
point.isYPos = dr["isYNeg"].ToString() == "0" ? false : true;
point.isYNeg = dr["isYPos"].ToString() == "0" ? false : true;
point.XPosLength = int.Parse(dr["XPosLength"].ToString());
point.XNegLength = int.Parse(dr["XNegLength"].ToString());
point.YPosLength = int.Parse(dr["YNegLength"].ToString());
point.YNegLength = int.Parse(dr["YPosLength"].ToString());
point.oriAgv = (EnumMsg.OriType)int.Parse(dr["OriAgv"].ToString());
point.oriDial = (EnumMsg.OriDial)int.Parse(dr["OriDial"].ToString());
point.isEnable = dr["isEnable"].ToString() == "0" ? false : true;
point.isOccupy = dr["isOccupy"].ToString() == "0" ? false : true;
point.strOccupyAgvNo = dr["strOccupyAgvNo"].ToString();
point.strRegionName = dr["strRegionName"].ToString();
point.isRegionApply = dr["isRegionApply"].ToString() == "0" ? false : true;
point.strRegionApplyAgvNo = dr["strRegionApplyAgvNo"].ToString();
point.stopTime = int.Parse(dr["stopTime"].ToString());
point.strPreBarcode = dr["strPreBarcode"].ToString();
point.intStopLevel = int.Parse(dr["intStopLevel"].ToString());
point.isStop = dr["isStop"].ToString() == "0" ? false : true;
point.tmpDirectionList = new List<TmpDirection>();
point.aroundPoint = new List<Point>();
point.lockedAgv = null;
App.PointList.Add(point);
}
foreach (Point point in App.PointList)
{
int xPos = 1;
int xNeg = 1;
int yPos = 1;
int yNeg = 1;
#region 搜索X正方向临近点
for (int i = point.intX; i < App.PointList.FindAll(a => a.AreaType == point.AreaType).Max(a => a.intX); i++)
{
point.xPosPoint = App.PointList.Find(a => a.intX == point.intX + xPos && a.intY == point.intY && a.AreaType == point.AreaType);
if (point.xPosPoint == null)
{
xPos++;
continue;
}
if (point.xPosPoint != null && point.isXPos) point.intXLength = point.XPosLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.xPosPoint);
break;
}
#endregion
#region 搜索X负方向临近点
for (int i = point.intX; i > App.PointList.FindAll(a => a.AreaType == point.AreaType).Min(a => a.intX); i--)
{
point.xNegPoint = App.PointList.FirstOrDefault(a => a.intX == point.intX - xNeg && a.intY == point.intY && a.AreaType == point.AreaType);
if (point.xNegPoint == null)
{
xNeg++;
continue;
}
if (point.xNegPoint != null && point.isXNeg) point.xNegPoint.intXLength = point.XNegLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.xNegPoint);
break;
}
#endregion
#region 搜索Y正反向临近点
for (int i = point.intY; i < App.PointList.FindAll(a => a.AreaType == point.AreaType).Max(a => a.intY); i++)
{
point.yPosPoint = App.PointList.FirstOrDefault(a => a.intX == point.intX && a.intY == point.intY + yPos && a.AreaType == point.AreaType);
if (point.yPosPoint == null)
{
yPos++;
continue;
}
if (point.yPosPoint != null && point.isYPos) point.intYLength = point.YPosLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.yPosPoint);
break;
}
#endregion
#region 搜索Y负方向临近点
for (int i = point.intY; i > App.PointList.FindAll(a => a.AreaType == point.AreaType).Min(a => a.intY); i--)
{
point.yNegPoint = App.PointList.FirstOrDefault(a => a.intX == point.intX && a.intY == point.intY - yNeg && a.AreaType == point.AreaType);
if (point.yNegPoint == null)
{
yNeg++;
continue;
}
if (point.yNegPoint != null && point.isYNeg) point.yNegPoint.intYLength = point.YNegLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.yNegPoint);
break;
}
#endregion
}
foreach (Point rePoint in App.PointList.FindAll(a => a.pointType == EnumMsg.PointType.站台点||a.pointType==EnumMsg.PointType.对接点))
{
if (rePoint.isYPos)
{
if (rePoint.yPosPoint.pointType != EnumMsg.PointType.站台点)
rePoint.strPreBarcode = rePoint.yPosPoint.strBarcode;
}
else if (rePoint.isYNeg)
{
if (rePoint.yNegPoint.pointType != EnumMsg.PointType.站台点)
rePoint.strPreBarcode = rePoint.yNegPoint.strBarcode;
}
else if (rePoint.isXPos)
{
if (rePoint.xPosPoint.pointType != EnumMsg.PointType.站台点)
rePoint.strPreBarcode = rePoint.xPosPoint.strBarcode;
}
else if (rePoint.isXNeg)
{
if (rePoint.xNegPoint.pointType != EnumMsg.PointType.站台点)
rePoint.strPreBarcode = rePoint.xNegPoint.strBarcode;
}
}
}
catch (Exception Ex)
{
errMsg = "地图点初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
public static void DownDemoPoint(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Base_DemoPoint");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Point point = new Point();
point.strBarcode = dr["strBarcode"].ToString();
point.AreaType = dr["pointAreaType"].ToString();
point.pointType = (EnumMsg.PointType)int.Parse(dr["pointType"].ToString());
point.intX = int.Parse(dr["intX"].ToString());
point.intY = 1000 - int.Parse(dr["intY"].ToString());
point.isXPos = dr["isXPos"].ToString() == "0" ? false : true;
point.isXNeg = dr["isXNeg"].ToString() == "0" ? false : true;
point.isYPos = dr["isYNeg"].ToString() == "0" ? false : true;
point.isYNeg = dr["isYPos"].ToString() == "0" ? false : true;
point.XPosLength = int.Parse(dr["XPosLength"].ToString());
point.XNegLength = int.Parse(dr["XNegLength"].ToString());
point.YPosLength = int.Parse(dr["YNegLength"].ToString());
point.YNegLength = int.Parse(dr["YPosLength"].ToString());
//point.isYPos = dr["isYPos"].ToString());
//point.isYNeg = dr["isYNeg"].ToString());
//point.YPosLength = int.Parse(dr["YPosLength"].ToString());
//point.YNegLength = int.Parse(dr["YNegLength"].ToString());
point.oriAgv = (EnumMsg.OriType)int.Parse(dr["OriAgv"].ToString());
point.oriDial = (EnumMsg.OriDial)int.Parse(dr["OriDial"].ToString());
point.isEnable = dr["isEnable"].ToString() == "0" ? false : true;
point.isOccupy = dr["isOccupy"].ToString() == "0" ? false : true;
point.strOccupyAgvNo = dr["strOccupyAgvNo"].ToString();
point.strRegionName = dr["strRegionName"].ToString();
point.isRegionApply = dr["isRegionApply"].ToString() == "0" ? false : true;
point.strRegionApplyAgvNo = dr["strRegionApplyAgvNo"].ToString();
point.stopTime = int.Parse(dr["stopTime"].ToString());
point.tmpDirectionList = new List<TmpDirection>();
point.aroundPoint = new List<Point>();
point.lockedAgv = null;
App.DemoPointList.Add(point);
}
foreach (Point point in App.DemoPointList)
{
int xPos = 1;
int xNeg = 1;
int yPos = 1;
int yNeg = 1;
#region 搜索X正方向临近点
for (int i = point.intX; i < App.DemoPointList.FindAll(a => a.AreaType == point.AreaType).Max(a => a.intX); i++)
{
point.xPosPoint = App.DemoPointList.Find(a => a.intX == point.intX + xPos && a.intY == point.intY && a.AreaType == point.AreaType);
if (point.xPosPoint == null)
{
xPos++;
continue;
}
if (point.xPosPoint != null && point.isXPos) point.intXLength = point.XPosLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.xPosPoint);
break;
}
#endregion
#region 搜索X负方向临近点
for (int i = point.intX; i > App.DemoPointList.FindAll(a => a.AreaType == point.AreaType).Min(a => a.intX); i--)
{
point.xNegPoint = App.DemoPointList.FirstOrDefault(a => a.intX == point.intX - xNeg && a.intY == point.intY && a.AreaType == point.AreaType);
if (point.xNegPoint == null)
{
xNeg++;
continue;
}
if (point.xNegPoint != null && point.isXNeg) point.xNegPoint.intXLength = point.XNegLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.xNegPoint);
break;
}
#endregion
#region 搜索Y正反向临近点
for (int i = point.intY; i < App.DemoPointList.FindAll(a => a.AreaType == point.AreaType).Max(a => a.intY); i++)
{
point.yPosPoint = App.DemoPointList.FirstOrDefault(a => a.intX == point.intX && a.intY == point.intY + yPos && a.AreaType == point.AreaType);
if (point.yPosPoint == null)
{
yPos++;
continue;
}
if (point.yPosPoint != null && point.isYPos) point.intYLength = point.YPosLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.yPosPoint);
break;
}
#endregion
#region 搜索Y负方向临近点
for (int i = point.intY; i > App.DemoPointList.FindAll(a => a.AreaType == point.AreaType).Min(a => a.intY); i--)
{
point.yNegPoint = App.DemoPointList.FirstOrDefault(a => a.intX == point.intX && a.intY == point.intY - yNeg && a.AreaType == point.AreaType);
if (point.yNegPoint == null)
{
yNeg++;
continue;
}
if (point.yNegPoint != null && point.isYNeg) point.yNegPoint.intYLength = point.YNegLength;
if (point.pointType == EnumMsg.PointType.站台点 || point.pointType == EnumMsg.PointType.回家点) point.aroundPoint.Add(point.yNegPoint);
break;
}
#endregion
}
foreach (Point rePoint in App.DemoPointList.FindAll(a => a.pointType == EnumMsg.PointType.站台点))
{
if (rePoint.isYPos) { if (rePoint.yPosPoint.pointType != EnumMsg.PointType.站台点) rePoint.yPosPoint.pointType = EnumMsg.PointType.站台附属点; rePoint.strPreBarcode = rePoint.yPosPoint.strBarcode; }
else if (rePoint.isYNeg) { if (rePoint.yNegPoint.pointType != EnumMsg.PointType.站台点) rePoint.yNegPoint.pointType = EnumMsg.PointType.站台附属点; rePoint.strPreBarcode = rePoint.yNegPoint.strBarcode; }
else if (rePoint.isXPos) { if (rePoint.xPosPoint.pointType != EnumMsg.PointType.站台点) { rePoint.xPosPoint.pointType = EnumMsg.PointType.站台附属点; } rePoint.strPreBarcode = rePoint.xPosPoint.strBarcode; }
else if (rePoint.isXNeg) { if (rePoint.xNegPoint.pointType != EnumMsg.PointType.站台点) rePoint.xNegPoint.pointType = EnumMsg.PointType.站台附属点; rePoint.strPreBarcode = rePoint.xNegPoint.strBarcode; }
}
foreach (Point rePoint in App.DemoPointList.FindAll(a => a.pointType == EnumMsg.PointType.电梯等待点))
{
if (rePoint.isXPos) { rePoint.xPosPoint.pointType = EnumMsg.PointType.电梯关门点; }
else if (rePoint.isXNeg) { rePoint.xNegPoint.pointType = EnumMsg.PointType.电梯关门点; }
else if (rePoint.isYPos) { rePoint.yPosPoint.pointType = EnumMsg.PointType.电梯关门点; }
else { rePoint.yNegPoint.pointType = EnumMsg.PointType.电梯关门点; }
}
}
catch (Exception Ex)
{
errMsg = "地图点初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
/// <summary>
/// 下载主任务信息
/// </summary>
/// <param name="errMsg"></param>
private static void DownTask(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Task");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
FTask task = new FTask();
task.strTaskNo = dr["strTaskNo"].ToString();
task.strTaskID = dr["strTaskID"].ToString();
task.strTaskGroup = dr["strTaskGroup"].ToString();
task.intTaskLevel = int.Parse(dr["intTaskLevel"].ToString());
task.strTaskBarcode = dr["strTaskBarcode"].ToString();
task.strInitial = dr["strInitial"].ToString();
task.strTarget = dr["strTarget"].ToString();
task.startPoint = App.PointList.Find(a => a.strBarcode == dr["startPoint"].ToString());
task.endPoint = App.PointList.Find(a => a.strBarcode == dr["endPoint"].ToString());
task.strAcceptTime = DateTime.Parse(dr["strAcceptTime"].ToString());
task.isTaskSubmit = dr["isTaskSubmit"].ToString() == "0" ? false : true;
task.strTaskAgv = dr["strTaskAgv"].ToString();
task.sonTaskList = new ObservableCollection<SonTask>();
task.strBeginTime = dr["strBeginTime"].ToString();
task.strEndTime = dr["strEndTime"].ToString();
//task.taskErrMsg = (EnumMsg.ErrMsg)int.Parse(dr["taskErrMsg"].ToString());
task.taskErrMsg = dr["taskErrMsg"].ToString();
task.direction = (EnumMsg.OriDial)int.Parse(dr["direction"].ToString());
App.TaskList.Add(task);
}
}
catch (Exception Ex)
{
errMsg = "主任务初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
private static void DownSonTask(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_SonTask ORDER BY strTaskNo,intSonTaskNo");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
SonTask sonTask = new SonTask();
sonTask.intSerialNo = int.Parse(dr["intSerialNo"].ToString());
sonTask.intSonTaskNo = int.Parse(dr["intSonTaskNo"].ToString());
sonTask.strTaskNo = dr["strTaskNo"].ToString();
sonTask.sonTaskType = (EnumMsg.AgvTaskType)int.Parse(dr["sonTaskType"].ToString());
sonTask.startPoint = App.PointList.Find(a => a.strBarcode == dr["startPoint"].ToString());
sonTask.endPoint = App.PointList.Find(a => a.strBarcode == dr["endPoint"].ToString());
//起点终点不再同一区域,判断
List<Point> listPoints = ComnMethod.GetAreaPoint(sonTask.startPoint, sonTask.endPoint);
sonTask.startPoint = listPoints.First();
sonTask.endPoint = listPoints.LastOrDefault();
sonTask.waitTime = int.Parse(dr["waitTime"].ToString());
sonTask.isCarry = dr["isCarry"].ToString() == "0" ? false : true;
sonTask.taskRequestType = (EnumMsg.TaskRequestType)int.Parse(dr["taskRequestType"].ToString());
sonTask.dialDirection = (EnumMsg.OriDial)int.Parse(dr["dialDirection"].ToString());
sonTask.agvDirection = (EnumMsg.OriType)int.Parse(dr["agvDirection"].ToString());
sonTask.pathPointList = new List<PathPoint>();
sonTask.sonTaskState = (EnumMsg.SonTaskState)int.Parse(dr["sonTaskState"].ToString());
sonTask.strBeginTime = dr["strBeginTime"].ToString();
sonTask.strEndTime = dr["strEndTime"].ToString();
sonTask.chargeLength = int.Parse(dr["chargeLength"].ToString());
FTask task = App.TaskList.FirstOrDefault(a => a.strTaskNo == sonTask.strTaskNo);
if (task == null)
{
App.ExFile.MessageError("SonTaskInit", sonTask.intSonTaskNo + "==" + sonTask.sonTaskType + "==" + sonTask.sonTaskState);
string sqlDelete = string.Format("DELETE FROM T_SonTask WHERE intSonTaskNo = '{0}';", sonTask.intSonTaskNo);
int sqlResult = DbHelperSQL.ExecuteSql(sqlDelete);
continue;
}
task.sonTaskList.Add(sonTask);
}
}
catch (Exception Ex)
{
errMsg = "子任务初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
private static void DownAgv(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Base_Agv");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Agv agv = new Agv();
agv.strAgvNo = dr["strAgvNo"].ToString();
agv.agvAreaType = dr["agvAreaType"].ToString();
agv.agvGroup = dr["agvGroup"].ToString();
agv.strBarcode = dr["strBarcode"].ToString();
agv.agvState = 0;
agv.heightState = 0;
agv.currentCharge = float.Parse(dr["currentCharge"].ToString());
agv.chargeTime = DateTime.Now;
agv.strChooseStation = dr["strChooseStation"].ToString() == null ? "" : dr["strChooseStation"].ToString();
agv.isEnable = dr["isEnable"].ToString() == "0" ? false : true;
agv.isOnline = false;
agv.agvTask = App.TaskList.FirstOrDefault(a => a.strTaskAgv == agv.strAgvNo);
agv.strStopReason = "";
agv.strAgvError = dr["strAgvError"].ToString() == null ? "" : dr["strAgvError"].ToString();
agv.taskTime = DateTime.Now;
agv.agvMilage = int.Parse(dr["agvMilage"].ToString());
agv.agvMap = dr["agvmap"].ToString();
agv.startCharges = float.Parse(dr["startCharges"].ToString());
agv.agvIP = dr["Ip"].ToString();
App.AgvList.Add(agv);
#region 20181003小车任务为回家任务将回家点设为Occupy
if (agv.isEnable && agv.agvTask != null && agv.agvTask.strTaskID == "回家")
{
agv.agvTask.endPoint.isOccupy = true;
agv.agvTask.endPoint.strOccupyAgvNo = agv.agvTask.strTaskNo;
}
#endregion
Point point = App.PointList.Find(a => a.strBarcode == agv.strBarcode);
if (point == null) continue;
point.lockedAgv = agv;
}
}
catch (Exception Ex)
{
errMsg = "小车初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
private static void DownPath(ref string errMsg)
{
try
{
string sql = "SELECT * FROM T_Base_PathPoint ORDER BY intSonTaskNo,intSerialNo";
DataSet ds = DbHelperSQL.Query(sql);
List<PathPoint> listPathPoint = new List<PathPoint>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
PathPoint pathPoint = new PathPoint();
pathPoint.areaType = dr["areaType"].ToString();
pathPoint.intSonTaskNo = int.Parse(dr["intSonTaskNo"].ToString());
pathPoint.intSerialNo = int.Parse(dr["intSerialNo"].ToString());
pathPoint.point = App.PointList.Find(a => a.strBarcode == dr["strBarcode"].ToString() && a.AreaType == pathPoint.areaType);
pathPoint.pathDirection = (EnumMsg.OriType)int.Parse(dr["pathDirection"].ToString());
pathPoint.isCorner = dr["isCorner"].ToString() == "0" ? false : true;
pathPoint.pathPointType = (EnumMsg.PointType)int.Parse(dr["pathPointType"].ToString());
listPathPoint.Add(pathPoint);
}
foreach (Agv agv in App.AgvList.Where(a => a.agvTask != null && a.agvTask.sonTaskList.Count != 0))
{
agv.agvTask.sonTaskList.ToList().Sort();
if (agv.agvTask.sonTaskList[0].sonTaskState < EnumMsg.SonTaskState.已建立路径)
continue;
//将此点放到对应子任务的路径中
SonTask sonTask = agv.agvTask.sonTaskList[0];
if (listPathPoint.Exists(a => a.intSonTaskNo == sonTask.intSonTaskNo))
{
sonTask.pathPointList = listPathPoint.FindAll(a => a.intSonTaskNo == sonTask.intSonTaskNo);
sonTask.pathPointList.Sort();
//GetPath.OriLock(sonTask.pathPointList, agv);
}
}
}
catch (Exception Ex)
{
errMsg = "路径初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
private static void DownConfig(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Config_TaskSplit");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Config_TaskSplit config_TaskSplit = new Config_TaskSplit();
config_TaskSplit.taskID = dr["taskID"].ToString();
config_TaskSplit.intSerialNo = int.Parse(dr["intSerialNo"].ToString());
config_TaskSplit.agvTaskType = (EnumMsg.AgvTaskType)int.Parse(dr["agvTaskType"].ToString());
config_TaskSplit.fromPoint = (EnumMsg.ConfigToFromPoint)int.Parse(dr["fromPoint"].ToString());
config_TaskSplit.toPoint = (EnumMsg.ConfigToFromPoint)int.Parse(dr["toPoint"].ToString());
config_TaskSplit.waitTime = int.Parse(dr["waitTime"].ToString());
config_TaskSplit.isCarry = dr["isCarry"].ToString() == "0" ? false : true;
config_TaskSplit.taskRequestType = (EnumMsg.TaskRequestType)int.Parse(dr["taskRequestType"].ToString());
App.Config_TaskSplitList.Add(config_TaskSplit);
}
}
catch (Exception Ex)
{
errMsg = "分解任务初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
private static void DownStation(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Base_Station");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Station station = new Station();
station.stationType = (EnumMsg.StationType)int.Parse(dr["stationType"].ToString());
station.stationArea = dr["stationArea"].ToString();
//station.stationState = (EnumMsg.StationState)int.Parse(dr["stationState"].ToString());
station.stationOri = (EnumMsg.OriType)int.Parse(dr["stationOri"].ToString());
station.stationLength = int.Parse(dr["stationLength"].ToString());
station.isEnable = dr["isEnable"].ToString() == "0" ? false : true;
station.isLocked = dr["isLocked"].ToString() == "0" ? false : true;
station.strBarcode = dr["strBarcode"].ToString();
station.strPreBarcode = dr["strPreBarcode"].ToString();
station.strStationNo = dr["strStationNo"].ToString();
//station.strRemark = dr["strRemarks"].ToString();
App.StationList.Add(station);
//if (station.stationType == EnumMsg.StationType.提升机)
//{
// WebApi.AcsPushBuild.PushLift(station);
//}
}
}
catch (Exception Ex)
{
errMsg = "站台初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
/// <summary>
/// 异常信息表
/// </summary>
/// <param name="errMsg"></param>
private static void DownErrMsg(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Config_ErrMsg");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Config_ErrMsg Err = new Config_ErrMsg();
Err.intErrorNo = int.Parse(dr["intErrorNo"].ToString());
Err.strErrorMsg = dr["strErrorMsg"].ToString();
App.Config_ErrMsgList.Add(Err);
}
}
catch (Exception Ex)
{
errMsg = "异常信息初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
/// <summary>
/// 电量控制
/// </summary>
/// <param name="errMsg"></param>
private static void KeyValue(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Config_KeyValue");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
switch (dr["KeyVariable"].ToString())
{
case "Cfull":
App.FullCharge = float.Parse(dr["Value"].ToString());
break;
case "Savety":
App.SafeCharge = float.Parse(dr["Value"].ToString());
break;
case "Danger":
App.DangerCharge = float.Parse(dr["Value"].ToString());
break;
case "MinCharges":
App.MinCharges = float.Parse(dr["Value"].ToString());
break;
default:
break;
}
}
}
catch (Exception Ex)
{
errMsg = "电量控制初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
/// <summary>
/// 任务AGV群组绑定
/// </summary>
/// <param name="errMsg"></param>
private static void DownTaskAgvGroup(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Config_TaskAgvGroup");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
TaskAgvGroup taskAgvGroup = new TaskAgvGroup();
taskAgvGroup.taskGroup = dr["taskGroup"].ToString();
taskAgvGroup.agvGroup = dr["agvGroup"].ToString();
App.TaskAgvGroupList.Add(taskAgvGroup);
}
}
catch (Exception Ex)
{
errMsg = "异常信息初始化失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
public static void DownConfigPoint(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Config_Point");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Config_Point config_Point = new Config_Point();
config_Point.intNo = int.Parse(dr["No"].ToString());
config_Point.strBarcode = dr["strBarcode"].ToString();
config_Point.areaType = dr["AreaType"].ToString();
config_Point.strRegionName = dr["strRegionName"].ToString();
App.Config_PointList.Add(config_Point);
}
}
catch (Exception Ex)
{
errMsg = "旋转区域点配置失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
public static void DownHoister(ref string errMsg)
{
try
{
string sql = string.Format("SELECT * FROM T_Base_Hoister");
DataSet ds = DbHelperSQL.Query(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Hoister hoister = new Hoister();
hoister.hoisterNo = short.Parse(dr["hoisterNo"].ToString());
hoister.hoisterAddress = dr["hoisterAddress"].ToString();
hoister.write_isGeting = dr["write_isGeting"].ToString() == "0" ? false : true;
App.HoisterList.Add(hoister);
}
}
catch (Exception Ex)
{
errMsg = "下载提升机信息失败:" + Ex.Message.Replace(Environment.NewLine, "");
}
}
}
}