Browse Source

充电机配置

k 1 year ago
parent
commit
3f4e90908d

+ 4 - 0
ruoyi-admin/src/main/resources/application-prod.yml

@@ -89,3 +89,7 @@ modbus:
             open: true
             host: 192.168.100.154
             port: 502
+        sixth: # 充电机
+            open: true
+            host: 192.168.100.160
+            port: 8899

+ 6 - 17
warewms-hard/src/main/java/com/ruoyi/hard/modbus/tcp/ChargingMachineClient.java

@@ -26,19 +26,12 @@ import static com.ruoyi.hard.modbus.tcp.ChargingMachineClient.CHARGER_ADDRESS_ME
 @Service
 public class ChargingMachineClient {
 
-    /**
-     * 充电机(三向车)
-     */
-    @Autowired(required = false)
-    @Qualifier("modbusTcpMasterTemplateFourth")
-    private ModbusTcpMasterTemplate modbusTcpMasterTemplateFourth;
-
     /**
      * 充电机(迷你堆垛)
      */
     @Autowired(required = false)
-    @Qualifier("modbusTcpMasterTemplateFifth")
-    private ModbusTcpMasterTemplate modbusTcpMasterTemplateFifth;
+    @Qualifier("modbusTcpMasterTemplateSixth")
+    private ModbusTcpMasterTemplate modbusTcpMasterTemplateSixth;
 
     /**
      * 充电机操作
@@ -89,8 +82,7 @@ public class ChargingMachineClient {
      * 则最终返回的数组:[0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
      */
     public boolean[] getStatus(boolean con) {
-        ModbusMasterUtil modbusMasterUtil = con ? modbusTcpMasterTemplateFourth.getModbusMasterUtil()
-                : modbusTcpMasterTemplateFifth.getModbusMasterUtil();
+        ModbusMasterUtil modbusMasterUtil = modbusTcpMasterTemplateSixth.getModbusMasterUtil();
         ReadResponse read = modbusMasterUtil.readCoils(1, CHARGER_STATUS.getOffset(), CHARGER_STATUS.getCommand());
         if (read == null || read.getBooleanData() == null) {
             log.error("获取充电机状态为空!");
@@ -109,8 +101,7 @@ public class ChargingMachineClient {
      * @return
      */
     private boolean start(boolean con) {
-        ModbusMasterUtil modbusMasterUtil = con ? modbusTcpMasterTemplateFourth.getModbusMasterUtil()
-                : modbusTcpMasterTemplateFifth.getModbusMasterUtil();
+        ModbusMasterUtil modbusMasterUtil = modbusTcpMasterTemplateSixth.getModbusMasterUtil();
         return modbusMasterUtil.writeCoil(1, START.getOffset(), START.getCommand());
     }
 
@@ -120,8 +111,7 @@ public class ChargingMachineClient {
      * @return
      */
     private boolean stop(boolean con) {
-        ModbusMasterUtil modbusMasterUtil = con ? modbusTcpMasterTemplateFourth.getModbusMasterUtil()
-                : modbusTcpMasterTemplateFifth.getModbusMasterUtil();
+        ModbusMasterUtil modbusMasterUtil = modbusTcpMasterTemplateSixth.getModbusMasterUtil();
         return modbusMasterUtil.writeCoil(1, STOP.getOffset(), STOP.getCommand());
     }
 
@@ -131,8 +121,7 @@ public class ChargingMachineClient {
      * @return
      */
     private boolean discharge(boolean con) {
-        ModbusMasterUtil modbusMasterUtil = con ? modbusTcpMasterTemplateFourth.getModbusMasterUtil()
-                : modbusTcpMasterTemplateFifth.getModbusMasterUtil();
+        ModbusMasterUtil modbusMasterUtil = modbusTcpMasterTemplateSixth.getModbusMasterUtil();
         return modbusMasterUtil.writeCoil(1, DISCHARGE.getOffset(), DISCHARGE.getCommand());
     }