分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-01-16 5884c9023393061afbe6d3d6e709e53e672ddde8
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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
var i = 1;
var j = 1;
var stack_arr = [17,16,15,14,13,12,11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
var audio = document.getElementById('music1');
var locationData = [];
 
//document.write("<script language=javascript src='hand_task_pager.js'></script>");
 
 
function CheckTab() {
    alert(1)
    $('#log-info').addClass("active");
    $('#profile').removeClass("active");
    $('#home').removeClass("active");
}
//穿梭板手动换面
function ManualHuanMian() {
    $('.from_location').css("display", "none");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("HuanMian");
}
//换轨开始
function ManualHuanGuiBegin() {
    $('.from_location').css("display", "block");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("HuanGuiBegin");
}
//堆垛机换轨
function ManualYiKu() {
    $('.from_location').css("display", "block");
    $('.to_location').css("display", "block");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("YiKu");
}
//换轨结束完成
function ManualHuanGuiEnd() {
    $('.from_location').css("display", "block");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("HuanGuiEnd");
}
//穿梭板入库
function ManualRuKu() {
    $('.from_location').css("display", "block");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("RuKu");
}
//穿梭板出库
function ManualChuKu() {
    $('.from_location').css("display", "block");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("ChuKu");
}
function ManualShuttleYiKu() {//穿梭板移库
    $('.from_location').css("display", "none");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "block");
    $('#list_type').val("ShuttleYiKu");
}
function ManualStackOutbound() {//堆垛机出库
    $('.from_location').css("display", "none");
    $('.to_location').css("display", "block");
    $('.shuttle_num').css("display", "none");
    $('#list_type').val("StackOutbound");
}
function ManualStackInbound() {///堆垛机入库
    $('.from_location').css("display", "none");
    $('.to_location').css("display", "block");
    $('.shuttle_num').css("display", "none");
    $('#list_type').val("StackInbound");
}
function ManualOnlyGet() {// 堆垛机只取
    $('.from_location').css("display", "block");
    $('.to_location').css("display", "none");
    $('.shuttle_num').css("display", "none");
    $('#list_type').val("StackOnlyGet");
}
function ManualOnlyPut() {// 堆垛机只放
    $('.from_location').css("display", "none");
    $('.to_location').css("display", "block");
    $('.shuttle_num').css("display", "none");
    $('#list_type').val("StackOnlyPut");
}
//发送指令
function SendShuttleTask() {
    var type = $('#list_type').val();
    var post_action = "";
    var sc_no = $('input[name="SD_StackNo"]:checked ').val();
    var stv_no = $('input[name="SD_STVNo"]:checked ').val();
    if (stv_no == undefined)
        stv_no = "";
    var from_address = $('#SD_FromLocation').val();
    var to_address = $('#SD_ToLocation').val();
    if ("HuanMian" == type) {
        post_action = "ManualHuanMian";
    } else if ("HuanGuiBegin" == type) {
        post_action = "ManualHuanGuiBegin";
    } else if ("YiKu" == type) {
        post_action = "ManualYiKu";
    } else if ("HuanGuiEnd" == type) {
        post_action = "ManualHuanGuiEnd";
    } else if ("RuKu" == type) {
        post_action = "ManualRuKu";
    } else if ("ChuKu" == type) {
        post_action = "ManualChuKu";
    } else if ("ShuttleYiKu" == type) {
        post_action = "ManualShuttleYiKu";
    } else if ("StackOutbound" == type) {
        post_action = "ManualStackOutbound";
    } else if ("StackInbound" == type) {
        post_action = "ManualStackInbound";
    } else if ("StackOnlyGet" == type) {
        post_action = "StackOnlyGet";
    } else if ("StackOnlyPut" == type) {
        post_action = "StackOnlyPut";
    }
    var current_url = "/AJAX/GetShuttleBoardInfo.ashx";
    if (post_action == "StackOnlyGet" || post_action == "StackOnlyPut") {
        current_url = "/AJAX/GetStackInfo.ashx";
    }
    if ("" != post_action) {
        $.ajax({
            type: "post",
            url: current_url,
            data: { action: post_action, q0: sc_no, q1: stv_no, q2: from_address, q3: to_address, q4: getUser() },
            async: false,
            success: function (msg) {
                if (msg.length > 0) {
                    swal("指令下发失败!", msg, "error");
                } else {
                    swal("指令下发成功!", "", "success");
                    clearUser();
                }
            }
        });
    }
}
//系统模式切换
function ChangeSystemMode(mode) {
    var changemode = null;
    if(mode == "AutomaticMode")
    {
        changemode = "自动模式";
    } else if (mode == "ManualMode")
    {
        changemode = "手动模式";
    }else
    {
        changemode = "异常模式";
    }
    if ("" != mode && null != mode && undefined != mode) {
        swal({
            title: "确定切换到" + changemode + "吗?",
            text: "切换后系统将变更运作方式!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定切换!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/SendTaskInfoOperation.ashx",
                data: { action: "ChangeSystemMode", q0: mode, q1: getUser() },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        $('#thisModel').val(mode);
                        swal("成功!", "当前为" + changemode, "success");
                        //刷新入库与出库任务
                        RefrashTaskInfo(1);
                        RefrashTaskOutInfo(1);
                        clearUser();
                    } else if (msg.indexOf('已切换到手动模式') != -1) {
                        $('#thisModel').val(mode);
                        swal("成功!", msg, "success");
                    }else{
                        swal("失败!", msg, "error");
                     }
                }
            });
        });
    }
}
 
//未登录按钮不可用 恢复
$('.btn-mask').click(function () {
    $('#myModal7').modal('show');
});
 
$('#mode_c').click(function () {
    var manual = "ManualMode";
    var auto = "AutomaticMode";
    var thisModel = $('#thisModel').val();
    $('#model').find('li').removeClass('model-backcolor');
    if(manual == thisModel)
    {
        $('#model').find('li:eq(0)').addClass('model-backcolor');
    } else if (auto == thisModel) {
        $('#model').find('li:eq(1)').addClass('model-backcolor');
    } else
    {
        $('#model').find('li:eq(2)').addClass('model-backcolor');
    }
});
//清除当前用户
function clearUser() {
    //$('#currentUser').val("");
    //$('.btn-mask').css("display", "block");
}
function LogBtn() {
    var username = $('#log_name').val();
    var pwd = $('#log_pwd').val();
    if ("" != username && "" != pwd) {
        $.ajax({
            type: "post",
            url: "/AJAX/OPCServiceOperation.ashx",
            data: { action: "GetUserInfo", q0: username, q1: pwd },
            async: false,
            success: function (msg) {
                if (msg.length == 0) {
                    $('#currentUser').val(username);
                    getModel();
                } else {
                    swal("登录失败!", msg, "error");
                }
                $('#myModal7').modal('hide');
                $('#log_pwd').val("");
            }
        });
    }
}
$('#myModal7').on('hidden.bs.modal', function (e) {
    var current_user = $('#currentUser').val();
    if ("" != current_user) {
        $('.btn-mask').css("display", "none");
    }
})
 
function getModel()
{
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "GetModel"},
        async: false,
        success: function (msg) {
            if (msg != "0") {
                $('#thisModel').val(msg);
            } else {
            }
        }
    });
}
// 操作者
function getUser() {
    var user = $('#currentUser').val();
    return user;
}
 
// 页面对象
//输送线
function Cline(task_no, task_state, address, tray_nbr, number, fromaddress) {
    this.task_no = task_no;//任务号
    this.task_state = task_state;//任务类型
    this.address = address;//目的地址
    this.tray_nbr = tray_nbr;//托盘条码
    this.number = number;//主键
    this.fromaddress = fromaddress;//起始地址
}
//AGV到位
function AGV_Arrive(arrive, run, leave) {
    this.arrive = arrive;//AGV到位  
    this.run = run;//接货运行
    this.leave = leave;//允许离开
}
//堆垛机
function Stacker(switch_online, switch_manual, task_no, row, col, layer, fault_code, state, number, StackToShuttleDriveBan, StackToShuttleHeartBeat) {
    this.switch_online = switch_online;//开关在线                      
    this.switch_manual = switch_manual;//正在执行任务的状态
    this.task_no = task_no;//任务序列号
    this.row = row;//排
    this.col = col;//列
    this.layer = layer;//层
    this.fault_code = fault_code;//故障码
    this.state = state;
    this.number = number;//堆垛机编号
    this.StackToShuttleDriveBan = StackToShuttleDriveBan;//堆垛机→穿梭板(驱动禁止)
    this.StackToShuttleHeartBeat = StackToShuttleHeartBeat;//堆垛机→穿梭板(心跳)
}
//穿梭板                
function STV(power, online_state, running_state, unusual_state, standby, task_no, row, col, layer, current_face, change_track_begin,
        change_track_begin_complete, change_track_end, chage_track_end_complete, down_task_sure, PLC_receive_task, shuttle_area, ShuttleAllowDeliveryOfGoods, ShuttleHeartBeat, ShuttleErrorCode,isLock) {
    this.power = power;//电量
    this.online_state = online_state;//联机状态
    this.running_state = running_state;//运行状态
    this.unusual_state = unusual_state;//异常状态
    this.standby = standby;//待机状态
    this.task_no = task_no;//任务号
    this.row = row;//当前列(行)
    this.col = col;//当前层
    this.layer = layer;//轨道顺序号(列)
    this.current_face = current_face;//当前面
    this.change_track_begin = change_track_begin;//换轨开始
    this.change_track_begin_complete = change_track_begin_complete;//换轨开始完成
    this.change_track_end = change_track_end;//换轨结束
    this.chage_track_end_complete = chage_track_end_complete;//换轨结束完成
    this.down_task_sure = down_task_sure;//任务确认下发
    this.PLC_receive_task = PLC_receive_task;//任务确认接收
    this.shuttle_area = shuttle_area;//当前区域
    this.ShuttleAllowDeliveryOfGoods = ShuttleAllowDeliveryOfGoods;//穿梭板→堆垛机(取放货允许)
    this.ShuttleHeartBeat = ShuttleHeartBeat;//穿梭板→堆垛机(心跳)
    this.ShuttleErrorCode = ShuttleErrorCode;
    this.isLock = isLock;
}
 
//输送线
var cline_1001 = new Cline();//输送线1001
var cline_1002 = new Cline();//输送线1002
var cline_1005 = new Cline();//输送线1005
var cline_1006 = new Cline();//输送线1006
var cline_1010 = new Cline();//输送线1010
//AGV到位
var agv_arrive_1 = new AGV_Arrive();
var agv_arrive_2 = new AGV_Arrive();
//堆垛机
var stacker_1 = new Stacker();//堆垛机_1
var stacker_2 = new Stacker();//堆垛机_2
//穿梭板
var stv_3 = new STV();
var stv_4 = new STV();
var stv_5 = new STV();
//光栅&安全门
var gs_1001_1 = false;
var gs_1001_2 = false;
var gs_1002_1 = false;
var gs_1002_2 = false;
var gs_1010_1 = false;
var gs_1010_2 = false;
var gs_1013_1 = false;
var gs_1013_2 = false;
var aqm_1001 = false;
var aqm_1010 = false;
 
// 页面对象
 
var interval = null;
var intervalLocation = null;
$(function () {
    $('#start-system').click(function () {
        if (i % 2 == 0) {
            // 关闭服务
            CloseOpcServer();
        } else {
            // 开启服务
            StartOpcServer();
            //interval = setInterval(GetData, 2000);
        }
        //i++;
    });
    
 
    $('#Equip_tasktype').change(function () {
        var tasktypeValue=$('option:selected', this).val() ;
        if (tasktypeValue == 'TaskType_WCS_StackGoChargeBack') {
            $('#Equip_FromLocation').val('1013');
            $('#Equip_ToLocation').val('001-019-001')
        }
        else if (tasktypeValue == 'TaskType_WCS_StackGoCharge') {
            $('#Equip_ToLocation').val('1013');
        }
        else {
            $('#Equip_FromLocation').val('');
            $('#Equip_ToLocation').val('');
        }
    });
});
//开启OPC服务
function StartOpcServer() {
    $(".stacker > li,.wire,.inshelves").css("background", "#4b5cc4");// color test    f3f9f1
    $(".alart,.boxs,.stacker > li,.wire,.inshelves").css("border", " 2px solid #bfeab1");
    $(".sign-box").css("background", "#90EE90");
    $(".hides").css("background", "white");// color test
    $(".hides").css("border", " 0px solid #bfeab1");// color test
    $('#start-system').html("关闭服务");
    i++;
    //$.ajax({
    //    type: "post",
    //    url: "/AJAX/OPCServiceOperation.ashx",
    //    data: { action: "StartOrCloseOpcServer", q0: 1 },
    //    async: false,
    //    success: function (msg) {
 
    //        if (msg.length > 0) {
    //            ShowMessage("开始服务失败:" + msg);
    //        }
    //        else {
    //            //ShowMessage("开始服务成功!");
    //            $('#menu_tab li').eq(0).addClass("active");
    //            $('#menu_tab li').eq(2).removeClass("active");
    //            //$(".roadway > li").css("background", "#90EE90");// color test
    //            $("#conveyerline_1001").css("background", "#cca4e3");// color test
    //            $(".stacker > li").css("background", "#4b5cc4");// color test
    //            $(".wire").css("background", "#4b5cc4");// color test
    //            $(".inshelves").css("background", "#4b5cc4");// color test
    //            $(".conveyerline > li").css("background", "#cca4e3");// color test
    //            $("font").css("background", "#90EE90");
    //            $('#start-system').html("关闭服务");
    //            $('#mode_c').attr("disabled", false);
    //            $('.content-right button').attr("disabled", false);
    //            $(".monitoring-area").on('click', 'a', showAction);
    //            interval = setInterval(GetPLCData, 500);
    //            intervalLocation = setInterval(GetlocationData, 5000);
    //            //GetPLCData();
    //            GetlocationData();
    //            i++;
    //            $.ajax({
    //                type: "post",
    //                url: "/AJAX/OPCServiceOperation.ashx",
    //                data: { action: "ReadModbus"},
    //                async: false,
    //                success: function (msg) {
    //                    if (msg != "成功") {
    //                        ShowMessage("开始WCS服务成功,Modbus服务开启失败:" + msg);
    //                    } else {
    //                        ShowMessage("开始WCS服务成功,Modbus服务开启成功:");
    //                    }
    //                }
    //            })
    //        }
    //    }
    //});
}
//关闭OPC服务
function CloseOpcServer() {
    $(".boxs,.stacker > li,.wire,.inshelves").css("border", " 1px solid skyblue");
    $(".sign-box").css("background", "#DADADA");
    $(".stacker > li,.inshelves,.wire").css("border", " 1px solid #f3f9f1");// color test
    $(".alart").css("border", " 1px solid skyblue");
    $(".hides").css("border", " 0px solid skyblue");// color test
    $('#start-system').html("开启服务");
    i++;
//    $.ajax({
//        type: "post",
//        url: "/AJAX/OPCServiceOperation.ashx",
//        data: { action: "StartOrCloseOpcServer", q0: 0 },
//        async: false,
//        success: function (msg) {
//            if (msg.length > 0) {
//                ShowMessage("关闭服务失败:" + msg);
//            } else {
//                //ShowMessage("服务已关闭");
//                $(".monitoring-area ul li").css("background", "white");
//                $('.stacker > li').removeClass("device-warning");
//                $("#conveyerline_1001").css("background", "#DADADA");
//                $("font").css("background", "#DADADA");
//                $('#start-system').html("开启服务");
//                $('.content-right button').attr("disabled", true);
//                $('.sign-box').css("background", "#DADADA");
//                clearInterval(interval); 
//                clearInterval(intervalLocation);
//                $('.monitoring-area').find('a').remove();
//                i++;
//                $.ajax({
//                    type: "post",
//                    url: "/AJAX/OPCServiceOperation.ashx",
//                    data: { action: "CloseModbus" },
//                    async: false,
//                    success: function (msg) {
//                        if (msg != "") {
//                            ShowMessage("WCS服务已关闭,Modbus服务关闭失败:" + msg);
//                        } else {
//                            ShowMessage("WCS服务已关闭,Modbus服务已关闭");
//                        }
//                    }
//                })
//            }
//        }
//    });
}
//获取PLC数据
function GetPLCData() {
    //GetAgvInfo();
   // GetLineInfo();
    GetConveyorHeartbeat();
    GetStackInfo();
    
    //GetShuttleBoardInfo();
    //GetAGVInfo();
    //$('.alarm-tb tr').remove();
    //GetCLErrorInfo();
    //GetSCErrorInfo();
    //GetShuttleErrorInfo();
    //setTimeout(GetPLCData, 500);
}
var lastData = "";
function GetlocationData() {
   
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "GetlocationData" },
        success: function (msg) {
            if (lastData != msg)
            {
                if (msg != null) {
                    lastData = msg;
                    $('.monitoring-area').find('a').remove();
                    var data = JSON.parse(msg);
                    data = data.Data;
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].container != null) {
                            locationData.push(data[i].container);
                            switch (data[i].container.location_line) {
                                case 1: {
                                    if (data[i].container.location_layer == 1) {
                                        GetState(data[i].container, 6, 30 - data[i].container.location_column)
                                    }
                                    if (data[i].container.location_layer == 2) {
                                        GetState(data[i].container, 7, 30 - data[i].container.location_column)
                                    }
                                    break;
                                }
                                case 2: {
                                    if (data[i].container.location_layer == 1) {
                                        GetState(data[i].container, 4, 30 - data[i].container.location_column)
                                    }
                                    if (data[i].container.location_layer == 2) {
                                        GetState(data[i].container, 3, 30 - data[i].container.location_column)
                                    }
                                    break;
                                }
                            }
                        }
                        else {
                            switch (data[i].location.location_line) {
                                case 1: {
                                    if (data[i].location.location_layer == 1) {
                                        GetState(data[i].location, 6, 30 - data[i].location.location_column)
                                    } else if (data[i].location.location_layer == 2) {
                                        GetState(data[i].location, 7, 30 - data[i].location.location_column)
                                    }
                                    break;
                                }
                                case 2: {
                                    if (data[i].location.location_layer == 1) {
                                        GetState(data[i].location, 4, 30 - data[i].location.location_column)
                                    } else if (data[i].location.location_layer == 2) {
                                        GetState(data[i].location, 3, 30 - data[i].location.location_column)
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    });
    
    //setTimeout(, 3000);
}
 
function GetState(data, row, Cloums) {
    if (data.location_state == "LocationState_Stored") {
        if (data.materiel_type == "阳极") {
            $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
                .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div  style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/Stored.png);background-size: contain"></div></a>');
        } else if (data.materiel_type == "阴极") {
            $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
                .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div  style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/Stored_Empty.png);background-size: contain"></div></a>');
        }
    }
    else if (data.location_state == "LocationState_InWaveComputing") {
        $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
            .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/InWaveComputing.png);background-size: contain"></div></a>');
    }
    else if (data.location_state == "LocationState_OutManualComputing") {
        $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
            .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/OutManualComputing.png);background-size: contain"></div></a>');
    }
    else if (data.location_state == "LocationState_Inbound_Assigned") {
        $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
            .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/Inbound_Assigned.png);background-size: contain"></div></a>');
    }
    else if (data.location_state == "LocationState_Outbound_Executing") {
        $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
            .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/Outbound_Executing.png);background-size: contain"></div></a>');
    }
    else if (data.location_state == "LocationState_Inbound_Executing") {
        $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
            .append('<a barCode = "' + data.containerhead_barcode + '" class="button_a" style="margin-top: 9px;"><div style="width: 36px;height: 35px; background-image:url(/Image/picture/ars_picture/Inbound_Executing.png);background-size: contain"></div></a>');
    }
    else if (data.location_state == "LocationState_Empty") {
 
        $(".monitoring-area ul:nth-child(" + row + ") li:nth-child(" + Cloums + ")")
            .append('<a barCode = "0" class="button_a" style="margin-top: 9px;"><div style="width: 36px;height: 35px;background: #DADADA;"></div></a>');
    }
}
 
function showAction() {
    var barcode = $(this).attr("barCode");
    if (barcode == 0) {
        swal("空货位!", "", "error");
    } else if (barcode == -1) {
        swal("货位未定义!", "", "error");
    } else {
        for (var i = 0; i < locationData.length; i++) {
            if (locationData[i].containerhead_barcode == barcode) {
                swal({
                    title: "货位信息",
                    text: "托盘号:" + barcode + "\n 物料编号:" + locationData[i].materiel_id + "\n物料名称:" + locationData[i].materiel_name + "\n物料类型:" + locationData[i].materiel_type
                        + "\n货位编号:" + locationData[i].location_id + "\n入库时间:" + locationData[i].containerdtl_createtime + "",
                    icon: "success",
                    buttons: "确定",
                });
            }
        }
    }
}
 
function GetShuttleErrorInfo()
{
    $.ajax({
        type: "post",
        url: "/AJAX/GetShuttleBoardInfo.ashx",
        data: { action: "GetShuttleErrorInfo" },
        async: false,
        success: function (msg) { }
    });
}
 
function GetCLErrorInfo() {
    $.ajax({
        type: "post",
        url: "/AJAX/GetConveyorLineInfo.ashx",
        data: { action: "GetConveyorLineErrorInfoProcess" },
        async: false,
        success: function (msg) {
            if (msg.length > 0) {
                var json = JSON.parse(msg);
                if (audio.paused) {
                    audio.play();
                }
                //console.log("输送线报警信息: " + json);
                gs_1001_1 = $.inArray('1001.1光栅报警', json) > -1 ? true : false;
                gs_1001_2 = $.inArray('1001.2光栅报警', json) > -1 ? true : false;
                gs_1002_1 = $.inArray('1002.1光栅报警', json) > -1 ? true : false;
                gs_1002_2 = $.inArray('1002.2光栅报警', json) > -1 ? true : false;
                gs_1010_1 = $.inArray('1010.1光栅报警', json) > -1 ? true : false;
                gs_1010_2 = $.inArray('1010.2光栅报警', json) > -1 ? true : false;
                gs_1013_1 = $.inArray('M01.1光栅报警', json) > -1 ? true : false;
                gs_1013_2 = $.inArray('M01.2光栅报警', json) > -1 ? true : false;
                aqm_1001 = $.inArray('1001安全门开', json) > -1 ? true : false;
                aqm_1010 = $.inArray('1010安全门开', json) > -1 ? true : false;
                for (var i = 0; i < json.length; i++) {
                    $("<tr><td>" + json[i] + "</td></tr>").appendTo(".alarm-tb");
                }
                if (gs_1001_1 == true) {
                    $('#grating_1001_1').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1001_1').removeClass('gs-warning-forhei');
                }
                if (gs_1001_2 == true) {
                    $('#grating_1001_2').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1001_2').removeClass('gs-warning-forhei');
                }
                if (gs_1002_1 == true) {
                    $('#grating_1002_1').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1002_1').removeClass('gs-warning-forhei');
                }
                if (gs_1002_2 == true) {
                    $('#grating_1002_2').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1002_2').removeClass('gs-warning-forhei');
                }
                if (gs_1010_1 == true) {
                    $('#grating_1010_1').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1010_1').removeClass('gs-warning-forhei');
                }
                if (gs_1010_2 == true) {
                    $('#grating_1010_2').addClass('gs-warning');
                } else {
                    $('#grating_1010_2').removeClass('gs-warning');
                }
                if (gs_1013_1 == true) {
                    $('#grating_1013_1').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1013_1').removeClass('gs-warning-forhei');
                }
                if (gs_1013_2 == true) {
                    $('#grating_1013_2').addClass('gs-warning-forhei');
                } else {
                    $('#grating_1013_2').removeClass('gs-warning-forhei');
                }
                if (aqm_1001 == true) {
                    $('#safe_door_G1001 .door-r').addClass('device-warning');
                    $('.door-left1001').addClass('safe-door-open1');
                    $('.door-right1001').addClass('safe-door-open2');
                } else {
                    $('#safe_door_G1001 .door-r').removeClass('device-warning');
                    $('.door-left1001').removeClass('safe-door-open1');
                    $('.door-right1001').removeClass('safe-door-open2');
                }
                if (aqm_1010 == true) {
                    $('#safe_door_G1010 .door-r').addClass('device-warning');
                    $('.door-left1010').addClass('safe-door-open1');
                    $('.door-right1010').addClass('safe-door-open2');
                } else {
                    $('#safe_door_G1010 .door-r').removeClass('device-warning');
                    $('.door-left1010').removeClass('safe-door-open1');
                    $('.door-right1010').removeClass('safe-door-open2');
                }
            } else {
                removeAllAlarm();
                if (!audio.paused) {
                    audio.pause();
                }
            }
        }
    });
}
// 移除所有报警
function removeAllAlarm() {
    $('#grating_1001_1').removeClass('gs-warning-forhei');
    $('#grating_1001_2').removeClass('gs-warning-forhei');
    $('#grating_1002_1').removeClass('gs-warning-forhei');
    $('#grating_1002_2').removeClass('gs-warning-forhei');
    $('#grating_1010_1').removeClass('gs-warning-forhei');
    $('#grating_1010_2').removeClass('gs-warning');
    $('#grating_1013_1').removeClass('gs-warning-forhei');
    $('#grating_1013_2').removeClass('gs-warning-forhei');
    $('#safe_door_G1001 .door-r').removeClass('device-warning');
    $('.door-left1001').removeClass('safe-door-open1');
    $('.door-right1001').removeClass('safe-door-open2');
    $('#safe_door_G1010 .door-r').removeClass('device-warning');
    $('.door-left1010').removeClass('safe-door-open1');
    $('.door-right1010').removeClass('safe-door-open2');
}
function GetSCErrorInfo() {
    $.ajax({
        type: "post",
        url: "/AJAX/GetStackInfo.ashx",
        data: { action: "GetStackErrorInfoProcess" },
        async: false,
        success: function (msg) {
            if (msg.length > 0) {
                var json = JSON.parse(msg);
                if (audio.paused) {
                    audio.play();
                }
                //$('#alarm').addClass("device-warning");
                for (var i = 0; i < json.length; i++) {
                    $("<tr><td>" + json[i].stack_no + json[i].error_info + "</td></tr>").appendTo(".alarm-tb");
                }
            } else {
                if (!audio.paused) {
                    audio.pause();
                }
            }
        }
    });
}
//获取输送线数据
function GetLineInfo() {
 
    $.ajax({
        type: "post",
        url: "/AJAX/GetConveyorLineInfo.ashx",
        data: { action: "GetConveyorLineProcess" },
        async: false,
        success: function (msg) {
 
            var json = JSON.parse(msg);
            for (var i = 0; i < json.length; i++) {
                var clineCon = new Cline();
                var controlNmae = "#conveyerline_";
                clineCon.number = json[i].Number;
                clineCon.task_no = json[i].TaskNumber;
                clineCon.tray_nbr = json[i].PalletNo;
                clineCon.address = json[i].ToAdresss;
                clineCon.fromaddress = json[i].FromAddress;
                controlNmae += clineCon.number;
 
                monitoringConveyerLineInfo(controlNmae, clineCon);
            }
        }
    });
}
function GetAgvInfo() {
    $.ajax({
        type: "post",
        url: "/AJAX/GetConveyorLineInfo.ashx",
        data: { action: "GetAgvInfoProcess" },
        async: false,
        success: function (msg) {
 
            var json = JSON.parse(msg);
            for (var i = 0; i < json.length; i++) {
                agv_arrive_1.arrive = json[i].AgvArrived1001;
                agv_arrive_1.run = json[i].AgvMoving1001;
                agv_arrive_1.leave = json[i].AgvAway1001;
                agv_arrive_2.arrive = json[i].AgvArrived1002;
                agv_arrive_2.run = json[i].AgvMoving1002;
                agv_arrive_2.leave = json[i].AgvAway1002;
                // AGV到位监控
                monitoringAGVArrive(agv_arrive_1, "2");
                monitoringAGVArrive(agv_arrive_2, "3");
            }
        }
    });
}
function GetConveyorHeartbeat() {
    $.ajax({
        type: "post",
        url: "/AJAX/GetConveyorLineInfo.ashx",
        data: { action: "GetConveyorLineXTProcess" },
        async: false,
        success: function (msg) {
 
            var json = JSON.parse(msg);
            for (var i = 0; i < json.length; i++) {
 
                addXTClass(json[i].ConveyorToStack1, '.cltosc1');
 
                //addXTClass(json[i].Stack1ToConveyor, '.sc1tocl');
 
                //addXTClass(json[i].ConveyorToShuttle3, '.cltostv3');
                //addXTClass(json[i].ConveyorToShuttle4, '.cltostv4');
                //addXTClass(json[i].ConveyorToShuttle5, '.cltostv5');
 
                //addXTClass(json[i].Shuttle3ToConveyor, '.stv3tocl');
                //addXTClass(json[i].Shuttle4ToConveyor, '.stv4tocl');
                //addXTClass(json[i].Shuttle5ToConveyor, '.stv5tocl');
            }
        }
    });
}
 
//获取堆垛机数据
function GetStackInfo() {
 
    $.ajax({
        type: "post",
        url: "/AJAX/GetStackInfo.ashx",
        data: { action: "GetStackInfoProcess" },
        async: false,
        success: function (msg) {
 
            var json = JSON.parse(msg);
            for (var i = 0; i < json.length; i++) {
                var stack = new Stacker();
                stack.switch_online = json[i].StackState_Receive;
                stack.fault_code = json[i].StackState_Fault;
                stack.task_no = json[i].StackTaskNo;
                stack.switch_manual = json[i].StackState_Execution;
                stack.row = json[i].StackLine;
                stack.col = json[i].StackColumn;
                //stack.layer = json[i].StackLayer;
                stack.state = json[i].StackState_Execution;
                stack.StackToShuttleDriveBan = json[i].StackToShuttleDriveBan;
                stack.StackToShuttleHeartBeat = json[i].StackToShuttleHeartBeat;
                stack.number = json[i].SCNumber;
 
                //var nbr = stack.number.substring(stack.number.length - 1);
                //var s_nbr = "#stacker_" + nbr + " > li";
 
                //if ("1" == nbr) {
                    stacker_1 = stack;
                    monitoringStacker( stacker_1, "2");
                //} else if ("2" == nbr) {
                //    stacker_2 = stack;
                //    monitoringStacker(s_nbr, stacker_2, "3");
                //}
            }
 
        }
    });
}
//获取穿梭板数据
function GetShuttleBoardInfo() {
    $.ajax({
        type: "post",
        url: "/AJAX/GetShuttleBoardInfo.ashx",
        data: { action: "GetShuttleBoardInfoProcess" },
        async: false,
        success: function (msg) {
            if (msg.length > 0) {
                var json = JSON.parse(msg);
                for (var i = 0; i < json.length; i++) {
                    var stv = new STV();
                    stv.standby = json[i].ShuttleStatus;
                    stv.online_state = json[i].ShuttleConnectingStatus;
                    stv.change_track_begin_complete = json[i].ShuttleChangeRailWayStartFinished;
                    stv.chage_track_end_complete = json[i].ShuttleChangeRailWayEndFinished;
                    stv.running_state = json[i].ShuttleMovingStatus;
                    stv.unusual_state = json[i].ShuttleErrorStatus;
                    stv.row = json[i].ShuttleRow; //行
                    stv.col = json[i].ShuttleCol; //列
                    stv.layer = json[i].ShuttleLayer; //层
                    stv.power = json[i].ShuttlePower;
                    stv.current_face = json[i].ShuttleFace;
                    stv.task_no = json[i].ShuttleTaskNum;
                    stv.change_track_begin = json[i].ShuttleChangeRailWayStart;
                    stv.change_track_end = json[i].ShuttleChangeRailWayEnd;
                    stv.down_task_sure = json[i].DownTaskSure;
                    stv.PLC_receive_task = json[i].ShuttlePLCReceivetask;
                    stv.shuttle_area = json[i].ShuttleArea;
                    stv.ShuttleAllowDeliveryOfGoods = json[i].ShuttleAllowDeliveryOfGoods;
                    stv.ShuttleHeartBeat = json[i].ShuttleHeartBeat;
                    stv.ShuttleErrorCode = json[i].ShuttleErrorCode;
 
                    stv.number = json[i].STVNumber;
 
                    // 穿梭板监控
                    if ("" != stv.number && undefined != stv.number && null != stv.number) {
                        var nbr = stv.number.substring(stv.number.length - 1);
                        if ("3" == nbr) {
                            stv_3 = stv;
                        } else if ("4" == nbr) {
                            stv_4 = stv;
                        } else if ("5" == nbr) {
                            stv_5 = stv;
                        }
                        var nbr_2 = (Number(nbr) - 1).toString();
                        stv.isLock = json[i].isLock;
                        monitoringSTV(stv, nbr_2, nbr);
                    }
                }
            }
        }
    });
}
//获取AGV数据
function GetAGVInfo() {
    $.ajax({
        type: "post",
        url: "/AJAX/GetAGVInfo.ashx",
        data: { action: "GetAGVInfoProcess" },
        async: false,
        success: function (msg) {
            $('.agv_arrived_tbs tr:gt(0)').empty();
            if (msg.length > 0) {
                var json = JSON.parse(msg);
                // AGV到位信息监控
                for (var x = 0; x < json.length; x++) {
                    //monitoringAGVArriveInfo(x + 1, agv_arrive[x]);
                    //var dt = eval(json[x].reqTime.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
                    $("<tr><td>" + json[x].method + "</td><td>" + json[x].reqCode + "</td><td>" + json[x].taskCode + "</td><td>" + json[x].userCallCode + "</td><td>"
                        + json[x].currentCallCode + "</td><td>" + json[x].item1 + "</td><td>" + json[x].reqTime + "</td></tr>").appendTo(".agv_arrived_tbs");
                }
            }
        }
    });
}
function MouseUp() {
    __doPostBack('Button_Query', "");
}
 
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
 
function AddNewOpcDetail() {
    openDlg("WebForm_ADDOPCDetails.aspx", { title: "新增", width: 850, height: 400 }, function (result) {
        if (!result) {
            // document.location = document.location
            return;
        }
    });
}
function AddNewOpcSCDetail() {
    openDlg("WebForm_ADDOPCSCDetails.aspx", { title: "新增", width: 850, height: 400 }, function (result) {
        if (!result) {
            // document.location = document.location
            return;
        }
    });
}
function AddNewOpcSTVDetail() {
    openDlg("WebForm_ADDOPCSTVDetails.aspx", { title: "新增", width: 850, height: 400 }, function (result) {
        if (!result) {
            // document.location = document.location
            return;
        }
    });
}
// 添加手动任务
function addLocalTask() {
    var equipment = $('input[name="Equip_no"]:checked').val();
    var tasktype = $('#Equip_tasktype').val();
    var tasktypeDescription = $('option[value="' + tasktype + '"]').text();
    var fromaddress = $('#Equip_FromLocation').val();
    var toaddress = $('#Equip_ToLocation').val();
    var reg = /0*([1-9]|1[0-2])-0*([1-9]|[1-2][0-9])-0*([1-4])/;
    if ("" != equipment && "" != tasktype) {
        var flag = false;
        var faddress = fromaddress.split('-');
        var taddress = toaddress.split('-');
        if (parseInt(faddress[0]) > 0 && parseInt(faddress[0]) < 3 && parseInt(faddress[1]) > 0 && parseInt(faddress[1]) < 31 && parseInt(faddress[2]) > 0 && parseInt(faddress[2]) < 3
            && parseInt(taddress[0]) > 0 && parseInt(taddress[0]) < 3 && parseInt(taddress[1]) > 0 && parseInt(taddress[1]) < 31 && parseInt(taddress[2]) > 0 && parseInt(taddress[2]) < 3)
        {
            flag = true;
        }
        if (flag == true) {
            var data = {
                "equipment": equipment,
                "tasktype": tasktype,
                "fromaddress": fromaddress,
                "toaddress": toaddress,
                "username": getUser(),
            };
            swal({
                title: "确定添加" + tasktypeDescription + "任务吗?",
                text: "此任务为手动任务!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定添加!",
                closeOnConfirm: false
            },
            function () {
                $.ajax({
                    type: "post",
                    url: "/AJAX/SendTaskInfoOperation.ashx",
                    data: { action: "AddLocalTask", q0: JSON.stringify(data) },
                    async: false,
                    success: function (msg) {
                        if ("" == msg) {
                            swal("成功!", tasktypeDescription + "已添加", "success");
                            clearUser();
                        } else {
                            swal("失败!", msg, "error");
                        }
                    }
                });
            });
        } else {
            swal("添加" + tasktypeDescription + "失败!", "货位格式验证失败", "error");
        }
    } else {
        swal("添加" + tasktypeDescription + "失败!", "未选择设备或任务类型为空", "error");
    }
}
// 穿梭板清除故障
function delShuttleError(stv_no) {
    swal({
        title: "确定清除" + stv_no + "号穿梭板故障信号吗?",
        text: "你将无法恢复到重置前的状态!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定清除!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetShuttleBoardInfo.ashx",
            data: { action: "delShuttleError", q0: stv_no, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", stv_no + "号穿梭板故障信号已经被清除", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
 
//穿梭板清除设备锁定
function delShuttleLock(stv_no) {
    swal({
        title: "确定清除" + stv_no + "号穿梭板设备锁定吗?",
        text: "你将无法恢复到重置前的状态!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定清除!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetShuttleBoardInfo.ashx",
            data: { action: "delShuttleLock", q0: stv_no, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", stv_no + "号穿梭板设备锁定已经被清除", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
 
//穿梭板开机确认
function ResetSTV() {
    var stvno = $('input[name="STVNO"]:checked ').val();
    var hang = $('#hang').val();
    var ceng = $('#ceng').val();
    if ("" != stvno && "" != hang && "" != ceng) {
        swal({
            title: "确定重置" + stvno + "号穿梭板吗?",
            text: "你将无法恢复到重置前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定重置!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/GetShuttleBoardInfo.ashx",
                data: { action: "ResetSTV", q0: getUser(), q1: stvno, q2: hang, q3: ceng },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", stvno + "号穿梭板已经被重置", "success");
                        clearUser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    } else {
        swal("失败!", "请将信息填写完整!", "error");
    }
}
//删除穿梭板握手信号
function delWSSign(stv_no) {
    swal({
        title: "确定删除" + stv_no + "穿梭板的握手信号吗?",
        text: "你将无法恢复到修改前的状态!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定完成!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetShuttleBoardInfo.ashx",
            data: { action: "delWSSign", q0: stv_no, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", stv_no + "穿梭板握手信号已删除", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 模态框
$('#myModal3').on('hidden.bs.modal', function (e) {
    // do something...
    //$('#STVNO').val("");
    $('#hang').val("");
    $('#ceng').val("");
})
//重置堆垛机
function ResetStocker(sc_no) {
    swal({
        title: "确定重置" + sc_no + "号堆垛机吗?",
        text: "你将无法恢复到重置前的状态!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定重置!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/RequestOperation/RequestOperation_2.ashx",
            data: { action: "ResetStocker", q0: getUser(), q1: sc_no },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", sc_no + "号堆垛机已经被重置", "success");
                    $('#STVNO').val("");
                    $('#hang').val("");
                    $('#ceng').val("");
                } else {
                    swal("失败!", msg, "error");
                }
 
            }
        });
    });
}
// 堆垛机报完成
function StockerCompleteTask(sc_no, state) {
    if ("1" == sc_no) {
        var task_no_1 = stacker_1.task_no;
        CompleteTask(sc_no, task_no_1, state);
    } else if ("2" == sc_no) {
        var task_no_2 = stacker_2.task_no;
        CompleteTask(sc_no, task_no_2, state);
    } else {
        swal("失败!", "未获取到设备号", "error");
    }
}
function CompleteTask(sc_no, task_no, state) {
    if ("" != task_no && undefined != task_no) {
        swal({
            title: "确定完成当前" + sc_no + "号堆垛机的任务吗?",
            text: "你将无法恢复到完成前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定完成!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/GetStackInfo.ashx",
                data: { action: "StockerCompleteTask", q0: sc_no, q1: task_no, q2: "complete", q3: getUser(), q4: state },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", sc_no + "号堆垛机已经手动完成任务", "success");
                        clearUser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    } else {
        swal("失败!", "任务号为空!", "error");
    }
}
// 堆垛机重发任务
function RepeatStocker(sc_no, state) {
    if ("1" == sc_no) {
        var task_no_1 = stacker_1.task_no;
        RepeatTask(sc_no, task_no_1, state);
    } else if ("2" == sc_no) {
        var task_no_2 = stacker_2.task_no;
        RepeatTask(sc_no, task_no_2, state);
    } else {
        swal("失败!", "未获取到设备号", "error");
    }
}
function RepeatTask(sc_no, task_no, state) {
    if ("" != task_no && undefined != task_no) {
        swal({
            title: "确定重新下发任务到" + sc_no + "号堆垛机吗?",
            text: "你将无法恢复到发送前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定重发!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/GetStackInfo.ashx",
                data: { action: "StockerCompleteTask", q0: sc_no, q1: task_no, q2: "repeat", q3: getUser(), q4: state },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", sc_no + "号堆垛机的任务已重发", "success");
                        clearUser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    } else {
        swal("失败!", "任务号为空!", "error");
    }
}
// 堆垛机回原点
function SCReturnOrigin(sc_no) {
    swal({
        title: "确定让" + sc_no + "号堆垛机回到原点吗?",
        text: "你将无法恢复到回原点前的状态!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetStackInfo.ashx",
            data: { action: "SCReturnOrigin", q0: sc_no, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", sc_no + "号堆垛机已经准备回到原点", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 模式切换按钮
function GetErrorMsg(stv_no) {
    $.ajax({
        type: "post",
        url: "/AJAX/GetShuttleBoardInfo.ashx?auto="+Math.random(),
        data: { action: "GetShuttleEquipmentInfo", q0: stv_no },
        async: false,
        success: function (msg) {
 
            if ("" != msg) {
                var json = JSON.parse(msg);
                var shuttle_no = $('input[name="STVEquipment"]').val();
                var shuttle_row = $('input[name="mc_row"]').val();
                var shuttle_col = $('input[name="mc_col"]').val();
                var shuttle_layer = $('input[name="mc_layer"]').val();
 
                if (shuttle_no != json.EQUIPMENTID)
                    $('input[name="STVEquipment"]').val(json.EQUIPMENTID);
                if (shuttle_row != json.Line)
                    $('input[name="mc_row"]').val(json.Line);
                if (shuttle_col != json.Column)
                    $('input[name="mc_col"]').val(json.Column);
                if (shuttle_layer != json.Layer)
                    $('input[name="mc_layer"]').val(json.Layer);
 
                var modelchange_1 = $('#modelchange_1').val();
                var modelchange_2 = $('#modelchange_2').val();
 
                var equipmentstate_1 = $('#equipmentstate_1').val();
                var equipmentstate_2 = $('#equipmentstate_2').val();
 
                var face_a = $('#face_a').val();
                var face_b = $('#face_b').val();
                
                if (modelchange_1 == json.IOModel)
                {
                    $('#modelchange_1').prop("checked", true);
                }
                   
                if (modelchange_2 == json.IOModel)
                {
                    $('#modelchange_2').prop("checked", true);
                }
 
                if (equipmentstate_1 == json.STATECODE)
                    $('#equipmentstate_1').prop("checked", true);
                if (equipmentstate_2 == json.STATECODE)
                    $('#equipmentstate_2').prop("checked", true);
 
                if (face_a == json.Side)
                    $('#face_a').prop("checked", true);
                if (face_b == json.Side)
                    $('#face_b').prop("checked", true);
                $('#hide-shuttle').val(json.EQUIPMENTID);
            }
        }
    });
}
// 穿梭板模式切换和数据维护保存按钮
function DelThisChangeTask() {
    var value = $('#hide-shuttle').val();
 
    var shuttle_no = $('input[name="STVEquipment"]').val();
    var shuttle_row = $('input[name="mc_row"]').val();
    var shuttle_col = $('input[name="mc_col"]').val();
    var shuttle_layer = $('input[name="mc_layer"]').val();
 
    var mc_face = $('input[name="mc_face"]:checked').val();
    var mc_modelchange = $('input[name="mc_modelchange"]:checked').val();
    var mc_equipmentstate = $('input[name="mc_equipmentstate"]:checked').val();
    var data = {
        "shuttleNo": shuttle_no,
        "shuttle_row": shuttle_row,
        "shuttle_col": shuttle_col,
        "shuttle_layer": shuttle_layer,
        "mc_face": mc_face,
        "mc_modelchange": mc_modelchange,
        "mc_equipmentstate": mc_equipmentstate
    }
 
    if ("" != value && value == shuttle_no) {
        swal({
            title: "确定修改" + value + "号穿梭板设备信息吗?",
            text: "你将无法恢复到之前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定修改!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/GetShuttleBoardInfo.ashx",
                data: { action: "ChangeShuttleModel", q0: JSON.stringify(data), q1: getUser() },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal(value + "号穿梭板模式切换成功", "success");
                        clearUser();
                    } else {
                        swal(value + "号穿梭板模式切换失败" + msg, "error");
                    }
                }
            });
        });
    } else {
        $('#hide-shuttle').val("");
        swal("信息获取错误", "error");
    }
}
// 穿梭板充电
function goCharge(stv_no) {
    swal({
        title: "确定让" + stv_no + "号穿梭板去充电吗?",
        text: "确定后将无法取消!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定充电!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetShuttleBoardInfo.ashx",
            data: { action: "GoCharge", q0: getUser(), q1: stv_no },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", stv_no + "号穿梭板已准备去充电", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 穿梭板换轨开始
function goChangeRailwayBegin(type) {
    var scno = $('input[name="SC_NO"]:checked ').val();
    var stv_no = $('input[name="HG_STVNO"]:checked ').val();
    var hang = $('#stv_nowrow').val();
    var ceng = $('#stv_nowlayer').val();
 
    if ("" != hang && "" != ceng) {
        swal({
            title: "确定让" + stv_no + "号穿梭板换轨开始吗?",
            text: "确定后将无法取消!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定换轨开始!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/GetShuttleBoardInfo.ashx",
                data: { action: "GoChangeRailwayBegin", q0: getUser(), q1: stv_no, q2: type, q3: scno, q4: hang, q5: ceng },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", stv_no + "号穿梭板已更新换轨状态", "success");
                        clearUser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    }
}
//穿梭板换轨结束完成
function goChangeRailway(stv_no, type) {
    var task_no = "";
    if ("3" == stv_no) {
        task_no = stv_3.task_no;
    } else if ("4" == stv_no) {
        task_no = stv_4.task_no;
    } else if ("5" == stv_no) {
        task_no = stv_5.task_no;
    }
    if ("" != task_no) {
        swal({
            title: "确定让" + stv_no + "号穿梭板换轨结束完成吗?",
            text: "确定后将无法取消!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定换轨结束完成!",
            closeOnConfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/AJAX/GetShuttleBoardInfo.ashx",
                data: { action: "GoChangeRailway", q0: getUser(), q1: stv_no, q2: type, q3: task_no },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", stv_no + "号穿梭板已更新换轨状态", "success");
                        clearUser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    }
}
// 修改agv信息状态
function UpdateAgvArrive() {
    var state = $('input[name="optionsRadios"]:checked ').val();
    var nbr = $('input[name="inlineRadioOptions"]:checked ').val();
    $('#myModal4').modal('hide');
    swal({
        title: "确定修改" + nbr + "的AGV到位状态吗?",
        text: "确定后将无法取消!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定修改!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetAGVInfo.ashx",
            data: { action: "UpdateAgvArrive", q0: nbr, q1: state, q2: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", nbr + "的AGV到位状态已修改", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 取消堆垛机任务
function CancelThisStackTask(sc_no) {
    swal({
        title: "确定删除" + sc_no + "的当前任务吗?",
        text: "确定后将无法取消!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定删除!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetStackInfo.ashx",
            data: { action: "CancelStackTask", q0: sc_no, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", sc_no + "的当前任务已删除", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 删除agv到位信息
function DeleteAgvArrive(nbr) {
    swal({
        title: "确定删除" + nbr + "的AGV到位任务吗?",
        text: "确定后将无法取消!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定删除!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetAGVInfo.ashx",
            data: { action: "DeleteAgvArrive", q0: nbr, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", nbr + "的AGV到位任务已删除", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 删除agv到位信号
function DeleteArriveSignal(nbr) {
    swal({
        title: "确定删除" + nbr + "的AGV到位信号吗?",
        text: "确定后将无法取消!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定删除!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetAGVInfo.ashx",
            data: { action: "DeleteArriveSignal", q0: nbr, q1: getUser() },
            async: false,
            success: function (msg) {
                if ("" == msg) {
                    swal("成功!", nbr + "的AGV到位信号已删除", "success");
                    clearUser();
                } else {
                    swal("失败!", msg, "error");
                }
            }
        });
    });
}
// 穿梭板监控
function monitoringSTV(stv, tr_no, stv_no) {
 
    if ("Shuttle3" == stv.number) {
        addXTClass(stv.ShuttleAllowDeliveryOfGoods, ".stv3_qfh");
        addXTClass(stv.ShuttleHeartBeat, ".stv3_xt");
    }
    if ("Shuttle4" == stv.number) {
        //console.log("取放货: " + stv.ShuttleAllowDeliveryOfGoods + ",心跳: " + stv.ShuttleHeartBeat);
        addXTClass(stv.ShuttleAllowDeliveryOfGoods, ".stv4_qfh");
        addXTClass(stv.ShuttleHeartBeat, ".stv4_xt");
    }
    if ("Shuttle5" == stv.number) {
        addXTClass(stv.ShuttleAllowDeliveryOfGoods, ".stv5_qfh");
        addXTClass(stv.ShuttleHeartBeat, ".stv5_xt");
    }
 
    var id = "#roadway_";
    var nbr = 0;
 
    if ("0" != stv.task_no && "" != stv.task_no && null != stv.task_no) {
        id += stv.row;// ul的id ----> 行
        nbr = Number(stv.col); // ----> 列
        //$(id + " li:eq(" + nbr + ")").css("background", "yellow");
        $("#font_stv_" + stv_no).remove();
        $(id + " > li:nth-child(" + nbr + ")").prepend($("<font id='font_stv_" + stv_no + "' style='display:block;width:100%;height:100%;line-height:46px;text-align:center;background:yellow'>" + stv.layer + "层</font>"));
    }
    $($(id + " > li:nth-child(" + nbr + ")").siblings()).css("background", "#90EE90");
    $($(id + " > li:nth-child(" + nbr + ")").siblings()).find("font").remove();
 
    if ("1" == stv.unusual_state) {
        $(id + " > li:nth-child(" + nbr + ")").css("background", "darkred");
        $(".stv_tb_s tr:nth-child(" + tr_no + ")").css("color", "white");
        $(".stv_tb_l tr:nth-child(" + tr_no + ")").css("color", "white");
        $(".stv_tb_s tr:nth-child(" + tr_no + ")").css("background", "darkred");
        $(".stv_tb_l tr:nth-child(" + tr_no + ")").css("background", "darkred");
    } else {
        $(".stv_tb_s tr:nth-child(" + tr_no + ")").css("color", "black");
        $(".stv_tb_l tr:nth-child(" + tr_no + ")").css("color", "black");
        $(".stv_tb_s tr:nth-child(" + tr_no + ")").css("background", "white");
        $(".stv_tb_l tr:nth-child(" + tr_no + ")").css("background", "white");
    }
 
    // 简述表格
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(2)").html(stv.power);
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(3)").html(stv.running_state);
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(4)").html(stv.isLock);
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(5)").html(stv.task_no);
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(6)").html(stv.row);//行
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(7)").html(stv.col);//列
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(8)").html(stv.layer);//层
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(9)").html(stv.down_task_sure);
    $(".stv_tb_s tr:nth-child(" + tr_no + ") td:nth-child(10)").html(stv.PLC_receive_task);
    // 详情表格
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(2)").html(stv.power);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(3)").html(stv.online_state);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(4)").html(stv.running_state);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(5)").html(stv.unusual_state);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(6)").html(stv.standby);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(7)").html(stv.task_no);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(8)").html(stv.row);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(9)").html(stv.col);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(10)").html(stv.layer);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(11)").html(stv.shuttle_area);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(12)").html(stv.current_face);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(13)").html(stv.change_track_begin);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(14)").html(stv.change_track_begin_complete);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(15)").html(stv.change_track_end);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(16)").html(stv.chage_track_end_complete);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(17)").html(stv.down_task_sure);
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(18)").html(stv.PLC_receive_task);
    
    $(".stv_tb_l tr:nth-child(" + tr_no + ") td:nth-child(19)").html(stv.ShuttleErrorCode);
}
 
// AGV到位信息监控
function monitoringAGVArriveInfo(tr_no, agv_arrived_info) {
    tr_no = Number(tr_no) + 1;
    // 简述表格
    $(".agv_arrived_tbs tr:nth-child(" + tr_no + ") td:nth-child(1)").html(agv_arrived_info.method);
    $(".agv_arrived_tbs tr:nth-child(" + tr_no + ") td:nth-child(2)").html(agv_arrived_info.taskCode);
    $(".agv_arrived_tbs tr:nth-child(" + tr_no + ") td:nth-child(3)").html(agv_arrived_info.userCallCode);
    $(".agv_arrived_tbs tr:nth-child(" + tr_no + ") td:nth-child(4)").html(agv_arrived_info.data);
    $(".agv_arrived_tbs tr:nth-child(" + tr_no + ") td:nth-child(5)").html(agv_arrived_info.item1);
    // 详情表格
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(1)").html(agv_arrived_info.reqCode);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(2)").html(agv_arrived_info.reqTime);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(3)").html(agv_arrived_info.clientCode);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(4)").html(agv_arrived_info.tokenCode);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(5)").html(agv_arrived_info.method);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(6)").html(agv_arrived_info.taskCode);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(7)").html(agv_arrived_info.userCallCode);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(8)").html(agv_arrived_info.currentCallCode);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(9)").html(agv_arrived_info.data);
    $(".agv_arrived_tbl tr:nth-child(" + tr_no + ") td:nth-child(10)").html(agv_arrived_info.item1);
}
 
// AGV到位监控
function monitoringAGVArrive(agv, tr_no) {
 
    if ("" != agv.arrive && null != agv.arrive) {
        $(".agv_arrive_tb tr:nth-child(" + tr_no + ") td:nth-child(2)").html(agv.arrive);
        $(".agv_arrive_tb tr:nth-child(" + tr_no + ") td:nth-child(3)").html(agv.run);
        $(".agv_arrive_tb tr:nth-child(" + tr_no + ") td:nth-child(4)").html(agv.leave);
    }
}
function addXTClass(flag, addID) {
    if (flag == "True") {
        $(addID).css("background", "#90EE90");
    } else if (flag == "False") {
        $(addID).css("background", "red");
    }
}
function addSCClass(flag, addID) {
    if (flag == "False") {
        $(addID).css("background", "red");
    } else if (flag == "True") {
        $(addID).css("background", "#90EE90");
    }
}
// 堆垛机监控
function monitoringStacker(obj, tr_no) {
 
    //if (obj.number == "SC1") {
        //console.log("驱动禁止: " + obj.StackToShuttleDriveBan + ",心跳: " + obj.StackToShuttleHeartBeat);
        //addSCClass(obj.StackToShuttleDriveBan, ".sc1_qdjz");
        addXTClass(obj.StackToShuttleHeartBeat, ".sc1_xt");
    //} else if (obj.number == "SC2") {
 
    //    addSCClass(obj.StackToShuttleDriveBan, ".sc2_qdjz");
    //    addXTClass(obj.StackToShuttleHeartBeat, ".sc2_xt");
    //}
 
    //var r = 0;
    //if ("0" != obj.task_no && "" != obj.task_no && null != obj.task_no) {
    //    r = stack_arr[Number(obj.col) - 1];
    //    $(equipment_id).eq(r).css("background", "yellow");
    //    if ("False" != obj.fault_code && "" != obj.fault_code && null != obj.fault_code) {
    //        $(equipment_id).eq(r).addClass("device-warning");
    //    } else {
    //        $(equipment_id).eq(r).removeClass("device-warning");
    //    }
    //    //$(equipment_id).eq(r).html(obj.layer + "层");
    //}
    //$($(equipment_id).eq(r).siblings()).css("background", "#4b5cc4");// color test
    //$($(equipment_id).eq(r).siblings()).removeClass("device-warning");
    //$($(equipment_id).eq(r).siblings()).html("");
 
    $(".stacker_tb tr:nth-child(" + tr_no + ") td:nth-child(2)").html(obj.switch_online);
    $(".stacker_tb tr:nth-child(" + tr_no + ") td:nth-child(3)").html(obj.task_no);
    $(".stacker_tb tr:nth-child(" + tr_no + ") td:nth-child(4)").html(obj.switch_manual);
    $(".stacker_tb tr:nth-child(" + tr_no + ") td:nth-child(5)").html(obj.col);
    //$(".stacker_tb tr:nth-child(" + tr_no + ") td:nth-child(6)").html(obj.layer);
    $(".stacker_tb tr:nth-child(" + tr_no + ") td:nth-child(6)").html(obj.fault_code);
}
 
//判断当前输送节点上的情况
function monitoringConveyerLineInfo(equipment_id, obj) {
    var str = equipment_id.substring(equipment_id.length - 4);
    var table_id = "#Cline_show_" + str;
    //alert(obj.task_no);//test test test test test test test test test test test test
    if ("0" != obj.task_no && "" != obj.task_no && null != obj.task_no) {
        $(equipment_id).css("background", "yellow");
        //if (j == 1) { // 有 bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug bug
        $(equipment_id).popover({
            trigger: 'click', //触发方式
            title: "输送机:" + str,//设置 弹出框 的标题
            html: true, // 为true的话,data-content里就能放html代码了
            placement: 'top',
            content: ContentMethod(str, obj),//这里可以直接写字符串,也可以 是一个函数,该函数返回一个字符串
            container: 'body'
        });
        //}
    } else {
        $(equipment_id).css("background", "#cca4e3");// color test
    }
 
    $(table_id + " tr:nth-child(2) td:nth-child(1)").html(obj.task_no);
    $(table_id + " tr:nth-child(2) td:nth-child(2)").html(obj.task_state);
    $(table_id + " tr:nth-child(2) td:nth-child(3)").html(obj.address);
    $(table_id + " tr:nth-child(2) td:nth-child(4)").html(obj.tray_nbr);
}
// 弹出框返回函数
function ContentMethod(equipment_id, obj) {
    return '<table id="Cline_show_' + equipment_id + '" class="table table-bordered">' +
               '<tr><td>任务号</td><td>起始地址</td><td>目的地址</td><td>托盘条码</td></tr>' +
               '<tr><td>' + obj.task_no + '</td><td>' + obj.fromaddress + '</td><td>' + obj.address + '</td><td>' + obj.tray_nbr + '</td></tr>' +
           '</table>';
}
 
//任务完成
function SendSuccessTask() {
    swal({
        title: "确定完成当前任务?",
        text: "确定后将无法取消!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定完成!",
        closeOnConfirm: false
    },
    function () {
        $.ajax({
            type: "post",
            url: "/AJAX/GetStackInfo.ashx",
            data: { action: "TaskSuccess" },
            async: false,
            success: function (msg) {
                debugger
                if (msg.length > 0) {
                    swal("指令下发失败!", msg, "error");
                } else {
                    swal("指令下发成功!", "", "success");
                    clearUser();
                }
            }
        });
    });
}
 
//任务初始化
// function TaskInitialize() {
//     swal({
//         title: "确定初始化堆垛机的任务吗?",
//         text: "确定后将无法取消!",
//         type: "warning",
//         showCancelButton: true,
//         confirmButtonColor: "#DD6B55",
//         confirmButtonText: "确定取消!",
//         closeOnConfirm: false
//     },
//         function () {
//             $.ajax({
//                 type: "post",
//                 url: "/AJAX/GetStackInfo.ashx",
//                 data: { action: "TaskInitialize", q1: getUser() },
//                 async: false,
//                 success: function (msg) {
//                     if ("" == msg) {
//                         swal("成功!", "任务已初始化", "success");
//                         clearUser();
//                     } else {
//                         swal("失败!", msg, "error");
//                     }
//                 }
//             });
//         });
// }