fix: 修复分切行架一直写信号的问题

This commit is contained in:
yanps
2024-01-15 13:15:05 +08:00
parent 9c6a234211
commit 6f603ac7a0
7 changed files with 119 additions and 47 deletions

View File

@@ -65,12 +65,14 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
int error = 0; int error = 0;
int move = 0; int move = 0;
int task1 = 0; int task1 = 0;
// int task2 = 0; int to_command = 0;
int last_mode = 0; int last_mode = 0;
int last_error = 0; int last_error = 0;
int last_move = 0; int last_move = 0;
int last_task1 = 0; int last_task1 = 0;
// int last_task2 = 0; int last_to_command = 0;
Boolean isonline = true; Boolean isonline = true;
Boolean iserror = false; Boolean iserror = false;
@@ -101,7 +103,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
move = this.itemProtocol.getMove(); move = this.itemProtocol.getMove();
task1 = this.itemProtocol.getTask1(); task1 = this.itemProtocol.getTask1();
// task2 = this.itemProtocol.getTask2(); to_command = this.itemProtocol.getToCommand();
if (mode != last_mode) { if (mode != last_mode) {
this.requireSucess = false; this.requireSucess = false;
@@ -110,7 +112,12 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
if (move != last_move) { if (move != last_move) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move); logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
} }
if (task1 != last_task1) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task1 + "->" + task1);
}
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
} catch (Exception var17) { } catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(var17.getStackTrace())); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(var17.getStackTrace()));
@@ -164,7 +171,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
last_error = error; last_error = error;
last_move = move; last_move = move;
last_task1 = task1; last_task1 = task1;
// last_task2 = task2; last_to_command = to_command;
} }
private synchronized void pullingSucess() { private synchronized void pullingSucess() {

View File

@@ -161,6 +161,11 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr
feedbackQty(); feedbackQty();
} }
break; break;
case 5:
if (task > 0 && !requireSucess && (qty1 > 0 || qty2 > 0)) {
manualFeedbackQty();
}
break;
default: default:
break; break;
@@ -176,31 +181,63 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr
last_qty2 = qty2; last_qty2 = qty2;
} }
private void manualFeedbackQty() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Instruction inst1 = instructionService.findByCode(String.valueOf(task));
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("9");
if (qty1 > 0) {
applyManipulatorActionRequest.setQty1(String.valueOf(qty1));
}
if (qty2 > 0) {
applyManipulatorActionRequest.setQty2(String.valueOf(qty2));
}
applyManipulatorActionRequest.setIs_hand("1");
applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
requireSucess = true;
message = "手动反馈LMS成功...";
logServer.deviceExecuteLog(this.device_code, "", "", "手动反馈重量请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 5);
this.writing(map);
} else {
requireSucess = false;
message = "手动完成反馈LMS失败" + applyManipulatorActionResponse.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "手动反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 99);
this.writing(map);
}
}
private void feedbackQty() { private void feedbackQty() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse; ApplyManipulatorActionResponse applyManipulatorActionResponse;
Instruction inst1 = instructionService.findByCode(String.valueOf(task)); Instruction inst1 = instructionService.findByCode(String.valueOf(task));
String task_code = inst1.getTask_code(); String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("2"); applyManipulatorActionRequest.setType("9");
if (qty1 > 0) { if (qty1 > 0) {
applyManipulatorActionRequest.setQty(String.valueOf(qty1)); applyManipulatorActionRequest.setQty1(String.valueOf(qty1));
} }
if (qty2 > 0) { if (qty2 > 0) {
applyManipulatorActionRequest.setQty(String.valueOf(qty2)); applyManipulatorActionRequest.setQty2(String.valueOf(qty2));
} }
applyManipulatorActionRequest.setTask_code1(task_code); applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) { if (applyManipulatorActionResponse.getstatus() == 200) {
requireSucess = true; requireSucess = true;
message = "反馈LMS成功..."; message = "自动反馈LMS成功...";
logServer.deviceExecuteLog(this.device_code, "", "", "反馈重量请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); logServer.deviceExecuteLog(this.device_code, "", "", "自动反馈重量请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 4); map.put("to_command", 4);
this.writing(map); this.writing(map);
} else { } else {
requireSucess = false; requireSucess = false;
message = "完成反馈LMS失败" + String.valueOf(applyManipulatorActionResponse); message = "自动完成反馈LMS失败" + String.valueOf(applyManipulatorActionResponse);
logServer.deviceExecuteLog(this.device_code, "", "", "反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); logServer.deviceExecuteLog(this.device_code, "", "", "自动反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 99); map.put("to_command", 99);
this.writing(map); this.writing(map);

View File

@@ -287,8 +287,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
param.put("product_area", paramService.findByCode("productArea").getValue()); param.put("product_area", paramService.findByCode("productArea").getValue());
acsToWmsService.sendDeviceStatus(param); acsToWmsService.sendDeviceStatus(param);
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); /*logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error); logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);*/
} }
if (status != last_status) { if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
@@ -310,10 +310,10 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
logServer.deviceItemValue(this.device_code, "action2", String.valueOf(action2)); logServer.deviceItemValue(this.device_code, "action2", String.valueOf(action2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action2" + last_action2 + "->" + action2); logServer.deviceExecuteLog(this.device_code, "", "", "信号action2" + last_action2 + "->" + action2);
} }
if (walk_y != last_walk_y) { /*if (walk_y != last_walk_y) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y));
logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y" + last_walk_y + "->" + walk_y); logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y" + last_walk_y + "->" + walk_y);
} }*/
if (task1 != last_task1) { if (task1 != last_task1) {
logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1)); logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task1" + last_task1 + "->" + task1); logServer.deviceExecuteLog(this.device_code, "", "", "信号task1" + last_task1 + "->" + task1);
@@ -322,14 +322,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
logServer.deviceItemValue(this.device_code, "task2", String.valueOf(task2)); logServer.deviceItemValue(this.device_code, "task2", String.valueOf(task2));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task2" + last_task2 + "->" + task2); logServer.deviceExecuteLog(this.device_code, "", "", "信号task2" + last_task2 + "->" + task2);
} }
if (x_position != last_x_position) { /*if (x_position != last_x_position) {
logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position" + last_x_position + "->" + x_position); logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position" + last_x_position + "->" + x_position);
} }*/
if (y_position != last_y_position) { /*if (y_position != last_y_position) {
logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position" + last_y_position + "->" + y_position); logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position" + last_y_position + "->" + y_position);
} }*/
update_instruction_status(); update_instruction_status();
@@ -446,6 +446,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
return true; return true;
} }
public synchronized boolean apply_task() { public synchronized boolean apply_task() {
Date date = new Date(); Date date = new Date();
if (date.getTime() - this.apply_task_time.getTime() < (long) this.apply_task_time_out) { if (date.getTime() - this.apply_task_time.getTime() < (long) this.apply_task_time_out) {
@@ -517,9 +518,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(getDeviceCode.endsWith("X")){ if (getDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(getDeviceCode,taskDto); Boolean result = this.checkIsSafe(getDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -539,9 +540,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(backGetDeviceCode.endsWith("X")){ if (backGetDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -556,9 +557,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(backGetDeviceCode.endsWith("X")){ if (backGetDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -605,9 +606,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(getDeviceCode.endsWith("X")){ if (getDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(getDeviceCode,taskDto); Boolean result = this.checkIsSafe(getDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -622,9 +623,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(getDeviceCode.endsWith("X")){ if (getDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(getDeviceCode,taskDto); Boolean result = this.checkIsSafe(getDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -644,9 +645,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(backGetDeviceCode.endsWith("X")){ if (backGetDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -661,9 +662,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos); taskDtos = this.sortTask(taskDtos);
taskDto = taskDtos.get(0); taskDto = taskDtos.get(0);
if(backGetDeviceCode.endsWith("X")){ if (backGetDeviceCode.endsWith("X")) {
Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
if(!result){ if (!result) {
taskDto = null; taskDto = null;
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
continue; continue;
@@ -1731,16 +1732,16 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
} }
} }
public boolean checkIsSafe(String device_code,TaskDto dto){ public boolean checkIsSafe(String device_code, TaskDto dto) {
String newDevice_code = forametDevice_code(device_code); String newDevice_code = forametDevice_code(device_code);
List<TaskDto> list = taskserver.queryTaskByDeviceCode(newDevice_code); List<TaskDto> list = taskserver.queryTaskByDeviceCode(newDevice_code);
if(list.size()>0){ if (list.size() > 0) {
return false; return false;
} }
return true; return true;
} }
public String forametDevice_code(String device_code){ public String forametDevice_code(String device_code) {
if (device_code.endsWith("X")) { if (device_code.endsWith("X")) {
return device_code.substring(0, device_code.length() - 1) + "S"; return device_code.substring(0, device_code.length() - 1) + "S";
} }

View File

@@ -39,7 +39,16 @@ public class ApplyManipulatorActionRequest extends BaseRequest {
/** /**
* 重量 * 重量
*/ */
private String qty; private String qty1;
/**
* 重量
*/
private String qty2;
/**
* 手动
*/
private String is_hand;
} }

View File

@@ -95,6 +95,13 @@ public interface InstructionService {
Instruction findByTaskcodeAndStatus(String code); Instruction findByTaskcodeAndStatus(String code);
/**
* 根据任务号查询缓存中的指令
* @param code
* @return
*/
Instruction findByTaskcodeCache(String code);
Instruction findByTaskcodeAndStatus(String code,String status); Instruction findByTaskcodeAndStatus(String code,String status);
/** /**

View File

@@ -279,6 +279,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
return null; return null;
} }
public Instruction findByTaskcodeCache(String code) {
Iterator var3 = instructions.iterator();
while (var3.hasNext()) {
Instruction instruction = (Instruction) var3.next();
if (StrUtil.equals(instruction.getTask_code(), code)) {
return instruction;
}
}
return null;
}
@Override @Override
public Instruction findByTaskcodeAndStatus(String code,String status) { public Instruction findByTaskcodeAndStatus(String code,String status) {

View File

@@ -344,8 +344,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
continue; continue;
} }
if ((task.getStart_device_code().equals(start_device_code) if ((task.getStart_device_code().equals(start_device_code)
|| (StrUtil.isNotEmpty(task.getStart_device_code2()) && task.getStart_device_code2().equals(start_device_code)) || (StrUtil.isNotEmpty(task.getStart_device_code2()) && task.getStart_device_code2().equals(start_device_code)))
&& StrUtil.equals(task.getTask_status(), "0"))) { && StrUtil.equals(task.getTask_status(), "0")) {
list.add(task); list.add(task);
} }
} }