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,74 +162,90 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
} }
private void executeLogicBefore() { private void executeLogicBefore() {
// 告诉agv急停(车辆) Date date = new Date();
if (error == 1) { if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
// 只给agv下发第二个互斥组例如GS01A2 log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); } else {
if (substring.equals("2")) { this.instruction_require_time = date;
// 根据当前互斥组设备里的状态 // 告诉agv急停(车辆)
JSONObject param = new JSONObject(); if (error == 1) {
String[] paramArr = {this.currentDeviceCode}; // 只给agv下发第二个互斥组例如GS01A2
param.put("blockGroup", paramArr); String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1);
if (substring.equals("2")) {
// 根据当前互斥组设备里的状态
JSONObject param = new JSONObject();
String[] paramArr = {this.currentDeviceCode};
param.put("blockGroup", paramArr);
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();
String[] carArr = {dataList.get(0).getString("id")}; boolean success1 = objectUnifiedResponse.isSuccess();
JSONObject json = new JSONObject(); if (success1) {
json.put("vehicles", carArr); requireSuccess = true;
if (ObjectUtil.isNotEmpty(carArr[0])) { }
// 请求下发agv急停
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); String[] carArr = {dataList.get(0).getString("id")};
//创建订单序列 JSONObject json = new JSONObject();
xianGongAgv.sendOrderStopToXZ(json); json.put("vehicles", carArr);
if (ObjectUtil.isNotEmpty(carArr[0])) {
// 请求下发agv急停
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class);
//创建订单序列
UnifiedResponse<Object> objectUnifiedResponse1 = xianGongAgv.sendOrderStopToXZ(json);
boolean success = objectUnifiedResponse1.isSuccess();
if (success) {
requireSuccess = true;
} else {
requireSuccess = false;
}
}
} }
} }
} // 给光栅下发命令5
/* // 告诉agv急停(互斥组) if (error == 5) {
if (error == 1) { String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1);
JSONObject json = new JSONObject(); if (substring.equals("2")) {
// 只给agv下发第二个互斥组例如GS01A2 // 给输送线写5
String[] key = {"toCommand"};
Integer[] value = {5};
writing(Arrays.asList(key),Arrays.asList(value));
String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); // 根据当前互斥组设备里的状态
if (substring.equals("2")) { JSONObject param = new JSONObject();
json.put("block_name", this.currentDeviceCode); String[] paramArr = {this.currentDeviceCode};
param.put("blockGroup", paramArr);
// 请求下发agv急停 UnifiedResponse<List<JSONObject>> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param);
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); List<JSONObject> dataList = objectUnifiedResponse.getData();
//创建订单序列
xianGongAgv.sendOrderStopToXZ(json);
}
}*/
// 给光栅下发命令5 boolean success1 = objectUnifiedResponse.isSuccess();
if (error == 5) { if (success1) {
String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); requireSuccess = true;
if (substring.equals("2")) { }
// 给输送线写5
String[] key = {"toCommand"};
Integer[] value = {5};
writing(Arrays.asList(key),Arrays.asList(value));
// 根据当前互斥组设备里的状态 String[] carArr = {dataList.get(0).getString("id")};
JSONObject param = new JSONObject(); JSONObject json = new JSONObject();
String[] paramArr = {this.currentDeviceCode}; json.put("vehicles", carArr);
param.put("blockGroup", paramArr);
UnifiedResponse<List<JSONObject>> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); // 请求下发agv继续
List<JSONObject> dataList = objectUnifiedResponse.getData(); XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class);
//创建订单序列
UnifiedResponse<Object> objectUnifiedResponse1 = xianGongAgv.sendOrderContinueToXZ(json);
String[] carArr = {dataList.get(0).getString("id")}; boolean success = objectUnifiedResponse1.isSuccess();
JSONObject json = new JSONObject(); if (success) {
json.put("vehicles", carArr); requireSuccess = true;
} else {
// 请求下发agv继续 requireSuccess = false;
XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); }
//创建订单序列 }
xianGongAgv.sendOrderContinueToXZ(json);
} }
} }
} }
@Override @Override