diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java index 1f07d989b..ff795f676 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -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() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java index d5f3ec3e2..9ae9b2b40 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java @@ -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; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java index 79d37e43d..c34d066fa 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java @@ -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(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java index 70d9e01ba..8de25f189 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java @@ -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(); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java index b557a37c4..4546ebdb9 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java @@ -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(); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java index 63d669dcb..f2690117c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java @@ -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(); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java index 65a0f8438..04161b0b8 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java @@ -148,4 +148,9 @@ public class ItemProtocol { list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); return list; } + + @Override + public String toString() { + return ""; + } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/manipulator_cache/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/manipulator_cache/ItemProtocol.java index bcf594ec4..66f789e26 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/manipulator_cache/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/manipulator_cache/ItemProtocol.java @@ -58,5 +58,8 @@ public class ItemProtocol { return list; } - + @Override + public String toString() { + return ""; + } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java index b7d1d66cb..3ee3a4d73 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -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() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java index 7f8d32e29..ff6736587 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java @@ -221,5 +221,8 @@ public class ItemProtocol { return list; } - + @Override + public String toString() { + return ""; + } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java index 2d8cd5f6b..fb5ca6ccd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java @@ -214,4 +214,9 @@ public class ItemProtocol { list.add(new ItemDto(item_to_barcode, "下发木箱条码", "DB601.STRING1.50")); return list; } + + @Override + public String toString() { + return ""; + } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java index d66581956..7544427d4 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java @@ -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 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; } + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java index 7acb57b51..b67c153ac 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java @@ -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() ); + } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml index ab174d9ef..97f936bfd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml @@ -110,6 +110,7 @@ https://juejin.cn/post/6844903775631572999 +