AC_SA_BoxBean.cs
101.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
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
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 流水线自动料仓-Box类
/// </summary>
public partial class AC_SA_BoxBean : KTK_Store
{
public DLScanSocket dlScanSocket;
private static bool IsIntSlvBlock = false;
/// <summary>
/// 开始运行
/// </summary>
public static bool IsRun = false;
public string CID = "";
public string Name = "";
public AC_SA_Config Config;
/// <summary>
/// 记录最后一次 出库的posID,出库完成发送给服务器之后清除
/// </summary>
public string lastPosId = "";
public StoreStatus lastPosIdStatus = StoreStatus.StoreOnline;
/// <summary>
/// 轴列表
/// </summary>
public List<ConfigMoveAxis> moveAxisList = new List<ConfigMoveAxis>();
/// <summary>
/// 轴报警信息
/// </summary>
private Dictionary<string, AxisAlarmInfo> AxisAlarmCodeMap = new Dictionary<string, AxisAlarmInfo>();
/// <summary>
/// 是否有压紧轴
/// </summary>
public bool IsHasCompress_Axis = true;
public bool UseBuzzer = ConfigAppSettings.GetIntValue(Setting_Init.UseBuzzer).Equals(1);
public bool UseAirBlow = ConfigAppSettings.GetIntValue(Setting_Init.UseAirBlow).Equals(1);
public int MaxScanCount = ConfigAppSettings.GetIntValue(Setting_Init.MaxScanCount);
public int CurrScanCount = 1;
//public ScanSocket scanSocket = new ScanSocket();
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
private System.Timers.Timer IoCheckTimer = new System.Timers.Timer();
private int OutStoreWaitSeconds = ConfigAppSettings.GetIntValue(Setting_Init.OutStoreWaitSeconds);
public AC_SA_BoxBean(AC_SA_Config config)
{
string msg = "{\"cid\":\"Tower-5\",\"seq\":879,\"op\":1,\"data\":{\"code\":\"=7x8=78.22610.5BLDL-017425|WG1121C4M-2105|4000|M780174250521XG83|MURATA##\",\"boxId\":\"1\",\"doorReelSignal\":\"1\"},\"status\":1,\"msg\":null,\"msgEn\":\"\",\"msgCode\":\"\",\"msgParam\":null,\"boxStatus\":{\"1\":{\"boxId\":1,\"status\":1,\"data\":{},\"msg\":\"\",\"temperature\":\"22.6\",\"humidity\":\"56.1\",\"posId\":null}},\"alarmList\":[],\"time\":1619505231653,\"lastSaveTime\":1619505231653,\"code\":\"=7x8=78.22610.5BLDL-017425|WG1121C4M-2105|4000|M780174250521XG83|MURATA##\",\"doorReelSingnal\":\"1\",\"online\":true,\"codeBoxId\":\"1\",\"posId\":null}"; Operation op = JsonHelper.DeserializeJsonToObject<Operation>(msg);
if (op.op.Equals(1))
{
ReviceInStoreProcess("aaa",op);
}
// int value= CalHeight(37);
Init();
serverConnectTimer = new System.Timers.Timer();
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = false;
serverConnectTimer.Elapsed += server_connect_timer_Tick;
IoCheckTimer = new System.Timers.Timer();
IoCheckTimer.Interval = 400;
IoCheckTimer.AutoReset = true;
IoCheckTimer.Enabled = false;
IoCheckTimer.Elapsed += IoCheckTimer_Elapsed;
//添加调试
if (config.IsInDebug == 1)
{
IsDebug = true;
}
IsHasCompress_Axis = config.IsHasCompress_Axis.Equals(1);
StoreName = ("料仓BOX_" + config.Id + " ").ToUpper();
this.StoreID = config.Id;
this.Config = config;
this.DIList = config.StoreDIList;
this.DOList = config.StoreDOList;
//Max_Humidity = config.Max_Humidity;
//Max_Temperature = config.Max_Temperature;
moveAxisList = new List<ConfigMoveAxis>();
MoveAxisConfig();
List<ACStorePosition> positionList = CSVPositionReader<ACStorePosition>.getPositionList();
PositionNumList = new List<string>();
foreach (ACStorePosition position in positionList)
{
if (position.StoreId.Equals(StoreID))
{
bool result = ACStorePosition.CheckPosition(position, Config);
if (result)
{
PositionNumList.Add(position.PositionNum);
}
}
}
LogUtil.info(StoreName + "共加载到["+positionList.Count+"]个库位,["+ PositionNumList.Count + "]个为料仓有效库位");
dlScanSocket = new DLScanSocket(config.Scanner_Ip, config.Scanner_Port, onCodeReceived);
//初始化摄像机配置
CodeManager.LoadConfig();
IOManager.Init();
//初始化 //连接设备
if (!IOManager.instance.ConnectionIOList(Config.DIODeviceNameList))
{
SetWarnMsg(ResourceControl.CustAlarm,"EtherCat PCI Card Open Fail.");
}
mainTimer.Enabled = false;
int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
if (isAuto == 1)
{
mainTimer.Enabled = true;
}
Thread.Sleep(300);
InitDoorRunMonitor();
//默认三个灯都亮
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.HIGH);
LogUtil.info(StoreName + " 初始化完成,OutStoreWaitSeconds=" + OutStoreWaitSeconds);
}
private void IoCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//判断急停
if (storeRunStatus >= StoreRunStatus.HomeMoving)
{
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
if (isInSuddenDown.Equals(false))
{
LogUtil.error(StoreName + "收到急停信号,等待100后再次验证急停");
Task.Factory.StartNew(delegate
{
Thread.Sleep(100);
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
isInSuddenDown = true;
LogUtil.error(LOGGER, StoreName + "收到急停信号,报警急停");
// WarnMsg = StoreName + "收到急停信号,报警急停";
SetWarnMsg(ResourceControl.inSuddenStop);//[1078]
//报警时会关闭所有轴
Alarm(StoreAlarmType.SuddenStop, "1", StoreMoveType.None);
}
});
}
}
else
{
//光栅处理
SafetyLightProcess();
}
}
}
/// <summary>
/// 配置速度,加减速时间
/// </summary>
public void MoveAxisConfig()
{
AC_SA_Config.ConfigAxis(Config);
moveAxisList = new List<ConfigMoveAxis>();
moveAxisList.Add(Config.Middle_Axis);
moveAxisList.Add(Config.UpDown_Axis);
moveAxisList.Add(Config.InOut_Axis);
this.AxisAlarmCodeMap = new Dictionary<string, AxisAlarmInfo>();
this.AxisAlarmCodeMap.Add(Config.UpDown_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(Config.InOut_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(this.Config.Middle_Axis.GetNameStr(), new AxisAlarmInfo());
if (Config.IsHasCompress_Axis.Equals(1))
{
moveAxisList.Add(Config.Comp_Axis);
this.AxisAlarmCodeMap.Add(this.Config.Comp_Axis.GetNameStr(), new AxisAlarmInfo());
}
}
/// <summary>
/// 开始运行
/// </summary>
public override bool StartRun()
{
LogUtil.info(LOGGER, StoreName + "开始启动,启动时间:" + StartTime.ToString());
autoNext = false;
mainTimer.Enabled = false;
alarmType = StoreAlarmType.None;
if (MaxScanCount <= 0)
{
MaxScanCount = 2;
ConfigAppSettings.SaveValue(Setting_Init.MaxScanCount, MaxScanCount);
}
//急停按钮和气压检测需要一起判断
IO_VALUE suddenBtn = IOManager.IOValue(IO_Type.SuddenStop_BTN);
//IO_VALUE airCheck = IOManager.IOValue(IO_Type.Airpressure_Check);
if (suddenBtn == IO_VALUE.HIGH)
//if (suddenBtn == IO_VALUE.HIGH && airCheck == IO_VALUE.HIGH)
{
//lastAirValue = airCheck;
lastAirCloseTime = DateTime.Now;
if (!RunAxis(true))
{
return false;
}
//TODO 启动时先所有轴远点返回,测试暂时关闭
storeRunStatus = StoreRunStatus.HomeMoving;
storeStatus = StoreStatus.ResetMove;
//启动温湿度服务器
HumitureController.Init(Config.Humiture_Port);
dlScanSocket.StartConnect();
ReturnHome();
StartTime = DateTime.Now;
mainTimer.Enabled = true;
IoCheckTimer.Enabled = true;
serverConnectTimer.Enabled = true;
IsRun = true;
return true;
}
else
{
if (suddenBtn.Equals(IO_VALUE.LOW))
{
SetWarnMsg(ResourceControl.startFail,"启动失败:急停未开");
LogUtil.error(LOGGER, " (" + StoreName + ")启动出现错误:急停没开 !启动失败!");
}
else
{
SetWarnMsg(ResourceControl.startFailAir,"启动失败:没有气压信号");
LogUtil.error(LOGGER, " (" + StoreName + ")启动出现错误:没有气压信号 !启动失败!");
}
return false;
}
}
#region 原点返回和复位处理
private void ReturnHome()
{
isNoAirCheck = false;
isInSuddenDown = false;
SetWarnMsg();
CurrInOutACount = 0;
CurrInOutCount = 0;
ClearInoutFail();
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
storeRunStatus = StoreRunStatus.HomeMoving;
StoreMove.NewMove(StoreMoveType.ReturnHome);
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack);
ACAxisHomeMove(Config.InOut_Axis);
LogUtil.info(LOGGER, StoreName + "开始原点返回,先把进出轴回原点");
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
public void MoveToP1()
{
//压紧轴回原点,叉子回到P1,关闭门旋转轴和升降轴回到P1
StoreMove.NewMove(StoreMoveType.StoreReset);
StoreMove.NextMoveStep(StoreMoveStep.BOX_M_H_TOP1_InOutToP1);
LogUtil.info(LOGGER, StoreName + "到待机状态,进出轴到P1,判断叉子没有料盘");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
// ComBeforeHomeMove();
//判断叉子没有料盘
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
}
public override void Reset()
{
Reset(true);
}
/// <summary>
/// 复位
/// </summary>
/// <param name="isNeedClearAuto">是否需要清理自动出入库</param>
public void Reset(bool isNeedClearAuto)
{
CurrInOutCount = 0;
CurrInOutACount = 0;
ClearInoutFail();
//复位之前先停止运行
if (isNeedClearAuto)
{
autoNext = false;
}
ACServerManager.SuddenStop(Config.Middle_Axis);
ACServerManager.SuddenStop(Config.UpDown_Axis);
ACServerManager.SuddenStop(Config.InOut_Axis);
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
isInSuddenDown = false;
isNoAirCheck = false;
alarmType = StoreAlarmType.None;
storeRunStatus = StoreRunStatus.Reset;
storeStatus = StoreStatus.ResetMove;
StoreMove.NewMove(StoreMoveType.StoreReset);
SetWarnMsg();
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
LogUtil.info(LOGGER, StoreName + "复位失败,急停未开");
return;
}
if (IOManager.IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
{
LogUtil.info(LOGGER, StoreName + "复位失败,没有气压信号");
//return;
}
if (!RunAxis(true))
{
LogUtil.info(LOGGER, StoreName + "复位时打开轴失败,需要再次复位,直接报警停止复位");
return;
}
mainTimer.Enabled = false;
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_LocationCylinderBack);
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
{
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(200));
}
else
{
LogUtil.info(LOGGER, StoreName + "开始复位:先定位气缸下降");
LocationDownAndWait();
}
mainTimer.Enabled = true;
isInPro = false;
}
private void InoutStartReset()
{
string portName = Config.InOut_Axis.DeviceName;
int slvAddr = Config.InOut_Axis.GetAxisValue();
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
LogUtil.info(LOGGER, StoreName + "复位中,进出轴开始原点返回");
ACAxisHomeMove(Config.InOut_Axis);
}
/// <summary>
/// 复位处理
/// </summary>
protected override void ResetProcess()
{
if (StoreMove.IsInWait)
{
CheckWait();
}
if (StoreMove.IsInWait)
{
return;
}
switch (StoreMove.MoveStep)
{
case StoreMoveStep.BOX_H_LocationCylinderBack:
InoutStartReset();
break;
//case StoreMoveStep.BOX_H_InOutMove:
// InoutStartReset();
// break;
case StoreMoveStep.BOX_H_InOutBack:
Thread.Sleep(200);
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutToP1);
LogUtil.info(LOGGER, StoreName + "复位中:进出轴到待机点P1,关闭仓门");
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(500));
//进出轴原点返回完成,将进出轴的位置设置=0
AxisCountClear(Config.InOut_Axis);
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
CloseDoor();
break;
case StoreMoveStep.BOX_H_InOutToP1:
//如果此时轴三还在报警,需要提示错误并等待
if (ACServerManager.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0)
{
LogUtil.error(LOGGER,StoreName+ "复位[" + StoreMove.MoveStep+"]过程中,进出轴报警!复位失败,请检查!");
return;
}
//复位和回原点要等轴3进出轴ORG亮了以后才能返回其他轴
LogUtil.info(LOGGER, StoreName + "复位中: 旋转轴,上下轴开始 原点返回");
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_wait);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(1000));
ACAxisHomeMove(Config.Middle_Axis);
ACAxisHomeMove(Config.UpDown_Axis);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_wait:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case StoreMoveStep.BOX_H_OtherAxisBack:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_wait2);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(1000));
LogUtil.info(LOGGER, StoreName + "复位中:压紧轴,旋转轴运动到P1,上下轴走到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_wait2:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_MiddleAxisToP1);
if (IsHasCompress_Axis)
{
ACAxisHomeMove(Config.Comp_Axis);
}
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case StoreMoveStep.BOX_H_MiddleAxisToP1:
ComMoveToPosition(Config.CompressAxis_P1_Position, Config.CompAxis_P1_Speed);
HuichuanLibrary.HCBoardManager.SetAxBacklash(Config.Middle_Axis.GetAxisValue(), Config.MiddleAxis_Reverse_Offset, Config.Middle_Axis.HomeLowSpeed, -1);
LogUtil.info(LOGGER, StoreName + "复位完成,设置旋转轴反向间隙:"+ Config.MiddleAxis_Reverse_Offset);
storeRunStatus = StoreRunStatus.Runing;
StoreMove.EndMove();
storeStatus = StoreStatus.StoreOnline;
if (alarmType.Equals(StoreAlarmType.None))
{
SetWarnMsg();
}
break;
case StoreMoveStep.BOX_M_H_TOP1_InOutToP1:
StoreMove.NextMoveStep(StoreMoveStep.BOX_M_H_TOP1_CompressHome);
LogUtil.info(LOGGER, StoreName + "到待机状态,压紧轴回原点,关闭仓门");
if (IsHasCompress_Axis)
{
ACAxisHomeMove(Config.Comp_Axis);
}
//关闭仓门
CloseDoor();
break;
case StoreMoveStep.BOX_M_H_TOP1_CompressHome:
StoreMove.NextMoveStep(StoreMoveStep.BOX_M_H_TOP1_OtherAxisToP1);
LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!");
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(1000));
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed);
break;
case StoreMoveStep.BOX_M_H_TOP1_OtherAxisToP1:
LogUtil.info(LOGGER, StoreName + "到待机状态完成");
StoreMove.EndMove();
storeStatus = StoreStatus.StoreOnline;
storeRunStatus = StoreRunStatus.Runing;
if (alarmType.Equals(StoreAlarmType.None))
{
SetWarnMsg();
}
break;
default: break;
}
}
private void ComMoveToPosition(int targetPosition, int targetSpeed)
{
if (IsHasCompress_Axis)
{
ACAxisMove(Config.Comp_Axis, targetPosition, targetSpeed);
}
}
/// <summary>
/// 原点返回处理
/// </summary>
protected override void ReturnHomeProcess()
{
if (StoreMove.IsInWait)
{
CheckWait();
}
if (StoreMove.IsInWait)
{
return;
}
switch (StoreMove.MoveStep)
{
case StoreMoveStep.BOX_H_LocationCylinderBack:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack_wait);
LogUtil.info(LOGGER, StoreName + "原点返回中,进出轴回原点");
//复位和回原点要等轴3进出轴ORG亮了以后才能返回其他轴
ACAxisHomeMove(Config.InOut_Axis);
break;
case StoreMoveStep.BOX_H_InOutBack_wait:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case StoreMoveStep.BOX_H_InOutBack:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutToP1);
LogUtil.info(LOGGER, StoreName + "原点返回中,进出轴退回P1点,关闭仓门,检测叉子没有料盘");
//进出轴原点返回完成,将进出轴的位置设置=0
AxisCountClear(Config.InOut_Axis);
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
// ComBeforeHomeMove();
//判断叉子没有料盘
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
CloseDoor();
break;
case StoreMoveStep.BOX_H_InOutToP1:
//如果此时轴三还在报警,需要提示错误并等待
if (ACServerManager.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0)
{
SetWarnMsg(ResourceControl.InoutAlarm);//1070
//WarnMsg = "进出轴报警!复位失败,请检查!";
LogUtil.error(LOGGER, "进出轴报警!复位失败,请检查!");
}
//复位和回原点要等轴3进出轴ORG亮了以后才能返回其他轴
LogUtil.info(LOGGER, StoreName + "原点返回中 :压紧轴,旋转轴,上下轴开始原点返回");
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_wait);
ACAxisHomeMove(Config.Middle_Axis);
ACAxisHomeMove(Config.UpDown_Axis);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_wait:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case StoreMoveStep.BOX_H_OtherAxisBack:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_01);
LogUtil.info(LOGGER, StoreName + "回原点:旋转轴运动到P1,上下轴到P1");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_01:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_02);
LogUtil.info(LOGGER, StoreName + "回原点:压紧轴回源点!");
if (IsHasCompress_Axis)
{
ACAxisHomeMove(Config.Comp_Axis);
}
break;
case StoreMoveStep.BOX_H_OtherAxisBack_02:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_03);
HuichuanLibrary.HCBoardManager.SetAxBacklash(Config.Middle_Axis.GetAxisValue(), Config.MiddleAxis_Reverse_Offset, Config.Middle_Axis.HomeLowSpeed, -1);
LogUtil.info(LOGGER, StoreName + "回原点完成,设置旋转轴反向间隙:" + Config.MiddleAxis_Reverse_Offset);
LogUtil.info(LOGGER, StoreName + "回原点:压紧轴到P1!");
ComMoveToPosition(Config.CompressAxis_P1_Position, Config.CompAxis_P1_Speed);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_03:
if (IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.LOW))
{
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_04);
LogUtil.info(LOGGER, StoreName + " 舱门口无盘, 执行往舱门口放盘");
}
else
{
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_MiddleAxisToP1);
LogUtil.info(LOGGER, StoreName + " 舱门口有盘, 回原结束");
}
break;
case StoreMoveStep.BOX_H_OtherAxisBack_04:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_05);
LogUtil.info(LOGGER, StoreName + " 打开舱门, 升降轴到p2");
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorIPosition_P2, Config.UpDownAxis_P2_Speed);
OpenDoor();
break;
case StoreMoveStep.BOX_H_OtherAxisBack_05:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_06);
LogUtil.info(LOGGER, StoreName + " 进出轴到p2");
var InOutAxis_DoorPosition_P2 = CSVPositionReader<ACStorePosition>.allPositionMap.First().Value.InOutAxis_DoorPosition_P2;
ACAxisMove(Config.InOut_Axis, InOutAxis_DoorPosition_P2, Config.InOutAxis_P2_Speed);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_06:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack_07);
LogUtil.info(LOGGER, StoreName + " 上下周到p8");
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorIBPosition_P8, Config.UpDownAxis_P8_Speed);
break;
case StoreMoveStep.BOX_H_OtherAxisBack_07:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_MiddleAxisToP1);
LogUtil.info(LOGGER, StoreName + " 进出轴到p1");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
break;
case StoreMoveStep.BOX_H_MiddleAxisToP1:
CloseDoor(false);
storeRunStatus = StoreRunStatus.Runing;
StoreMove.EndMove();
storeStatus = StoreStatus.StoreOnline;
SetWarnMsg();
break;
default: break;
}
}
#endregion
public bool RunAxis(bool isCheck)
{
//IOManager.IOMove(IO_Type.Run_Signal, IO_VALUE.HIGH);
Thread.Sleep(1000);
//打开所有轴
foreach (ConfigMoveAxis moveAxis in moveAxisList)
{
string portName = moveAxis.DeviceName;
short slvAddr = moveAxis.GetAxisValue();
ACServerManager.OpenPort(portName);
Thread.Sleep(50);
//初始化串口
//ACServerManager.InitSlvAddr(portName, slvAddr);
if (!IsIntSlvBlock)
{
ACServerManager.InitSlvAddr(portName, slvAddr, moveAxis.TargetSpeed, moveAxis.TargetSpeed*4, moveAxis.TargetSpeed*4);
Thread.Sleep(100);
}
ACServerManager.AlarmClear(portName, slvAddr);
Thread.Sleep(50);
ACServerManager.ServoOn(portName, slvAddr);
}
Thread.Sleep(1000);
//打开所有轴
if (isCheck)
{
if (!OpenAllAxis())
{
return false;
}
}
IsIntSlvBlock = true;
//IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.HIGH);
return true;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
private bool OpenAllAxis()
{
//判断轴是否正常
foreach (ConfigMoveAxis axis in moveAxisList)
{
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
{
LogUtil.info(LOGGER, StoreName + "成功打开轴:" + axis.Explain);
}
else
{
//清理报警,再重新打开一次
LogUtil.info(LOGGER, StoreName + "第一次打开轴" + axis.Explain + "失败,先清理一下报警,再重新打开一次");
ACServerManager.AlarmClear(axis.DeviceName, axis.GetAxisValue());
System.Threading.Thread.Sleep(1200);
ACServerManager.ServoOn(axis.DeviceName, axis.GetAxisValue());
System.Threading.Thread.Sleep(100);
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
{
LogUtil.info(LOGGER, StoreName + "清理报警后重新打卡轴成功:" + axis.Explain);
}
else
{
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue());
int alarmCode = GetAlarmCodeByAxis(axis);
SetWarnMsg(ResourceControl.OpenAxisFail,axis.DisplayStr);
// WarnMsg = StoreName + "打开轴" + axis.Explain + "失败 ";
LogUtil.info(LOGGER, StoreName +WarnObj.WarnMsg);
Alarm(StoreAlarmType.AxisAlarm, GetAlarmCodeByAxis(axis).ToString(), StoreMove.MoveType);
return false;
}
}
}
return true;
}
public void CloseAllAxis()
{
LogUtil.info(StoreName + "关闭刹车,关闭伺服");
//IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
foreach (ConfigMoveAxis axis in moveAxisList)
{
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue());
//关闭串口,等下次重新打开
// ACServerManager.ColsePort(axis.DeviceName);
}
Thread.Sleep(100);
//IOManager.IOMove(IO_Type.Run_Signal, IO_VALUE.LOW);
}
private int GetAlarmCodeByAxis(ConfigMoveAxis axis)
{
int alarmCode = LineAlarm.InOutAxisAlarm;
int axisType = axis.GetAxisValue() % 4;
if (axisType == 1)
{
alarmCode = LineAlarm.MiddleAxisAlarm;
}
else if (axisType == 2)
{
alarmCode = LineAlarm.UpDownAxisAlarm;
}
else if (axisType == 3)
{
alarmCode = LineAlarm.InOutAxisAlarm;
}
else
{
alarmCode = LineAlarm.CompressAxisAlarm;
}
return alarmCode;
}
/// <summary>
/// 停止运行
/// </summary>
public override void StopRun()
{
SetWarnMsg();
autoNext = false;
IoCheckTimer.Enabled = false;
serverConnectTimer.Enabled = false;
StopMove(true);
storeRunStatus = StoreRunStatus.Wait;
mainTimer.Enabled = false;
TimeSpan span = DateTime.Now - StartTime;
IsRun = false;
dlScanSocket.Close();
IOManager.instance.CloseAllDO();
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
}
public override void Alarm(StoreAlarmType alarmType, string alarmDetial, StoreMoveType storeMoveType)
{
//string alarmMsg,string alarmMsgEn,
SaveAlarmInfo(alarmType, alarmDetial, WarnObj.WarnMsg, WarnObj.WarnMsgEn, WarnObj.WarnMsgJp, storeMoveType);
autoNext = false;
if (this.alarmType.Equals(alarmType) && alarmType != StoreAlarmType.SuddenStop && alarmType != StoreAlarmType.NoAirCheck)
{
return;
}
LogUtil.error(LOGGER, StoreName + " 报警,报警类型:" + alarmType);
this.alarmType = alarmType;
if (alarmType.Equals(StoreAlarmType.AxisAlarm) | alarmType.Equals(StoreAlarmType.AxisMoveError))
{
LogUtil.error(LOGGER, StoreName + "轴报警,关闭刹车,停止运动,关闭轴,打开报警灯");
//IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StopMove(true);
}
else if (alarmType == StoreAlarmType.SuddenStop)
{
isInSuddenDown = true;
LogUtil.error(LOGGER, StoreName + "收到急停信号,关闭刹车,停止运动,关闭轴,打开报警灯 ");
//IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StoreMove.EndMove();
StopMove(true);
storeStatus = StoreStatus.SuddenStop;
}
else if (alarmType.Equals(StoreAlarmType.NoAirCheck))
{
isNoAirCheck = true;
LogUtil.error(LOGGER, StoreName + " 未检测到气压信号 ,打开刹车,停止运动,关闭轴,打开报警灯 ");
//IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StoreMove.EndMove();
StopMove(true);
storeStatus = StoreStatus.SuddenStop;
}
}
private bool InProcess = false;
//private DateTime preProcessTime = DateTime.Now;
private bool IsChongfu = false;
private Stopwatch stopwatch = new Stopwatch();
protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (InProcess)
{
//TimeSpan span = DateTime.Now - preProcessTime;
if (stopwatch.Elapsed.TotalMinutes < 1)
{
return;
}
else
{
LogUtil.error("主定时器:InProcess已等待" + stopwatch.Elapsed.ToString() + "重新处理");
IsChongfu = true;
}
}
try
{
InProcess = true;
//preProcessTime = DateTime.Now;
stopwatch.Restart();
IoCheckProcess();
ShowTimeLog("IoCheckProcess");
TimerProcess();
ShowTimeLog("TimerProcess");
//检查运动轴报警
if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown) && (!isNoAirCheck))
{
ShowTimeLog("开始检测轴报警");
CheckAxisAlarm();
ShowTimeLog("轴报警检测完成");
}
}
catch (Exception ex)
{
LOGGER.Error(StoreName + "定时处理出错:" + ex.ToString());
}
IsChongfu = false;
InProcess = false;
}
private IO_VALUE preAirValue = IO_VALUE.HIGH;
private void AirCheckProcess()
{
//LOGGER.Info( "UseAirBlow:" + UseAirBlow.ToString());
if (!UseAirBlow)
{
isNoAirCheck = false;
return;
}
IO_VALUE currAirValue = IOManager.IOValue(IO_Type.Airpressure_Check);
if (isInSuddenDown)
{
return;
}
if (isNoAirCheck)
{
return;
}
if (currAirValue.Equals(IO_VALUE.LOW))
{
//判断是否持续了3秒
if (preAirValue.Equals(IO_VALUE.LOW))
{
TimeSpan span = DateTime.Now - lastAirCloseTime;
if (span.TotalSeconds > Config.AirCheckSeconds)
{
//WarnMsg = "未检测到气压信号";
SetWarnMsg(ResourceControl.NoAIr);//1079
preAirValue = IO_VALUE.LOW;
//LogUtil.info("已持续【" + FormUtil.GetSpanStr(span) + "】未检测到气压信号,报警");
//Alarm(StoreAlarmType.NoAirCheck, "2", StoreMoveType.None);
return;
}
}
else
{
lastAirCloseTime = DateTime.Now;
isNoAirCheck = false;
}
}
else
{
isNoAirCheck = false;
}
preAirValue = currAirValue;
}
private void ShowTimeLog(string info)
{
if (IsChongfu)
{
LogUtil.info("【" + info + "】 处理完成,耗时:" + stopwatch.Elapsed.ToString());
}
}
private void LedProcess()
{
try
{
// 机器状态 顶灯显示
// 绿 黄 红
//机器复位中 闪 灭 灭
//机器待机中 亮 灭 灭
//机器出入库中 闪 闪 灭
//温湿度超限报警中 亮 闪 灭
//温湿度超限报警中超过30分钟 亮 闪 闪
//机器未启动 灭 灭 灭
//机器设备故障(非温湿度)报警 亮 灭 闪
//报警时只需要亮红灯
DateTime time = DateTime.Now;
bool isTemp30M = false;
if (TempOrHumidityIsAlarm)
{
TimeSpan span = DateTime.Now - TempAlarmTime;
if (span.Minutes > 30)
{
isTemp30M = true;
}
}
bool isNeedAlarmLed = false;
//报警灯
if (!alarmType.Equals(StoreAlarmType.None) || isTemp30M || InStoreFail)
{
isNeedAlarmLed = true;
}
if (isNeedAlarmLed && IOManager.IOValue(IO_Type.Alarm_HddLed).Equals(IO_VALUE.LOW))
{
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.HIGH);
}
else
{
if (IOManager.IOValue(IO_Type.Alarm_HddLed).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
}
}
//报警时绿灯和黄灯灭
if (isNeedAlarmLed)
{
if (IOManager.IOValue(IO_Type.AutoRun_HddLed).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
if (IOManager.IOValue(IO_Type.RunSign_HddLed).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
//if (UseBuzzer && IOManager.IOValue(IO_Type.Alarm_Buzzer).Equals(IO_VALUE.LOW))
//{
// IOManager.IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH);
//}
//return;
}
if (UseBuzzer && isNeedAlarmLed)
{
if (IOManager.IOValue(IO_Type.Alarm_Buzzer).Equals(IO_VALUE.LOW))
{
IOManager.IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH);
}
}
else if (IOManager.IOValue(IO_Type.Alarm_Buzzer).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW);
}
//绿灯闪
if ((StoreMove.MoveType.Equals(StoreMoveType.InStore) || StoreMove.MoveType.Equals(StoreMoveType.OutStore)
|| storeRunStatus.Equals(StoreRunStatus.HomeMoving) || storeRunStatus.Equals(StoreRunStatus.Reset))
&& IOManager.IOValue(IO_Type.AutoRun_HddLed).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
else
{
//绿灯亮
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
}
//黄灯
if (StoreMove.MoveType.Equals(StoreMoveType.InStore) || StoreMove.MoveType.Equals(StoreMoveType.OutStore) || TempOrHumidityIsAlarm || isTemp30M)
{
if (IOManager.IOValue(IO_Type.RunSign_HddLed).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
}
else
{
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
}
}
else
{
if (IOManager.IOValue(IO_Type.RunSign_HddLed).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
}
}
//仓门打开,打开照明
if (Config.StoreDOList.ContainsKey(IO_Type.Device_Led))
{
bool doorIsOpen = false;
if (IOManager.IOValue(IO_Type.Door_Limit).Equals(IO_VALUE.LOW))
{
doorIsOpen = true;
}
else if (Config.StoreDIList.ContainsKey(IO_Type.Door_LeftLimit) && IOManager.IOValue(IO_Type.Door_LeftLimit).Equals(IO_VALUE.LOW))
{
doorIsOpen = true;
}
else if (Config.StoreDIList.ContainsKey(IO_Type.Door_RightLimit) && IOManager.IOValue(IO_Type.Door_RightLimit).Equals(IO_VALUE.LOW))
{
doorIsOpen = true;
}
//else if (!doorIsOpen)
//{
// doorIsOpen = true;
//}
if (doorIsOpen)
{
if (IOManager.IOValue(IO_Type.Device_Led).Equals(IO_VALUE.LOW))
{
IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.HIGH);
}
}
//else
//{
// if (IOManager.IOValue(IO_Type.Device_Led).Equals(IO_VALUE.HIGH))
// {
// IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.LOW);
// }
//}
}
}
catch (Exception ex)
{
LOGGER.Error(StoreName + "灯处理定时器出错:", ex);
}
}
private IO_VALUE lastAutoRun = IO_VALUE.LOW;
private IO_VALUE lastAirValue = IO_VALUE.LOW;
public void IoCheckProcess()
{
DateTime time = DateTime.Now;
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
//取新的Io状态
IO_VALUE autoSingle = IOManager.IOValue(IO_Type.AutoRun_Signal);
if (ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1))
{
if (autoSingle.Equals(IO_VALUE.HIGH) && lastAutoRun.Equals(IO_VALUE.LOW))
{
//没有启动时收到复位按钮,相当于启动按钮
LogUtil.info(LOGGER, StoreName + "没有启动时收到复位按钮,相当于启动按钮,开始调用启动方法!");
bool result = StartRun();
if (result.Equals(false))
{
LogUtil.error("料仓启动失败,继续等待下次启动!");
mainTimer.Enabled = true;
}
}
lastAutoRun = autoSingle;
return;
}
lastAutoRun = autoSingle;
}
//判断急停
else if (storeRunStatus >= StoreRunStatus.HomeMoving)
{
//急停按钮
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
return;
}
else if (IOManager.IOValue(IO_Type.Reset_BTN).Equals(IO_VALUE.HIGH))
{
//收到复位信号,若报警直接复位,若不报警且无操作,回到待机点
if (alarmType.Equals(StoreAlarmType.None) && isInSuddenDown.Equals(false) && isNoAirCheck.Equals(false))
{
if (StoreMove.MoveType.Equals(StoreMoveType.None))
{
LogUtil.info(LOGGER, "收到复位信号但是没有报警,且当前无操作,只回到待机点");
MoveToP1();
}
else
{
LogUtil.info(LOGGER, "收到复位信号但是已经在" + StoreMove.MoveType + "处理中,且无报警,不处理");
//WarnMsg = "收到复位信号但是已经在" + StoreMove.MoveType + "处理中,且无报警,不处理";
}
}
else
{
//判断已经在复位中并且没有报警,不需要重新复位
if (StoreMove.MoveType.Equals(StoreMoveType.StoreReset) && alarmType.Equals(StoreAlarmType.None))
{
LogUtil.error(LOGGER, "收到复位信号:已经在复位中且没有报警,不需要重新复位!");
}
else
{
//收到复位信号
LogUtil.info(LOGGER, "收到复位信号,自动复位");
//WarnMsg = "收到复位信号,自动复位";
SetWarnMsg(ResourceControl.AutoReset);
Reset();
}
}
}
AirCheckProcess();
}
//ShowTimeLog("复位和启动按钮");
////检查运动轴报警
//if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown) )
//{
// ShowTimeLog("开始检测轴报警");
// CheckAxisAlarm();
// ShowTimeLog("轴报警检测完成");
//}
}
private object safetyInProcess = "";
/// <summary>
/// 光栅处理
/// </summary>
private void SafetyLightProcess()
{
if (Monitor.TryEnter(safetyInProcess))
{
try
{
//遮挡光栅信号
if (IOManager.IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW))
{
if (NeedCheckSafetyLight.Equals(1))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("入库SI_05_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
}
}
}
else
{
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SO_10_DeviceToDoorPro();
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
LOGGER.Info("入库SI_05_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SI_05_DeviceToDoor();
}
}
}
}
catch (Exception ex)
{
LogUtil.error("光栅处理出错:" + ex.ToString());
}
finally
{
Monitor.Exit(safetyInProcess);
}
}
}
public void TimerProcess()
{
try
{
DateTime time = DateTime.Now;
if (StoreMove.MoveType != StoreMoveType.None)
{
BusyMoveProcess();
ShowTimeLog("BusyMoveProcess");
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing))
{
//判断是否需要出入库
if (StoreMove.MoveType.Equals(StoreMoveType.None) && alarmType.Equals(StoreAlarmType.None))
{
IO_VALUE checkIO = IOManager.IOValue(IO_Type.TrayCheck_Door);
int height = GetHeight();
//判断料门口是否有料
//光栅不遮挡时才扫码
if ((checkIO.Equals(IO_VALUE.HIGH)) &&IOManager.IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.HIGH)&& height > 0 )
{
if (!CanStartCode() || IsDebug || InStoreFail)// || IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
// return;
}
//检测到料盘,等待1秒后扫码
else
{
if (isWaitScan)
{
TimeSpan span = DateTime.Now - StartWaitScanTime;
if (span.TotalSeconds > 1 && CanStartCode())
{
isWaitScan = false;
IsScanCode = true;
CurrScanCount++;
LogUtil.info(StoreName + "[" + CurrScanCount + "]检测到" + height + "mm料盘,开始扫码");
//GetCameraCode();
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanTime = DateTime.Now;
var isdl = dlScanSocket.BeginScan();
LogUtil.info(StoreName + "DL扫码枪="+isdl);
if (!isdl)
{
Task.Run(() =>
{
List<string> codelist;
var IsServerAccess = CodeManager.IsServerAccess();
LogUtil.info(StoreName + "IsServerAccess=" + IsServerAccess);
if (IsServerAccess)
{
codelist = new List<string>() { "server" };
}
else
{
codelist = CodeManager.CameraScan();
}
onCodeReceived(codelist.ToArray());
});
}
}
}
else
{
isWaitScan = true;
StartWaitScanTime = DateTime.Now;
}
}
}
else
{
ClearInoutFail();
isWaitScan = false;
}
}
ShowTimeLog("判断是否需要出入库");
AutoResetProcess();
ShowTimeLog("AutoResetProcess");
IOTimeOutProcess();
ShowTimeLog("IOTimeOutProcess");
}
}
catch (Exception ex)
{
LOGGER.Error(StoreName + "定时处理出错", ex);
}
}
private DateTime preIoTimerOutTime = DateTime.Now;
/// <summary>
/// io检测异常
/// </summary>
private void IOTimeOutProcess()
{
try
{
TimeSpan span = DateTime.Now - preIoTimerOutTime;
if (span.TotalSeconds > 1)
{
preIoTimerOutTime = DateTime.Now;
if (!alarmType.Equals(StoreAlarmType.IoSingleTimeOut))
{
return;
}
if (storeRunStatus < StoreRunStatus.Runing)
{
return;
}
if (isInSuddenDown || isNoAirCheck)
{
return;
}
//若BOX和移栽都没有在等待Io的过程中则此Io超时异常可能已经处理过
if (StoreMove.IsInWait == false)
{
LogUtil.info(StoreName + "之前有IO超时异常【" + alarmInfo.alarmDetail + "】,但是当前已经没有在等待中,清理信号超时异常!");
alarmType = StoreAlarmType.None;
SetWarnMsg();
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "IOTimeOutProcess出错:" + ex.ToString());
}
}
/// <summary>
/// 超过配置次数时需要复位
/// </summary>
private void AutoResetProcess()
{
try
{
if (CurrInOutACount >= this.Config.Box_ResetACount)
{
if (storeRunStatus < StoreRunStatus.Runing || StoreMove.MoveType == StoreMoveType.InStore || StoreMove.MoveType == StoreMoveType.OutStore)
{
LogUtil.info(LOGGER, StoreName + "已经累计出入库" + CurrInOutACount + "次,当时当前正在忙碌中暂不复位");
}
else
{
LogUtil.info(LOGGER, StoreName + "已经累计出入库" + CurrInOutACount + "次,需要复位一下");
Reset();
}
}
//else if (CurrInOutCount >= this.Config.Box_ResetMCount)
//{
// if (storeRunStatus < StoreRunStatus.Runing || StoreMove.MoveType == StoreMoveType.InStore || StoreMove.MoveType == StoreMoveType.OutStore)
// {
// LogUtil.info(LOGGER, StoreName + "已经累计出入库" + CurrInOutCount + "次,当时当前正在忙碌中暂不复位旋转轴");
// }
// else
// {
// LogUtil.info(LOGGER, StoreName + "已经累计出入库" + CurrInOutCount + "次,需要复位一下旋转轴");
// }
//}
else if(!IsDebug)
{
//调试状态不处理出库任务
FixtureCodeInfo currInOutFixture = null;
lock (waitOutListLock)
{
if (waitOutStoreList.Count > 0 && CanStarInOut())
{
currInOutFixture = waitOutStoreList[0];
waitOutStoreList.RemoveAt(0);
}
}
if (currInOutFixture != null)
{ //出库
if (currInOutFixture.WareNum.Equals(""))
{
LogUtil.info(LOGGER, StoreName + "开始执行排队中的出库【" + currInOutFixture.ToStr() + "】");
bool result = StartOutStoreMove(new InOutStoreParam("", currInOutFixture.PosId, currInOutFixture.plateH, currInOutFixture.plateW));
if (!result)
{
LogUtil.info(LOGGER, StoreName + " 执行排队中的出库【" + currInOutFixture.ToStr() + "】失败,重新加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "处理出入库排队列表出错:" + ex.ToString());
}
}
/// <summary>
/// 判断是否报警,返回 true表示报警 报警检测2秒钟检测一次
/// </summary>
/// <returns></returns>
private DateTime checkAlarmTime = DateTime.Now;
public bool CheckAxisAlarm()
{
if (alarmType.Equals(StoreAlarmType.AxisAlarm) || alarmType.Equals(StoreAlarmType.AxisMoveError))
{
return true;
}
TimeSpan span = DateTime.Now - checkAlarmTime;
//在回原点,复位,出入库时,检测报警间隔减小
if (storeRunStatus.Equals(StoreRunStatus.Busy) || storeRunStatus.Equals(StoreRunStatus.HomeMoving) || storeRunStatus.Equals(StoreRunStatus.Reset))
{
if (span.TotalSeconds < 1)
{
return false;
}
}
else
{
if (span.TotalSeconds < 3)
{
return false;
}
}
checkAlarmTime = DateTime.Now;
bool isInAlarm = false;
//Task.Factory.StartNew(delegate
// {
foreach (ConfigMoveAxis axisInfo in moveAxisList)
{
short axis = axisInfo.GetAxisValue();
string deviceName = axisInfo.GetNameStr();
AxisAlarmInfo info = AxisAlarmCodeMap[deviceName];
int alarmIo = ACServerManager.GetAlarmStatus(deviceName, axis);
if (alarmIo == 1)
{
//WarnMsg = StoreName + " 运动轴" + axisInfo.Explain + "报警";
SetWarnMsg(ResourceControl.AxisAlarm, axisInfo.DisplayStr);//1080
info.AlarmIoValue = alarmIo;
Alarm(StoreAlarmType.AxisAlarm, GetAlarmCodeByAxis(axisInfo).ToString(), StoreMoveType.None);
isInAlarm = true;
}
else
{
if (!info.AlarmIoValue.Equals(alarmIo))
{
LogUtil.error(LOGGER, StoreName + " 运动轴 " + axisInfo.Explain + ",报警已解除!");
info.AlarmIoValue = alarmIo;
}
}
AxisAlarmCodeMap[deviceName] = info;
}
//});
//判断报警状态
return isInAlarm;
}
/// <summary>
/// 停止所有运行
/// </summary>
public override void StopMove(bool IsCloseAxis)
{
//IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
//运动版停止
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
DoorStop();
if (IsHasCompress_Axis)
{
ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue());
// ShuoKeControls.SuddownStop(Config.CompressAxis_Slv);
}
else
{
if (Config.IsHasLocationCylinder >= 1)
{
//定位气缸停止
//IOManager.IOMove(IO_Type.LocationCylinder_Down, IO_VALUE.LOW);
//IOManager.IOMove(IO_Type.LocationCylinder_Up, IO_VALUE.LOW);
}
}
if (IsCloseAxis)
{
CloseAllAxis();
}
LogUtil.info(LOGGER, StoreName + "StopMove");
isInPro = false;
}
/// <summary>
/// 判断是可以开始出入库(当前在忙碌状态则需要排队等待)
/// </summary>
/// <returns></returns>
public bool CanStarInOut()
{
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.OutStoreExecute)
|| storeStatus.Equals(StoreStatus.InStoreEnd)
|| storeStatus.Equals(StoreStatus.OutStoreBoxEnd)
|| storeStatus.Equals(StoreStatus.OutStorEnd)
)
{
return false;
}
return true;
}
#region datalogic扫码枪代码
private bool isWaitScan = false;
private DateTime StartWaitScanTime = DateTime.Now;
private bool InStoreFail = false;
private bool IsScanCode = false;
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="message"></param>
private void onCodeReceived(string[] codeList)
{
try
{
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
string message = ProcessCode(codeList);
message = ScanCodeManager.ReplaceCode(message);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg =ResourceControl.GetChinaString(ResourceControl.NoCodeMsg, "没有收到二维码信息,请重新放入料盘");
CodeMsgEn = ResourceControl.GetEnglishString(ResourceControl.NoCodeMsg, "没有收到二维码信息,请重新放入料盘");
if (CurrScanCount >= MaxScanCount)
{
InStoreFail = true;
LogUtil.info(LOGGER, StoreName + "[" + CurrScanCount + "]未收到二维码,请重新放入料盘,通知服务器未扫到条码");
//TODO 向服务器发送未扫到码消息
//发送扫码内容到服务器进行入库操作
Operation operationT = getLineBoxStatus();
operationT.op = 1;
int dInfo = (int)IOManager.IOValue(IO_Type.TrayCheck_Door);
operationT.data = new Dictionary<string, string>() { { "code", message }, { "boxId", StoreID.ToString() }, { ParamDefine.doorReelSignal, dInfo.ToString() } };
HttpHelper.Post(StoreManager.GetPostApi(server), operationT, false);
}
else
{
LogUtil.info(LOGGER, StoreName + "[" + CurrScanCount + "]未收到二维码,请重新放入料盘");
}
IsScanCode = false;
return;
}
// InStoreFail = false;
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogUtil.info(LOGGER, StoreName + "二维码【 " + message + "】,设备未启动,不需要发送服务器");
IsScanCode = false;
return;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.info(LOGGER, StoreName + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
int doorReelSignal = (int)IOManager.IOValue(IO_Type.TrayCheck_Door);
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", StoreID.ToString() }, { ParamDefine.doorReelSignal, doorReelSignal.ToString() } };
// string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
LogUtil.info(LOGGER, StoreName + "二维码【" + message + "】没有收到服务器反馈!");
IsScanCode = false;
return;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
InStoreFail = true;
LogUtil.info(LOGGER, StoreName + " 二维码【" + message + "】 服务器反馈 :" + resultOperation.msg);
IsScanCode = false;
return;
}
IsScanCode = false;
if (resultOperation.op.Equals(1))
{
ReviceInStoreProcess(message, resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
IsScanCode = false;
LOGGER.Error(StoreName + ex.ToString());
}
}
private void ReviceInStoreProcess(string message, Operation resultOperation)
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
string plateW = data[ParamDefine.plateW];
string plateH = data[ParamDefine.plateH];
//string[] posArray = posId.Split('#');
//if (!(posArray.Length == 2))
//{
// InStoreFail = true;
// //WarnMsg = StoreName + "入库库位格式错误:二维码【" + message + "】库位【" + posId + "】";
// SetWarnMsg(ResourceControl.InStoreError, message, posId);
// LogUtil.error(LOGGER, "服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
// LogUtil.info(LOGGER, "服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
// return;
//}
//int storeId = int.Parse(posArray[0]);
//根据发送的posId获取位置列表
ACStorePosition position = CSVPositionReader<ACStorePosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
InStoreFail = true;
SetWarnMsg(ResourceControl.InStoreNoPosition, message, posId);//[1081]
// WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(LOGGER, "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
LogUtil.info(LOGGER, "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return;
}
//TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器;
if (CanStarInOut())
{
ClearInoutFail();
InOutStoreParam param = new InOutStoreParam(message, posId, plateH, plateW, 0);
StartInStoreMove(param);
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
}
else
{
InStoreFail = true;
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 正在忙碌中,无法入库!");
IsScanCode = false;
}
}
}
private void ClearInoutFail()
{
CodeMsg = "";
CurrScanCount = 0;
InStoreFail = false;
IsScanCode = false;
}
#endregion
#region Halcon扫码枪代码
private DateTime LastScanTime = DateTime.Now;
public void GetCameraCode()
{
if (CanStartCode())
{
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanTime = DateTime.Now;
dlScanSocket.BeginScan();
Task.Run(() => {
var codelist = CodeManager.CameraScan();
onCodeReceived(codelist.ToArray());
});
}
else
{
LogUtil.info("GetCameraCode()开始扫码失败,请等待上次扫码结束");
}
}
private bool CanStartCode()
{
TimeSpan span = DateTime.Now - LastScanTime;
if (IsScanCode && span.TotalSeconds < 10)
{
return false;
}
return true;
}
public string spiltStr = "##";
private string ProcessCode(string[] codeList)
{
string message = "";
string codeSize = "";
List<string> codelists = new List<string>(codeList);
//= 7x12 = CODE
foreach (string code in codelists.ToArray())
{
if (code.Trim().Length > 5)
continue;
//根据二维码开头获取固定尺寸
codeSize = Config.GetCodeSize(code.Trim());
if (!String.IsNullOrEmpty(codeSize))
{
LogUtil.info(Name + "夹具弃用条码【" + codeSize + "】:" + code);
codelists.Remove(code);
break;
//message = message + "=" + "1+0x0-" + codeSize + "=" + code + dlScanSocket.spiltStr;
}
}
if (String.IsNullOrEmpty(codeSize))
{
//无固定尺寸,判断宽度是否是固定,如果不是固定,直接获取当前高度宽度
codeSize = GetSize() + "x" + GetHeight();
if (codeList.Count() == 1 && codeList[0] == "server") {
codeSize = IOManager.IOValue(IO_Type.TrayCheck_Door_13).Equals(IO_VALUE.HIGH)?"13":"7" + "x0";
}
}
foreach (string code in codelists.ToArray())
{
message = message + "=" + "1+0x0-" + codeSize + "=" + code + dlScanSocket.spiltStr;
}
return message;
}
#endregion
#region 高度传感器处理
private int Width_7 = 7;
private int Width_13 = 13;
private int Width_15 = 15;
// 0、1对应7寸盘,2,3对应13寸盘
public int GetSize()
{
if (Config.Default_TrayWidth > 0)
{
//如果配置了默认宽度,使用默认宽度且不能修改
return Config.Default_TrayWidth;
}
if (Config.AIDI3_Addr < 0 || Config.AIDI4_Addr <= 0)
{
return Width_7;
}
else if (Config.AIDI1_Addr < 0 || Config.AIDI2_Addr < 0)
{
return Width_13;
}
if (GetBiglHeight(15) > 0)
{
return Width_15;
}
else if (GetBiglHeight(13) > 0)
{
return Width_13;
}
else
{
return Width_7;
}
}
public int GetHeight()
{
if (Config.Default_TrayWidth.Equals(Width_7))
{
return GetSmallHeight();
}
else
{
int h = GetBiglHeight(15);
if (h > 0)
{
return h;
}
h = GetBiglHeight(13);
if (h > 0)
{
return h;
}
return GetSmallHeight();
}
}
private int GetSmallHeight()
{
if (Config.AIDI1_Addr < 0 || Config.AIDI2_Addr < 0)
{
return 0;
}
int result = 0;
if (Config.Default_TrayWidth.Equals(Width_7).Equals(false)&&IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.LOW))
{
return result;
}
double ai1Value = ConvertAI(IOManager.GetADIOValue(Config.AIDI1_Addr), Config.AIDI1_DefaultPosition);
double ai2Value = ConvertAI(IOManager.GetADIOValue(Config.AIDI2_Addr), Config.AIDI2_DefaultPosition);
double Value = 0;
if (ai1Value > 5 && ai2Value > 5)
Value=Math.Round((ai1Value + ai2Value) / 2, 1);
else if (ai1Value>5)
Value=Math.Round(ai1Value, 1);
else if (ai2Value>5)
Value=Math.Round(ai2Value, 1);
// Common.LogUtil.OutputDebugString($"ai1Value:{ai1Value},ai1Value:{ai2Value},Value:{Value}");
return CalHeight(Value);
}
private int GetBiglHeight(int size)
{
if (Config.AIDI3_Addr < 0 || Config.AIDI4_Addr < 0)
{
return 0;
}
int result = 0;
if (Config.Default_TrayWidth.Equals(size).Equals(false) && IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.LOW))
{
return result;
}
double Value;
double ai3Value = ConvertAI(IOManager.GetADIOValue(Config.AIDI3_Addr), Config.AIDI3_DefaultPosition);
double ai4Value = ConvertAI(IOManager.GetADIOValue(Config.AIDI4_Addr), Config.AIDI4_DefaultPosition);
if (size == 13)
{
Value = Math.Round(ai3Value, 1);
}
else
{
Value = Math.Round(ai4Value, 1);
}
return CalHeight(Value);
}
private int CalHeight(double Value)
{
int result = 0;
if (Value < 5)
{
result = 0;
}
else if (Value < 8)
{
result = 8;
}
else
{
result = (int)Math.Floor(1F * (Value) / 4) * 4;
result = (int)Math.Floor(1F * (Value));
if (result <= 8)
{
result = 8;
}
}
if (result >= 48)
{
result = 56;
}
else if (result >= 38)
{
result = 44;
}
else if (result >= 32)
{
result = 32;
}
else if (result >= 20)
{
result = 24;
}
else if (result >= 16)
{
result = 16;
}
else if (result >= 13)
{
result = 12;
}
else if (result >= 5)
{
result = 8;
}
else
{
result = 0;
}
return result;
}
public static double ConvertAI(double aiValue, double defaultValue)
{
double xishu = (double)StoreManager.Config.AI_ConvertPosition;
double result = Math.Round((aiValue - defaultValue) / xishu, 2);
return result;
}
#endregion
#region 温湿度处理
/// <summary>
/// 湿度标准,超过后需要报警
/// </summary>
private float Max_Humidity = 0;
/// <summary>
/// 温度标准,超过后需要报警
/// </summary>
private float Max_Temperature = 0;
private bool IsInBlowing = false;
private DateTime LastBeginBlowTime = DateTime.Now;
private DateTime LastEndBlowTime = new DateTime(1997, 1, 1);
private DateTime preLogTime = DateTime.Now;
public bool TempOrHumidityIsAlarm = false;
public DateTime TempAlarmTime = DateTime.Now;
private float StartBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StartBlowValue);
private float StopBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StopBlowValue);
private int DoorOpenAirBlow = ConfigAppSettings.GetIntValue(Setting_Init.DoorOpenAirBlow);
public string currTempStr = "";
DateTime doorAndTrayLastrunTime = DateTime.Now;
private void HumidityProcess()
{
try
{
if (DoorOpenAirBlow == 1)
{
if (IOManager.IOValue(IO_Type.Door_Down).Equals(IO_VALUE.LOW) || IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH))
{
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.HIGH);
doorAndTrayLastrunTime = DateTime.Now;
//IsInBlowing = true;
return;
}
if (!IsInBlowing && doorAndTrayLastrunTime != new DateTime(1997, 1, 1) && IOManager.IOValue(IO_Type.Door_Down).Equals(IO_VALUE.HIGH) && IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.LOW))
{
if ((DateTime.Now - doorAndTrayLastrunTime).TotalSeconds > 2)
{
doorAndTrayLastrunTime = new DateTime(1997, 1, 1);
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
}
}
}
if ((DateTime.Now - preLogTime).TotalSeconds > 10)
{
preLogTime = DateTime.Now;
//用最大的湿度判断是否需要吹气,开始吹气的值=发过来的值-4
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.GetTempAddrList());
ASTemperateParam param = HumitureController.LastData;
double humidity = 0;
double temp = 0;
if (param != null)
{
humidity = param.Humidity;
temp = param.Temperate;
currTempStr = humidity + " %," + temp + "℃" ;
// currTempStr = ("当前湿度:" + humidity.ToString() + ",当前温度:" + temp);
}
//double currMaxHumidity = HumitureServer.GetMaxHumidity(Config.GetTempAddrList());
double currMaxHumidity = param.Humidity;
float startBlowHumidity = Max_Humidity - StartBlowValue;
float stopBlowHumidity = Max_Humidity - StopBlowValue;
//判断是否需要吹气
if (startBlowHumidity > 0 && startBlowHumidity < currMaxHumidity && IsInBlowing.Equals(false))
{
//判断是否距离上次结束指定的时间
TimeSpan span = DateTime.Now - LastEndBlowTime;
if (span.TotalMinutes > this.Config.BlowAir_Interval)
{
LOGGER.Info("当前最大湿度:" + currMaxHumidity.ToString() + ",开始吹气湿度:" + startBlowHumidity + ",当前不在吹气中,且间隔超过" + Config.BlowAir_Interval + "分钟,开始吹气!");
IsInBlowing = true;
//Thread.Sleep(100);
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.HIGH);
LastBeginBlowTime = DateTime.Now;
LastEndBlowTime = DateTime.Now;
}
}
if (IsInBlowing && stopBlowHumidity > currMaxHumidity)
{
LOGGER.Info("当前最大湿度:" + currMaxHumidity.ToString() + ",停止吹气湿度:" + stopBlowHumidity + ",停止吹气!");
IsInBlowing = false;
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
LastEndBlowTime = DateTime.Now;
}
if (IsInBlowing)
{
//判断是否需要结束吹气
TimeSpan span = DateTime.Now - LastBeginBlowTime;
if (span.TotalMinutes > this.Config.BlowAir_Time)
{
LOGGER.Info("已经吹气" + span.TotalMinutes + "分钟,超过配置的吹气时间" + Config.BlowAir_Time + "分钟,停止吹气!");
IsInBlowing = false;
//Thread.Sleep(100);
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
LastEndBlowTime = DateTime.Now;
}
}
bool needAlarm = false;
//如果开始吹气并且当前达到报警值
if (IsInBlowing && humidity > Max_Humidity)
{
needAlarm = true;
}
else if (temp > Max_Temperature && Max_Temperature > 0)
{
LOGGER.Info("当前温度【" + param.Temperate + "】超过最高温度【" + Max_Temperature + "】,开始报警!");
needAlarm = true;
//Thread.Sleep(100);
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
}
else if (temp < Max_Temperature)
{
if (IsInBlowing.Equals(false) && TempOrHumidityIsAlarm)
{
LOGGER.Info("不在吹气中,且当前温度【" + param.Temperate + "】低于【" + Max_Temperature + "】,关闭报警!");
TempOrHumidityIsAlarm = false;
//Thread.Sleep(100);
IOManager.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
}
}
else
{
TempOrHumidityIsAlarm = false;
}
if (needAlarm)
{
HTAlarm();
}
}
}
catch (Exception ex)
{
LOGGER.Error(StoreName + "HumidityProcess出错:" + ex.ToString());
}
}
private void HTAlarm()
{
if (TempOrHumidityIsAlarm)
{
return;
}
TempAlarmTime = DateTime.Now;
TempOrHumidityIsAlarm = true;
}
#endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private string CodeMsg = "";
private string CodeMsgEn = "";
private bool isInProcess = false;
public void server_connect_timer_Tick(object sender, EventArgs e)
{
if (isInProcess)
{
return;
}
//HumitureServer.RandomData(Config.GetTempAddrList());
isInProcess = true;
if (StoreManager.IsConnectServer)
{
try
{
SendLineStatus();
}
catch (Exception ex)
{
LOGGER.Error("定时给服务器发送消息出错:", ex);
}
// dlScanSocket.TimerCheck();
}
HumitureController.QueryData();
HumidityProcess();
LedProcess();
isInProcess = false;
}
/// <summary>
/// 获取整个料仓的状态
/// </summary>
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
if (WarnObj.WarnMsg != "")
{
//lineOperation.status = (int)StoreStatus.Warning;
lineOperation.msg = WarnObj.WarnMsg;
lineOperation.msgEn = WarnObj.WarnMsgEn;
lineOperation.msgJp = WarnObj.WarnMsgJp;
}
else if (IsRun)
{
lineOperation.status = (int)StoreStatus.StoreOnline;
}
lineOperation.status = (int)StoreStatus.StoreOnline;
//判断如果是等待料盘拿走超时,状态改为4Warning
if (alarmType.Equals(StoreAlarmType.IoSingleTimeOut) && StoreMove.MoveType.Equals(StoreMoveType.OutStore))
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_15_WaitTake) || StoreMove.MoveStep.Equals(StoreMoveStep.SO_16_CheckIsTake))
{
lineOperation.status = (int)StoreStatus.Warning;
}
}
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = StoreID;
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
boxStatus.msg = WarnObj.WarnMsg;
boxStatus.msgEn = WarnObj.WarnMsgEn;
boxStatus.msgJp = WarnObj.WarnMsgJp;
lineOperation.msg = WarnObj.WarnMsg;
lineOperation.msgEn = WarnObj.WarnMsgEn;
lineOperation.msgJp = WarnObj.WarnMsgJp;
//if (WarnObj.WarnMsg.Equals(""))
//{
// boxStatus.msg = CodeMsg;
// boxStatus.msgEn = CodeMsgEn;
// // lineOperation.msg = CodeMsg;
// lineOperation.msg = CodeMsg;
// lineOperation.msgEn = CodeMsgEn;
//}
//if (CodeMsg.Equals(""))
if(WarnObj.WarnMsg.Equals(""))
{
if (storeRunStatus.Equals(StoreRunStatus.Runing) && IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
boxStatus.msg = ResourceControl.GetChinaString("叉子料盘检测有料,请检查");
lineOperation.msg = ResourceControl.GetChinaString("叉子料盘检测有料,请检查");
boxStatus.msgEn = ResourceControl.GetEnglishString("叉子料盘检测有料,请检查");
lineOperation.msgEn = ResourceControl.GetEnglishString("叉子料盘检测有料,请检查");
boxStatus.msgJp = ResourceControl.GetJapaneseString("叉子料盘检测有料,请检查");
lineOperation.msgJp = ResourceControl.GetJapaneseString("叉子料盘检测有料,请检查");
}
}
//else
//{
// //如果是扫码入库失败,也发4
// lineOperation.status = (int)StoreStatus.Warning;
//}
CodeMsg = "";
//SetWarnMsg();
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
else if (!lastPosId.Equals(""))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
boxStatus.status = (int)lastPosIdStatus;
if (lastPosId != "")
{
LogUtil.info(LOGGER, "给服务器发送出入库完成消息:" + StoreName + ",status【" + lastPosIdStatus + "】posId【" + lastPosId + "】");
}
lastPosId = "";
}
else if (storeStatus.Equals(StoreStatus.OutStoreBoxEnd) || storeStatus.Equals(StoreStatus.InStoreEnd)
|| storeStatus.Equals(StoreStatus.OutStorEnd))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
}
if (boxStatus.status.Equals((int)StoreStatus.StoreOnline))
{
if (InStoreFail)
{
boxStatus.status = (int)StoreStatus.InStoreError;
}
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
ASTemperateParam param = HumitureController.LastData;
if (param != null)
{
boxStatus.humidity = param.Humidity.ToString();
boxStatus.temperature = param.Temperate.ToString();
}
lineOperation.boxStatus.Add(StoreID, boxStatus);
if (!alarmType.Equals(StoreAlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
int doorReelSignal = (int)IOManager.IOValue(IO_Type.TrayCheck_Door);
lineOperation.data = new Dictionary<string, string> { { ParamDefine.doorReelSignal, doorReelSignal.ToString() } };
return lineOperation;
}
public void SendLineStatus()
{
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (Max_Humidity <= 0 || (Max_Temperature <= 0))
{
lineOperation.op = 5;
LogUtil.info(LOGGER, StoreName + "没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op);
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), lineOperation, false);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op <= 0))
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1))
{
ReviceInStoreProcess("", resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 600)
{
LogUtil.info(StoreName + "TimerProcess[" + span.TotalMilliseconds + "]");
}
}
private void ProcessHumidityCMD(Operation resultOperation)
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.maxHumidity) && data.ContainsKey(ParamDefine.maxTemperature))
{
string maxHumidity = data[ParamDefine.maxHumidity];
string maxTemp = data[ParamDefine.maxTemperature];
LogUtil.info(LOGGER, "收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
try
{
this.Max_Humidity = (float)Convert.ToDouble(maxHumidity);
this.Max_Temperature = (float)Convert.ToDouble(maxTemp);
LogUtil.info(LOGGER, "保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
}
catch (Exception ex)
{
LogUtil.error("转换温湿度失败:" + ex.ToString());
}
}
}
private void ReviceOutStoreProcess(Operation resultOperation) {
DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
string posIdStr = data[ParamDefine.posId];
string plateWStr = data[ParamDefine.plateW];
string plateHStr = data[ParamDefine.plateH];
LogUtil.info(LOGGER, "收到服务器出库消息:poaIs=" + posIdStr + ",platew=" + plateWStr + ",plateh=" + plateHStr);
char splitChar = '|';
string[] posIdArray = posIdStr.Split(splitChar);
string[] plateWArray = plateWStr.Split(splitChar);
string[] plateHArray = plateHStr.Split(splitChar);
int index = -1;
foreach (string posId in posIdArray)
{
index++;
string plateW = plateWArray[index];
string plateH = plateHArray[index];
//string[] posArray = posId.Split('#');
//if (posArray.Length != 2)
//{
// //WarnMsg = StoreName + "出库格式错误:库位号【" + posId + "】";
// SetWarnMsg(ResourceControl.OutStoreError, posId);
// LogUtil.error(LOGGER, "收到服务器出库命令:库位号【" + posId + "】格式错误");
// continue;
//}
//int storeId = int.Parse(posArray[0]);
//根据发送的posId获取位置列表
ACStorePosition position = CSVPositionReader<ACStorePosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
//WarnMsg = StoreName + "出库未找库位:【" + posId + "】";
SetWarnMsg(ResourceControl.OutStoreNoPosition, posId);//1082
LogUtil.error(LOGGER, "收到服务器出库命令:未找到【" + posId + "】的库位信息");
continue;
}
else
{
if (StoreMove.MoveType == StoreMoveType.OutStore && StoreMove.MoveParam.PositionNum == posId)
{
LogUtil.error(LOGGER, "执行出库【" + posId + "】失败,当前库位正在出库");
continue;
}
FixtureCodeInfo currInOutFixture = new FixtureCodeInfo(0, "", posId, plateW, plateH);
if (CanStarInOut())
{
bool result = StartOutStoreMove(new InOutStoreParam("", posId, plateH, plateW));
if (!result)
{
LogUtil.info(LOGGER, StoreName + " 执行出库【" + currInOutFixture.ToStr() + "】失败,加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
else
{
LogUtil.error(LOGGER, "执行出库【" + currInOutFixture.ToStr() + "】失败,当前在忙碌中,加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 100)
{
LogUtil.info(StoreName + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
}
#endregion
}
}