From 15154033d40f857f61760f137ca59eaf29908aa3 Mon Sep 17 00:00:00 2001
From: cpT <1@123>
Date: 星期三, 02 七月 2025 10:03:57 +0800
Subject: [PATCH] #改造
---
src/main/java/com/zy/core/thread/RgvThread.java | 390 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 290 insertions(+), 100 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/RgvThread.java b/src/main/java/com/zy/core/thread/RgvThread.java
index 54adad5..49b1123 100644
--- a/src/main/java/com/zy/core/thread/RgvThread.java
+++ b/src/main/java/com/zy/core/thread/RgvThread.java
@@ -65,7 +65,10 @@
private boolean resetFlag2 = false;
private boolean connectRgv = false;
+ public Long currentTimeMilliConnectRgv= 0L;
+
private boolean delRgvTask = false;
+ private short wrkSign = 0;
public RgvThread(RgvSlave slave) {
this.slave = slave;
@@ -74,6 +77,12 @@
@Override
@SuppressWarnings("InfiniteLoopStatement")
public void run() {
+ initRgv();
+ try{
+ Thread.sleep(2000);
+ } catch (Exception e){
+
+ }
connectRgv = this.connect();
while(!connectRgv){
try {
@@ -94,7 +103,7 @@
new Thread(this::taskIssued).start();
// 鍚姩婕父绾跨▼
-// new Thread(this::taskWalkIssued).start();
+ new Thread(this::taskWalkIssued).start();
// new Thread(this::taskWalkIssued2).start();
// 鍚姩浠诲姟瀹屾垚绾跨▼
@@ -104,6 +113,7 @@
private void rgvConnect() {
while (true) {
try {
+ Thread.sleep(1000);
if(!connectRgv){
try {
connectRgv = this.connect();
@@ -116,9 +126,9 @@
log.error("rgv杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "rgv杩炴帴澶辫触"+e.getMessage());
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "rgv杩炴帴澶辫触"+e.getMessage());
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
initRgv();
// e.printStackTrace();
@@ -129,8 +139,17 @@
private void readStatusRgv() {
while (true) {
try {
+ if(!connectRgv){
+ try {
+ Thread.sleep(1000L);
+ } catch (Exception e){
+
+ }
+ initRgv();
+ continue;
+ }
Thread.sleep(20);
-// System.out.println("璇荤嚎绋�"+ slave.getId());
+// System.out.println("璇荤嚎绋�,灏忚溅鍙�"+ slave.getId()+"鏃堕棿鎴筹細"+System.currentTimeMillis());
readStatus();
@@ -138,9 +157,9 @@
log.error("RGV鏁版嵁璇诲彇绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV鏁版嵁璇诲彇绾跨▼寮傚父"+e.getMessage());
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV鏁版嵁璇诲彇绾跨▼寮傚父"+e.getMessage());
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
initRgv();
// e.printStackTrace();
@@ -156,24 +175,34 @@
private void taskComplete() {
while (true) {
try {
+ if(!connectRgv){
+ try {
+ Thread.sleep(1000L);
+ } catch (Exception e){
+
+ }
+ continue;
+ }
if (delRgvTask){
writeDelRgvTask();
delRgvTask = false;
continue;
}
- Thread.sleep(40);
+ Thread.sleep(50L);
+
OperateResultExOne<byte[]> result = siemensNet.Read("DB100.12", (short) 1);
boolean[] status = siemensNet.getByteTransform().TransBool(result.Content, 0, 1);
if (status[0]){
+ Thread.sleep(500L);
OperateResult result4 = siemensNet.Write("DB100.12.0", false);
}
} catch (Exception e) {
log.error("RGV鏁版嵁浠诲姟涓嬪彂澶嶄綅绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV鏁版嵁浠诲姟涓嬪彂澶嶄綅绾跨▼寮傚父"+e.getMessage());
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV鏁版嵁浠诲姟涓嬪彂澶嶄綅绾跨▼寮傚父"+e.getMessage());
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
initRgv();
// e.printStackTrace();
@@ -237,7 +266,7 @@
// log.error("RGV浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
// try{
// DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
-// deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV浠诲姟涓嬪彂绾跨▼寮傚父"+e.getMessage());
+// deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV浠诲姟涓嬪彂绾跨▼寮傚父"+e.getMessage());
// } catch (Exception e2){
// log.error("e2:"+e2.getMessage());
// }
@@ -249,58 +278,73 @@
/**
* 婕父
*/
-// private void taskWalkIssued() {
-// while (true) {
-// try {
-// // 浼戠湢 1 绉�
-// Thread.sleep(100);
-//
-// if (!deviceDetection()) {
-// continue;
-// }
-// RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
-// if (rgvTaskProtocol == null) {
-// initRgv();
-// rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
-// }
-// if (rgvTaskProtocol.getAvoid() != 1) {
-// continue;
-// }
-// TaskProtocol issued = new TaskProtocol();
-// issued.setTaskNo(32222L);
-// issued.setTargetPosition(rgvTaskProtocol.getAvoidingTheDestination());
-// issued.setTaskStatus(1);
-// issued.setDirection(true);
-// write(issued);
-// rgvTaskProtocol.setAvoid(0);
-//
+ private void taskWalkIssued() {
+ while (true) {
+ try {
+ if(!connectRgv){
+ try {
+ Thread.sleep(1000L);
+ } catch (Exception e){
+
+ }
+ continue;
+ }
+ // 浼戠湢 1 绉�
+ Thread.sleep(100);
+
+ if (!deviceDetection()) {
+ continue;
+ }
+ RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
+ if (rgvTaskProtocol == null) {
+ initRgv();
+ rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
+ }
+ if (rgvTaskProtocol.getAvoid() != 1) {
+ continue;
+ }
+ TaskProtocol issued = new TaskProtocol();
+ issued.setTaskNo(32222L);
+ issued.setTargetPosition(rgvTaskProtocol.getAvoidingTheDestination());
+ issued.setTaskStatus(1);
+ issued.setDirection(true);
+ write(issued);
+ rgvTaskProtocol.setAvoid(0);
+
// Thread.sleep(200);
-// RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
-//
-// } catch (Exception e) {
-// log.error("RGV琛岃蛋浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛�" + e.getMessage());
-//// e.printStackTrace();
-// }
-// }
-// }
+ RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
+
+ } catch (Exception e) {
+ log.error("RGV琛岃蛋浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛�" + e.getMessage());
+// e.printStackTrace();
+ }
+ }
+ }
/**
* 浠诲姟涓嬪彂
*/
private void taskIssued() {
while (true) {
+ if(!connectRgv){
+ try {
+ Thread.sleep(1000L);
+ } catch (Exception e){
+
+ }
+ continue;
+ }
RgvRunProtocol rgvRun = RgvRunCache.getRgvRun();
if (!rgvRun.getRgvNo().equals(slave.getId())){
-
continue;
}
try {
- Thread.sleep(50);
+ Thread.sleep(100);
rgvRun = RgvRunCache.getRgvRun();
// System.out.println(JSON.toJSON(rgvRun));
// 浼戠湢 1 绉�
- if (System.currentTimeMillis() - rgvRun.currentTimeMilliOld > 1000) {
+ if (System.currentTimeMillis() - rgvRun.currentTimeMilliOld > 500L) {
rgvRun.currentTimeMilliOld = System.currentTimeMillis()+50;
} else {
continue;
@@ -309,7 +353,9 @@
rgvRun.currentTimeMilliOld = System.currentTimeMillis()+50;
rgvRun.setRgvNo(slave.getOtherId());
RgvRunCache.updateRgvStatus(rgvRun);
- RgvErrCache.updateRgvErr(slave.getId(),errorRgv);
+ if (!errorRgv.equals("鏃�")){
+ RgvErrCache.updateRgvErr(slave.getId(),errorRgv);
+ }
continue;
}
@@ -334,20 +380,6 @@
continue;
}
if (rgvTaskProtocol.getAvoid() != 0) {
- if (rgvTaskProtocol.getAvoid() == 1) {
- TaskProtocol issued = new TaskProtocol();
- issued.setTaskNo(32222L);
- issued.setTargetPosition(rgvTaskProtocol.getAvoidingTheDestination());
- issued.setTaskStatus(1);
- issued.setDirection(true);
- write(issued);
- RgvErrCache.updateRgvErr(slave.getId());
- rgvTaskProtocol.setAvoid(0);
-
-// try{Thread.sleep(50L);} catch (Exception e){}
-
- RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
- }
rgvRun.currentTimeMilliOld = System.currentTimeMillis()+50;
rgvRun.setRgvNo(slave.getOtherId());
RgvRunCache.updateRgvStatus(rgvRun);
@@ -443,9 +475,9 @@
log.error("RGV浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV浠诲姟涓嬪彂绾跨▼寮傚父"+e.getMessage());
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV浠诲姟涓嬪彂绾跨▼寮傚父"+e.getMessage());
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
rgvRun = RgvRunCache.getRgvRun();
rgvRun.currentTimeMilliOld = System.currentTimeMillis()+50;
@@ -495,7 +527,7 @@
return false;
}
if (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM)) {
- errorRgv = slave.getId()+"鍙峰皬杞﹂潪绌洪棽";
+ errorRgv = "鏃�";
return false;
}
if ( (Math.abs(rgvProtocol.getRgvPos() - rgvProtocol.getRgvPosDestination())>100) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM)) {
@@ -535,6 +567,10 @@
public boolean otherRgvAvoid(Long targetPosition) {
RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId());
+ long onePos = Math.abs(targetPosition - rgvProtocol.getRgvPos());
+ if (onePos<50){
+ return true;
+ }
RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
@@ -572,9 +608,9 @@
errorRgv = "RGV琛岃蛋鐩爣瓒呭嚭鑼冨洿";
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -597,6 +633,66 @@
return false;
}
}
+ TaskProtocol nowPosRunTask2 = taskProtocolCacheOther.getNowPosRunTask2();
+ if (!Cools.isEmpty(nowPosRunTask2)){
+ boolean signNowPosRun = true;
+ boolean signNowPosA = true;
+ if (targetPosition - rgvProtocol.getRgvPos()>0){
+ if (nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos()>0){
+ if (rgvProtocol.getRgvPos()>rgvProtocolOther.getRgvPos()){
+ signNowPosA = false;
+ signNowPosRun = false;
+ }
+ }
+ } else if (targetPosition - rgvProtocol.getRgvPos()<0){
+ if (nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos()<0){
+ if (rgvProtocol.getRgvPos()<rgvProtocolOther.getRgvPos()){
+ signNowPosA = false;
+ signNowPosRun = false;
+ }
+ }
+ }
+
+ if (signNowPosA){
+ if (nowPosRunTask2.getTaskStatus()==3){
+ long twoPos = Math.abs(nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos());
+ if (Math.abs(onePos - twoPos)>100){
+ if (onePos-50>twoPos+50){
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, nowPosRunTask2.getTargetPositionStaNoPlcId());
+ StaProtocol staProtocol = devpThread.getStation().get(nowPosRunTask2.getTargetPositionStaNo());
+ if (staProtocol == null ) {
+ signNowPosRun =false;
+ }
+ if (signNowPosRun){
+ // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
+ if (staProtocol.isAutoing() && !staProtocol.isLoading()
+ ){
+ errorRgv = slave.getOtherId()+"鍙稲GV绛夊緟浣滀笟...";
+ return false;
+ }
+ }
+ signNowPosRun =false;
+ }
+ }
+ } else {
+ long twoPos = Math.abs(nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos());
+ if (twoPos<100){
+ errorRgv = slave.getOtherId()+"鍙稲GV绛夊緟浣滀笟...";
+ return false;
+ }
+ if (Math.abs(onePos - twoPos)>100){
+ if (onePos-50>twoPos+50){
+ signNowPosRun =false;
+ }
+ }
+ }
+ }
+
+ if (signNowPosRun){
+ errorRgv = slave.getOtherId()+"鍙稲GV绛夊緟浣滀笟...";
+ return false;
+ }
+ }
long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing();
if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) {
log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
@@ -604,9 +700,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -632,9 +728,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -661,9 +757,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -718,9 +814,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -743,6 +839,67 @@
return false;
}
}
+
+ TaskProtocol nowPosRunTask2 = taskProtocolCacheOther.getNowPosRunTask2();
+ if (!Cools.isEmpty(nowPosRunTask2)){
+ boolean signNowPosRun = true;
+ boolean signNowPosA = true;
+ if (targetPosition - rgvProtocol.getRgvPos()>0){
+ if (nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos()>0){
+ if (rgvProtocol.getRgvPos()>rgvProtocolOther.getRgvPos()){
+ signNowPosA = false;
+ signNowPosRun = false;
+ }
+ }
+ } else if (targetPosition - rgvProtocol.getRgvPos()<0){
+ if (nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos()<0){
+ if (rgvProtocol.getRgvPos()<rgvProtocolOther.getRgvPos()){
+ signNowPosA = false;
+ signNowPosRun = false;
+ }
+ }
+ }
+
+ if (signNowPosA){
+ if (nowPosRunTask2.getTaskStatus()==3){
+ long twoPos = Math.abs(nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos());
+ if (Math.abs(onePos - twoPos)>100){
+ if (onePos-50>twoPos+50){
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, nowPosRunTask2.getTargetPositionStaNoPlcId());
+ StaProtocol staProtocol = devpThread.getStation().get(nowPosRunTask2.getTargetPositionStaNo());
+ if (staProtocol == null ) {
+ signNowPosRun =false;
+ }
+ if (signNowPosRun){
+ // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
+ if (staProtocol.isAutoing() && !staProtocol.isLoading()
+ ){
+ errorRgv = slave.getOtherId()+"鍙稲GV绛夊緟浣滀笟...";
+ return false;
+ }
+ }
+ signNowPosRun =false;
+ }
+ }
+ } else {
+ long twoPos = Math.abs(nowPosRunTask2.getTargetPosition() - rgvProtocolOther.getRgvPos());
+ if (twoPos<100){
+ errorRgv = slave.getOtherId()+"鍙稲GV绛夊緟浣滀笟...";
+ return false;
+ }
+ if (Math.abs(onePos - twoPos)>100){
+ if (onePos-50>twoPos+50){
+ signNowPosRun =false;
+ }
+ }
+ }
+ }
+
+ if (signNowPosRun){
+ errorRgv = slave.getOtherId()+"鍙稲GV绛夊緟浣滀笟...";
+ return false;
+ }
+ }
long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng();
if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) {
log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
@@ -750,9 +907,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -778,9 +935,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -808,9 +965,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
@@ -870,9 +1027,9 @@
log.error("RGV寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV寮傚父"+e.getMessage());
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV寮傚父"+e.getMessage());
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
rgvProtocol.setStatusEnable(true);
}
@@ -906,11 +1063,18 @@
// OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慠GV plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
log.error("RGV plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
- try{
- DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGVplc杩炴帴澶辫触");
- } catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+ if (System.currentTimeMillis()-currentTimeMilliConnectRgv>1000*60*10){
+ try{
+ DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGVplc杩炴帴澶辫触");
+ } catch (Exception e2){
+// log.error("e2:"+e2.getMessage());
+ }
+ if (currentTimeMilliConnectRgv == 0){
+ currentTimeMilliConnectRgv = System.currentTimeMillis()-1000*60*10-1;
+ } else {
+ currentTimeMilliConnectRgv = System.currentTimeMillis();
+ }
}
}
initRgv();
@@ -941,6 +1105,16 @@
}
rgvProtocol.setStatus(siemensNet.getByteTransform().TransInt16(result.Content, 8));
+// rgvProtocol.setStatus((short)1);
+
+ //浣滀笟鍚姩涓� 瑙e喅浠诲姟涓嬪彂鍚庡皬杞︾姸鎬佹湭鏇存柊锛屽皬杞︾姸鎬佷笉鍙婃椂
+ if (this.wrkSign == 1 && rgvProtocol.getStatus()!=(short)1){
+ this.wrkSign = 0;
+ }
+ if (this.wrkSign == 1){
+ rgvProtocol.setStatus((short)110);
+ }
+
rgvProtocol.setTaskNo((long)siemensNet.getByteTransform().TransInt32(result.Content, 10));
rgvProtocol.setRgvNo((int)siemensNet.getByteTransform().TransInt16(result.Content, 14));
@@ -959,8 +1133,10 @@
rgvProtocol.setErr4(status[11]);
rgvProtocol.setErr5(status[12]);
rgvProtocol.setErr6(status[13]);
+ rgvProtocol.setErr7(status[14]);
+ rgvProtocol.setErr8(status[15]);
// System.out.println("璇荤嚎绋�"+ slave.getId()+"---"+JSON.toJSONString(rgvProtocol));
-
+// System.out.println("璇荤嚎绋�,灏忚溅鍙�"+ slave.getId()+"鏃堕棿鎴筹細"+System.currentTimeMillis()+"灏忚溅鏁版嵁锛�"+JSON.toJSONString(rgvProtocol));
OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛", DateUtils.convert(new Date()), slave.getId()));
// // 宸ヤ綅1澶嶄綅淇″彿
// if (rgvProtocol.getStatusType().equals(RgvStatusType.WAITING)
@@ -994,9 +1170,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV plc鏁版嵁搴撴洿鏂板け璐�");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV plc鏁版嵁搴撴洿鏂板け璐�");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
}
} catch (Exception ignore) {
@@ -1015,9 +1191,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "璇诲彇RGV plc鐘舵�佷俊鎭け璐�");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "璇诲彇RGV plc鐘舵�佷俊鎭け璐�");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
}
} catch (Exception e) {
@@ -1027,9 +1203,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "璇诲彇RGV plc鐘舵�佷俊鎭け璐�");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "璇诲彇RGV plc鐘舵�佷俊鎭け璐�");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
initRgv();
}
@@ -1044,17 +1220,16 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV鍐欏叆鍛戒护涓虹┖");
+ deviceErrorService.addDeviceError("rgvErr", slave.getId(), "RGV鍐欏叆鍛戒护涓虹┖");
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
return false;
}
// convertRow(command);
// taskProtocol.setRgvNo(slave.getId());
- Long[] array = new Long[11];
+// Long[] array = new Long[11];
OperateResult result41 = siemensNet.Write("DB100.12.0", false);
-
// array[0] = taskProtocol.getAckFinish1();
// array[1] = taskProtocol.getTaskNo();
// array[2] = taskProtocol.getTaskMode();
@@ -1066,8 +1241,13 @@
OperateResult result1 = siemensNet.Write("DB100.4", (short) taskStatus);
OperateResult result2 = siemensNet.Write("DB100.6", taskProtocol.getTaskNo().intValue());
OperateResult result3 = siemensNet.Write("DB100.10", taskProtocol.isDirection()? (short) 1 : (short) 2); // 鎵ц鏂瑰悜锛堥潰鏈濊建閬� 瀹氫綅鍊煎乏灏忓彸澶э級 true:宸� false:鍙�
+ Thread.sleep(20L);
OperateResult result4 = siemensNet.Write("DB100.12.0", true);
+ this.wrkSign = 1;
+
+// log.info("浠诲姟涓嬪彂绾跨▼,灏忚溅鍙�"+ slave.getId()+"鏃堕棿鎴筹細"+System.currentTimeMillis());
+
// if (taskProtocol.getAckFinish1() == 0) {
// short commandFinish = 3; //宸ヤ綅1銆�2浠诲姟鍚屾椂鍐欏叆
// Thread.sleep(100L);
@@ -1095,6 +1275,7 @@
} catch (Exception ignore) {
}
+ readStatus();
if (result != null && result.IsSuccess) {
// Thread.sleep(50);
// this.readStatus();
@@ -1103,9 +1284,9 @@
try{
DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV 鍛戒护涓嬪彂"+JSON.toJSON(taskProtocol));
+ deviceErrorService.addDeviceError("rgvWrite", slave.getId(), "RGV 鍛戒护涓嬪彂"+JSON.toJSON(taskProtocol));
} catch (Exception e2){
- log.error("e2:"+e2.getMessage());
+// log.error("e2:"+e2.getMessage());
}
OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(taskProtocol)));
return true;
@@ -1123,6 +1304,7 @@
OperateResult result1 = siemensNet.Write("DB100.4", (short) 0);
OperateResult result2 = siemensNet.Write("DB100.6", (int) 0);
OperateResult result3 = siemensNet.Write("DB100.10", (short) 0); // 鎵ц鏂瑰悜锛堥潰鏈濊建閬� 瀹氫綅鍊煎乏灏忓彸澶э級 true:宸� false:鍙�
+ log.info("浠诲姟瀹屾垚涓嬪彂绾跨▼,灏忚溅鍙�"+ slave.getId()+"鏃堕棿鎴筹細"+System.currentTimeMillis());
try {
// 鏃ュ織璁板綍
@@ -1159,6 +1341,14 @@
}
+ /**
+ * 娓呴櫎浣滀笟鍚姩涓�
+ */
+ @Override
+ public void setWrkSign() {
+ this.wrkSign = 0;
+ }
+
public void setDelRgvTask() {
delRgvTask = true;
}
--
Gitblit v1.9.1