Bläddra i källkod

光电:
(1)空托1->空托2

k 1 år sedan
förälder
incheckning
2e83505914

+ 20 - 0
ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java

@@ -30,6 +30,8 @@ public class StartService implements CommandLineRunner {
     private AutoButtonBoxTask02 autoButtonBoxTask02;
     @Autowired
     private AutoButtonBoxTask03 autoButtonBoxTask03;
+    @Autowired
+    private AutoPhotoelectricTask autoPhotoelectricTask;
 
 
     @Override
@@ -71,4 +73,22 @@ public class StartService implements CommandLineRunner {
     public void autoButtonBoxTask03() {
         autoButtonBoxTask03.run();
     }
+    /**
+     * 光电监控任务 - 空托1
+     */
+    public void autoPhotoelectricTask01() {
+        autoPhotoelectricTask.run();
+    }
+    /**
+     * 光电监控任务 - 空托2
+     */
+    public void autoPhotoelectricTask02() {
+        autoPhotoelectricTask.run01();
+    }
+    /**
+     * 光电监控任务 - 空托3
+     */
+    public void autoPhotoelectricTask03() {
+        autoPhotoelectricTask.run02();
+    }
 }

+ 54 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoPhotoelectricTask.java

@@ -0,0 +1,54 @@
+package com.ruoyi.ams.agv.ndc.thread;
+
+import com.ruoyi.ams.nieyan.service.AgvCallProxyService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.hard.modbus.tcp.ButtonBoxClient;
+import com.ruoyi.hard.modbus.tcp.ModbusTcpWeigherClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class AutoPhotoelectricTask {
+
+    @Autowired(required = false)
+    private ModbusTcpWeigherClient modbusTcpWeigherClient;
+    @Autowired
+    private AgvCallProxyService agvCallProxyService;
+    // 空托1 3个点位
+    public static final String EMPTY_PALLET_POINT_01 = "218";
+    public static final String EMPTY_PALLET_POINT_02 = "219";
+    public static final String EMPTY_PALLET_POINT_03 = "220";
+
+    public void run() {
+        boolean b = modbusTcpWeigherClient.readPhotoelectricity01();
+        if (b) {
+            photoelectricTask(EMPTY_PALLET_POINT_01, "1号光电");
+        }
+    }
+
+    public void run01() {
+        boolean b = modbusTcpWeigherClient.readPhotoelectricity01();
+        if (b) {
+            photoelectricTask(EMPTY_PALLET_POINT_02, "2号光电");
+        }
+    }
+
+    public void run02() {
+        boolean b = modbusTcpWeigherClient.readPhotoelectricity01();
+        if (b) {
+            photoelectricTask(EMPTY_PALLET_POINT_03, "2号光电");
+        }
+    }
+
+    public void photoelectricTask(String locationFrom, String remark) {
+        log.info(remark + "-光电已经触发");
+        AjaxResult ajaxResult = agvCallProxyService.supplementEmptyTray(locationFrom, null
+                , "光电");
+        if (!ajaxResult.isSuccess()) {
+            log.info(ajaxResult.getMsg());
+            return;
+        }
+    }
+}