This commit is contained in:
USER-20220102CG\noblelift
2023-03-02 21:17:27 +08:00
parent a27eceffc6
commit 4274b556bb
13 changed files with 115 additions and 29 deletions

View File

@@ -56,4 +56,7 @@ public interface AcsConfig {
String MAXSENDTASKTIME = "maxSendTaskTime"; String MAXSENDTASKTIME = "maxSendTaskTime";
//指令下发立库 //指令下发立库
String INSTSENDLK = "instSendLk"; String INSTSENDLK = "instSendLk";
//是否允许下发
String ISALLOWTASK= "is_allow_task";
} }

View File

@@ -79,6 +79,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
int task = 0; int task = 0;
int last_task = 0; int last_task = 0;
int heartbeat = 0;
int last_heartbeat = 0;
Boolean isonline = true; Boolean isonline = true;
int hasGoods = 0; int hasGoods = 0;
@@ -126,6 +129,10 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
walk_y = this.itemProtocol.getWalk_y(); walk_y = this.itemProtocol.getWalk_y();
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
heartbeat = this.itemProtocol.getHeartbeat();
if(heartbeat != last_heartbeat){
logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
}
if (mode != last_mode) { if (mode != last_mode) {
if (mode == 2) { if (mode == 2) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号复位前requireSuccess" + requireSucess); logServer.deviceExecuteLog(this.device_code, "", "", "信号复位前requireSuccess" + requireSucess);
@@ -417,7 +424,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
} catch (Exception var17) { } catch (Exception var17) {
var17.printStackTrace(); var17.printStackTrace();
feedMessage = var17.getMessage(); feedMessage = var17.getMessage();
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage()); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage()+ ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol) );
} }
// if (!this.itemProtocol.getIsonline()) { // if (!this.itemProtocol.getIsonline()) {
@@ -477,6 +485,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
last_walk_y = walk_y; last_walk_y = walk_y;
last_error = error; last_error = error;
last_task = task; last_task = task;
last_heartbeat = heartbeat;
} }

View File

@@ -122,7 +122,8 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
int branchProtocol = 0; int branchProtocol = 0;
String inst_message; String inst_message;
String last_inst_message; String last_inst_message;
int heartbeat = 0;
int last_heartbeat = 0;
//当前指令 //当前指令
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
@@ -149,6 +150,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
to_command = this.itemProtocol.getTo_command(); to_command = this.itemProtocol.getTo_command();
heartbeat = this.itemProtocol.getHeartbeat();
if(heartbeat != last_heartbeat){
logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
}
if (mode != last_mode) { if (mode != last_mode) {
if (mode == 2) { if (mode == 2) {
requireSucess = false; requireSucess = false;
@@ -227,8 +232,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (Exception var17) { } catch (Exception var17) {
var17.printStackTrace(); var17.printStackTrace();
inst_message = var17.getMessage(); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage()+ ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol) );
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage());
} }
if("true".equals(this.device.getExtraValue().get("ship_device_update"))){ if("true".equals(this.device.getExtraValue().get("ship_device_update"))){
@@ -313,6 +317,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
last_carrier_direction = carrier_direction; last_carrier_direction = carrier_direction;
last_error = error; last_error = error;
last_task = task; last_task = task;
last_heartbeat = heartbeat;
} }
private void shipDeviceUpdate() { private void shipDeviceUpdate() {

View File

@@ -88,7 +88,8 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
int last_task = 0; int last_task = 0;
int agvphase = 0; int agvphase = 0;
String task_code = null; String task_code = null;
int heartbeat = 0;
int last_heartbeat = 0;
int phase = 0; int phase = 0;
int index = 0; int index = 0;
Boolean isonline = true; Boolean isonline = true;
@@ -142,6 +143,10 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
carrier_direction = this.itemProtocol.getCarrier_direction(); carrier_direction = this.itemProtocol.getCarrier_direction();
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
heartbeat = this.itemProtocol.getHeartbeat();
if(heartbeat != last_heartbeat){
logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
}
if (mode != last_mode) { if (mode != last_mode) {
if (mode == 2) { if (mode == 2) {
requireSucess = false; requireSucess = false;
@@ -262,6 +267,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
last_carrier_direction = carrier_direction; last_carrier_direction = carrier_direction;
last_error = error; last_error = error;
last_task = task; last_task = task;
last_heartbeat = heartbeat;
} }
private void shipDeviceUpdate() { private void shipDeviceUpdate() {

View File

@@ -69,7 +69,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
@Autowired NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); @Autowired NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
// 当前指令 // 当前指令
Instruction inst = null; Instruction inst = null;
int heartbeat = 0;
int last_heartbeat = 0;
// 工作模式 // 工作模式
int mode = 0; int mode = 0;
int last_mode = 0; int last_mode = 0;
@@ -139,6 +140,10 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
weight = this.itemProtocol.getWeight(); weight = this.itemProtocol.getWeight();
heartbeat = this.itemProtocol.getHeartbeat();
if(heartbeat != last_heartbeat){
logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
}
if (mode != last_mode) { if (mode != last_mode) {
if (mode == 2) { if (mode == 2) {
requireSucess = false; requireSucess = false;
@@ -281,6 +286,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
last_carrier_direction = carrier_direction; last_carrier_direction = carrier_direction;
last_error = error; last_error = error;
last_task = task; last_task = task;
last_heartbeat = heartbeat;
} }
public boolean exe_error() { public boolean exe_error() {

View File

@@ -70,7 +70,8 @@ public class SiemensOneFloorAGVConveyorDeviceDriver extends AbstractOpcDeviceDri
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
//当前指令 //当前指令
Instruction inst = null; Instruction inst = null;
int heartbeat = 0;
int last_heartbeat = 0;
//工作模式 //工作模式
int mode = 0; int mode = 0;
int last_mode = 0; int last_mode = 0;

View File

@@ -104,6 +104,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
int branchProtocol = 0; int branchProtocol = 0;
int heartbeat = 0;
int last_heartbeat = 0;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag; int flag;
@@ -158,7 +161,10 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
task2 = this.itemProtocol.getTask2(); task2 = this.itemProtocol.getTask2();
to_command1 = this.itemProtocol.getTo_command1(); to_command1 = this.itemProtocol.getTo_command1();
to_command2 = this.itemProtocol.getTo_command2(); to_command2 = this.itemProtocol.getTo_command2();
heartbeat = this.itemProtocol.getHeartbeat();
if(heartbeat != last_heartbeat){
logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat" + last_heartbeat + "->" + heartbeat);
}
if (mode != last_mode) { if (mode != last_mode) {
if (mode == 2) { if (mode == 2) {
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为:" + requireSucess); logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为:" + requireSucess);
@@ -626,12 +632,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
} }
} }
} }
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var17) { feedMessage = e.getMessage();
var17.printStackTrace(); System.out.println("11111111:"+e.getMessage());
feedMessage = var17.getMessage(); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + e.getMessage()+ ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol) );
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage());
} }
if (mode == 0) { if (mode == 0) {
@@ -724,6 +729,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
last_type = type; last_type = type;
last_task1 = task1; last_task1 = task1;
last_task2 = task2; last_task2 = task2;
last_heartbeat = heartbeat;
} }
//关联设备异常申请任务 //关联设备异常申请任务

View File

@@ -87,6 +87,9 @@ public class ItemProtocol {
return this.getOpcStringValue(item_barcode); return this.getOpcStringValue(item_barcode);
} }
public int getTotTask() {
return this.getOpcIntegerValue(item_to_task);
}
Boolean isonline; Boolean isonline;

View File

@@ -84,6 +84,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
int action = 0; int action = 0;
int error = 0; int error = 0;
int task = 0; int task = 0;
int to_task = 0;
String plcbarcode = null; String plcbarcode = null;
String last_plcbarcode = null; String last_plcbarcode = null;
int plcbarcode_length = 0; int plcbarcode_length = 0;
@@ -193,7 +194,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
plcbarcode = this.itemProtocol.getplcBarCode(); plcbarcode = this.itemProtocol.getplcBarCode();
plcbarcode_length = this.itemProtocol.getBarCode_length(); plcbarcode_length = this.itemProtocol.getBarCode_length();
to_task = this.itemProtocol.getTotTask();
if (mode != last_mode) { if (mode != last_mode) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode +"复位请求标记"); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode +"复位请求标记");
if(mode == 2){ if(mode == 2){
@@ -549,11 +550,44 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
//需要判断指令中的指令 再次请求不能生成 //需要判断指令中的指令 再次请求不能生成
if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(),"1"))) { if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(),"1"))) {
{ {
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code Instruction instdto = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(),"1");
+ "已存在对应任务"); if(to_task != Integer.parseInt(instdto.getInstruction_code())){
requireSucess = true; List list = new ArrayList();
applySucess = true; Map map = new HashMap();
return true; if (StrUtil.isNotEmpty(taskdto.getTo_z())) {
if (StrUtil.equals(taskdto.getTo_z(), "01")) {
map.put("code", "to_target");
map.put("value", "102");
} else if (StrUtil.equals(taskdto.getTo_z(), "02")) {
map.put("code", "to_target");
map.put("value", "201");
} else if (StrUtil.equals(taskdto.getTo_z(), "03")) {
map.put("code", "to_target");
map.put("value", "301");
}
}
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", instdto.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
message = "下发电气任务号成功";
requireSucess = true;
applySucess = true;
return true;
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code
+ "已存在对应任务");
requireSucess = true;
applySucess = true;
return true;
}
} }
} }
} }

View File

@@ -472,7 +472,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
log.info("crateTask-----输入参数{}", param); log.info("crateTask-----输入参数{}", param);
JSONArray datas = JSONArray.parseArray(param); JSONArray datas = JSONArray.parseArray(param);
CreateTaskResponse response = new CreateTaskResponse(); CreateTaskResponse response = new CreateTaskResponse();
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
String cancelTaskCheck = paramService.findByCode(AcsConfig.ISALLOWTASK).getValue();
JSONArray errArr = new JSONArray(); JSONArray errArr = new JSONArray();
if(StrUtil.equals(cancelTaskCheck,"0")){
response.setStatus(400);
response.setMessage("ACS系统需要更新请稍等");
response.setErrArr(datas);
return response;
}
for (int i = 0; i < datas.size(); i++) { for (int i = 0; i < datas.size(); i++) {
String data = datas.get(i).toString(); String data = datas.get(i).toString();
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);

View File

@@ -121,6 +121,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0])); itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
} catch (Exception e){ } catch (Exception e){
System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code()); System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code());
log.trace("数据同步异常:{}", this.getOpcServer().getOpc_code());
//e.printStackTrace(); //e.printStackTrace();
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
@@ -138,10 +139,10 @@ public class DeviceOpcProtocolRunable implements Runnable {
time_out = false; time_out = false;
} }
// if(ObjectUtil.isEmpty(itemStatus)) { if(ObjectUtil.isEmpty(itemStatus)) {
// System.out.println( tag + " :itemStatus is null"); System.out.println( tag + " :itemStatus is null");
// break; log.warn(" {} 读取异常 : {} itemStatus is null", tag);
// } }
Set<Item> items = itemStatus.keySet(); Set<Item> items = itemStatus.keySet();
@@ -171,12 +172,13 @@ public class DeviceOpcProtocolRunable implements Runnable {
value = OpcUtl.getValue(item, itemState); value = OpcUtl.getValue(item, itemState);
his = accessor_value.getValue(item.getId()); his = accessor_value.getValue(item.getId());
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality()); log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his);
} }
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码 } while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
OpcItemDto itemDto = this.getItem(item.getId()); OpcItemDto itemDto = this.getItem(item.getId());
if (itemDto.getNeed_log() != null && itemDto.getNeed_log()) { //默认记录日志
if (true) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
//设备的ITEM项 //设备的ITEM项
List<String> relate_items = itemDto.getRelate_items(); List<String> relate_items = itemDto.getRelate_items();
@@ -188,7 +190,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
sb.append("key:" + relate + "value:" + obj + ";"); sb.append("key:" + relate + "value:" + obj + ";");
} }
log.info("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb}); log.warn("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb});
} }
// accessor_value.setValueWithPersistence(item.getId(),accessor_value.getValue(item.getId())); // accessor_value.setValueWithPersistence(item.getId(),accessor_value.getValue(item.getId()));
@@ -203,6 +205,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
try { try {
this.server.disconnect(); this.server.disconnect();
} catch (Exception var25) { } catch (Exception var25) {
log.warn("{} : server disconnect", var25);
} }
} }
@@ -217,6 +220,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000)); Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
log.warn("OPC 读取线程读取异常{} :", e);
// Thread.currentThread().interrupt();不会真正停止线程 // Thread.currentThread().interrupt();不会真正停止线程
} }
++this.error_num; ++this.error_num;

View File

@@ -4,7 +4,7 @@ public class OpcConfig {
public static Boolean auto_start_opc = Boolean.valueOf(true); public static Boolean auto_start_opc = Boolean.valueOf(true);
public static String udw_opc_value_key = "opc_value"; public static String udw_opc_value_key = "opc_value";
public static Integer synchronized_millisecond = Integer.valueOf(100); public static Integer synchronized_millisecond = Integer.valueOf(100);
public static Integer synchronized_exception_wait_second = Integer.valueOf(10); public static Integer synchronized_exception_wait_second = Integer.valueOf(3);
public static Integer retry_times = Integer.valueOf(3); public static Integer retry_times = Integer.valueOf(3);
public static String sync_issue_type_code = "device_opc_sync"; public static String sync_issue_type_code = "device_opc_sync";
public static String opc_server_default_group = "group"; public static String opc_server_default_group = "group";

View File

@@ -40,7 +40,7 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/WmsToAcs.xml"/> <include resource="log/WmsToAcs.xml"/>
<include resource="log/OpcUtil.xml"/> <include resource="log/OpcUtil.xml"/>
<include resource="log/TwoNDCSocketConnectionAutoRun.xml"/> <include resource="log/TwoNDCSocketConnectionAutoRun.xml"/>
<include resource="log/TwoNdcOneDeviceDriver.xml"/> <include resource="log/AgvNdcTwoDeviceDriver.xml"/>
<include resource="log/TwoNDC2SocketConnectionAutoRun.xml"/> <include resource="log/TwoNDC2SocketConnectionAutoRun.xml"/>