From bb5b93aa317e91aabb3d2f5d7e176c3aa7ba811e Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 05 六月 2024 16:12:37 +0800
Subject: [PATCH] #初始化
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 117 ++++++++++++++++++++++------------------------------------
1 files changed, 44 insertions(+), 73 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index f0435a5..84431b6 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -22,6 +22,7 @@
import com.zy.core.enums.SlaveType;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.Task;
+import com.zy.core.model.protocol.StaError1;
import com.zy.core.model.protocol.StaProtocol;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -45,6 +46,7 @@
private SiemensS7Net siemensS7Net;
private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
private short heartBeatVal = 1;
+ private StaError1 staError1;
// public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
//
// }};
@@ -53,27 +55,21 @@
add(104);add(105);add(106);add(107);
add(108);add(109);add(110);add(111);
add(112);add(113);add(114);add(115);
- add(116);add(117);add(118);add(119);
- add(120);add(121);add(122);add(123);
- add(124);add(125);add(126);add(127);
- add(128);add(129);add(130);add(131);
- add(132);add(133);add(134);add(135);
- add(136);add(137);add(138);add(139);
- add(140);add(141);add(142);add(143);
- add(144);add(145);add(146);add(147);
- add(148);add(149);add(150);add(151);
- add(152);add(153);add(154);add(155);
- add(156);add(157);add(158);add(159);
- add(160);add(161);
- add(1);
-// add(200);add(201);add(202);
+ add(116);add(117);
+
+ add(200);add(201);add(202);add(203);
+ add(204);add(205);add(206);add(207);
+ add(208);add(209);add(210);add(211);
+ add(212);add(213);add(214);add(215);
+ add(216);add(217);add(218);add(219);
+ add(220);add(221);add(222);add(223);
}};
public static final ArrayList<Integer> BarcodeList = new ArrayList<Integer>() {{
- add(0); add(1); add(2);
+ add(101); add(201);
}};
public static final ArrayList<Integer> staNosErrList = new ArrayList<Integer>() {{
- add(106); add(107); add(159);
+ add(101); add(201);
}};
private Integer count=0;
@@ -81,7 +77,7 @@
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 6;
+ private int barcodeSize = 2;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -135,7 +131,7 @@
}
// 蹇冭烦
// heartbeat();
- Thread.sleep(300);
+ Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
@@ -148,7 +144,7 @@
private void initSite() {
count ++;
ArrayList<Integer> staNos = getStaNo();
- if(count > 77) {
+ if(count > 40) {
// 绔欑偣缂栧彿
for (Integer siteId : staNos) {
StaProtocol staProtocol = station.get(siteId);
@@ -230,60 +226,6 @@
}
}
}
- BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class);
- //RGV灏忚溅1
- Thread.sleep(100);
- OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB50.200",(short)10);
- if (result3.IsSuccess) {
- BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result3.Content, 0));
- if (!Cools.isEmpty(basRgvMap)){
- Integer siteId = 1;
- StaProtocol staProtocol = station.get(siteId);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
- }
- staProtocol.setAutoing(true);
- staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 8)));
- }
- }
- //RGV灏忚溅2
- Thread.sleep(100);
- OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB50.212",(short)10);
- if (result4.IsSuccess) {
- BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result4.Content, 0));
- if (!Cools.isEmpty(basRgvMap)){
- Integer siteId = 2;
- StaProtocol staProtocol = station.get(siteId);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
- }
- staProtocol.setAutoing(true);
- staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result4.Content, 8)));
- }
- }
-
- //RGV灏忚溅3
- Thread.sleep(100);
- OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB50.224",(short)10);
- if (result5.IsSuccess) {
- BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result5.Content, 0));
- if (!Cools.isEmpty(basRgvMap)){
- Integer siteId = 3;
- StaProtocol staProtocol = station.get(siteId);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
- }
- staProtocol.setAutoing(true);
- staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result5.Content, 8)));
- }
- }
-
//鏉$爜鎵弿鍣�
ArrayList<Integer> barcodeList = BarcodeList;
OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840", (short) (barcodeList.size() * 8));
@@ -316,6 +258,7 @@
}
}
+ //plc鏁呴殰
OperateResultExOne<byte[]> resultErr2 = siemensS7Net.Read("DB13.2", (short) (staNoSize*4));
if (resultErr2.IsSuccess) {
for (int i = 0; i < staNoSize; i++) {
@@ -332,6 +275,33 @@
staProtocol.setUpcontactErr(status[7]);
}
+ }
+ OperateResultExOne<byte[]> resultErr3 = siemensS7Net.Read("DB13.400", (short) 3);
+ if (resultErr3.IsSuccess) {
+ if (staError1 == null){
+ staError1 = new StaError1();
+ }
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr3.Content, 0, 3);
+ staError1.setEMERGENCY_Stop_Core(status[0]);
+ staError1.setEMERGENCY_STOP1(status[1]);
+ staError1.setEMERGENCY_STOP2(status[2]);
+ staError1.setEMERGENCY_STOP3(status[3]);
+ staError1.setEMERGENCY_STOP4(status[4]);
+
+ staError1.setDoor_EMERGENCY_STOP1(status[5]);
+ staError1.setDoor_EMERGENCY_STOP2(status[6]);
+ staError1.setDoor_EMERGENCY_STOP3(status[7]);
+ staError1.setDoor_EMERGENCY_STOP4(status[8]);
+ staError1.setDoor_EMERGENCY_STOP5(status[9]);
+ staError1.setDoor_EMERGENCY_STOP6(status[10]);
+
+ staError1.setDoor_Open_Err1(status[11]);
+ staError1.setDoor_Open_Err1(status[12]);
+ staError1.setDoor_Open_Err1(status[13]);
+ staError1.setDoor_Open_Err1(status[14]);
+ staError1.setDoor_Open_Err1(status[15]);
+ staError1.setDoor_Open_Err1(status[16]);
+
}
@@ -382,6 +352,7 @@
Thread.sleep(200);
write1 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo().shortValue()); // 鐩爣绔�
if(write.IsSuccess && write1.IsSuccess){
+ log.error("鍐欏叆杈撻�佺嚎鍛戒护鎴愬姛銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
break;
}
else {
--
Gitblit v1.9.1