fix: 联调修改
This commit is contained in:
@@ -51,6 +51,7 @@ import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static redis.clients.jedis.HostAndPort.localhost;
|
||||
@@ -225,6 +226,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
System.out.println("in"+ LocalDateTime.now() +"开始时间"+this.getDeviceCode());
|
||||
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
@@ -248,7 +251,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
if (move != last_mode && move==0) {
|
||||
if (move != last_move && move==0) {
|
||||
requireSucess = false;
|
||||
clearWrite();
|
||||
}
|
||||
@@ -343,7 +346,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
last_to_task = to_task;
|
||||
last_to_container_no = to_container_no;
|
||||
last_to_container_type = to_container_type;
|
||||
|
||||
System.out.println("out"+ LocalDateTime.now() +"结束时间"+this.getDeviceCode());
|
||||
}
|
||||
|
||||
public void clearWrite() {
|
||||
|
||||
@@ -5,22 +5,22 @@ import org.nl.acs.device_driver.DeviceDriver;
|
||||
public interface ExecutableDeviceDriver extends DeviceDriver {
|
||||
/**
|
||||
* executeAuto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
default void executeAuto() throws Exception {
|
||||
// try {
|
||||
// this.execute();
|
||||
// } catch (Throwable var6) {
|
||||
// String message = "线程调用异常:" + var6.getMessage();
|
||||
// Log.error(message);
|
||||
// } finally {
|
||||
// }
|
||||
this.execute();
|
||||
try {
|
||||
this.execute();
|
||||
} catch (Throwable var6) {
|
||||
String message = "线程调用异常:" + var6.getMessage();
|
||||
}
|
||||
// this.execute();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* execute
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
void execute() throws Exception;
|
||||
|
||||
@@ -212,7 +212,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
if (move != last_mode && move==0) {
|
||||
if (move != last_move && move==0) {
|
||||
requireSucess = false;
|
||||
clearWrite();
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
//}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 25:
|
||||
//二楼到一楼输送线申请行架任务
|
||||
if (move == 1 && !requireSucess) {
|
||||
applyManipulatorTask();
|
||||
|
||||
@@ -204,7 +204,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
if (move != last_mode && move==0) {
|
||||
if (move != last_move && move==0) {
|
||||
requireSucess = false;
|
||||
clearWrite();
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
if (move != last_mode && move==0) {
|
||||
if (move != last_move && move==0) {
|
||||
requireSucess = false;
|
||||
clearWrite();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -214,7 +215,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
if (move != last_mode && move==0) {
|
||||
if (move != last_move && move==0) {
|
||||
requireSucess = false;
|
||||
clearWrite();
|
||||
}
|
||||
|
||||
@@ -148,4 +148,9 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,5 +58,8 @@ public class ItemProtocol {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -210,6 +211,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
System.out.println("in 开始时间"+ LocalDateTime.now() +this.getDeviceCode());
|
||||
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
@@ -247,7 +250,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
clearWrite();
|
||||
}
|
||||
}
|
||||
if (move != last_mode && move==0) {
|
||||
if (move != last_move && move==0) {
|
||||
requireSucess = false;
|
||||
clearWrite();
|
||||
}
|
||||
@@ -374,6 +377,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
last_height = height;
|
||||
last_weight = weight;
|
||||
last_barcode = barcode;
|
||||
System.out.println("out 开始时间"+ LocalDateTime.now() +this.getDeviceCode());
|
||||
}
|
||||
|
||||
private void applyErrorHeight() {
|
||||
|
||||
@@ -221,5 +221,8 @@ public class ItemProtocol {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,4 +214,9 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_to_barcode, "下发木箱条码", "DB601.STRING1.50"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -264,8 +265,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
String notCreateInstMessage = null;
|
||||
|
||||
private int instruction_require_time_out = 3000;
|
||||
private int instruction_update_time_out = 3000;
|
||||
private int instruction_require_time_out = 1000;
|
||||
private int instruction_update_time_out = 1000;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_update_time = new Date();
|
||||
List<String> getDeviceCodeList = null;
|
||||
@@ -299,7 +300,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void execute() throws Exception {
|
||||
System.out.println("in"+ LocalDateTime.now() +"开始时间"+this.getDeviceCode());
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
@@ -330,7 +333,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
|
||||
// 更新指令状态
|
||||
if (mode == 3 && task > 0) {
|
||||
if (mode == 3 && task > 0 && command == 1) {
|
||||
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);
|
||||
@@ -484,7 +487,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
inst = null;
|
||||
requireSucess = false;
|
||||
break;
|
||||
case 6:
|
||||
@@ -541,6 +544,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
last_special1 = special1;
|
||||
last_special2 = special2;
|
||||
last_storage_cache = storage_cache;
|
||||
System.out.println("out"+ LocalDateTime.now() +"结束时间"+this.getDeviceCode());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -822,7 +827,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
String startDeviceCode = instructionErro.getStart_device_code();
|
||||
Device startDeviceError = deviceAppService.findDeviceByCode(startDeviceCode);
|
||||
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
|
||||
pakagePLCData(list, startDeviceError.getExtraValue().get("x").toString(), startDeviceError.getExtraValue().get("z").toString(), startDeviceError.getExtraValue().get("y").toString(), instructionErro.getExecute_code(), instructionErro.getInstruction_code());
|
||||
pakagePLCData(list, startDeviceError.getExtraValue().get("x").toString(), startDeviceError.getExtraValue().get("z").toString(), startDeviceError.getExtraValue().get("y").toString(), "1", instructionErro.getInstruction_code());
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
@@ -832,7 +837,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
if ("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) {
|
||||
List list = new ArrayList();
|
||||
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
|
||||
pakagePLCData(list, instructionErro.getTo_x(), instructionErro.getTo_y(), instructionErro.getTo_z(), instructionErro.getExecute_code(), instructionErro.getInstruction_code());
|
||||
pakagePLCData(list, instructionErro.getTo_x(), instructionErro.getTo_y(), instructionErro.getTo_z(), "2", instructionErro.getInstruction_code());
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
@@ -844,7 +849,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
if ("1".equals(instructionErro.getExecute_code()) || "2".equals(instructionErro.getExecute_code())) {
|
||||
List list = new ArrayList();
|
||||
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) {
|
||||
pakagePLCData(list, instructionErro.getFrom_x(), instructionErro.getFrom_y(), instructionErro.getFrom_z(), instructionErro.getExecute_code(), instructionErro.getInstruction_code());
|
||||
pakagePLCData(list, instructionErro.getFrom_x(), instructionErro.getFrom_y(), instructionErro.getFrom_z(), "1", instructionErro.getInstruction_code());
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
@@ -854,8 +859,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
String next_device_code = instructionErro.getNext_device_code();
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
List list = new ArrayList();
|
||||
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
|
||||
pakagePLCData(list, nextDevice.getExtraValue().get("x").toString(), nextDevice.getExtraValue().get("z").toString(), nextDevice.getExtraValue().get("y").toString(), instructionErro.getExecute_code(), instructionErro.getInstruction_code());
|
||||
if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) {
|
||||
pakagePLCData(list, nextDevice.getExtraValue().get("x").toString(), nextDevice.getExtraValue().get("z").toString(), nextDevice.getExtraValue().get("y").toString(), "2", instructionErro.getInstruction_code());
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
@@ -1315,4 +1320,5 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,22 +2,25 @@ package org.nl.acs.opc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.auto.run.AbstractAutoRunnable;
|
||||
import org.nl.acs.auto.run.AutoRunService;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||
import org.nl.config.thread.TheadFactoryName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService;
|
||||
@Autowired
|
||||
private AutoRunService autoRunService;
|
||||
int cache_thread = 3;
|
||||
|
||||
int corePoolSize = 50;
|
||||
@@ -41,8 +44,8 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
new TheadFactoryName()
|
||||
);*/
|
||||
this.executorService = new ThreadPoolExecutor(
|
||||
10,
|
||||
20,
|
||||
50,
|
||||
100,
|
||||
1L,
|
||||
TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<>(queueLength),
|
||||
@@ -81,11 +84,16 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
log.info("设备执行线程等待opc同步线程...");
|
||||
Thread.sleep(1000L);
|
||||
if (i > 60) {
|
||||
UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
||||
if(accessor_value.getAllKey().size() < 1){
|
||||
autoRunService.startThread("DeviceOpcSynchronizeAutoRun");
|
||||
}
|
||||
log.info("设备执行线程放弃等待opc同步线程...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Thread.sleep(10000L);
|
||||
log.info("设备执行线程开始...");
|
||||
|
||||
while (true) {
|
||||
@@ -98,8 +106,10 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
//不包含正在执行的线程,则进行执行
|
||||
if (!this.runs.keySet().contains(deviceDriver.getDeviceCode())) {
|
||||
BlockedRunable runnable = new BlockedRunable() {
|
||||
|
||||
@Override
|
||||
public void subRun() throws Exception {
|
||||
System.out.println("add 线程开始时间"+ LocalDateTime.now() + deviceDriver.getDeviceCode() );
|
||||
deviceDriver.executeAuto();
|
||||
}
|
||||
|
||||
@@ -111,9 +121,10 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
if (!this.runs.keySet().contains(deviceDriver.getDeviceCode())) {
|
||||
this.runs.put(deviceDriver.getDeviceCode(), runnable);
|
||||
}
|
||||
|
||||
runnable.setIndex(this.runs);
|
||||
this.executorService.submit(runnable);
|
||||
System.out.println("run 线程开始时间"+ LocalDateTime.now() + deviceDriver.getDeviceCode() );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
<!--生产环境:打印控制台和输出到文件-->
|
||||
<springProfile name="prod">
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</root>
|
||||
|
||||
Reference in New Issue
Block a user