|
@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.google.common.util.concurrent.Uninterruptibles; |
|
|
import lombok.Getter; |
|
|
import lombok.Getter; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.Setter; |
|
|
import lombok.Setter; |
|
@ -37,6 +38,7 @@ import org.nl.config.lucene.service.LuceneExecuteLogService; |
|
|
import org.nl.config.lucene.service.dto.LuceneLogDto; |
|
|
import org.nl.config.lucene.service.dto.LuceneLogDto; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
import java.util.concurrent.locks.Lock; |
|
|
import java.util.concurrent.locks.Lock; |
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Matcher; |
|
@ -398,8 +400,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void execute() { |
|
|
public void execute() { |
|
|
|
|
|
try { |
|
|
this.currentDeviceCode = this.getDevice().getDevice_code(); |
|
|
this.currentDeviceCode = this.getDevice().getDevice_code(); |
|
|
this.loadAssignData(currentDeviceCode, ItemProtocol.class); |
|
|
this.loadAssignData(currentDeviceCode, ItemProtocol.class); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错,错误信息: " + e.getMessage())); |
|
|
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错,错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); |
|
|
|
|
|
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private boolean isTimeValid(long currentTimeMillis) { |
|
|
private boolean isTimeValid(long currentTimeMillis) { |
|
@ -486,7 +494,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void executeLogic() { |
|
|
public void executeLogic() { |
|
|
if (this.front_task != 0 && this.back_task != 0) { |
|
|
if (this.front_task != 0 && this.back_task != 0) { |
|
@ -599,7 +606,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
if (ObjectUtil.isEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) { |
|
|
if (ObjectUtil.isEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) { |
|
|
if (this.to_command != 0) { |
|
|
if (this.to_command != 0) { |
|
|
this.writing(ItemProtocol.TO_COMMAND.getKey(), 0); |
|
|
this.writing(ItemProtocol.TO_COMMAND.getKey(), 0); |
|
|
Thread.sleep(1000); |
|
|
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); |
|
|
} |
|
|
} |
|
|
if (this.stopReceiveTask) { |
|
|
if (this.stopReceiveTask) { |
|
|
this.unExecutedMessage = "堆垛机设置为停止接收任务"; |
|
|
this.unExecutedMessage = "堆垛机设置为停止接收任务"; |
|
@ -884,7 +891,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
// List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
|
|
|
// List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
|
|
|
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice"); |
|
|
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice"); |
|
|
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice"); |
|
|
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice"); |
|
|
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, front_start_device_code); |
|
|
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, front_start_device_code, getLinkDeviceCode); |
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
@ -892,6 +901,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
} else { |
|
|
} else { |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
//下发前叉放货信息
|
|
|
//下发前叉放货信息
|
|
@ -976,11 +988,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
} |
|
|
} |
|
|
} else if (instanceAppearance(back_start_device) && instanceAppearance(back_next_device)) { |
|
|
} else if (instanceAppearance(back_start_device) && instanceAppearance(back_next_device)) { |
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
//List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
|
|
|
//List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
|
|
|
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice"); |
|
|
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice"); |
|
|
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice"); |
|
|
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice"); |
|
|
frontInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getFrontDeviceCodeList, specialGetDevice, specialPutDevice, back_start_device_code); |
|
|
String getLinkDeviceCode = Optional.ofNullable(back_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); |
|
|
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)){ |
|
|
|
|
|
frontInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getFrontDeviceCodeList, specialGetDevice, specialPutDevice, back_start_device_code, getLinkDeviceCode); |
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
@ -988,6 +1002,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
} else { |
|
|
} else { |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
@ -1250,7 +1267,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
if (front_start_device == null) { |
|
|
if (front_start_device == null) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, start_device_code); |
|
|
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); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
List<Instruction> backInsts = instructionService.findReadyInstBySpecialDevice(getBackDeviceCodeList, specialGetDevice, specialPutDevice); |
|
|
List<Instruction> backInsts = instructionService.findReadyInstBySpecialDevice(getBackDeviceCodeList, specialGetDevice, specialPutDevice); |
|
|