fix 双工位RGV

This commit is contained in:
USER-20220102CG\noblelift
2023-07-18 09:49:41 +08:00
parent 8b956ddc3a
commit 71b5617841
11 changed files with 635 additions and 103 deletions

View File

@@ -759,10 +759,10 @@ public class LnshPackagePalletizingManipulatorSiteDeviceDriver extends AbstractO
break;
case 6:
//码垛完成
// if (!requireSucess) {
// applyEmpty();
// }
if (!requireSucess) {
applyEmpty();
}
if (resultSucess) {
palletizing();
}
break;
@@ -851,6 +851,7 @@ public class LnshPackagePalletizingManipulatorSiteDeviceDriver extends AbstractO
last_encoder_qty = encoder_qty;
last_status = status;
last_unqualified_qty = unqualified_qty;
last_one_cribTotal = one_cribTotal;
}
@@ -987,7 +988,7 @@ public class LnshPackagePalletizingManipulatorSiteDeviceDriver extends AbstractO
JSONObject jsonObject = JSONObject.parseObject(result.body());
if ("200".equals(jsonObject.getString("status"))) {
this.writing(this.mode);
this.setResultSucess(false);
this.setRequireSucess(true);
}
}
result.close();

View File

@@ -70,6 +70,11 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
Boolean requireSucess1 = false;
Boolean requireSucess2 = false;
//后工位申请任务请求标记
Boolean requireBackSucess = false;
//前工位申请任务请求标记
Boolean requireHeadSucess = false;
int hasGoods = 0;
String message = null;
Boolean iserror = false;
@@ -121,11 +126,31 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
int qty = 0;
int last_qty = 0;
int to_command1 =0;
int to_oneset1 =0;
int to_target1 =0;
int to_task1 =0;
int last_to_command1 =0;
int last_to_oneset1 =0;
int last_to_target1 =0;
int last_to_task1 =0;
int to_command2 =0;
int to_oneset2 =0;
int to_target2 =0;
int to_task2 =0;
int last_to_command2 =0;
int last_to_oneset2 =0;
int last_to_target2 =0;
int last_to_task2 =0;
String specifications = "";
String last_specifications = "";
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private Date instruction_update_time = new Date();
private Date instruction_apply_time = new Date();
private Date instruction_require_time2 = new Date();
@@ -133,6 +158,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
private Date instruction_apply_time2 = new Date();
private int instruction_require_time_out = 3000;
private int instruction_update_time_out = 500;
@Override
public Device getDevice() {
@@ -164,8 +190,23 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
batch = this.itemProtocol.getBatch();
specifications = this.itemProtocol.getSpecifications();
qty = this.itemProtocol.getQty();
to_task1 = this.itemProtocol.getTo_task1();
to_command1 = this.itemProtocol.getTo_command1();
to_oneset1 = this.itemProtocol.getTo_onset1();
to_target1 = this.itemProtocol.getTo_target1();
to_task2 = this.itemProtocol.getTo_task2();
to_command2 = this.itemProtocol.getTo_command2();
to_oneset2 = this.itemProtocol.getTo_onset2();
to_target2 = this.itemProtocol.getTo_target2();
if (mode != last_mode) {
if(mode==2){
this.setRequireSucess1(false);
logServer.deviceExecuteLog(this.device_code, "", "", "模式变待机复位前工位请求标记requireSucess1:" + requireSucess1);
this.setRequireSucess2(false);
logServer.deviceExecuteLog(this.device_code, "", "", "模式变待机复位后工位请求标记requireSucess2:" + requireSucess2);
}
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
@@ -178,10 +219,18 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
logServer.deviceExecuteLog(this.device_code, "", "", "信号status" + last_status + "->" + status);
}
if (move_1 != last_move_1) {
if(move_1 ==0){
this.setRequireSucess1(false);
logServer.deviceExecuteLog(this.device_code, "", "", "前工位有货变无货复位前工位请求标记requireSucess1:" + requireSucess1);
}
logServer.deviceItemValue(this.device_code, "move_1", String.valueOf(move_1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move_1" + last_move_1 + "->" + move_1);
}
if (move_2 != last_move_2) {
if(move_2 ==0){
this.setRequireSucess2(false);
logServer.deviceExecuteLog(this.device_code, "", "", "后工位有货变无货复位后工位请求标记requireSucess2:" + requireSucess2);
}
logServer.deviceItemValue(this.device_code, "move_2", String.valueOf(move_2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move_2" + last_move_2 + "->" + move_2);
}
@@ -241,96 +290,120 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
logServer.deviceItemValue(this.device_code, "specifications", specifications);
logServer.deviceExecuteLog(this.device_code, "", "", "信号specifications" + last_specifications + "->" + specifications);
}
if (move_1 == 0 && task1 == 0) {
this.setRequireSucess1(false);
logServer.deviceExecuteLog(this.device_code, "", "", "前工位无货且无任务复位前工位请求标记requireSucess1:" + requireSucess1);
if (to_task1 != last_to_task1) {
logServer.deviceItemValue(this.device_code, "to_task1",String.valueOf(to_task1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task1" + last_to_task1 + "->" + to_task1);
}
if (move_2 == 0 && task2 == 0) {
this.setRequireSucess2(false);
logServer.deviceExecuteLog(this.device_code, "", "", "后工位无货且无任务复位后工位请求标记requireSucess2:" + requireSucess1);
if (to_target1 != last_to_target1) {
logServer.deviceItemValue(this.device_code, "to_task1",String.valueOf(to_target1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target1" + last_to_target1 + "->" + to_target1);
}
if (to_oneset1 != last_to_oneset1) {
logServer.deviceItemValue(this.device_code, "to_task1",String.valueOf(to_oneset1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_oneset1" + last_to_oneset1 + "->" + to_oneset1);
}
if (to_command1 != last_to_command1) {
logServer.deviceItemValue(this.device_code, "to_task1",String.valueOf(to_command1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command1" + last_to_command1 + "->" + to_command1);
}
if (to_task2 != last_to_task2) {
logServer.deviceItemValue(this.device_code, "to_task1",String.valueOf(to_task2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task2" + last_to_task2 + "->" + to_task2);
}
if (to_target2 != last_to_target2) {
logServer.deviceItemValue(this.device_code, "to_task2",String.valueOf(to_task2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target2" + last_to_target2 + "->" + to_target2);
}
if (to_oneset2 != last_to_oneset2) {
logServer.deviceItemValue(this.device_code, "to_task2",String.valueOf(to_oneset2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_oneset2" + last_to_oneset2 + "->" + to_oneset2);
}
if (to_command2 != last_to_command2) {
logServer.deviceItemValue(this.device_code, "to_command2",String.valueOf(to_command2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command2" + last_to_command2 + "->" + to_command2);
}
// if (move_1 == 0 && task1 == 0) {
// this.setRequireSucess1(false);
// logServer.deviceExecuteLog(this.device_code, "", "", "前工位无货且无任务复位前工位请求标记requireSucess1:" + requireSucess1);
// }
// if (move_2 == 0 && task2 == 0) {
// this.setRequireSucess2(false);
// logServer.deviceExecuteLog(this.device_code, "", "", "后工位无货且无任务复位后工位请求标记requireSucess2:" + requireSucess1);
// }
if(task1 > 0 || task2 > 0){
update_instruction_status();
}
if (task1 > 0) {
//inst_message
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
instructionService.update(inst1);
}
// //执行双任务下的业务逻辑
// //给后工位下发空盘放货信号
// if (mode == 3 && action_1 == 2 && action_2 == 2 && move_1 != 0 && move_2 != 0 && task1 > 0 && task2 > 0) {
// if(to_command2 !=2 ){
// writing("to_command2", "2");
// }
// }
// //给前工位下发放货信号
// if (mode == 3 && action_2 == 4 && move_1 != 0 && move_2 == 0 && task1 > 0) {
// if(to_command2 !=2 ) {
// writing("to_command1", "2");
// }
// }
//
// //执行单任务下的业务逻辑
// //给后工位下发空盘放货信号
// //判断条件 前工位无任务、无货 后工位有任务取货完成
// if (mode == 3 && action_2 == 2 && move_2 != 0 && move_1 == 0 && task2 > 0 && task1 == 0) {
// if(to_command2 !=2 ) {
// writing("to_command2", "2");
// }
// }
// //给前工位取满托下发放货信号
// if (mode == 3 && action_1 == 2 && move_1 != 0 && move_2 == 0 && task1 > 0 && task2 == 0) {
// if(to_command2 !=2 ) {
// writing("to_command1", "2");
// }
// }
//双任务下 后工位取货完成,然后给前工位下发取满盘任务取货命令
if (mode == 3 && action_2 == 2 && action_1 == 0 && move_2 != 0 && move_1 == 0 && task2 > 0) {
if(to_command1 !=1 ){
writing("to_command1", "1");
}
}
if (action_1 == 4 && move_1 == 0 && task1 > 0) {
//inst_message
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
try {
finish_instruction(inst1);
} catch (Exception e) {
log.error("RGV 前工位完成指令异常", e);
logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage());
}
writing("to_command1", "0");
writing("to_onset1", "0");
writing("to_target1", "0");
writing("to_task1", "0");
}
this.requireSucess1 = false;
}
if (task2 > 0) {
//inst_message
inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
if (inst2 != null) {
if (StrUtil.equals(inst2.getInstruction_status(), "0")) {
inst2.setInstruction_status("1");
instructionService.update(inst2);
}
//双任务下发 前后工位取货完成 给后工位放货命令
if (mode == 3 && action_2 == 2 && action_1 == 2 && move_2 != 0 && move_1 != 0 && task2 > 0 && task1 > 0) {
if(to_command2 !=2 ) {
writing("to_command2", "2");
}
}
if (action_2 == 4 && move_2 == 0 && task2 > 0) {
//inst_message
inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
if (inst2 != null) {
try {
finish_instruction(inst2);
} catch (Exception e) {
log.error("RGV 前工位完成指令异常", e);
logServer.deviceExecuteLog(this.device_code, "", "", "后工位指令" + task1 + "完成异常,异常原因:" + e.getMessage());
}
writing("to_command2", "0");
writing("to_onset2", "0");
writing("to_target2", "0");
writing("to_task2", "0");
//双任务下发 后工位放货完成 给前工位下发放货
if (mode == 3 && action_2 == 4 && action_1 == 2 && move_2 != 0 && move_1 != 0 && task2 > 0 && task1 > 0) {
if(to_command1 !=2 ) {
writing("to_command1", "2");
}
this.requireSucess2 = false;
}
//执行双任务下的业务逻辑
//给后工位下发空盘放货信号
if (mode == 3 && action_1 == 2 && action_2 == 2 && move_1 != 0 && move_2 != 0 && task1 > 0 && task2 > 0) {
writing("to_command2", "2");
}
//给前工位下发放货信号
if (mode == 3 && action_2 == 4 && move_1 != 0 && move_2 == 0 && task1 > 0) {
writing("to_command1", "2");
//后工位单任务下发 空托或者半托缓存任务
if (mode == 3 && action_2 == 2 && action_1 == 0 && move_2 > 0 && move_1 == 0 && task2 > 0 && task1 == 0) {
if(to_command2 !=2 ) {
writing("to_command2", "2");
}
}
//执行单任务下的业务逻辑
//给后工位下发空盘放货信号
//判断条件 前工位无任务、无货 后工位有任务取货完成
if (mode == 3 && action_2 == 2 && move_2 != 0 && move_1 == 0 && task2 > 0 && task1 == 0) {
writing("to_command2", "2");
}
//给前工位取满托下发放货信号
if (mode == 3 && action_1 == 2 && move_1 != 0 && move_2 == 0 && task1 > 0 && task2 == 0) {
writing("to_command1", "2");
//前工位单任务下发 强制包装的任务
if (mode == 3 && action_1 == 2 && action_2 == 0 && move_1 > 0 && move_2 == 0 && task1 > 0 && task2 == 0) {
if(to_command1 !=2 ) {
writing("to_command1", "2");
}
}
} catch (Exception var17) {
return;
}
@@ -362,19 +435,19 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
return;
case 2:
//后工位申请任务
if (move_2 == 0 && action_2 == 0 && !requireSucess2 && task2 == 0) {
instruction_require2();
}
//前工位申请任务
if (move_2 == 0 && action_2 == 0 && task2 == 0 && move_1 == 0 && task1 == 0 && action_1 == 0 && !requireSucess1 && !requireSucess2) {
// if (move_2 == 0 && action_2 == 0 && !requireSucess2 && task2 == 0) {
// instruction_require2();
// }
// 申请任务
if (move_1 == 0 && move_2 == 0 && action_1 == 0 && action_2 == 0 && task1 == 0 && task2 == 0 && !requireSucess1) {
instruction_require();
}
break;
case 3:
//前工位申请任务
if (move_1 == 0 && action_1 == 0 && task1 == 0 && ( action_2 == 1 || action_2 == 2 )&& !requireSucess1) {
instruction_require();
}
//前工位申请任务 新增上后工位任务号>0的判断
// if (move_1 == 0 && action_1 == 0 && task2> 0 && task1 == 0 && ( action_2 == 1 || action_2 == 2 )&& !requireSucess1 && requireSucess2) {
// instruction_require();
// }
break;
}
@@ -410,6 +483,15 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
last_specifications = specifications;
last_batch = batch;
last_qty = qty;
last_to_command1 = to_command1;
last_to_oneset1 = to_oneset1;
last_to_target1 = to_target1;
last_to_task1 = to_task1;
last_to_command2 = to_command2;
last_to_oneset2 = to_oneset2;
last_to_target2 = to_target2;
last_to_task2 = to_task2;
}
@@ -426,12 +508,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
String demoArray[] = demosub.split(",");
List<String> device_code_list = Arrays.asList(demoArray);
TaskDto task = null;
if (mode == 3) {
Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
device_code_list = new ArrayList<>();
device_code_list.add(inst2.getNext_device_code());
logServer.deviceExecuteLog(device_code, "", "", "前工位申请起点为" + inst2.getNext_device_code() + "的任务");
}
for (int i = 0; i < device_code_list.size(); i++) {
if (ObjectUtil.isNotEmpty(taskserver.queryTaskByDeviceCode(device_code_list.get(i).replace("\"", "")))) {
task = taskserver.queryTaskByDeviceCode(device_code_list.get(i).replace("\"", "")).get(0);
@@ -445,11 +522,21 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
String priority = task.getPriority();
String start_point_code = task.getStart_point_code();
String start_device_code = task.getStart_device_code();
String start_device_code2 = task.getStart_device_code2();
String route_plan_code = task.getRoute_plan_code();
String next_point_code = task.getNext_point_code();
String next_device_code = task.getNext_device_code();
String next_device_code2 = task.getNext_device_code2();
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
Device startdevice2 = null;
Device nextdevice2 = null;
if(ObjectUtil.isNotEmpty(start_device_code2)){
startdevice2 = deviceAppservice.findDeviceByCode(start_device_code2);
}
if(ObjectUtil.isNotEmpty(next_device_code2)){
nextdevice2 = deviceAppservice.findDeviceByCode(next_device_code2);
}
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
@@ -467,6 +554,10 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setStart_point_code2(start_device_code2);
instdto.setNext_point_code2(next_device_code2);
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
@@ -483,17 +574,266 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
//创建指令后修改任务状态
task.setTask_status("1");
taskserver.update(task);
requireSucess1 = true;
String start_addr = startdevice.getExtraValue().get("OPCServer").toString();
String next_addr = nextdevice.getExtraValue().get("OPCServer").toString();
//下发4个点任务
if(ObjectUtil.isNotEmpty(start_device_code2) && ObjectUtil.isNotEmpty(next_device_code2) ){
//前工位送满托任务
String start_addr = startdevice.getExtraValue().get("OPCServer").toString();
String next_addr = nextdevice.getExtraValue().get("OPCServer").toString();
//后工位送空托盘任务
String start_addr2 = startdevice2.getExtraValue().get("OPCServer").toString();
String next_addr2 = nextdevice2.getExtraValue().get("OPCServer").toString();
writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
logServer.deviceExecuteLog(this.device_code, "", "", "申请前工位满料任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code());
// writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
writing("to_command2", "1");
writing("to_onset2", start_addr2);
writing("to_target1", next_addr2);
writing("to_task2", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task2").toString()
, instdto.getInstruction_code())) {
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
writing("to_command2", "1");
writing("to_onset2", start_addr2);
writing("to_target2", next_addr2);
writing("to_task2", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess1 = false;
return false;
}
}
requireSucess1 = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请前后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code());
} else {
String start_addr = startdevice.getExtraValue().get("OPCServer").toString();
String next_addr = nextdevice.getExtraValue().get("OPCServer").toString();
//如果终点是BZSLW 则用前工位
if(StrUtil.equals("BZSLW",next_device_code)){
writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task1").toString()
, instdto.getInstruction_code())) {
writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess1 = false;
return false;
}
}
} else {
writing("to_command2", "1");
writing("to_onset2", start_addr);
writing("to_target2", next_addr);
writing("to_task2", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task1").toString()
, instdto.getInstruction_code())) {
writing("to_command2", "1");
writing("to_onset2", start_addr);
writing("to_target2", start_addr);
writing("to_task2", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess1 = false;
return false;
}
}
}
requireSucess1 = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code());
}
} else {
//申请后工位任务
String linkobj2 = (String) this.getDevice().getExtraValue().get("get_device_code2");
String demosub2 = linkobj2.substring(1, linkobj2.length() - 1);
String demoArray2[] = demosub2.split(",");
List<String> device_code_list2 = Arrays.asList(demoArray2);
TaskDto task2 = null;
for (int i = 0; i < device_code_list2.size(); i++) {
if (ObjectUtil.isNotEmpty(taskserver.queryTaskByDeviceCode(device_code_list2.get(i).replace("\"", "")))) {
task2 = taskserver.queryTaskByDeviceCode(device_code_list2.get(i).replace("\"", "")).get(0);
}
if (ObjectUtil.isNotEmpty(task2)) break;
}
if (!ObjectUtil.isEmpty(task2)) {
String taskid = task2.getTask_id();
String taskcode = task2.getTask_code();
String vehiclecode = task2.getVehicle_code();
String priority = task2.getPriority();
String start_point_code = task2.getStart_point_code();
String start_device_code = task2.getStart_device_code();
String start_device_code2 = task2.getStart_device_code2();
String route_plan_code = task2.getRoute_plan_code();
String next_point_code = task2.getNext_point_code();
String next_device_code = task2.getNext_device_code();
String next_device_code2 = task2.getNext_device_code2();
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
Device startdevice2 = null;
Device nextdevice2 = null;
if(ObjectUtil.isNotEmpty(start_device_code2)){
startdevice2 = deviceAppservice.findDeviceByCode(start_device_code2);
}
if(ObjectUtil.isNotEmpty(next_device_code2)){
nextdevice2 = deviceAppservice.findDeviceByCode(next_device_code2);
}
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(task2.getRemark());
instdto.setMaterial(task2.getMaterial());
instdto.setQuantity(task2.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setStart_point_code2(start_device_code2);
instdto.setNext_point_code2(next_device_code2);
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
try {
instructionService.create(instdto);
} catch (Exception e) {
e.printStackTrace();
}
//创建指令后修改任务状态
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
task2.setTask_status("1");
//创建指令后修改任务状态
task2.setTask_status("1");
taskserver.update(task2);
//下发4个点任务
if(ObjectUtil.isNotEmpty(start_device_code2) && ObjectUtil.isNotEmpty(next_device_code2) ){
//前工位送满托任务
String start_addr = startdevice.getExtraValue().get("OPCServer").toString();
String next_addr = nextdevice.getExtraValue().get("OPCServer").toString();
//后工位送空托盘任务
String start_addr2 = startdevice2.getExtraValue().get("OPCServer").toString();
String next_addr2 = nextdevice2.getExtraValue().get("OPCServer").toString();
// writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
writing("to_command2", "1");
writing("to_onset2", start_addr2);
writing("to_target1", next_addr2);
writing("to_task2", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task2").toString()
, instdto.getInstruction_code())) {
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
writing("to_command2", "1");
writing("to_onset2", start_addr2);
writing("to_target2", next_addr2);
writing("to_task2", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess1 = false;
return false;
}
}
requireSucess1 = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请前后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code());
} else {
String start_addr = startdevice.getExtraValue().get("OPCServer").toString();
String next_addr = nextdevice.getExtraValue().get("OPCServer").toString();
//如果终点是BZSLW 则用前工位
if(StrUtil.equals("BZSLW",next_device_code)){
writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task1").toString()
, instdto.getInstruction_code())) {
writing("to_command1", "1");
writing("to_onset1", start_addr);
writing("to_target1", next_addr);
writing("to_task1", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess1 = false;
return false;
}
}
} else {
writing("to_command2", "1");
writing("to_onset2", start_addr);
writing("to_target2", next_addr);
writing("to_task2", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task1").toString()
, instdto.getInstruction_code())) {
writing("to_command2", "1");
writing("to_onset2", start_addr);
writing("to_target2", start_addr);
writing("to_task2", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess1 = false;
return false;
}
}
}
requireSucess1 = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位任务成功,requireSucess1" + requireSucess1 + ",指令号:" + instdto.getInstruction_code());
}
requireSucess1 = true;
}
}
}
return true;
@@ -563,7 +903,6 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
//创建指令后修改任务状态
task.setTask_status("1");
taskserver.update(task);
requireSucess2 = true;
String start_addr = startdevice.getExtraValue().get("OPCServer").toString();
@@ -574,6 +913,26 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
writing("to_target2", next_addr);
writing("to_task2", instdto.getInstruction_code());
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task2").toString()
, instdto.getInstruction_code())) {
writing("to_command2", "1");
writing("to_onset2", start_addr);
writing("to_target2", next_addr);
writing("to_task2", instdto.getInstruction_code());
logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(instdto.getTask_code()))){
requireSucess2 = false;
return false;
}
}
requireSucess2 = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请后工位空盘任务成功,requireSucess2" + requireSucess2 + ",指令号:" + instdto.getInstruction_code());
}
@@ -781,4 +1140,95 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
public void setDeviceStatus(JSONObject data) {
}
/**
* 更新指令状态
*/
public synchronized void update_instruction_status() throws Exception {
Date date = new Date();
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
} else {
this.instruction_update_time = date;
if(task1 >0 && task2>0 && action_1 == 4 && action_2 == 4 && move_1 ==0 && move_2==0){
//inst_message
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
try {
finish_instruction(inst1);
} catch (Exception e) {
log.error("RGV 前工位完成指令异常", e);
logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage());
}
writing("to_command1", "0");
writing("to_onset1", "0");
writing("to_target1", "0");
writing("to_task1", "0");
writing("to_command2", "0");
writing("to_onset2", "0");
writing("to_target2", "0");
writing("to_task2", "0");
}
this.requireSucess1 = false;
//单独的后工位任务
} else if (action_2 == 4 && move_2 == 0 && task2 > 0 && action_1 == 0 && move_2 == 0 && task1 == 0 ) {
//inst_message
inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
if (inst2 != null) {
try {
finish_instruction(inst2);
} catch (Exception e) {
log.error("RGV 前工位完成指令异常", e);
logServer.deviceExecuteLog(this.device_code, "", "", "后工位指令" + task1 + "完成异常,异常原因:" + e.getMessage());
}
writing("to_command2", "0");
writing("to_onset2", "0");
writing("to_target2", "0");
writing("to_task2", "0");
}
this.requireSucess1 = false;
} else if (action_1 == 4 && move_1 == 0 && task1 > 0 && action_2 == 0 && move_2 == 0 && task2 == 0 ) {
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
try {
finish_instruction(inst1);
} catch (Exception e) {
log.error("RGV 前工位完成指令异常", e);
logServer.deviceExecuteLog(this.device_code, "", "", "前工位指令" + task1 + "完成异常,异常原因:" + e.getMessage());
}
writing("to_command1", "0");
writing("to_onset1", "0");
writing("to_target1", "0");
writing("to_task1", "0");
}
this.requireSucess1 = false;
}
if (task1 > 0) {
inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
instructionService.update(inst1);
}
}
}
if (task2 > 0) {
inst2 = instructionService.findByCodeFromCache(String.valueOf(task2));
if (inst2 != null) {
if (StrUtil.equals(inst2.getInstruction_status(), "0")) {
inst2.setInstruction_status("1");
instructionService.update(inst2);
}
}
}
}
}
}

View File

@@ -80,6 +80,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
task_code = task.getString("task_code");
String start_point_code = task.getString("start_device_code");
String next_point_code = task.getString("next_device_code");
// 双工RGV任务 后工位任务
String start_point_code2 = task.getString("start_device_code2");
String next_point_code2 = task.getString("next_device_code2");
String start_device_code2 = task.getString("start_device_code2");
String next_device_code2 = task.getString("next_device_code2");
String start_device_code = "";
String next_device_code = "";
String start_parent_code = "";
@@ -153,6 +158,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("next_parent_code", next_parent_code);
jo.put("start_device_code", start_device_code);
jo.put("next_device_code", next_device_code);
jo.put("start_point_code2", start_point_code2);
jo.put("next_point_code2", next_point_code2);
jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2);
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("vehicle_type", vehicle_type);

View File

@@ -71,6 +71,9 @@ public interface InstructionService {
*/
Instruction findById(String instruction_id);
Instruction findByTaskcodeAndStatus(String code);
/**
* 根据编码查询
*

View File

@@ -104,6 +104,26 @@ public class InstructionDto implements Serializable {
*/
private String next_device_code;
/**
* 起始点位编码2
*/
private String start_point_code2;
/**
* 起始设备编码2
*/
private String start_device_code2;
/**
* 目标点位编码
*/
private String next_point_code2;
/**
* 目标设备编码2
*/
private String next_device_code2;
/**
* 排
*/

View File

@@ -203,6 +203,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
return obj;
}
@Override
public Instruction findByTaskcodeAndStatus(String code) {
Iterator var3 = instructions.iterator();
while (var3.hasNext()) {
Instruction instruction = (Instruction) var3.next();
if (StrUtil.equals(instruction.getTask_code(), code)
&& StrUtil.equals(instruction.getInstruction_status(), "0")) {
return instruction;
}
}
return null;
}
@Override
public Instruction findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_instruction");

View File

@@ -78,6 +78,16 @@ public class TaskDto implements Serializable {
*/
private String start_device_code;
/**
* 起始点位编码
*/
private String start_point_code2;
/**
* 起始设备编码
*/
private String start_device_code2;
/**
* 目标点位编码
*/
@@ -88,6 +98,16 @@ public class TaskDto implements Serializable {
*/
private String next_device_code;
/**
* 目标点位编码2
*/
private String next_point_code2;
/**
* 目标设备编码2
*/
private String next_device_code2;
/**
* 排
*/

View File

@@ -32,6 +32,7 @@ import org.springframework.stereotype.Component;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Date;
import java.util.Map;
@@ -73,7 +74,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
return "NDC在线连接";
}
public void autoRun() {
public void autoRun() throws IOException {
try {
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class);
@@ -85,8 +86,11 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogServiceImpl.class);
ip = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT));
InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
byte[] b = new byte[1028];
socket = new Socket(ip, port);
socket.connect(socketAddress,2*1000);
socket.setKeepAlive(true);//长链接
dos = new DataOutputStream(socket.getOutputStream());
dis = new DataInputStream(socket.getInputStream());
@@ -94,9 +98,14 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
int count = dis.read(b);
if (count == -1) {
log.error("agv连接出现异常:服务端被关闭");
if (ObjectUtil.isNotEmpty(socket)) {
socket.close();
}
break;
}
int[] arr = new int[count];
StringBuffer bs = new StringBuffer();
@@ -858,7 +867,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} catch (Exception e) {
log.error("[NDC在线连接] 执行错误,请重新启动线程!", e);
if (ObjectUtil.isNotEmpty(socket)) {
socket.close();
}
}
}

View File

@@ -129,6 +129,8 @@
<el-table-column prop="start_parent_code" label="父起点点位" min-width="100" show-overflow-tooltip />
<el-table-column prop="next_point_code" label="终点" min-width="100" show-overflow-tooltip />
<el-table-column prop="next_parent_code" label="父终点点位" min-width="100" show-overflow-tooltip />
<el-table-column prop="start_point_code2" label="起点2" min-width="100" show-overflow-tooltip />
<el-table-column prop="next_point_code2" label="终点2" min-width="100" show-overflow-tooltip />
<el-table-column prop="carno" label="车号" />
<el-table-column prop="compound_inst" label="复合指令">
<template slot-scope="scope">

View File

@@ -246,6 +246,8 @@
<el-table-column prop="start_parent_code" label="父起点点位" min-width="100" show-overflow-tooltip />
<el-table-column prop="next_point_code" label="终点" min-width="100" show-overflow-tooltip />
<el-table-column prop="next_parent_code" label="父终点点位" min-width="100" show-overflow-tooltip />
<el-table-column prop="start_point_code2" label="起点2" min-width="100" show-overflow-tooltip />
<el-table-column prop="next_point_code2" label="终点2" min-width="100" show-overflow-tooltip />
<el-table-column prop="compound_task" label="复合任务">
<template slot-scope="scope">
<span v-if="scope.row.compound_task==='0' ">否</span>