双晟指令解析发送
This commit is contained in:
parent
6fc63e7563
commit
d23f325579
|
@ -72,6 +72,9 @@ public class Redis2DBPersistenceService {
|
|||
if (Objects.isNull(deviceId)) {
|
||||
continue;
|
||||
}
|
||||
if (!this.redisTemplate.hasKey(PersistenceHandler.DEVICE_INFO_CACHE + deviceId)) {
|
||||
continue;
|
||||
}
|
||||
if (Objects.nonNull(idGatewayMappingMap)) {
|
||||
operations.put(PersistenceHandler.DEVICE_DATA_CACHE + deviceId,
|
||||
"online", String.valueOf(idGatewayMappingMap.containsKey(deviceId)));
|
||||
|
|
|
@ -63,11 +63,12 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
Long commandId;
|
||||
String[] messageSplit;
|
||||
Map<String, Object> commandMap;
|
||||
String messageString, collectionMessage, commandString;
|
||||
String messageString = null, collectionMessage, commandString;
|
||||
Map<String, ModbusMessage.MessagePoint> messagePointMap;
|
||||
// 网关标识/设备标识/命令标识/采集下发时间/采集数据接收时间/采集数据体
|
||||
// 4B454E454E4731343030303030333538/1/10000/1732365690000/1732365691000/01042C07D0000
|
||||
for (Message message : messages) {
|
||||
try {
|
||||
messageString = new String(message.getBody());
|
||||
messageSplit = StringUtils.split(messageString, "/");
|
||||
if (messageSplit.length < 6) {
|
||||
|
@ -157,6 +158,9 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
.queueName(message.getMessageProperties().getConsumerQueue())
|
||||
.build());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("初始数据解析异常: {}, {}", message.getMessageProperties().getConsumerQueue(), messageString, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,13 @@ 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.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 套压模式
|
||||
|
@ -27,21 +30,25 @@ public class CasingMode extends Command implements Timing {
|
|||
private static final long serialVersionUID = -6609483152571838191L;
|
||||
/**
|
||||
* 开井套压
|
||||
* 152
|
||||
*/
|
||||
@NotNull(message = "开井套压不能为空")
|
||||
private BigDecimal wellOpenPressureValue = BigDecimal.ZERO;
|
||||
/**
|
||||
* 关井套压
|
||||
* 160
|
||||
*/
|
||||
@NotNull(message = "关井套压不能为空")
|
||||
private BigDecimal wellClosePressureValue = BigDecimal.ZERO;
|
||||
/**
|
||||
* 最小关井时间
|
||||
* 166
|
||||
*/
|
||||
@NotBlank(message = "最小关井时间不能为空,格式:HH:mm:ss")
|
||||
private String minWellCloseTimeDuration;
|
||||
/**
|
||||
* 最大关井时间
|
||||
* 168
|
||||
*/
|
||||
@NotBlank(message = "最大关井时间不能为空,格式:HH:mm:ss")
|
||||
private String maxWellCloseTimeDuration;
|
||||
|
@ -53,6 +60,33 @@ public class CasingMode extends Command implements Timing {
|
|||
|
||||
@Override
|
||||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
return null;
|
||||
List<ModbusCommandDto> resultList = new ArrayList<ModbusCommandDto>(3);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长 控制模式
|
||||
// 01 10 0032 0002 04 6(00000006, 6:套压(开)-套压(关)模式)
|
||||
resultList.add(ModbusCommandDto.builder().command("0110003200020400000006").length(16).build());
|
||||
|
||||
StringBuilder command = new StringBuilder(250);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 0098 0002 04
|
||||
command.append("01100098000204");
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.wellOpenPressureValue.multiply(ONE_HUNDRED).intValue()), 8, "0"));
|
||||
resultList.add(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
|
||||
command.setLength(0);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 00A0 0002 04
|
||||
command.append("011000A0000204");
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.wellClosePressureValue.multiply(ONE_HUNDRED).intValue()), 8, "0"));
|
||||
resultList.add(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
|
||||
command.setLength(0);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 00A6 0004 08
|
||||
command.append("011000A6000204");
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.minWellCloseTimeDuration)), 8, "0"));
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.maxWellCloseTimeDuration)), 8, "0"));
|
||||
resultList.add(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
|
@ -50,8 +50,8 @@ public class SamplingInterval extends Command {
|
|||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
StringBuilder command = new StringBuilder(250);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 0055 0004 08
|
||||
command.append("01100055000408");
|
||||
// 01 10 0054 0004 08
|
||||
command.append("01100054000408");
|
||||
command.append(StringUtils.leftPad(Integer.toHexString(this.continuousSamplingIntervalDuration), 8, "0"));
|
||||
command.append(StringUtils.leftPad(Integer.toHexString(this.sensorSignalEffectiveLevel.multiply(ONE_HUNDRED).intValue()), 8, "0"));
|
||||
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TimeMode extends Command implements Timing {
|
|||
|
||||
/**
|
||||
* 柱塞延迟时间
|
||||
* 200 2
|
||||
* 180 2
|
||||
*/
|
||||
@NotBlank(message = "柱塞延迟时间不能为空,格式:HH:mm:ss")
|
||||
private String plungerDelayDuration;
|
||||
|
@ -64,6 +64,10 @@ public class TimeMode extends Command implements Timing {
|
|||
@Override
|
||||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
List<ModbusCommandDto> resultList = new ArrayList<ModbusCommandDto>(3);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长 控制模式
|
||||
// 01 10 0032 0002 04 1(00000001, 1:时间(开)-时间(开)模式)
|
||||
resultList.add(ModbusCommandDto.builder().command("0110003200020400000001").length(16).build());
|
||||
|
||||
StringBuilder command = new StringBuilder(250);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 0096 0002 04
|
||||
|
@ -73,9 +77,16 @@ public class TimeMode extends Command implements Timing {
|
|||
|
||||
command.setLength(0);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 0096 0002 04
|
||||
command.append("01100096000204");
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.wellOpenTimeTimestamp)), 8, "0"));
|
||||
// 01 10 009E 0002 04
|
||||
command.append("0110009E000204");
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.wellCloseTimeTimestamp)), 8, "0"));
|
||||
resultList.add(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
|
||||
command.setLength(0);
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 00B4 0002 04
|
||||
command.append("011000B4000204");
|
||||
command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.plungerDelayDuration)), 8, "0"));
|
||||
resultList.add(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
|
||||
return resultList;
|
||||
|
|
Loading…
Reference in New Issue