rev:加定时

This commit is contained in:
2025-09-03 12:20:13 +08:00
parent a9f17506e7
commit c1c1dd685a

View File

@@ -24,6 +24,7 @@ import org.nl.modules.quartz.task.QueryXGTGroupStatus;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@@ -109,6 +110,9 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
* 车号 * 车号
*/ */
private String car_no; private String car_no;
private Date instruction_require_time = new Date();
private int instruction_require_time_out = 5000;
@Override @Override
public Device getDevice() { public Device getDevice() {
@@ -133,8 +137,16 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
@Override @Override
public void executeLogic() { public void executeLogic() {
if (this.error != this.lastError ) {
if (this.error == 1 || this.error == 5) {
this.requireSuccess = false;
}
}
if (!this.requireSuccess) {
this.executeLogicBefore(); this.executeLogicBefore();
}
if (!this.online) { if (!this.online) {
this.message = "设备离线"; this.message = "设备离线";
} else if (this.mode == 0) { } else if (this.mode == 0) {
@@ -150,6 +162,11 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
} }
private void executeLogicBefore() { private void executeLogicBefore() {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
} else {
this.instruction_require_time = date;
// 告诉agv急停(车辆) // 告诉agv急停(车辆)
if (error == 1) { if (error == 1) {
// 只给agv下发第二个互斥组例如GS01A2 // 只给agv下发第二个互斥组例如GS01A2
@@ -163,6 +180,11 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
UnifiedResponse<List<JSONObject>> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); UnifiedResponse<List<JSONObject>> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param);
List<JSONObject> dataList = objectUnifiedResponse.getData(); List<JSONObject> dataList = objectUnifiedResponse.getData();
boolean success1 = objectUnifiedResponse.isSuccess();
if (success1) {
requireSuccess = true;
}
String[] carArr = {dataList.get(0).getString("id")}; String[] carArr = {dataList.get(0).getString("id")};
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("vehicles", carArr); json.put("vehicles", carArr);
@@ -170,26 +192,16 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
// 请求下发agv急停 // 请求下发agv急停
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class);
//创建订单序列 //创建订单序列
xianGongAgv.sendOrderStopToXZ(json); UnifiedResponse<Object> objectUnifiedResponse1 = xianGongAgv.sendOrderStopToXZ(json);
boolean success = objectUnifiedResponse1.isSuccess();
if (success) {
requireSuccess = true;
} else {
requireSuccess = false;
} }
} }
} }
/* // 告诉agv急停(互斥组)
if (error == 1) {
JSONObject json = new JSONObject();
// 只给agv下发第二个互斥组例如GS01A2
String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1);
if (substring.equals("2")) {
json.put("block_name", this.currentDeviceCode);
// 请求下发agv急停
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class);
//创建订单序列
xianGongAgv.sendOrderStopToXZ(json);
} }
}*/
// 给光栅下发命令5 // 给光栅下发命令5
if (error == 5) { if (error == 5) {
@@ -208,6 +220,11 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
UnifiedResponse<List<JSONObject>> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); UnifiedResponse<List<JSONObject>> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param);
List<JSONObject> dataList = objectUnifiedResponse.getData(); List<JSONObject> dataList = objectUnifiedResponse.getData();
boolean success1 = objectUnifiedResponse.isSuccess();
if (success1) {
requireSuccess = true;
}
String[] carArr = {dataList.get(0).getString("id")}; String[] carArr = {dataList.get(0).getString("id")};
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("vehicles", carArr); json.put("vehicles", carArr);
@@ -215,10 +232,21 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
// 请求下发agv继续 // 请求下发agv继续
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class);
//创建订单序列 //创建订单序列
xianGongAgv.sendOrderContinueToXZ(json); UnifiedResponse<Object> objectUnifiedResponse1 = xianGongAgv.sendOrderContinueToXZ(json);
boolean success = objectUnifiedResponse1.isSuccess();
if (success) {
requireSuccess = true;
} else {
requireSuccess = false;
} }
} }
} }
}
}
@Override @Override
public JSONObject getDeviceStatusName() throws Exception { public JSONObject getDeviceStatusName() throws Exception {