Browse Source

modbusTcp连接对象资源增加到10个

k 2 years ago
parent
commit
6a0d5d0196

+ 65 - 0
src/main/java/com/jwk/spring/boot/autoconfigure/ModbusAutoConfiguration.java

@@ -154,4 +154,69 @@ public class ModbusAutoConfiguration {
         ModbusProperties.TcpMaster tcp = modbusProperties.getTcpMaster().getFifth();
         return new ModbusTcpMasterTemplate(tcp.getHost(), tcp.getPort());
     }
+
+    /**
+     * TCP-Master sixth
+     *
+     * @param modbusProperties
+     * @return
+     */
+    @Bean
+    @ConditionalOnProperty(prefix = "modbus.tcp-master.sixth", name = "open", havingValue = "true")
+    public ModbusTcpMasterTemplate modbusTcpMasterTemplateSixth(ModbusProperties modbusProperties) {
+        ModbusProperties.TcpMaster tcp = modbusProperties.getTcpMaster().getSixth();
+        return new ModbusTcpMasterTemplate(tcp.getHost(), tcp.getPort());
+    }
+
+    /**
+     * TCP-Master seventh
+     *
+     * @param modbusProperties
+     * @return
+     */
+    @Bean
+    @ConditionalOnProperty(prefix = "modbus.tcp-master.seventh", name = "open", havingValue = "true")
+    public ModbusTcpMasterTemplate modbusTcpMasterTemplateSeventh(ModbusProperties modbusProperties) {
+        ModbusProperties.TcpMaster tcp = modbusProperties.getTcpMaster().getSeventh();
+        return new ModbusTcpMasterTemplate(tcp.getHost(), tcp.getPort());
+    }
+
+    /**
+     * TCP-Master eighth
+     *
+     * @param modbusProperties
+     * @return
+     */
+    @Bean
+    @ConditionalOnProperty(prefix = "modbus.tcp-master.eighth", name = "open", havingValue = "true")
+    public ModbusTcpMasterTemplate modbusTcpMasterTemplateEighth(ModbusProperties modbusProperties) {
+        ModbusProperties.TcpMaster tcp = modbusProperties.getTcpMaster().getEighth();
+        return new ModbusTcpMasterTemplate(tcp.getHost(), tcp.getPort());
+    }
+
+    /**
+     * TCP-Master ninth
+     *
+     * @param modbusProperties
+     * @return
+     */
+    @Bean
+    @ConditionalOnProperty(prefix = "modbus.tcp-master.ninth", name = "open", havingValue = "true")
+    public ModbusTcpMasterTemplate modbusTcpMasterTemplateNinth(ModbusProperties modbusProperties) {
+        ModbusProperties.TcpMaster tcp = modbusProperties.getTcpMaster().getNinth();
+        return new ModbusTcpMasterTemplate(tcp.getHost(), tcp.getPort());
+    }
+
+    /**
+     * TCP-Master tenth
+     *
+     * @param modbusProperties
+     * @return
+     */
+    @Bean
+    @ConditionalOnProperty(prefix = "modbus.tcp-master.tenth", name = "open", havingValue = "true")
+    public ModbusTcpMasterTemplate modbusTcpMasterTemplateTenth(ModbusProperties modbusProperties) {
+        ModbusProperties.TcpMaster tcp = modbusProperties.getTcpMaster().getTenth();
+        return new ModbusTcpMasterTemplate(tcp.getHost(), tcp.getPort());
+    }
 }

+ 5 - 0
src/main/java/com/jwk/spring/boot/autoconfigure/ModbusProperties.java

@@ -45,6 +45,11 @@ public class ModbusProperties {
         private TcpMaster third;
         private TcpMaster fourth;
         private TcpMaster fifth;
+        private TcpMaster sixth;
+        private TcpMaster seventh;
+        private TcpMaster eighth;
+        private TcpMaster ninth;
+        private TcpMaster tenth;
     }
 
     @Data