From 26e01b3be27f13ee189c491e8d9ef333980a0c57 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期日, 16 三月 2025 12:42:08 +0800
Subject: [PATCH] *
---
src/main/java/com/zy/core/thread/SiemensCrnThread.java | 55 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index 912044c..3da01f5 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -5,6 +5,7 @@
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;
import com.alibaba.fastjson.JSON;
+import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasCrnOpt;
@@ -38,6 +39,15 @@
private CrnProtocol crnProtocol;
private boolean resetFlag = false;
+ public Long sign = System.currentTimeMillis();
+
+ public boolean isRunning = true;
+
+ /**
+ * 鍫嗗灈鏈烘槸鍚﹀湪鍥炲師鐐硅繍鍔ㄤ腑鏍囪
+ */
+ private boolean backHpFlag = false;
+
public SiemensCrnThread(CrnSlave slave) {
this.slave = slave;
}
@@ -46,7 +56,7 @@
@SuppressWarnings("InfiniteLoopStatement")
public void run() {
this.connect();
- while (true) {
+ while (isRunning) {
try {
int step = 1;
Task task = MessageQueue.poll(SlaveType.Crn, slave.getId());
@@ -87,7 +97,8 @@
} catch (Exception e) {
// e.printStackTrace();
}
-
+// System.out.println("绗�"+slave.getId()+"涓爢鍨涙満绾跨▼杩愯涓�杞細"+(System.currentTimeMillis()-sign));
+ sign = System.currentTimeMillis();
}
}
@@ -142,10 +153,11 @@
*/
private void readStatus(){
try {
- OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 70);
+ OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56);
if (result.IsSuccess) {
if (null == crnProtocol) {
crnProtocol = new CrnProtocol();
+ crnProtocol.setCrnNo(slave.getId());
}
crnProtocol.setMode(siemensNet.getByteTransform().TransInt16(result.Content, 0));
crnProtocol.setTaskNo(siemensNet.getByteTransform().TransInt16(result.Content, 2));
@@ -162,18 +174,23 @@
crnProtocol.setTemp3(siemensNet.getByteTransform().TransInt16(result.Content, 24));
crnProtocol.setTemp4(siemensNet.getByteTransform().TransInt16(result.Content, 26));
crnProtocol.setxSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 28));
- crnProtocol.setySpeed(siemensNet.getByteTransform().TransInt16(result.Content, 30));
- crnProtocol.setzSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 32));
- crnProtocol.setxDistance(siemensNet.getByteTransform().TransInt16(result.Content, 34));
- crnProtocol.setyDistance(siemensNet.getByteTransform().TransInt16(result.Content, 36));
- crnProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 38));
- crnProtocol.setyDuration(siemensNet.getByteTransform().TransInt16(result.Content, 40));
+ crnProtocol.setySpeed(siemensNet.getByteTransform().TransInt16(result.Content, 32));
+ crnProtocol.setzSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 36));
+ crnProtocol.setxDistance(siemensNet.getByteTransform().TransInt16(result.Content, 40));
+ crnProtocol.setyDistance(siemensNet.getByteTransform().TransInt16(result.Content, 44));
+ crnProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48));
+ crnProtocol.setyDuration(siemensNet.getByteTransform().TransInt16(result.Content, 52));
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId()));
// 澶嶄綅淇″彿
- if (crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) {
+ if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) {
+ log.error("-------------------------------------------绗竴姝ャ�乕鍫嗗灈鏈哄彿锛歿}, 宸ヤ綔鍙凤細{}, 杞借揣鍙�:{}]==>> 鐘舵�佷负10锛岀瓑寰呯‘璁わ紒锛�",
+ slave.getId(),crnProtocol.getTaskNo(), crnProtocol.getLoaded()==1 ? "鏈夌墿" : "鏃犵墿");
if (resetFlag) {
+ if(crnProtocol.getTaskNo()==9999){
+ backHpFlag = false;
+ }
CrnCommand crnCommand = new CrnCommand();
crnCommand.setAckFinish((short)1);
if (write(crnCommand)) {
@@ -223,9 +240,9 @@
log.error("鍫嗗灈鏈哄啓鍏ュ懡浠や负绌�");
return false;
}
- convertRow(command);
+// convertRow(command);
command.setCrnNo(slave.getId());
- short[] array = new short[12];
+ short[] array = new short[10];
array[0] = command.getAckFinish();
array[1] = command.getTaskNo();
array[2] = command.getTaskMode();
@@ -235,14 +252,15 @@
array[6] = command.getDestinationPosX();
array[7] = command.getDestinationPosY();
array[8] = command.getDestinationPosZ();
- array[9] = command.getSourceStaNo();
- array[10] = command.getDestinationStaNo();
- array[11] = command.getCommand();
+// array[9] = command.getSourceStaNo();
+// array[10] = command.getDestinationStaNo();
+ array[9] = command.getCommand();
OperateResult result = siemensNet.Write("DB100.0", array);
if (command.getAckFinish() == 0) {
short commandFinish = 1;
- result = siemensNet.Write("DB100.22", commandFinish);
+ Thread.sleep(100L);
+ result = siemensNet.Write("DB100.18", commandFinish);
}
try {
@@ -402,4 +420,9 @@
}
+ // 鎻愪緵涓�涓柟娉曟潵鍋滄绾跨▼
+ public void requestStop() {
+ isRunning = false;
+ }
+
}
--
Gitblit v1.9.1