From 0be842a3c8a3063e933f35a8bb1bc9e578f27699 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期五, 28 六月 2024 17:22:19 +0800
Subject: [PATCH] led复位修改
---
src/main/java/com/zy/common/model/MatDto.java | 2 +
src/main/java/com/zy/core/thread/SiemensCrnThread.java | 43 +++++++++++++++++++++
src/main/java/com/zy/core/thread/LedThread.java | 2
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 53 ++++++++++++++++++++------
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 2
5 files changed, 87 insertions(+), 15 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 3bc9660..22ce192 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -96,7 +96,7 @@
* 缁勬墭
* 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
*/
- public synchronized void generateStoreWrkFile(Integer mark) {
+ public synchronized void generateStoreWrkFile(Integer mark) throws InterruptedException {
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
for (DevpSlave devp : slaveProperties.getDevp()) { //閬嶅巻杈撻�佺嚎
// 閬嶅巻鍏ュ簱鍙�
@@ -125,10 +125,7 @@
鏄�2鍙疯緭閫佺嚎9995鎷f枡浠诲姟
*/
String barcode = barcodeThread.getBarcode();
- if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
- || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() == 9995 && devp.getId() == 2)) {
- continue;
- }
+
// 灏哄妫�娴嬪紓甯�
boolean back = false;
@@ -192,6 +189,12 @@
devpThread.setPakMk(staProtocol.getSiteId(), false);
MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg));
+ Thread.sleep(500);
+ }
+
+ if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
+ || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() == 9995 && devp.getId() == 2)) {
+ continue;
}
if (staProtocol.isAutoing() && staProtocol.isInEnable()
@@ -264,12 +267,21 @@
ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
ledCommand.setLocNo(dto.getLocNo());
ledCommand.setStaNo(dto.getStaNo());
+ ArrayList<MatDto> matDtos = new ArrayList<>();
+ MatDto matDto = new MatDto();
+ matDto.setLocNo(dto.getLocNo());
+ matDtos.add(matDto);
+ ledCommand.setMatDtos(matDtos);
ledCommand.setBarcode(barcode);
commands.add(ledCommand);
if (devp.getId() == 1) {
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands));
+ if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands))){
+ ledThread.setLedMk(false);
+ }
} else {
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands));
+ if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands))){
+ ledThread.setLedMk(false);
+ }
}
// ledThread.errorReset();
}
@@ -451,6 +463,8 @@
.eq("stn_no", stnNo) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
.eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿
StaDesc staDesc = staDescService.selectOne(wrapper);
+ //LED
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
if (Cools.isEmpty(staDesc)) {
News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
if (devp.getId() == 2) {
@@ -459,8 +473,7 @@
devpThread.setPakMk(staProtocol.getSiteId(), false);
MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
}
- //LED
- LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
+
// led 寮傚父鏄剧ず
if (ledThread != null) {
String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�"+pickSta.getBackSta().shortValue()+"绔欑偣";
@@ -516,11 +529,20 @@
ledCommand.setLocNo(wrkMast.getLocNo());
ledCommand.setStaNo(wrkMast.getStaNo());
ledCommand.setBarcode(barcode);
+ ArrayList<MatDto> matDtos = new ArrayList<>();
+ MatDto matDto = new MatDto();
+ matDto.setLocNo(wrkMast.getLocNo());
+ matDtos.add(matDto);
+ ledCommand.setMatDtos(matDtos);
commands.add(ledCommand);
if (devp.getId() == 1) {
- MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands));
+ if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands))) {
+ ledThread.setLedMk(false);
+ }
} else {
- MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands));
+ if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands))){
+ ledThread.setLedMk(false);
+ }
}
// 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
@@ -1573,6 +1595,11 @@
ledCommand.setLocNo(dto.getLocNo());
ledCommand.setStaNo(dto.getStaNo());
ledCommand.setBarcode("");
+ ArrayList<MatDto> matDtos = new ArrayList<>();
+ MatDto matDto = new MatDto();
+ matDto.setLocNo(dto.getLocNo());
+ matDtos.add(matDto);
+ ledCommand.setMatDtos(matDtos);
commands.add(ledCommand);
if (devp.getId() == 1) {
MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands));
@@ -1627,7 +1654,7 @@
// 宸ヤ綔妗i泦鍚�
List<WrkMast> wrkMasts = new ArrayList<>();
for (Integer staNo : led.getStaArr()) {
- if (staNo == 104 || staNo == 204) {
+ if (staNo == 104 || staNo == 204 || staNo == 304) {
continue;
}
// 鑾峰彇鍙夎溅绔欑偣
@@ -1704,7 +1731,7 @@
} else {
ledThread.setLedMk(false);
}
- } else {
+ } else if(led.getId() == 1 || led.getId() == 2){
if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
News.error(""+mark+" - 3"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
continue;
diff --git a/src/main/java/com/zy/common/model/MatDto.java b/src/main/java/com/zy/common/model/MatDto.java
index 6c20f86..900c637 100644
--- a/src/main/java/com/zy/common/model/MatDto.java
+++ b/src/main/java/com/zy/common/model/MatDto.java
@@ -27,6 +27,8 @@
// 鎵规
private String batch;
+ private String locNo;
+
public MatDto() {
}
diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java
index ca8971b..259ef47 100644
--- a/src/main/java/com/zy/core/thread/LedThread.java
+++ b/src/main/java/com/zy/core/thread/LedThread.java
@@ -185,7 +185,7 @@
// page.newLine("鑷姩鍖栫珛浣撲粨搴�");
// page.newLine("瑗挎牸杩堣偂浠芥湁闄愬叕鍙�");
// }
- page.newLine("涓壃鏅鸿兘浠撳偍");
+ page.newLine("鎹蜂紬鏅鸿兘浠撳偍");
// 璁剧疆瀛椾綋
page.setFont(new Font("瀹嬩綋",Font.PLAIN,13));
diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index 005bba0..c45527c 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -256,6 +256,49 @@
array[8] = command.getDestinationPosZ();
array[9] = command.getCommand();
result = siemensNet.Write("DB100.0", array);
+
+ //鍫嗗灈鏈轰换鍔″啓鍏ュ悗锛屽洖璇讳竴娆★紝鐪嬫槸鍚︽垚鍔�
+ Thread.sleep(200);
+ try{
+ OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 18);
+ if (resultRead.IsSuccess) {
+ CrnCommand one = new CrnCommand();
+ one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2));
+ one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4));
+ one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6));
+ one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8));
+ one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10));
+ one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12));
+ one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14));
+ one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16));
+ if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode())
+ || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY())
+ || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX())
+ || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
+ ){
+ try{
+ News.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
+ }catch (Exception e){
+ try{
+ News.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSON(command),JSON.toJSON(resultRead));
+ }catch (Exception e1){
+ News.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
+ }
+ }
+ if(!resetFlag){
+ News.error("鍫嗗灈鏈哄懡浠ゅ洖璇诲け璐ュ悗锛岄噸鏂版坊鍔犱换鍔″埌闃熷垪2 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
+ MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command));
+ }
+ Thread.sleep(100);
+ readStatus();
+ return false;
+ } else {
+// News.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
+ }
+ }
+ }catch (Exception e){
+ News.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲嚭閿�");
+ }
}
} else {
// 鍐欎换鍔″畬鎴愮‘璁�
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 506993f..d56fef9 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -278,7 +278,7 @@
OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.42", (short) 8);
if (resultErr.IsSuccess) {
boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, 0, 1);
- StaProtocol staProtocol = station.get(303);
+ StaProtocol staProtocol = station.get(304);
staProtocol.setFrontErr(status[0]);
staProtocol.setBackErr(status[1]);
staProtocol.setHighErr(status[2]);
--
Gitblit v1.9.1