From daeda3ceebf1dafb388437423a983451720661a5 Mon Sep 17 00:00:00 2001
From: lsh <lsh123456>
Date: 星期二, 07 三月 2023 08:23:55 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/SiemensCrnThread.java | 36 ++++++++-
src/main/java/com/zy/core/thread/SteThread.java | 14 +++
src/main/java/com/zy/core/thread/LedThread.java | 6 -
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 27 ++++--
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 140 ++++++++++++++++++++++++----------
src/main/resources/application.yml | 6
6 files changed, 164 insertions(+), 65 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index c32a5d8..c7a5445 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -408,7 +408,6 @@
if (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990) {
wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo());
if (null == wrkMast) {
- News.error("{}浠诲姟鍙烽敊璇紝鏆傛棤鎷f枡浠诲姟锛�", staProtocol.getWorkNo());
continue;
}
} else {
@@ -734,7 +733,9 @@
}
// 缃《浠诲姟
- wrkMast.setIoPri((double) 9999);
+ if (wrkMast.getIoPri()<8000){
+ wrkMast.setIoPri(wrkMast.getIoPri()+9000d);
+ }
wrkMastMapper.updateById(wrkMast);
// 鐩爣搴撲綅 ===>> 鏈�澶栧眰搴撲綅
@@ -949,7 +950,9 @@
}
// 缃《浠诲姟
- wrkMast.setIoPri((double) 9998);
+ if (wrkMast.getIoPri()<8000){
+ wrkMast.setIoPri(wrkMast.getIoPri()+8999d);
+ }
wrkMastMapper.updateById(wrkMast);
// 鏈�澶栧眰搴撲綅锛岀洿鎺ュ爢鍨涙満鍑哄簱
@@ -2586,14 +2589,18 @@
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, 1);
SteProtocol steProtocol = steThread.getSteProtocol();
if (null == wrkCharge) {
- if (steProtocol.getChargeStatus()==(short)0 && steProtocol.isBrushConnect()){
- SteCommand steCommand = new SteCommand();
- steCommand.setSteNo(1); // 绌挎杞︾紪鍙�
- steCommand.setTaskNo(10060); // 宸ヤ綔鍙�
- steCommand.setTaskMode(SteTaskModeType.CLOSE_CHARGE); // 浠诲姟妯″紡: 鏂紑鍏呯數
- if (!MessageQueue.offer(SlaveType.Ste, 1, new Task(2, steCommand))) {
- News.error("绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", wrkCharge.getSteNo(), JSON.toJSON(steCommand));
+ try{
+ if (steProtocol.getChargeStatus()==(short)0 && steProtocol.isBrushConnect()){
+ SteCommand steCommand = new SteCommand();
+ steCommand.setSteNo(1); // 绌挎杞︾紪鍙�
+ steCommand.setTaskNo(10060); // 宸ヤ綔鍙�
+ steCommand.setTaskMode(SteTaskModeType.CLOSE_CHARGE); // 浠诲姟妯″紡: 鏂紑鍏呯數
+ if (!MessageQueue.offer(SlaveType.Ste, 1, new Task(2, steCommand))) {
+ News.error("绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", wrkCharge.getSteNo(), JSON.toJSON(steCommand));
+ }
}
+ }catch (Exception e){
+ return;
}
return;
}
diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java
index f7e1687..1581f7a 100644
--- a/src/main/java/com/zy/core/thread/LedThread.java
+++ b/src/main/java/com/zy/core/thread/LedThread.java
@@ -78,10 +78,8 @@
sb.append("鐩爣绔欙細").append(command.getStaNo()).append("\n");
if (!command.isEmptyMk()) {
for (MatDto matDto : command.getMatDtos()) {
- sb.append(matDto.getOrderNo()).append("\n");
- sb.append(matDto.getMatnr()).append("\n");
- sb.append(matDto.getModel()).append("\n");
- sb.append(matDto.getTotal()).append("/").append(matDto.getCount()).append("\n");
+ sb.append("鐗╂枡缂栫爜锛�").append(matDto.getMatnr()).append("\n");
+ sb.append("鏁伴噺锛�").append(matDto.getCount()).append("\n");
}
}
sb.append("\n");
diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index 9ce7789..78869df 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -255,12 +255,40 @@
array[7] = command.getDestinationPosY();
array[8] = command.getDestinationPosZ();
array[9] = command.getCommand();
- OperateResult result = siemensNet.Write("DB100.0", array);
+ OperateResult result=null;
+ //浠诲姟涓嬪彂娆℃暟
+ int writeCount = 0;
+ do {
+ result = siemensNet.Write("DB100.0", array);
+ if(result.IsSuccess){
+ Thread.sleep(200);
+ OperateResultExOne<byte[]> readResult = siemensNet.Read("DB100.0", (short) 20);
+ if(readResult.IsSuccess){
+ short ackFinish = siemensNet.getByteTransform().TransInt16(readResult.Content, 0);
+ short taskNo = siemensNet.getByteTransform().TransInt16(readResult.Content, 2);
+ if(command.getTaskNo().equals(taskNo) && command.getAckFinish().equals(ackFinish)){
+ //浠诲姟鍛戒护鍐欏叆鎴愬姛
+ log.info("鍐欏叆鍫嗗灈鏈哄懡浠ゅ悗杩斿洖鎴愬姛锛屽苟涓斿洖璇绘垚鍔熴�傚爢鍨涙満plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(command), writeCount);
+ break;
+ } else {//杩斿洖缁撴灉鏄垚鍔熶簡锛屼絾鏄湡瀹炲�间笉鐩稿悓
+ writeCount++;
+ log.error("鍐欏叆鍫嗗灈鏈哄懡浠ゅ悗杩斿洖鎴愬姛锛屼絾鏄鍙栦换鍔″�间笉涓�鑷淬�傚爢鍨涙満plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(command), writeCount);
+ }
+ } else {
+ writeCount++;
+ log.error("鍐欏叆鍫嗗灈鏈哄懡浠ゅ悗璇诲彇澶辫触銆傚爢鍨涙満plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(command), writeCount);
+ }
+ }
+ else {
+ writeCount++;
+ log.error("鍐欏叆鍫嗗灈鏈哄懡浠ゅ悗璇诲彇澶辫触銆傚爢鍨涙満plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(command), writeCount);
+ }
+ }while (writeCount<5);
if (command.getAckFinish() == 0) {
- short commandFinish = 1;
- Thread.sleep(300);
- result = siemensNet.Write("DB100.18", commandFinish);
+ short commandFinish = 1;
+ Thread.sleep(300);
+ result = siemensNet.Write("DB100.18", commandFinish);
}
try {
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 718f5af..edce7b1 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -166,49 +166,49 @@
}
}
- // 鍏呯數淇″彿浣�
+ // 鍏呯數淇″彿浣�1
Thread.sleep(50);
- OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB102.109", (short)1);
- if (result3.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, 0, 1);
- charge0 = status[0];
+ OperateResultExOne<byte[]> result32 = siemensS7Net.Read("DB102.109", (short)1);
+ if (result32.IsSuccess) {
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(result32.Content, 0, 1);
+ charge0 = status[0]; //1:鍙互鍏呯數 0锛氬彲鑳界绾� 鍙兘鍦ㄥ厖鐢�
}
- // 鍏呯數淇″彿浣�
+ // 鍏呯數淇″彿浣�2
Thread.sleep(50);
OperateResultExOne<byte[]> result31 = siemensS7Net.Read("DB100.201", (short)1);
- if (result3.IsSuccess) {
+ if (result31.IsSuccess) {
boolean[] status = siemensS7Net.getByteTransform().TransBool(result31.Content, 0, 1);
charge1 = status[0];
}
- // 澶栧舰妫�娴� - 102
- Thread.sleep(50);
- OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB102.129", (short)1);
- if (result4.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1);
- StaProtocol staProtocol = station.get(102);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- // 澶栧舰妫�娴� - 203
- Thread.sleep(50);
- OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB102.130", (short)1);
- if (result5.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 1);
- StaProtocol staProtocol = station.get(202);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
+// // 澶栧舰妫�娴� - 102
+// Thread.sleep(50);
+// OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB102.129", (short)1);
+// if (result4.IsSuccess) {
+// boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1);
+// StaProtocol staProtocol = station.get(102);
+// staProtocol.setFrontErr(status[0]);
+// staProtocol.setBackErr(status[1]);
+// staProtocol.setHighErr(status[2]);
+// staProtocol.setLeftErr(status[3]);
+// staProtocol.setRightErr(status[4]);
+// staProtocol.setWeightErr(status[5]);
+// staProtocol.setBarcodeErr(status[6]);
+// }
+// // 澶栧舰妫�娴� - 203
+// Thread.sleep(50);
+// OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB102.130", (short)1);
+// if (result5.IsSuccess) {
+// boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 1);
+// StaProtocol staProtocol = station.get(202);
+// staProtocol.setFrontErr(status[0]);
+// staProtocol.setBackErr(status[1]);
+// staProtocol.setHighErr(status[2]);
+// staProtocol.setLeftErr(status[3]);
+// staProtocol.setRightErr(status[4]);
+// staProtocol.setWeightErr(status[5]);
+// staProtocol.setBarcodeErr(status[6]);
+// }
if (result.IsSuccess && result1.IsSuccess) {
@@ -273,20 +273,74 @@
return;
}
int index = staNos.indexOf(staProtocol.getSiteId());
- OperateResult write = siemensS7Net.Write("DB100." + index*4, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
- Thread.sleep(500);
- OperateResult write1 = siemensS7Net.Write("DB100." + (index*4+2), staProtocol.getStaNo()); // 鐩爣绔�
+ short[] array = new short[2];
+ array[0] = staProtocol.getWorkNo();
+ array[1] = staProtocol.getStaNo();
+// OperateResult write = siemensS7Net.Write("DB100." + index*4, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
+// Thread.sleep(500);
+// OperateResult write1 = siemensS7Net.Write("DB100." + (index*4+2), staProtocol.getStaNo()); // 鐩爣绔�
- if (!write.IsSuccess || !write1.IsSuccess) {
+ OperateResult writeResult;
+ //浠诲姟涓嬪彂娆℃暟
+ int writeCount = 0;
+ //浠诲姟涓嬪彂鎴愬姛鏍囪瘑
+ boolean writeFlag = false;
+ while(writeCount < 5){
+ writeResult = siemensS7Net.Write("DB100." + index*4, array); // 宸ヤ綔鍙枫�佺洰鏍囩珯
+ if(writeResult.IsSuccess){
+ Thread.sleep(200);
+ OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB100." + index*4, (short)4);
+ if(readResult.IsSuccess){
+ short workNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 0);
+ short staNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 2);
+ if(staProtocol.getWorkNo().equals(workNo) && staProtocol.getStaNo().equals(staNo)){
+ //浠诲姟鍛戒护鍐欏叆鎴愬姛
+ writeFlag = true;
+ log.info("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝骞朵笖鍥炶鎴愬姛銆傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ break;
+ } else {//杩斿洖缁撴灉鏄垚鍔熶簡锛屼絾鏄湡瀹炲�间笉鐩稿悓
+ writeCount++;
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2},鍐欏叆娆℃暟={3}",
+ slave.getId(), JSON.toJSON(staProtocol),writeCount));
+ log.error("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ }
+ } else {
+ writeCount++;
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护鍚庤鍙栧け璐ャ�傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2},鍐欏叆娆℃暟={3}",
+ slave.getId(), JSON.toJSON(staProtocol), writeCount));
+ log.error("鍐欏叆杈撻�佺嚎鍛戒护鍚庤鍙栧け璐ャ�傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ }
+ } else {
+ writeCount++;
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2},鍐欏叆娆℃暟={3}",
+ slave.getId(), JSON.toJSON(staProtocol),writeCount));
+ log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ }
+ Thread.sleep(200);
+ }
+
+ //鍐欏懡浠ゅ皾璇曚簡5娆¤繕鏄け璐ヤ簡
+ if(!writeFlag){
staProtocol = station.get(staProtocol.getSiteId());
if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) {
staProtocol.setPakMk(true);
}
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
- News.error("鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护灏濊瘯5娆″け璐ャ�傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
+ log.error("鍐欏叆杈撻�佺嚎鍛戒护灏濊瘯5娆″け璐ャ�傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
+
+ //閲嶆柊娣诲姞鏁版嵁鍒颁换鍔¢槦鍒�
+ boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol));
+ read();//璇诲彇1娆¤澶囩姸鎬�
+ return;
} else {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
- News.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂锛� {}", slave.getId(), JSON.toJSON(staProtocol));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
+ log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol));
+
+ Integer siteId = staProtocol.getSiteId();
+ staProtocol = station.get(siteId);
+ if ((siteId == 101 || siteId == 201)&&(staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0)) {
+ staProtocol.setPakMk(true);
+ }
}
}
diff --git a/src/main/java/com/zy/core/thread/SteThread.java b/src/main/java/com/zy/core/thread/SteThread.java
index 00776ba..72dbc49 100644
--- a/src/main/java/com/zy/core/thread/SteThread.java
+++ b/src/main/java/com/zy/core/thread/SteThread.java
@@ -301,7 +301,7 @@
}
//鍒ゆ柇灏忚溅鏄惁鍦ㄥ厖鐢�
SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
- if (!devpThread.charge0 || devpThread.charge1){
+ if (devpThread.charge1){
// led 寮傚父鏄剧ず
LedThread ledThread1 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
LedThread ledThread2 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
@@ -313,6 +313,18 @@
}
News.error("绌挎杞︽鍦ㄥ厖鐢�");
return false;
+ }else if (!devpThread.charge0){
+ // led 寮傚父鏄剧ず
+ LedThread ledThread1 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
+ LedThread ledThread2 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
+ LedThread ledThread3 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
+ if (ledThread1 != null && ledThread2 != null && ledThread3 != null) {
+ MessageQueue.offer(SlaveType.Led, 1, new Task(3, "绌挎杞﹀彲鑳藉湪绂荤嚎鍏呯數锛屾鏌ョ數鎺ф煖绌挎杞︽槸鍚﹀厖鐢垫々鍦ㄧ嚎"));
+ MessageQueue.offer(SlaveType.Led, 2, new Task(3, "绌挎杞﹀彲鑳藉湪绂荤嚎鍏呯數锛屾鏌ョ數鎺ф煖绌挎杞︽槸鍚﹀厖鐢垫々鍦ㄧ嚎"));
+ MessageQueue.offer(SlaveType.Led, 3, new Task(3, "绌挎杞﹀彲鑳藉湪绂荤嚎鍏呯數锛屾鏌ョ數鎺ф煖绌挎杞︽槸鍚﹀厖鐢垫々鍦ㄧ嚎"));
+ }
+ News.error("绌挎杞﹀彲鑳藉湪绂荤嚎鍏呯數锛屾鏌ョ數鎺ф煖绌挎杞︽槸鍚﹀厖鐢垫々鍦ㄧ嚎");
+ return false;
}
command.setSteNo(slave.getId());
OperateResult result = null;
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 5ddcdeb..251f3c5 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -8,7 +8,7 @@
name: @pom.build.finalName@
datasource:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
- url: jdbc:sqlserver://localhost:1433;databasename=szfzasrs
+ url: jdbc:sqlserver://10.10.10.209:1433;databasename=szfzasrs
username: sa
# password: Zoneyung@zy56$
password: sa@123
@@ -35,12 +35,12 @@
enable: false
wms:
- url: localhost:8081/szfzwms
+ url: 10.10.10.209:8080/szfzwms
erp:
db:
driver_class_name: com.microsoft.sqlserver.jdbc.SQLServerDriver
- ur: jdbc:sqlserver://10.20.46.23:1433;databasename=POY_ASRS
+ ur: jdbc:sqlserver://10.10.10.209:1433;databasename=POY_ASRS
username: poy-asrs
password: Poy@2022
--
Gitblit v1.9.1