|
|
@ -8,10 +8,7 @@ import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.util.concurrent.Uninterruptibles; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.Setter; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.acs.device.device.domain.Device; |
|
|
|
import org.nl.acs.device.device.service.DeviceAppService; |
|
|
@ -646,9 +643,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
int numericPart = Integer.parseInt(getNumericPart(frontInst.getNext_device_code())); |
|
|
|
if (numericPart % 4 == 2 || numericPart % 4 == 3) { |
|
|
|
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code())); |
|
|
|
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
|
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} else { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
@ -720,9 +730,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
|
backInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
this.backWrite(back_start_device, backInst); |
|
|
|
int numericPart = Integer.parseInt(getNumericPart(backInst.getNext_device_code())); |
|
|
|
if (numericPart % 4 == 2 || numericPart % 4 == 3) { |
|
|
|
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code())); |
|
|
|
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
|
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} else { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
this.backWrite(back_start_device, backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
this.backWrite(back_start_device, backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
@ -813,15 +836,19 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
int numericPart = Integer.parseInt(getNumericPart(backInst.getNext_device_code())); |
|
|
|
if (numericPart % 4 == 2 || numericPart % 4 == 3) { |
|
|
|
String qPoint = getZdPoint(backInst.getNext_point_code()); |
|
|
|
TaskDto taskDto = taskService.findByNextPointCode(qPoint); |
|
|
|
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code())); |
|
|
|
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
|
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} else { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
this.backWrite(back_start_device, backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
this.backWrite(back_start_device, backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
@ -892,7 +919,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice"); |
|
|
|
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice"); |
|
|
|
String getLinkDeviceCode = Optional.ofNullable(front_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)){ |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)) { |
|
|
|
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, front_start_device_code, getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
@ -921,9 +948,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
int numericPart = Integer.parseInt(getNumericPart(frontInst.getNext_device_code())); |
|
|
|
if (numericPart % 4 == 2 || numericPart % 4 == 3) { |
|
|
|
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code())); |
|
|
|
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
|
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} else { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
@ -993,7 +1033,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice"); |
|
|
|
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice"); |
|
|
|
String getLinkDeviceCode = Optional.ofNullable(back_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)){ |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)) { |
|
|
|
frontInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getFrontDeviceCodeList, specialGetDevice, specialPutDevice, back_start_device_code, getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
@ -1268,8 +1308,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
return false; |
|
|
|
} |
|
|
|
String getLinkDeviceCode = Optional.ofNullable(front_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)){ |
|
|
|
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, start_device_code,getLinkDeviceCode); |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)) { |
|
|
|
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, start_device_code, getLinkDeviceCode); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -1624,6 +1664,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); |
|
|
|
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
//先查询入库位是深库位的入库指令信息
|
|
|
|
List<Instruction> frontInsts = instructionService.findDeepReadyInstByStartDeviceCode(getFrontDeviceCodeList, frontNoY); |
|
|
|
if (CollectionUtil.isNotEmpty(frontInsts)) { |
|
|
|
frontInst = frontInsts.get(0); |
|
|
@ -1634,11 +1675,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
if (front_start_device != null) { |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode"); |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)) { |
|
|
|
//根据前叉指令信息,查询是否存在对应的后叉的深库位的入库指令信息
|
|
|
|
backInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
|
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
|
return; |
|
|
|
//如果不存在深库位的后叉信息,查询是否存在浅库位的后叉信息
|
|
|
|
backInst = instructionService.findShallowReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
//如果存在,就查询是否有终点是浅库位对应的深库位的指令信息
|
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code())); |
|
|
|
if (ObjectUtil.isNotEmpty(instruction)) { |
|
|
|
backInst = null; |
|
|
|
} else { |
|
|
|
//如果有就单取深库位的
|
|
|
|
//如果没有就双取
|
|
|
|
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1657,11 +1711,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(back_start_device, "getLinkDeviceCode"); |
|
|
|
front_start_device = deviceAppService.findDeviceByCode(getLinkDeviceCode); |
|
|
|
if (front_start_device != null) { |
|
|
|
//根据后叉指令信息,查询是否存在对应的前叉的深库位的入库指令信息
|
|
|
|
frontInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
|
return; |
|
|
|
//如果不存在深库位的前叉信息,查询是否存在浅库位的前叉信息
|
|
|
|
frontInst = instructionService.findShallowReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
//如果存在,就查询是否有终点是浅库位对应的深库位的指令信息
|
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code())); |
|
|
|
if (ObjectUtil.isNotEmpty(instruction)) { |
|
|
|
frontInst = null; |
|
|
|
} else { |
|
|
|
//如果有就单取深库位的
|
|
|
|
//如果没有就双取
|
|
|
|
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "第二次查询到前叉指令号:" + frontInst.getInstruction_code())); |
|
|
@ -2079,7 +2146,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
String start_device_code = backInst.getStart_device_code(); |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(start_device_code); |
|
|
|
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
this.writing(this.getBackKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())), Integer.parseInt(frontInst.getFrom_y()), Integer.parseInt(frontInst.getFrom_z()), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum())); |
|
|
|
this.writing(this.getBackKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(backInst.getFrom_x())), Integer.parseInt(backInst.getFrom_y()), Integer.parseInt(backInst.getFrom_z()), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum())); |
|
|
|
} else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
|
Integer x = this.handExtraIntValue(start_device, "currentX"); |
|
|
|
Integer y = this.handExtraIntValue(start_device, "currentY"); |
|
|
@ -2470,6 +2537,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
return String.format("%s%02d%s", type, row, rest); |
|
|
|
} |
|
|
|
|
|
|
|
private String getDeepPoint(String point_code) { |
|
|
|
if (point_code == null || point_code.chars().filter(ch -> ch == '-').count() != 2) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
String type = point_code.substring(0, 1); |
|
|
|
int row = Integer.parseInt(point_code.substring(1, 3)); |
|
|
|
String rest = point_code.substring(3); |
|
|
|
|
|
|
|
if (row == 2) { |
|
|
|
row -= 1; |
|
|
|
} else if (row == 3) { |
|
|
|
row += 1; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return String.format("%s%02d%s", type, row, rest); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 封装指令 |
|
|
|
* |
|
|
|