Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # src/main/java/com/isu/gaswellwatch/modbus/impl/CommandServiceImpl.java
This commit is contained in:
commit
b7025256a1
|
@ -7,6 +7,7 @@ import com.isu.gaswellwatch.modbus.CommandService;
|
||||||
import com.isu.gaswellwatch.vo.command.CollectCommand;
|
import com.isu.gaswellwatch.vo.command.CollectCommand;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -25,13 +26,13 @@ public class CommandController {
|
||||||
|
|
||||||
@PostMapping(value = "/control")
|
@PostMapping(value = "/control")
|
||||||
@OperationLog(description = "下发控制指令", type = LogType.ADD)
|
@OperationLog(description = "下发控制指令", type = LogType.ADD)
|
||||||
public Response<String> control(@RequestBody Command command) {
|
public Response<String> control(@RequestBody @Validated Command command) {
|
||||||
return this.commandService.control(command);
|
return this.commandService.control(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/collect")
|
@PostMapping(value = "/collect")
|
||||||
@OperationLog(description = "下发采集指令", type = LogType.ADD)
|
@OperationLog(description = "下发采集指令", type = LogType.ADD)
|
||||||
public Response<String> collect(@RequestBody CollectCommand command) {
|
public Response<String> collect(@RequestBody @Validated CollectCommand command) {
|
||||||
return this.commandService.collect(command);
|
return this.commandService.collect(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
||||||
public class Redis2DBPersistenceService {
|
public class Redis2DBPersistenceService {
|
||||||
|
|
||||||
public static final String DEFAULT_DATA_TABLE = "t_device_data_";
|
public static final String DEFAULT_DATA_TABLE = "t_device_data_";
|
||||||
private static final String DEVICE_INFO_SQL = "SELECT d.*, dp.code as modbus_device_product_code from device d "
|
public static final String DEVICE_INFO_SQL = "SELECT d.*, dp.code as modbus_device_product_code from device d "
|
||||||
+ "join dictionary dp on dp.id = d.product where d.id = ";
|
+ "join dictionary dp on dp.id = d.product where d.id = ";
|
||||||
private static final String EXISTS_TABLE_SQL = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA"
|
private static final String EXISTS_TABLE_SQL = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA"
|
||||||
+ " IN ('gaswellwatch', 'gas_well_watch') AND TABLE_NAME='$TableName$'";
|
+ " IN ('gaswellwatch', 'gas_well_watch') AND TABLE_NAME='$TableName$'";
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
package com.isu.gaswellwatch.modbus.impl;
|
package com.isu.gaswellwatch.modbus.impl;
|
||||||
|
|
||||||
import com.isu.gaswellwatch.dao.DeviceDao;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.entity.Response;
|
import com.isu.gaswellwatch.entity.Response;
|
||||||
import com.isu.gaswellwatch.modbus.CommandService;
|
import com.isu.gaswellwatch.modbus.CommandService;
|
||||||
import com.isu.gaswellwatch.service.DeviceOptLogService;
|
import com.isu.gaswellwatch.service.DeviceOptLogService;
|
||||||
|
import com.isu.gaswellwatch.modbus.data.PersistenceHandler;
|
||||||
|
import com.isu.gaswellwatch.modbus.data.Redis2DBPersistenceService;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.http.RequestEntity;
|
import org.springframework.http.RequestEntity;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +36,9 @@ import java.util.Objects;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CommandServiceImpl implements CommandService {
|
public class CommandServiceImpl implements CommandService {
|
||||||
|
|
||||||
private final DeviceDao deviceDao;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
@Resource(name = "stringRedisTemplate")
|
||||||
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
private final RestTemplate restTemplate = new RestTemplate();
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
@Resource
|
@Resource
|
||||||
private DeviceOptLogService deviceOptLogService;
|
private DeviceOptLogService deviceOptLogService;
|
||||||
|
@ -60,16 +70,38 @@ public class CommandServiceImpl implements CommandService {
|
||||||
if (ObjectUtils.isEmpty(modbusCommands)) {
|
if (ObjectUtils.isEmpty(modbusCommands)) {
|
||||||
return Response.failed("Modbus command is empty");
|
return Response.failed("Modbus command is empty");
|
||||||
}
|
}
|
||||||
this.deviceDao.getDeviceById(command.getDeviceId());
|
HashOperations<String, String, String> operations = this.redisTemplate.opsForHash();
|
||||||
|
Map<String, String> deviceInfoMap = operations.entries(
|
||||||
|
PersistenceHandler.DEVICE_INFO_CACHE + command.getDeviceId());
|
||||||
|
if (ObjectUtils.isEmpty(deviceInfoMap)) {
|
||||||
|
Map<String, Object> deviceInfo = this.jdbcTemplate.queryForMap(
|
||||||
|
Redis2DBPersistenceService.DEVICE_INFO_SQL + command.getDeviceId());
|
||||||
|
if (ObjectUtils.isNotEmpty(deviceInfo)) {
|
||||||
|
deviceInfoMap = new HashMap<>(deviceInfo.size());
|
||||||
|
for (Map.Entry<String, Object> entry : deviceInfo.entrySet()) {
|
||||||
|
deviceInfoMap.put(entry.getKey(),
|
||||||
|
Objects.isNull(entry.getValue()) ? null : String.valueOf(entry.getValue()));
|
||||||
|
}
|
||||||
|
operations.putAll(PersistenceHandler.DEVICE_INFO_CACHE + command.getDeviceId(), deviceInfoMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modbusCommands.forEach(item -> {
|
String identifier;
|
||||||
// .key(StringUtils.joinWith("/", identifier,
|
long timestamp = System.currentTimeMillis();
|
||||||
// MapUtil.getStr(item, "deviceId"),
|
for (ModbusCommandDto item : modbusCommands) {
|
||||||
// MapUtil.getStr(item, "commandId"),
|
if (StringUtils.isBlank(item.getCommand())) {
|
||||||
// timestamp))
|
return Response.failed("Modbus command is empty");
|
||||||
item.setKey("");
|
}
|
||||||
item.setIdentifier("");
|
if (item.getLength() < 10) {
|
||||||
});
|
return Response.failed("Modbus command return message length failed");
|
||||||
|
}
|
||||||
|
identifier = MapUtil.getStr(deviceInfoMap, "gateway_sn");
|
||||||
|
item.setKey(StringUtils.joinWith("/", identifier,
|
||||||
|
MapUtil.getStr(deviceInfoMap, "deviceId"),
|
||||||
|
MapUtil.getStr(deviceInfoMap, "commandId"),
|
||||||
|
timestamp));
|
||||||
|
item.setIdentifier(identifier);
|
||||||
|
}
|
||||||
RequestEntity<Collection<ModbusCommandDto>> request = RequestEntity
|
RequestEntity<Collection<ModbusCommandDto>> request = RequestEntity
|
||||||
.post("http://localhost:9999/modbus-tcp/" + type)
|
.post("http://localhost:9999/modbus-tcp/" + type)
|
||||||
.body(modbusCommands);
|
.body(modbusCommands);
|
||||||
|
|
|
@ -3,9 +3,15 @@ package com.isu.gaswellwatch.vo.command;
|
||||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.TurnOff;
|
import com.isu.gaswellwatch.vo.command.etc.PlungerTimer;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.TurnOn;
|
import com.isu.gaswellwatch.vo.command.etc.SensorDelay;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.mode.*;
|
import com.isu.gaswellwatch.vo.command.knpcv1.mode.*;
|
||||||
|
import com.isu.gaswellwatch.vo.command.scss.ControlMode;
|
||||||
|
import com.isu.gaswellwatch.vo.command.scss.PlungerLogicMode;
|
||||||
|
import com.isu.gaswellwatch.vo.command.scss.SimpleLogicMode;
|
||||||
|
import com.isu.gaswellwatch.vo.command.scss.SystemInfo;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,14 +31,24 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "code")
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "code")
|
||||||
@JsonSubTypes(value = {
|
@JsonSubTypes(value = {
|
||||||
@JsonSubTypes.Type(value = TurnOn.class, name = Command.KNPCV1_TURN_ON_THE_WELL),
|
|
||||||
@JsonSubTypes.Type(value = TurnOff.class, name = Command.KNPCV1_TURN_OFF_THE_WELL),
|
|
||||||
@JsonSubTypes.Type(value = TimerMode.class, name = Command.KNPCV1_RUN_TIMER),
|
@JsonSubTypes.Type(value = TimerMode.class, name = Command.KNPCV1_RUN_TIMER),
|
||||||
@JsonSubTypes.Type(value = TimingMode.class, name = Command.KNPCV1_RUN_TIMING),
|
@JsonSubTypes.Type(value = TimingMode.class, name = Command.KNPCV1_RUN_TIMING),
|
||||||
@JsonSubTypes.Type(value = ManualMode.class, name = Command.KNPCV1_RUN_MANUAL),
|
@JsonSubTypes.Type(value = ManualMode.class, name = Command.KNPCV1_RUN_MANUAL),
|
||||||
@JsonSubTypes.Type(value = PlungerMode.class, name = Command.KNPCV1_RUN_PLUNGER),
|
@JsonSubTypes.Type(value = PlungerMode.class, name = Command.KNPCV1_RUN_PLUNGER),
|
||||||
@JsonSubTypes.Type(value = PressureMode.class, name = Command.KNPCV1_RUN_PRESSURE),
|
@JsonSubTypes.Type(value = PressureMode.class, name = Command.KNPCV1_RUN_PRESSURE),
|
||||||
@JsonSubTypes.Type(value = TimePressureMode.class, name = Command.KNPCV1_RUN_TIME_PRESSURE),
|
@JsonSubTypes.Type(value = TimePressureMode.class, name = Command.KNPCV1_RUN_TIME_PRESSURE),
|
||||||
|
@JsonSubTypes.Type(value = SensorDelay.class, name = Command.ETC_SENSOR_DELAY),
|
||||||
|
@JsonSubTypes.Type(value = PlungerTimer.class, name = Command.ETC_PLUNGER_TIMER),
|
||||||
|
@JsonSubTypes.Type(value = SystemInfo.class, name = Command.SCSS_SYSTEM_INFO),
|
||||||
|
@JsonSubTypes.Type(value = ControlMode.class, name = Command.SCSS_CONTROL_MODE),
|
||||||
|
@JsonSubTypes.Type(value = SimpleLogicMode.class, name = Command.SCSS_SIMPLE_LOGIC_MODE),
|
||||||
|
@JsonSubTypes.Type(value = PlungerLogicMode.class, name = Command.SCSS_PLUNGER_LOGIC_MODE),
|
||||||
|
@JsonSubTypes.Type(value = com.isu.gaswellwatch.vo.command.etc.TurnOn.class, name = Command.ETC_TURN_ON_THE_WELL),
|
||||||
|
@JsonSubTypes.Type(value = com.isu.gaswellwatch.vo.command.etc.TurnOff.class, name = Command.ETC_TURN_OFF_THE_WELL),
|
||||||
|
@JsonSubTypes.Type(value = com.isu.gaswellwatch.vo.command.scss.TurnOn.class, name = Command.SCSS_TURN_ON_THE_WELL),
|
||||||
|
@JsonSubTypes.Type(value = com.isu.gaswellwatch.vo.command.scss.TurnOff.class, name = Command.SCSS_TURN_OFF_THE_WELL),
|
||||||
|
@JsonSubTypes.Type(value = com.isu.gaswellwatch.vo.command.knpcv1.TurnOn.class, name = Command.KNPCV1_TURN_ON_THE_WELL),
|
||||||
|
@JsonSubTypes.Type(value = com.isu.gaswellwatch.vo.command.knpcv1.TurnOff.class, name = Command.KNPCV1_TURN_OFF_THE_WELL),
|
||||||
})
|
})
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -57,8 +73,33 @@ public abstract class Command implements Serializable {
|
||||||
public static final String KNPCV1_RUN_TIME_PRESSURE = "KNPCV1.RUN.TIME_PRESSURE";
|
public static final String KNPCV1_RUN_TIME_PRESSURE = "KNPCV1.RUN.TIME_PRESSURE";
|
||||||
/* 点表类型:KNPCV1 end */
|
/* 点表类型:KNPCV1 end */
|
||||||
|
|
||||||
|
/* 点表类型:SCSS start */
|
||||||
|
/* 系统基本信息 */
|
||||||
|
public static final String SCSS_SYSTEM_INFO = "SCSS.SYSTEM_INFO";
|
||||||
|
/* 开关井 */
|
||||||
|
public static final String SCSS_TURN_ON_THE_WELL = "SCSS.TURN_ON_THE_WELL";
|
||||||
|
public static final String SCSS_TURN_OFF_THE_WELL = "SCSS.TURN_OFF_THE_WELL";
|
||||||
|
/* 模式指令 */
|
||||||
|
public static final String SCSS_CONTROL_MODE = "SCSS.CONTROL_MODE";
|
||||||
|
public static final String SCSS_SIMPLE_LOGIC_MODE = "SCSS.SIMPLE_LOGIC_MODE";
|
||||||
|
public static final String SCSS_PLUNGER_LOGIC_MODE = "SCSS.PLUNGER_LOGIC_MODE";
|
||||||
|
|
||||||
|
/* 点表类型:SCSS end */
|
||||||
|
|
||||||
|
/* 点表类型:ETC start */
|
||||||
|
/* 开关井 */
|
||||||
|
public static final String ETC_TURN_ON_THE_WELL = "ETC.TURN_ON_THE_WELL";
|
||||||
|
public static final String ETC_TURN_OFF_THE_WELL = "ETC.TURN_OFF_THE_WELL";
|
||||||
|
/* 模式指令*/
|
||||||
|
public static final String ETC_SENSOR_DELAY = "ETC.SENSOR_DELAY";
|
||||||
|
public static final String ETC_PLUNGER_TIMER = "ETC.PLUNGER_TIMER";
|
||||||
|
|
||||||
|
/* 点表类型:ETC end */
|
||||||
|
|
||||||
|
@NotBlank(message = "指令编码不能为空")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
|
@NotNull(message = "下发设备标识不能为空")
|
||||||
private Long deviceId;
|
private Long deviceId;
|
||||||
|
|
||||||
public Collection<ModbusCommandDto> buildModbusCommand() {
|
public Collection<ModbusCommandDto> buildModbusCommand() {
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.etc;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 22:56
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class PlungerTimer extends Command implements Timing {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 888739283997908251L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 柱塞上升时间。[0-999]:[0-59]:[0-59]
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "柱塞上升时间不能为空")
|
||||||
|
private String plungerRiseTime;
|
||||||
|
|
||||||
|
public PlungerTimer() {
|
||||||
|
this.setCode("ETC.PLUNGER_TIMER");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validate() {
|
||||||
|
return super.validate() && StringUtils.isNotBlank(this.plungerRiseTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
StringBuilder command = new StringBuilder(60);
|
||||||
|
// 0003*2->hex
|
||||||
|
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||||
|
// 01 10 006A 0003 06
|
||||||
|
command.append("0110006A000306").append(this.toHexString(this.plungerRiseTime));
|
||||||
|
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlungerRiseTime(String plungerRiseTime) {
|
||||||
|
this.plungerRiseTime = this.timingValidate(plungerRiseTime, "plungerRiseTime");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.etc;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 23:04
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class SensorDelay extends Command implements Timing {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -126267138442242492L;
|
||||||
|
/**
|
||||||
|
* 到达传感器延时时间。[0-999]:[0-59]:[0-59]
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "到达传感器延时时间不能为空")
|
||||||
|
private String arrivalSensorDelayTime;
|
||||||
|
/**
|
||||||
|
* 关井时间。[0-999]:[0-59]:[0-59]
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "关井时间不能为空")
|
||||||
|
private String wellShutInTime;
|
||||||
|
/**
|
||||||
|
* 续流时间。[0-999]:[0-59]:[0-59]
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "续流时间不能为空")
|
||||||
|
private String afterFlowTime;
|
||||||
|
|
||||||
|
public SensorDelay() {
|
||||||
|
this.setCode("ETC.SENSOR_DELAY");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validate() {
|
||||||
|
return super.validate()
|
||||||
|
&& StringUtils.isNotBlank(this.afterFlowTime)
|
||||||
|
&& StringUtils.isNotBlank(this.wellShutInTime)
|
||||||
|
&& StringUtils.isNotBlank(this.arrivalSensorDelayTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
StringBuilder command = new StringBuilder(60);
|
||||||
|
// 0009*2->hex
|
||||||
|
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||||
|
// 01 10 008B 0009 12
|
||||||
|
command.append("0110008B000912")
|
||||||
|
.append(this.toHexString(this.arrivalSensorDelayTime))
|
||||||
|
.append(this.toHexString(this.wellShutInTime))
|
||||||
|
.append(this.toHexString(this.afterFlowTime));
|
||||||
|
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAfterFlowTime(String afterFlowTime) {
|
||||||
|
this.afterFlowTime = this.timingValidate(afterFlowTime, "afterFlowTime");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWellShutInTime(String wellShutInTime) {
|
||||||
|
this.wellShutInTime = this.timingValidate(wellShutInTime, "wellShutInTime");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArrivalSensorDelayTime(String arrivalSensorDelayTime) {
|
||||||
|
this.arrivalSensorDelayTime = this.timingValidate(arrivalSensorDelayTime, "arrivalSensorDelayTime");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.etc;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 22:44
|
||||||
|
*/
|
||||||
|
public class TurnOff extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 5520601184417717931L;
|
||||||
|
|
||||||
|
public TurnOff() {
|
||||||
|
this.setCode("ETC.TURN_OFF_THE_WELL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
return List.of(ModbusCommandDto.builder().command("01050001FF00").length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.etc;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 22:48
|
||||||
|
*/
|
||||||
|
public class TurnOn extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 7288866205502636187L;
|
||||||
|
|
||||||
|
public TurnOn() {
|
||||||
|
this.setCode("ETC.TURN_ON_THE_WELL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
return List.of(ModbusCommandDto.builder().command("01050001FF00").length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import com.isu.gaswellwatch.vo.command.Timing;
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -37,10 +38,12 @@ public class PlungerMode extends ChangeRunMode implements Timing {
|
||||||
/**
|
/**
|
||||||
* 柱塞模式续流时长。[0-999]:[0-59]:[0-59]
|
* 柱塞模式续流时长。[0-999]:[0-59]:[0-59]
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "续流时长不能为空")
|
||||||
private String plugSustainTime;
|
private String plugSustainTime;
|
||||||
/**
|
/**
|
||||||
* 柱塞模式关井时长。[0-999]:[0-59]:[0-59]
|
* 柱塞模式关井时长。[0-999]:[0-59]:[0-59]
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "关井时长不能为空")
|
||||||
private String plugCloseTime;
|
private String plugCloseTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import com.isu.gaswellwatch.vo.command.Timing;
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -62,21 +63,25 @@ public class PressureMode extends ChangeRunMode implements Timing {
|
||||||
* 最大开井时长
|
* 最大开井时长
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "最大开井时长不能为空")
|
||||||
private String maxOpenWell = "00:00:00";
|
private String maxOpenWell = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 最小开井时长
|
* 最小开井时长
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "最小开井时长不能为空")
|
||||||
private String minOpenWell = "00:00:00";
|
private String minOpenWell = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 最大关井时长
|
* 最大关井时长
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "最大关井时长不能为空")
|
||||||
private String maxCloseWell = "00:00:00";
|
private String maxCloseWell = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 最小关井时长
|
* 最小关井时长
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "最小关井时长不能为空")
|
||||||
private String minCloseWell = "00:00:00";
|
private String minCloseWell = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 开井压力保护使能
|
* 开井压力保护使能
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import com.isu.gaswellwatch.vo.command.Timing;
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -51,6 +52,7 @@ public class TimePressureMode extends ChangeRunMode implements Timing {
|
||||||
* 时压模式开井时长
|
* 时压模式开井时长
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "开井时长不能为空")
|
||||||
private String tpOpenTiming = "00:00:00";
|
private String tpOpenTiming = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 时压模式关井源
|
* 时压模式关井源
|
||||||
|
@ -73,6 +75,7 @@ public class TimePressureMode extends ChangeRunMode implements Timing {
|
||||||
* 时压模式关井时长
|
* 时压模式关井时长
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "关井时长不能为空")
|
||||||
private String tpCloseTiming = "00:00:00";
|
private String tpCloseTiming = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 时压模式压力稳定时长:秒,[0-120]
|
* 时压模式压力稳定时长:秒,[0-120]
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import com.isu.gaswellwatch.vo.command.Timing;
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -52,24 +53,26 @@ public class TimerMode extends ChangeRunMode implements Timing {
|
||||||
* 定时器1开井时间
|
* 定时器1开井时间
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotNull(message = "定时器1开井时间不能为空")
|
||||||
private LocalTime timer1Open = LocalTime.MIN;
|
private LocalTime timer1Open = LocalTime.MIN;
|
||||||
/**
|
/**
|
||||||
* 定时器1关井时间
|
* 定时器1关井时间
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotNull(message = "定时器1关井时间不能为空")
|
||||||
private LocalTime timer1Close = LocalTime.MIN;
|
private LocalTime timer1Close = LocalTime.MIN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时器2开井时间
|
* 定时器2开井时间
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotNull(message = "定时器2开井时间不能为空")
|
||||||
private LocalTime timer2Open = LocalTime.MIN;
|
private LocalTime timer2Open = LocalTime.MIN;
|
||||||
/**
|
/**
|
||||||
* 定时器2关井时间
|
* 定时器2关井时间
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotNull(message = "定时器2关井时间不能为空")
|
||||||
private LocalTime timer2Close = LocalTime.MIN;
|
private LocalTime timer2Close = LocalTime.MIN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时器3开井时间
|
* 定时器3开井时间
|
||||||
*/
|
*/
|
||||||
|
@ -80,7 +83,6 @@ public class TimerMode extends ChangeRunMode implements Timing {
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private LocalTime timer3Close = LocalTime.MIN;
|
private LocalTime timer3Close = LocalTime.MIN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时器4开井时间
|
* 定时器4开井时间
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
import com.isu.gaswellwatch.vo.command.Timing;
|
import com.isu.gaswellwatch.vo.command.Timing;
|
||||||
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
import com.isu.gaswellwatch.vo.command.knpcv1.ChangeRunMode;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -30,16 +31,19 @@ public class TimingMode extends ChangeRunMode implements Timing {
|
||||||
* 计时器开井时长。[0-999]:[0-59]:[0-59]
|
* 计时器开井时长。[0-999]:[0-59]:[0-59]
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "开井时长不能为空")
|
||||||
private String timingOpen = "00:00:00";
|
private String timingOpen = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 计时器关井时长。[0-999]:[0-59]:[0-59]
|
* 计时器关井时长。[0-999]:[0-59]:[0-59]
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "关井时长不能为空")
|
||||||
private String timingClose = "00:00:00";
|
private String timingClose = "00:00:00";
|
||||||
/**
|
/**
|
||||||
* 计时器延时时长。[0-999]:[0-59]:[0-59]
|
* 计时器延时时长。[0-999]:[0-59]:[0-59]
|
||||||
*/
|
*/
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
@NotBlank(message = "延时时长不能为空")
|
||||||
private String timingCelay = "00:00:00";
|
private String timingCelay = "00:00:00";
|
||||||
|
|
||||||
public TimingMode() {
|
public TimingMode() {
|
||||||
|
|
|
@ -0,0 +1,176 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.scss;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制定值数据寄存器地址
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com>王仕龙</a>
|
||||||
|
* 2024/11/28 0:15
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class ControlMode extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -3782424709053622334L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制模式
|
||||||
|
*/
|
||||||
|
private int ctlModel;
|
||||||
|
/**
|
||||||
|
* 套压最小值
|
||||||
|
*/
|
||||||
|
private int minPressure;
|
||||||
|
/**
|
||||||
|
* 套压最大值
|
||||||
|
*/
|
||||||
|
private int maxPressure;
|
||||||
|
/**
|
||||||
|
* 套压最小电压
|
||||||
|
*/
|
||||||
|
private int pressureMinVoltage;
|
||||||
|
/**
|
||||||
|
* 套压最大电压
|
||||||
|
*/
|
||||||
|
private int pressureMaxVoltage;
|
||||||
|
/**
|
||||||
|
* 油压最小值
|
||||||
|
*/
|
||||||
|
private int oilMin;
|
||||||
|
/**
|
||||||
|
* 油压最大值
|
||||||
|
*/
|
||||||
|
private int oliMax;
|
||||||
|
/**
|
||||||
|
* 油压最小电压
|
||||||
|
*/
|
||||||
|
private int oilMinVoltage;
|
||||||
|
/**
|
||||||
|
* 油压最大电压
|
||||||
|
*/
|
||||||
|
private int oilMaxVoltage;
|
||||||
|
/**
|
||||||
|
* 输压最小值
|
||||||
|
*/
|
||||||
|
private int inputPressureMinValue;
|
||||||
|
/**
|
||||||
|
* 输压最大值
|
||||||
|
*/
|
||||||
|
private int inputPressureMaxValue;
|
||||||
|
/**
|
||||||
|
* 输压最小电压
|
||||||
|
*/
|
||||||
|
private int inputVoltageMinValue;
|
||||||
|
/**
|
||||||
|
* 输压最大电压
|
||||||
|
*/
|
||||||
|
private int inputVoltageMaxValue;
|
||||||
|
/**
|
||||||
|
* 流量最小值
|
||||||
|
*/
|
||||||
|
private int flowRateMinValue;
|
||||||
|
/**
|
||||||
|
* 流量最大值
|
||||||
|
*/
|
||||||
|
private int flowRateMaxValue;
|
||||||
|
/**
|
||||||
|
* 流量最小电压
|
||||||
|
*/
|
||||||
|
private int flowVoltageMinValue;
|
||||||
|
/**
|
||||||
|
* 流量最大电压
|
||||||
|
*/
|
||||||
|
private int flowVoltageMaxValue;
|
||||||
|
/**
|
||||||
|
* 连续采样间隔
|
||||||
|
*/
|
||||||
|
private int continuousSamplingIntervalDuration;
|
||||||
|
/**
|
||||||
|
* 到达传感器有效电平
|
||||||
|
*/
|
||||||
|
private int sensorSignalEffectiveLevel;
|
||||||
|
/**
|
||||||
|
* 套压补偿极性
|
||||||
|
*/
|
||||||
|
private int pressureCompensationPolarityFlag;
|
||||||
|
/**
|
||||||
|
* 套压补偿值
|
||||||
|
*/
|
||||||
|
private int pressureCompensationValueSetting;
|
||||||
|
/**
|
||||||
|
* 油压补偿极性
|
||||||
|
*/
|
||||||
|
private int oilPressureCompensationPolarityFlag;
|
||||||
|
/**
|
||||||
|
* 油压补偿值
|
||||||
|
*/
|
||||||
|
private int oilPressureCompensationValueSetting;
|
||||||
|
/**
|
||||||
|
* 输压补偿极性
|
||||||
|
*/
|
||||||
|
private int inputPressureCompensationPolarityFlag;
|
||||||
|
/**
|
||||||
|
* 输压补偿值
|
||||||
|
*/
|
||||||
|
private int inputPressureCompensationValueSetting;
|
||||||
|
/**
|
||||||
|
* 流量补偿极性
|
||||||
|
*/
|
||||||
|
private int flowCompensationPolarityFlag;
|
||||||
|
/**
|
||||||
|
* 流量补偿值
|
||||||
|
*/
|
||||||
|
private int flowCompensationValueSetting;
|
||||||
|
|
||||||
|
public ControlMode() {
|
||||||
|
this.setCode("SCSS.CONTROL_MODE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
StringBuilder command = new StringBuilder(250);
|
||||||
|
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||||
|
// 01 10 0032 0036 6C
|
||||||
|
command.append("0110003200366C");
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.ctlModel), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.minPressure), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.maxPressure), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.pressureMinVoltage), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.pressureMaxVoltage), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.oilMin), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.oliMax), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.oilMinVoltage), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.oilMaxVoltage), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inputPressureMinValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inputPressureMaxValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inputVoltageMinValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inputVoltageMaxValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.flowRateMinValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.flowRateMaxValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.flowVoltageMinValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.flowVoltageMaxValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.continuousSamplingIntervalDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.sensorSignalEffectiveLevel), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.pressureCompensationPolarityFlag), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.pressureCompensationValueSetting), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.oilPressureCompensationPolarityFlag), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.oilPressureCompensationValueSetting), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inputPressureCompensationPolarityFlag), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inputPressureCompensationValueSetting), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.flowCompensationPolarityFlag), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.flowCompensationValueSetting), 8, "0"));
|
||||||
|
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.scss;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑定值-柱塞模式定值数据寄存器地址
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com>王仕龙</a>
|
||||||
|
* 2024/11/28 0:45
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class PlungerLogicMode extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -3715097823142330692L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 柱塞上升时间
|
||||||
|
*/
|
||||||
|
private int plungerRiseDuration;
|
||||||
|
/**
|
||||||
|
* 续流时间
|
||||||
|
*/
|
||||||
|
private int continuosFlowDuration;
|
||||||
|
/**
|
||||||
|
* 关井时间
|
||||||
|
*/
|
||||||
|
private int wellCloseTimeDuration;
|
||||||
|
/**
|
||||||
|
* 未到达关井时间
|
||||||
|
*/
|
||||||
|
private int wellCloseTimeNotReachedDuration;
|
||||||
|
/**
|
||||||
|
* 未到达次数
|
||||||
|
*/
|
||||||
|
private int wellCloseNotReachedCountValue;
|
||||||
|
/**
|
||||||
|
* 柱塞延迟时间
|
||||||
|
*/
|
||||||
|
private int plungerDelayDurationRepeat;
|
||||||
|
/**
|
||||||
|
* 目标时间
|
||||||
|
*/
|
||||||
|
private int targetTimeTimestamp;
|
||||||
|
/**
|
||||||
|
* 目标时间范围
|
||||||
|
*/
|
||||||
|
private int targetTimeRangeValue;
|
||||||
|
/**
|
||||||
|
* 续流增加时间
|
||||||
|
*/
|
||||||
|
private int continuosFlowIncreaseDuration;
|
||||||
|
/**
|
||||||
|
* 续流减少时间
|
||||||
|
*/
|
||||||
|
private int continuosFlowDecreaseDuration;
|
||||||
|
/**
|
||||||
|
* 关井增加时间
|
||||||
|
*/
|
||||||
|
private int wellCloseIncreaseDuration;
|
||||||
|
/**
|
||||||
|
* 关井减少时间
|
||||||
|
*/
|
||||||
|
private int wellCloseDecreaseDuration;
|
||||||
|
/**
|
||||||
|
* 最小关井时间
|
||||||
|
*/
|
||||||
|
private int minWellCloseTimeDuration2;
|
||||||
|
/**
|
||||||
|
* 最大关井时间
|
||||||
|
*/
|
||||||
|
private int maxWellCloseTimeDuration2;
|
||||||
|
/**
|
||||||
|
* 最小续流时间
|
||||||
|
*/
|
||||||
|
private int minContinuosFlowTimeDuration;
|
||||||
|
/**
|
||||||
|
* 最大续流时间
|
||||||
|
*/
|
||||||
|
private int maxContinuosFlowTimeDuration;
|
||||||
|
/**
|
||||||
|
* 最小开井时间
|
||||||
|
*/
|
||||||
|
private int minWellOpenTimeDuration2;
|
||||||
|
/**
|
||||||
|
* 最大开井时间
|
||||||
|
*/
|
||||||
|
private int maxWellOpenTimeDuration2;
|
||||||
|
/**
|
||||||
|
* 开井套压
|
||||||
|
*/
|
||||||
|
private int wellOpenPressureValueAtOpen;
|
||||||
|
/**
|
||||||
|
* 开井油压
|
||||||
|
*/
|
||||||
|
private int wellOpenOilPressureValueAtOpen;
|
||||||
|
/**
|
||||||
|
* 开井载荷因子预设值
|
||||||
|
*/
|
||||||
|
private int wellOpenLoadFactorPresetsAtOpen;
|
||||||
|
/**
|
||||||
|
* 关井套压
|
||||||
|
*/
|
||||||
|
private int wellClosePressureValueAtClose;
|
||||||
|
/**
|
||||||
|
* 关井油压
|
||||||
|
*/
|
||||||
|
private int wellCloseOilPressureValueAtClose;
|
||||||
|
/**
|
||||||
|
* 关井流量
|
||||||
|
*/
|
||||||
|
private int wellCloseFlowValueAtClose;
|
||||||
|
|
||||||
|
public PlungerLogicMode() {
|
||||||
|
this.setCode("SCSS.PLUNGER_LOGIC_MODE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
StringBuilder command = new StringBuilder(130);
|
||||||
|
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||||
|
// 01 10 00C8 0030 60
|
||||||
|
command.append("011000C8003060");
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.plungerRiseDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.continuosFlowDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseTimeNotReachedDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseNotReachedCountValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.plungerDelayDurationRepeat), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.targetTimeTimestamp), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.targetTimeRangeValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.continuosFlowIncreaseDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.continuosFlowDecreaseDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseIncreaseDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseDecreaseDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.minWellCloseTimeDuration2), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.maxWellCloseTimeDuration2), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.minContinuosFlowTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.maxContinuosFlowTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.minWellOpenTimeDuration2), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.maxWellOpenTimeDuration2), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenPressureValueAtOpen), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenOilPressureValueAtOpen), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenLoadFactorPresetsAtOpen), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellClosePressureValueAtClose), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseOilPressureValueAtClose), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseFlowValueAtClose), 8, "0"));
|
||||||
|
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.scss;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑定值-简单模式定值数据寄存器地址
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com>王仕龙</a>
|
||||||
|
* 2024/11/28 0:31
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class SimpleLogicMode extends Command {
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 8899565585137994751L;
|
||||||
|
/**
|
||||||
|
* 开井时间,以秒为单位的时间
|
||||||
|
*/
|
||||||
|
private int wellOpenTimeTimestamp;
|
||||||
|
/**
|
||||||
|
* 开井套压
|
||||||
|
*/
|
||||||
|
private int wellOpenPressureValue;
|
||||||
|
/**
|
||||||
|
* 开井油压
|
||||||
|
*/
|
||||||
|
private int wellOpenOilPressureValue;
|
||||||
|
/**
|
||||||
|
* 开井载荷因子预设值
|
||||||
|
*/
|
||||||
|
private int wellOpenLoadFactorPresets;
|
||||||
|
/**
|
||||||
|
* 关井时间
|
||||||
|
*/
|
||||||
|
private int wellCloseTimeTimestamp;
|
||||||
|
/**
|
||||||
|
* 关井套压
|
||||||
|
*/
|
||||||
|
private int wellClosePressureValue;
|
||||||
|
/**
|
||||||
|
* 关井油压
|
||||||
|
*/
|
||||||
|
private int wellCloseOilPressureValue;
|
||||||
|
/**
|
||||||
|
* 关井流量
|
||||||
|
*/
|
||||||
|
private int wellCloseFlowValue;
|
||||||
|
/**
|
||||||
|
* 最小开井时间
|
||||||
|
*/
|
||||||
|
private int inWellOpenTimeDuration;
|
||||||
|
/**
|
||||||
|
* 最大开井时间
|
||||||
|
*/
|
||||||
|
private int axWellOpenTimeDuration;
|
||||||
|
/**
|
||||||
|
* 最小关井时间
|
||||||
|
*/
|
||||||
|
private int inWellCloseTimeDuration;
|
||||||
|
/**
|
||||||
|
* 最大关井时间
|
||||||
|
*/
|
||||||
|
private int axWellCloseTimeDuration;
|
||||||
|
/**
|
||||||
|
* 压力稳定时间
|
||||||
|
*/
|
||||||
|
private int ressureStabilizationDuration;
|
||||||
|
/**
|
||||||
|
* 流量稳定时间
|
||||||
|
*/
|
||||||
|
private int lowStabilizationDuration;
|
||||||
|
/**
|
||||||
|
* 载荷因子稳定时间
|
||||||
|
*/
|
||||||
|
private int loadFactorStabilizationDuration;
|
||||||
|
/**
|
||||||
|
* 柱塞延迟时间
|
||||||
|
*/
|
||||||
|
private int plungerDelayDuration;
|
||||||
|
|
||||||
|
public SimpleLogicMode() {
|
||||||
|
this.setCode("SCSS.SIMPLE_LOGIC_MODE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
StringBuilder command = new StringBuilder(130);
|
||||||
|
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||||
|
// 01 10 0096 0020 40
|
||||||
|
command.append("01100096002040");
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenTimeTimestamp), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenPressureValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenOilPressureValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellOpenLoadFactorPresets), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseTimeTimestamp), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellClosePressureValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseOilPressureValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.wellCloseFlowValue), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inWellOpenTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.axWellOpenTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.inWellCloseTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.axWellCloseTimeDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.ressureStabilizationDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.lowStabilizationDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.loadFactorStabilizationDuration), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.plungerDelayDuration), 8, "0"));
|
||||||
|
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.scss;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.temporal.ChronoField;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 23:53
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class SystemInfo extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -4927792179148968016L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期时间, yyyy-MM-dd HH:mm:ss.SSS
|
||||||
|
*/
|
||||||
|
@NotNull(message = "系统时间不能为空")
|
||||||
|
private LocalDateTime dataTime;
|
||||||
|
/**
|
||||||
|
* 显示延时
|
||||||
|
*/
|
||||||
|
private int showDelay = 0;
|
||||||
|
/**
|
||||||
|
* 开井采样间隔
|
||||||
|
*/
|
||||||
|
private int openWellSamplingInterval = 0;
|
||||||
|
/**
|
||||||
|
* 关井采样间隔
|
||||||
|
*/
|
||||||
|
private int closeWellSamplingInterval = 0;
|
||||||
|
|
||||||
|
public SystemInfo() {
|
||||||
|
this.setCode("SCSS.SYSTEM_INFO");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validate() {
|
||||||
|
return super.validate() && Objects.isNull(this.dataTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
StringBuilder command = new StringBuilder(100);
|
||||||
|
// 0014*2->hex
|
||||||
|
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||||
|
// 01 10 0000 0014 28
|
||||||
|
command.append("01100000001428");
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.getYear() - 2000), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.getMonthValue()), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.getDayOfMonth()), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.getHour()), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.getMinute()), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.getSecond()), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.dataTime.get(ChronoField.MILLI_OF_SECOND)), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.showDelay), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.openWellSamplingInterval), 8, "0"));
|
||||||
|
command.append(StringUtils.leftPad(Integer.toHexString(this.closeWellSamplingInterval), 8, "0"));
|
||||||
|
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.scss;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 22:40
|
||||||
|
*/
|
||||||
|
public class TurnOff extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 5520601184417717931L;
|
||||||
|
|
||||||
|
public TurnOff() {
|
||||||
|
this.setCode("SCSS.TURN_OFF_THE_WELL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
return List.of(ModbusCommandDto.builder().command("010500010000").length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.isu.gaswellwatch.vo.command.scss;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
|
||||||
|
* 2024/11/27 22:57
|
||||||
|
*/
|
||||||
|
public class TurnOn extends Command {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 7288866205502636187L;
|
||||||
|
|
||||||
|
public TurnOn() {
|
||||||
|
this.setCode("SCSS.TURN_ON_THE_WELL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||||
|
return List.of(ModbusCommandDto.builder().command("01050001FF00").length(16).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue