123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package com.jwk.spring.boot.autoconfigure;
- import lombok.Data;
- import org.springframework.boot.context.properties.ConfigurationProperties;
- /**
- * @author JWK
- * @version 1.0
- * @date 2022/12/2 15:40
- */
- @Data
- @ConfigurationProperties(prefix = ModbusProperties.DEMO_PREFIX)
- public class ModbusProperties {
- public static final String DEMO_PREFIX = "modbus";
- /**
- * 注入方式:
- * '@Autowired(required = true)'
- * private ModbusRtuMasterTemplate modbusRtuMasterTemplateFirst;
- * 没有open=true的bean千万不要注入,@Autowired(required = false)也不行.
- */
- private RtuMasterOrder rtuMaster;
- /**
- * 注入方式:
- * '@Autowired(required = true)'
- * private ModbusTcpMasterTemplate modbusTcpMasterTemplateFirst;
- * 没有open=true的bean千万不要注入,@Autowired(required = false)也不行.
- */
- private TcpMasterOrder tcpMaster;
- @Data
- public static class RtuMasterOrder {
- private RtuMaster first;
- private RtuMaster second;
- private RtuMaster third;
- private RtuMaster fourth;
- private RtuMaster fifth;
- }
- @Data
- public static class TcpMasterOrder {
- private TcpMaster first;
- private TcpMaster second;
- private TcpMaster third;
- private TcpMaster fourth;
- private TcpMaster fifth;
- }
- @Data
- public static class RtuMaster {
- /**
- * 开启串口
- */
- private boolean open = false;
- /**
- * 串口
- */
- private String port = "COM1";
- /**
- * 波特率
- */
- private Integer baudRate = 9600;
- /**
- * 数据位的位数,RTU是8位,ASCII是7位
- */
- private Integer dataBits = 8;
- /**
- * 停止位的位数,如果无奇偶校验为2,有奇偶校验为1
- */
- private Integer stopBits = 1;
- /**
- * 奇偶校验位,无校验是0,奇校验是1,偶校验是2
- */
- private Integer parity = 0;
- /**
- * 硬件之间输入流应答控制
- */
- private Integer flowControlIn = 0;
- /**
- * 硬件之间输出流应答控制
- */
- private Integer flowControlOut = 0;
- }
- @Data
- public static class TcpMaster {
- /**
- * 开启TCP连接
- */
- private boolean open = false;
- /**
- * ip地址
- */
- private String host = "127.0.0.1";
- /**
- * 端口
- */
- private Integer port = 502;
- }
- }
|