From c471b38363268108200e6c88c87fc219d17eb17f Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期二, 26 十一月 2024 13:13:58 +0800
Subject: [PATCH] 项目搭建完成
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 322 -----------------------------------------------------
1 files changed, 4 insertions(+), 318 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 723985c..db266b3 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -48,8 +48,6 @@
public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
add(100);add(101);add(102);add(103);
add(104);add(105);add(106);add(107);
- add(200);add(201);add(202);add(203);add(210);
- add(300);add(301);add(302);add(303);add(304);add(305);
}};
public static final ArrayList<Integer> BarcodeList = new ArrayList<Integer>() {{
@@ -73,11 +71,6 @@
* 4.鍑哄簱妯″紡
*/
public IoModeType ioModeOf101 = IoModeType.NONE;
- public IoModeType ioModeOf103 = IoModeType.NONE;
- public IoModeType ioModeOf305 = IoModeType.NONE;
-// public IoModeType ioMode = IoModeType.NONE;
-// public IoModeType ioModeOf4F = IoModeType.NONE;
-// public IoModeType ioMode = IoModeType.NONE;
public SiemensDevpThread(DevpSlave slave) {
this.slave = slave;
@@ -108,10 +101,6 @@
write((StaProtocol)task.getData());
// log.error("杈撻�佺嚎涓嬪彂鍛戒护锛�"+((StaProtocol) task.getData()).getWorkNo()+","+((StaProtocol) task.getData()).getStaNo());
break;
- // 鍐欏紑闂�
- case 3:
- write2((Integer) task.getData());
- break;
default:
break;
}
@@ -122,41 +111,6 @@
e.printStackTrace();
}
- }
- }
-
- private void write2(int flag) throws InterruptedException {
- if (flag == 0) {
- OperateResultExOne<byte[]> readOpenResult = siemensS7Net.Read("DB100.826", (short) 1);
- if (readOpenResult.IsSuccess) {
- boolean[] booleans = siemensS7Net.getByteTransform().TransBool(readOpenResult.Content, 0, 1);
- booleans[1] = true; // 鍏抽棬淇″彿
- booleans[0] = false;
- siemensS7Net.Write("DB100.826",booleans);
- }
- } else if(flag == 1) {
- OperateResultExOne<byte[]> readOpenResult = siemensS7Net.Read("DB100.826", (short) 1);
- if (readOpenResult.IsSuccess) {
- boolean[] booleans = siemensS7Net.getByteTransform().TransBool(readOpenResult.Content, 0, 1);
- booleans[0] = true; // 寮�闂ㄤ俊鍙�
- booleans[1] = false;
- siemensS7Net.Write("DB100.826",booleans);
- }
- }
- Thread.sleep(500);
- OperateResultExOne<byte[]> readOpenResult = siemensS7Net.Read("DB100.826", (short) 1);
- if (readOpenResult.IsSuccess) {
- boolean[] booleans = siemensS7Net.getByteTransform().TransBool(readOpenResult.Content, 0, 1);
- StaProtocol staProtocol = station.get(305);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(305);
- station.put(305, staProtocol);
- }
- staProtocol.setOpenAskDoor(booleans[0]);
- staProtocol.setCloseAskDoor(booleans[1]);
- staProtocol.setIfOpenDoor(booleans[2]);
- staProtocol.setIfCloseDoor(booleans[3]);
}
}
@@ -210,11 +164,8 @@
/**
* 璇诲彇鐘舵�� ====> 鏁村潡plc
*/
- private void read() throws InterruptedException {
-// // 鏇存柊鍏ュ嚭搴撴ā寮�
-// updateIoMode();
-// ArrayList<Integer> staNos = getStaNo();
-// int staNoSize = staNos.size();
+ private void read() {
+
// 璇讳竴妤艰繛缁�8涓珯鐐�
OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (8*8));
if (result.IsSuccess) {
@@ -245,112 +196,6 @@
}
}
}
- // 璇讳簩妤艰繛缁�4涓珯鐐�
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.800", (short) (4*8));
- if (result2.IsSuccess) {
- for (int i = 8; i < 12; i++) {
- Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
- StaProtocol staProtocol = station.get(siteId);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
- }
- staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result2.Content, (i-8)*8)); // 宸ヤ綔鍙�
-
- staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result2.Content, (i-8)*8 + 4)); // 鐩爣绔�
-
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result2.Content, (i-8)*8 + 6, 2);
- staProtocol.setAutoing(status[0]); // 鑷姩
- staProtocol.setLoading(status[1]); // 鏈夌墿
- staProtocol.setInEnable(status[2]); // 鍙叆
- staProtocol.setOutEnable(status[3]);// 鍙嚭
- staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
- staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
- staProtocol.setHigh(status[6]); // 楂樺簱浣�
- staProtocol.setLow(status[7]); // 浣庡簱浣�
-
- if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
- staProtocol.setPakMk(true);
- }
- }
- }
- // 璇讳簩妤�210
- OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.880", (short) (8));
- if (result3.IsSuccess) {
- Integer siteId = staNos.get(12); // 绔欑偣缂栧彿210
- StaProtocol staProtocol = station.get(siteId);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
- }
- staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result3.Content, 0)); // 宸ヤ綔鍙�
-
- staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result3.Content, 4)); // 鐩爣绔�
-
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, 6, 2);
- staProtocol.setAutoing(status[0]); // 鑷姩
- staProtocol.setLoading(status[1]); // 鏈夌墿
- staProtocol.setInEnable(status[2]); // 鍙叆
- staProtocol.setOutEnable(status[3]);// 鍙嚭
- staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
- staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
- staProtocol.setHigh(status[6]); // 楂樺簱浣�
- staProtocol.setLow(status[7]); // 浣庡簱浣�
-
- if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
- staProtocol.setPakMk(true);
- }
- }
- // 璇讳簩妤�3鍖�
- OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB101.1600", (short) (6*8));
- if (result2.IsSuccess) {
- for (int i = 13; i < staNos.size(); i++) {
- Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
- StaProtocol staProtocol = station.get(siteId);
- if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
- }
- staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result4.Content, (i-13)*8)); // 宸ヤ綔鍙�
-
- staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result4.Content, (i-13)*8 + 4)); // 鐩爣绔�
-
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, (i-13)*8 + 6, 2);
- staProtocol.setAutoing(status[0]); // 鑷姩
- staProtocol.setLoading(status[1]); // 鏈夌墿
- staProtocol.setInEnable(status[2]); // 鍙叆
- staProtocol.setOutEnable(status[3]);// 鍙嚭
- staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
- staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
- staProtocol.setHigh(status[6]); // 楂樺簱浣�
- staProtocol.setLow(status[7]); // 浣庡簱浣�
-
- if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
- staProtocol.setPakMk(true);
- }
- }
- }
-// 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)));
-// }
-// }
// 鏉$爜鎵弿鍣�
OperateResultExOne<byte[]> barcodeResult = siemensS7Net.Read("DB101.1672", (short) ((BarcodeList.size()+1) * 8)); // 涓嶈繛缁�
@@ -379,6 +224,7 @@
staProtocol.setBarcodeErr(status[6]);
}
}
+
// 璇讳竴妤艰繛缁�8涓珯鐐癸紝鏁呴殰淇℃伅鍙嶉
OperateResultExOne<byte[]> resultErr2 = siemensS7Net.Read("DB101.3312", (short) (8*2));
if (resultErr2.IsSuccess) {
@@ -396,145 +242,6 @@
}
}
- // 璇讳簩妤艰繛缁�4涓珯鐐癸紝鏁呴殰淇℃伅鍙嶉
- OperateResultExOne<byte[]> resultErr3 = siemensS7Net.Read("DB101.3512", (short) (4*2));
- if (resultErr3.IsSuccess) {
- for (int i = 8; i < 12; i++) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr3.Content, (i-8) * 2 + 1, 1);
- StaProtocol staProtocol = station.get(staNos.get(i)); // 绔欑偣缂栧彿
- staProtocol.setBreakerErr(status[0]);
- staProtocol.setInfraredErr(status[1]);
- staProtocol.setOutTimeErr(status[2]);
- staProtocol.setSeizeSeatErr(status[3]);
- staProtocol.setWrkYgoodsN(status[4]);
- staProtocol.setInverterErr(status[5]);
- staProtocol.setContactErr(status[6]);
- staProtocol.setUpcontactErr(status[7]);
- }
- }
- // 璇讳笁鍖烘晠闅滀俊鎭弽棣�
- OperateResultExOne<byte[]> resultErr4 = siemensS7Net.Read("DB101.2096", (short) (6*2));
- if (resultErr4.IsSuccess) {
- for (int i = 13; i < staNos.size(); i++) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr4.Content, (i-13) * 2 + 1, 1);
- StaProtocol staProtocol = station.get(staNos.get(i)); // 绔欑偣缂栧彿
- staProtocol.setBreakerErr(status[0]);
- staProtocol.setInfraredErr(status[1]);
- staProtocol.setOutTimeErr(status[2]);
- staProtocol.setSeizeSeatErr(status[3]);
- staProtocol.setWrkYgoodsN(status[4]);
- staProtocol.setInverterErr(status[5]);
- staProtocol.setContactErr(status[6]);
- staProtocol.setUpcontactErr(status[7]);
- }
- }
-
- // 涓�妤煎嚭鍏ュ簱妯″紡鍒囨崲
-// OperateResultExOne<byte[]> ioModeResult = siemensS7Net.Read("DB101.3724", (short) 1);
-// if (ioModeResult.IsSuccess) {
-// boolean[] ioModelBooleans = siemensS7Net.getByteTransform().TransBool(ioModeResult.Content, 0, 1);
-//// log.info("璇诲彇鍑哄叆搴撴ā寮忥細" + Arrays.toString(ioModelBooleans));
-// WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class);
-// if (ioModelBooleans[0]) { // 100鍒囧叆搴�
-// if (ioModeOf101 == IoModeType.PAKOUT_MODE) {
-// int outCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 101)
-// .eq("sta_no", 100).in("wrk_sts", 12, 13, 14));
-// if (outCount == 0) {
-// boolean[] booleans = new boolean[8];
-// booleans[0]=true;
-// ioModeOf101 = IoModeType.PAKIN_MODE;
-// siemensS7Net.Write("DB100.824",booleans);
-// log.info("101鍒囨崲鍏ュ簱妯″紡鎴愬姛");
-// }
-// }
-// }
-// if (ioModelBooleans[1]) { // 100鍒囧嚭搴�
-// if (ioModeOf101 == IoModeType.PAKIN_MODE) {
-// int inCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 1)
-// .eq("sta_no", 101).in("wrk_sts", 2, 3, 4));
-// if (inCount == 0) {
-// boolean[] booleans = new boolean[8];
-// booleans[0]=true;
-// ioModeOf101 = IoModeType.PAKOUT_MODE;
-// siemensS7Net.Write("DB100.824",booleans);
-// log.info("101鍒囨崲鍑哄簱妯″紡鎴愬姛");
-// }
-// }
-// }
-// if (ioModelBooleans[2]) { // 102鍒囧叆搴�
-// if (ioModeOf103 == IoModeType.PAKOUT_MODE) {
-// int outCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 101)
-// .eq("sta_no", 102).in("wrk_sts", 12, 13, 14));
-// if (outCount == 0) {
-// boolean[] booleans = new boolean[8];
-// booleans[1]=true;
-// ioModeOf103 = IoModeType.PAKIN_MODE;
-// siemensS7Net.Write("DB100.824",booleans);
-// log.info("103鍒囨崲鍏ュ簱妯″紡鎴愬姛");
-// }
-// }
-// }
-// if (ioModelBooleans[3]) { // 102鍒囧嚭搴�
-// if (ioModeOf103 == IoModeType.PAKIN_MODE) {
-// int inCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 1)
-// .eq("sta_no", 103).in("wrk_sts", 2, 3, 4));
-// if (inCount == 0) {
-// boolean[] booleans = new boolean[8];
-// booleans[1]=true;
-// ioModeOf103 = IoModeType.PAKOUT_MODE;
-// siemensS7Net.Write("DB100.824",booleans);
-// log.info("103鍒囨崲鍑哄簱妯″紡鎴愬姛");
-// }
-// }
-// }
-// }
-
- // 璇诲紑闂ㄤ俊鍙�
-// OperateResultExOne<byte[]> readOpenResult = siemensS7Net.Read("DB100.826", (short) 1);
-// if (readOpenResult.IsSuccess) {
-// boolean[] booleans = siemensS7Net.getByteTransform().TransBool(readOpenResult.Content, 0, 1);
-// StaProtocol staProtocol = station.get(305);
-// if (null == staProtocol) {
-// staProtocol = new StaProtocol();
-// staProtocol.setSiteId(305);
-// station.put(305, staProtocol);
-// }
-// staProtocol.setOpenAskDoor(booleans[0]);
-// staProtocol.setCloseAskDoor(booleans[1]);
-// staProtocol.setIfOpenDoor(booleans[2]);
-// staProtocol.setIfCloseDoor(booleans[3]);
-//// log.info("寮�闂ㄤ俊鍙凤細" + Arrays.toString(booleans));
-// }
-
-
-//// 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]);
-//
-// }
-
if (result.IsSuccess) {
@@ -583,17 +290,6 @@
case 105: address = 20; break;
case 106: address = 24; break;
case 107: address = 28; break;
- case 200: address = 400; break;
- case 201: address = 404; break;
- case 202: address = 408; break;
- case 203: address = 412; break;
- case 210: address = 440; break;
- case 300: address = 800; break;
- case 301: address = 804; break;
- case 302: address = 808; break;
- case 303: address = 812; break;
- case 304: address = 816; break;
- case 305: address = 820; break;
default:
}
if(address == -1) {
@@ -627,16 +323,6 @@
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
News.info("SiemensDevp"+" - 5"+" - 杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂锛� {}", slave.getId(), JSON.toJSON(staProtocol));
}
- }
-
- // 鏇存柊鍏ュ嚭搴撴ā寮�
- private void updateIoMode() throws InterruptedException {
-// if (this.ioModeOf2F != IoModeType.NONE) {
-// if (!siemensS7Net.Write("DB100.180", this.ioModeOf2F.id).IsSuccess) {
-// OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎2F鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
-// News.error("SiemensDevp"+" - 6"+" - 鍐欏叆杈撻�佺嚎2F鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
-// }
-// }
}
/**
@@ -675,7 +361,7 @@
slave.setIp("10.10.10.18");
SiemensDevpThread devpThread = new SiemensDevpThread(slave);
devpThread.connect();
- devpThread.write2(0);
+
devpThread.read();
// // 鍐�
// StaProtocol staProtocol = devpThread.getStation().get(1);
--
Gitblit v1.9.1