新增老版维尔普斯指令
This commit is contained in:
parent
686a200dd6
commit
66174695a3
|
@ -3,8 +3,6 @@ package com.isu.gaswellwatch.modbus.data.decode.impl;
|
|||
|
||||
import com.isu.gaswellwatch.modbus.data.ModbusMessage;
|
||||
import com.isu.gaswellwatch.modbus.data.decode.DecodeHandler;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -20,15 +18,15 @@ public class ByteToStringDecodeHandler implements DecodeHandler {
|
|||
|
||||
@Override
|
||||
public String decode(Map<String, Object> commandPointMap, String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return value;
|
||||
}
|
||||
int length = value.length() / 4;
|
||||
byte[] bytes = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
bytes[0] = NumberUtils.createInteger(value.substring(i * 4, i * 4 + 4)).byteValue();
|
||||
}
|
||||
return new String(bytes);
|
||||
// if (StringUtils.isBlank(value)) {
|
||||
// return value;
|
||||
// }
|
||||
// int length = value.length() / 4;
|
||||
// byte[] bytes = new byte[length];
|
||||
// for (int i = 0; i < length; i++) {
|
||||
// bytes[0] = NumberUtils.createInteger(value.substring(i * 4, i * 4 + 4)).byteValue();
|
||||
// }
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,7 @@ public class HighLowBinDecodeHandler implements DecodeHandler {
|
|||
if (StringUtils.isBlank(value)) {
|
||||
return value;
|
||||
}
|
||||
return String.valueOf(Integer.parseInt(value, 16));
|
||||
return String.valueOf(Long.parseLong(value, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,23 +31,16 @@ public class WepsCurrentLocalDateTimeDecodeHandler implements DecodeHandler {
|
|||
String minuteSecond = times[0];
|
||||
String weekHour = times[1];
|
||||
String monthDay = times[2];
|
||||
String year = times[4];
|
||||
String year = times[3];
|
||||
|
||||
// minuteSecond = Integer.toHexString(NumberUtils.createInteger(minuteSecond));
|
||||
// weekHour = Integer.toHexString(NumberUtils.createInteger(weekHour));
|
||||
// monthDay = Integer.toHexString(NumberUtils.createInteger(monthDay));
|
||||
// year = Integer.toHexString(NumberUtils.createInteger(year));
|
||||
|
||||
if (StringUtils.startsWithIgnoreCase(minuteSecond, "0x")) {
|
||||
minuteSecond = StringUtils.substring(minuteSecond, 2);
|
||||
}
|
||||
minuteSecond = StringUtils.leftPad(minuteSecond, 4, '0');
|
||||
if (StringUtils.startsWithIgnoreCase(weekHour, "0x")) {
|
||||
weekHour = StringUtils.substring(weekHour, 2);
|
||||
}
|
||||
weekHour = StringUtils.leftPad(weekHour, 4, '0');
|
||||
if (StringUtils.startsWithIgnoreCase(monthDay, "0x")) {
|
||||
monthDay = StringUtils.substring(monthDay, 2);
|
||||
}
|
||||
monthDay = StringUtils.leftPad(monthDay, 4, '0');
|
||||
if (StringUtils.startsWithIgnoreCase(year, "0x")) {
|
||||
year = StringUtils.substring(year, 2);
|
||||
}
|
||||
|
||||
return year + "-" + StringUtils.substring(monthDay, 0, 2) + "-" +
|
||||
StringUtils.substring(monthDay, 2) + " " + StringUtils.substring(weekHour, 2) + ":" +
|
||||
|
|
|
@ -24,11 +24,12 @@ public class WepsDecimalDecodeHandler implements DecodeHandler {
|
|||
return value;
|
||||
}
|
||||
if (StringUtils.startsWith(value, ".")) {
|
||||
return NumberUtils.createBigDecimal("0" + value).toString();
|
||||
return NumberUtils.createBigDecimal("0" + StringUtils.strip(value, "-")).toString();
|
||||
} else if (StringUtils.endsWith(value, ".")) {
|
||||
return NumberUtils.createBigDecimal(value + "0").toString();
|
||||
} else {
|
||||
return value;
|
||||
String[] numbers = StringUtils.split(value, ".");
|
||||
return numbers[0] + "." + Math.abs(NumberUtils.createLong(numbers[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,13 +32,7 @@ public class WepsRemainingLocalTimeDecodeHandler implements DecodeHandler {
|
|||
String minuteSecond = times[0];
|
||||
String dayHour = times[1];
|
||||
|
||||
if (StringUtils.startsWithIgnoreCase(minuteSecond, "0x")) {
|
||||
minuteSecond = StringUtils.substring(minuteSecond, 2);
|
||||
}
|
||||
minuteSecond = StringUtils.leftPad(minuteSecond, 4, '0');
|
||||
if (StringUtils.startsWithIgnoreCase(dayHour, "0x")) {
|
||||
dayHour = StringUtils.substring(dayHour, 2);
|
||||
}
|
||||
dayHour = StringUtils.leftPad(dayHour, 4, '0');
|
||||
|
||||
long daySeconds = TimeUnit.DAYS.toSeconds(NumberUtils.createLong(StringUtils.substring(dayHour, 0, 2)));
|
||||
|
|
|
@ -265,7 +265,15 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
ModbusMessage.MessagePoint messagePoint;
|
||||
for (int i = 0; i < stepSize; i++) {
|
||||
messagePoint = pointMap.get(StringUtils.leftPad(String.valueOf(startAddress + i), 4, '0'));
|
||||
values[i] = messagePoint.getValue();
|
||||
if (MapUtil.getBool(commandPointMap, "use_hex", Boolean.FALSE)) {
|
||||
values[i] = messagePoint.getOriginalValue();
|
||||
} else {
|
||||
if (Objects.isNull(messagePoint)) {
|
||||
values[i] = StringUtils.EMPTY;
|
||||
} else {
|
||||
values[i] = messagePoint.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
String format = MapUtil.getStr(commandPointMap, "format");
|
||||
return decodeMessage(decodeName, commandPointMap,
|
||||
|
@ -278,7 +286,11 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
ModbusMessage.MessagePoint messagePoint;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
messagePoint = pointMap.get(StringUtils.leftPad(String.valueOf(startAddress + i), 4, '0'));
|
||||
values[i] = messagePoint.getOriginalValue();
|
||||
if (Objects.isNull(messagePoint)) {
|
||||
values[i] = StringUtils.EMPTY;
|
||||
} else {
|
||||
values[i] = messagePoint.getOriginalValue();
|
||||
}
|
||||
}
|
||||
return highLowBinDecodeHandler.decode(commandPointMap, StringUtils.join(values));
|
||||
}
|
||||
|
@ -291,7 +303,11 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
for (int i = 0; i < stepSize; i++) {
|
||||
highPoint = pointMap.get(StringUtils.leftPad(String.valueOf(startAddress + i * 2), 4, '0'));
|
||||
lowPoint = pointMap.get(StringUtils.leftPad(String.valueOf(startAddress + i * 2 + 1), 4, '0'));
|
||||
values[i] = highLowBinDecodeHandler.decode(commandPointMap, highPoint.getOriginalValue() + lowPoint.getOriginalValue());
|
||||
if (Objects.isNull(highPoint) || Objects.isNull(lowPoint)) {
|
||||
values[i] = StringUtils.EMPTY;
|
||||
} else {
|
||||
values[i] = highLowBinDecodeHandler.decode(commandPointMap, highPoint.getOriginalValue() + lowPoint.getOriginalValue());
|
||||
}
|
||||
}
|
||||
|
||||
String format = MapUtil.getStr(commandPointMap, "format");
|
||||
|
|
|
@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
@ -43,6 +44,8 @@ public class CommandServiceImpl implements CommandService {
|
|||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
@Resource
|
||||
private DeviceOptLogService deviceOptLogService;
|
||||
@Value("${app.modbus-rtcp-host:http://localhost:9999}")
|
||||
private String modbusRtcpHost;
|
||||
|
||||
@Override
|
||||
public Response<String> control(Command command) {
|
||||
|
@ -50,15 +53,14 @@ public class CommandServiceImpl implements CommandService {
|
|||
|
||||
//记录用户保存控制指令日志
|
||||
Integer flag = null;
|
||||
if (Command.KNPCV1_TURN_ON_THE_WELL.equals(command.getCode())||Command.ETC_TURN_ON_THE_WELL.equals(command.getCode())||
|
||||
Command.SCSS_TURN_ON_THE_WELL.equals(command.getCode())) {
|
||||
if (StringUtils.equalsAny(command.getCode(), Command.KNPCV1_TURN_ON_THE_WELL, Command.ETC_TURN_ON_THE_WELL,
|
||||
Command.SCSS_TURN_ON_THE_WELL, Command.WEPS_TURN_ON_THE_WELL, Command.MI_WEPS_TURN_ON_THE_WELL)) {
|
||||
flag = 1;
|
||||
} else if (Command.KNPCV1_TURN_OFF_THE_WELL.equals(command.getCode())||
|
||||
Command.ETC_TURN_OFF_THE_WELL.equals(command.getCode())||
|
||||
Command.SCSS_TURN_OFF_THE_WELL.equals(command.getCode())) {
|
||||
} else if (StringUtils.equalsAny(command.getCode(), Command.KNPCV1_TURN_OFF_THE_WELL, Command.ETC_TURN_OFF_THE_WELL,
|
||||
Command.SCSS_TURN_OFF_THE_WELL, Command.WEPS_TURN_OFF_THE_WELL, Command.MI_WEPS_TURN_OFF_THE_WELL)) {
|
||||
flag = 0;
|
||||
}
|
||||
this.deviceOptLogService.saveGasWellOptLog(flag, command.getDeviceId(),"");
|
||||
this.deviceOptLogService.saveGasWellOptLog(flag, command.getDeviceId(), "");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -111,7 +113,7 @@ public class CommandServiceImpl implements CommandService {
|
|||
item.setIdentifier(identifier);
|
||||
}
|
||||
RequestEntity<Collection<ModbusCommandDto>> request = RequestEntity
|
||||
.post("http://localhost:9999/modbus-tcp/" + type)
|
||||
.post(this.modbusRtcpHost + "/modbus-tcp/" + type)
|
||||
.body(modbusCommands);
|
||||
ResponseEntity<Response<String>> response = this.restTemplate.exchange(request,
|
||||
new ParameterizedTypeReference<Response<String>>() {
|
||||
|
|
|
@ -124,16 +124,16 @@ public abstract class Command implements Serializable {
|
|||
|
||||
/* 点表类型:新版威尔普斯 start */
|
||||
// 新版威尔普斯,柱塞模式
|
||||
public static final String WEPS_PLUG_CONTROL = "WEPS.PLUG.CONTROL";
|
||||
public static final String WEPS_TURN_ON_THE_WELL = "WEPS.TURN_ON_THE_WELL";
|
||||
public static final String WEPS_TURN_OFF_THE_WELL = "WEPS.TURN_OFF_THE_WELL";
|
||||
public static final String WEPS_PLUG_CONTROL = "WEPS.PLUG.CONTROL";
|
||||
/* 点表类型:新版威尔普斯 end */
|
||||
|
||||
/* 点表类型:老版威尔普斯 start */
|
||||
// 老版威尔普斯,柱塞模式
|
||||
public static final String MI_WEPS_PLUG_CONTROL = "MI_WEPS.PLUG.CONTROL";
|
||||
public static final String MI_WEPS_TURN_ON_THE_WELL = "MI_WEPS.TURN_ON_THE_WELL";
|
||||
public static final String MI_WEPS_TURN_OFF_THE_WELL = "MI_WEPS.TURN_OFF_THE_WELL";
|
||||
public static final String MI_WEPS_PLUG_CONTROL = "MI_WEPS.PLUG.CONTROL";
|
||||
/* 点表类型:老版威尔普斯 end */
|
||||
|
||||
public static final BigDecimal ONE_SIXTY = BigDecimal.valueOf(60);
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package com.isu.gaswellwatch.vo.command.weps;
|
||||
|
||||
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||
import com.isu.gaswellwatch.vo.command.Command;
|
||||
import com.isu.gaswellwatch.vo.command.Timing;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 威尔普斯控制指令
|
||||
*
|
||||
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
|
||||
* 2025/1/10 11:00
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
public class MiWepsPlugControl extends Command implements Timing {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -7540015879950965127L;
|
||||
|
||||
// private Integer gasWellNumber; // 气井编号
|
||||
private Integer depthOfLockDevice; // 卡定器深度 单位:米
|
||||
private Integer arrivingSensor; // 到达传感器 0/1:禁用/启用
|
||||
private Integer zigbee; // Zigbee 0/1:禁用/启用
|
||||
private Integer pulseWidth; // 脉冲宽度 驱动电磁阀使用
|
||||
private Integer plugRisingSpeed; // 上升速度 米/分钟
|
||||
private Integer plugTooFastSpeed; // 过快速度 米/分钟
|
||||
private Integer plugTooSlowSpeed; // 过缓速度 米/分钟
|
||||
// private Integer gasWellName; // 气井名称
|
||||
// 分段
|
||||
private Integer oilAndCasDataCollectionInterval; // 油、套压数据采集间隔 0:每5秒采样;1:每10秒采样;2:每15秒采样;3:每30秒采样;4:每1秒采样;5:每2秒采样;6:每3秒采样;7:每4秒采样
|
||||
private Integer storeDataIntervalOnOpenWell; // 数据存储间隔(开井期间) 0:每1分钟存储;1:每5分钟存储;2:每10分钟存储;3:每15分钟存储;4:每30秒存储;5:每15秒存储;6:每5秒存储
|
||||
private Integer storeDataIntervalOnCloseWell; // 数据存储间隔(关井期间) 0:每1分钟存储;1:每5分钟存储;2:每10分钟存储;3:每15分钟存储;4:每30秒存储;5:每15秒存储;6:每5秒存储
|
||||
// 分段
|
||||
// private Integer communicationPowerThreshold; // 通信电量门限 Zigbee通讯使用
|
||||
// private Integer reserve1; // 保留 Zigbee通讯使用
|
||||
// private Integer startTimeOfDaytime; // 白天起始时间 Zigbee通讯使用
|
||||
// private Integer endTimeOfDaytime; // 白天结束时间 Zigbee通讯使用
|
||||
private Integer controlWorkTime; // 控制器工作状态 0:生产模式;1:常开模式;2:常关模式
|
||||
private Integer produceMode; // 生产制度设置 0:定时开关井;1:时间优化模式;2:压力微升模式;3:压力回升模式;4:压力跌落模式
|
||||
private String plungerRiseTime; // 上升时间 单位:秒
|
||||
private String dangerousRiseTime; // 危险上升时间 单位:秒
|
||||
private String tooFastRiseTime; // 过快上升时间 单位:秒
|
||||
private String tooSlowRiseTime; // 过缓上升时间 单位:秒
|
||||
private Integer tooFastCount; // 过快次数
|
||||
private String tooFastRaiseOpenWellTime; // 过快增加开井时间 单位:秒
|
||||
private String tooFastLowerCloseWellTime; // 过快减少关井时间 单位:秒
|
||||
private String tooSlowLowerOpenWellTime; // 过缓减少开井时间 单位:秒
|
||||
private String tooSlowRaiseCloseWellTime; // 过缓增加关井时间 单位:秒
|
||||
private String checkStabilityTime; // 检测稳定时间 单位:秒
|
||||
private String minCloseWellTime; // 最小关井时间 单位:秒
|
||||
private String maxCloseWellTime; // 最大关井时间 单位:秒
|
||||
private String wellCloseTimeNotReachedDuration; // 未到达关井时间 单位:秒
|
||||
private String minOpenWellTime; // 最小开井时间 单位:秒
|
||||
private String maxOpenWellTime; // 最大开井时间 单位:秒
|
||||
private String afterFlowTime; // 续流时间 单位:秒
|
||||
private String notReachedFlowTime; // 未到续流时间 单位:秒
|
||||
private String closeTime; // 关井时间 单位:秒
|
||||
private String openTime; // 开井时间 单位:秒
|
||||
private BigDecimal openPressure; // 开井压力 单位:MPa
|
||||
private BigDecimal closePressure; // 关井压力 单位:MPa
|
||||
private BigDecimal littleRisePressure; // 微升压力 单位:MPa
|
||||
private Integer gasCollectionMode; // 集气模式 0:低压集气模式;1:高压集气模式
|
||||
// private Integer reserve2; // 保留
|
||||
// 分段
|
||||
private BigDecimal protectionPressure; // 保护压力 单位:MPa
|
||||
|
||||
public MiWepsPlugControl() {
|
||||
this.setCode("MI_WEPS.PLUG.CONTROL");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
|
||||
StringBuilder command = new StringBuilder(250);
|
||||
// 100
|
||||
// 地址码 功能码 起始地址 连续长度 连续字长
|
||||
// 01 10 003F 0013 26
|
||||
command.append("0110003F001326");
|
||||
// command.append(StringUtils.leftPad(Integer.toHexString(this.runMode), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Integer.toHexString(this.wellStatus), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Integer.toHexString(this.gasCollectionMethod), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.highPressureProtection.multiply(ONE_HUNDRED).longValue()), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.lowPressureProtection.multiply(ONE_HUNDRED).longValue()), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Integer.toHexString(this.tooFastCount), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.dangerousRiseTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.tooFastRiseTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.openWellTime.multiply(ONE_SIXTY).longValue()), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.closeWellTime.multiply(ONE_SIXTY).longValue()), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.openWellCasPressure.multiply(ONE_HUNDRED).longValue()), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.littleRiseCasPressure.multiply(ONE_HUNDRED).longValue()), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toSeconds(this.checkStabilityTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toMinutes(this.minCloseWellTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toMinutes(this.maxCloseWellTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toMinutes(this.minOpenWellTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Long.toHexString(this.toMinutes(this.maxOpenWellTime)), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Integer.toHexString(this.wellDepth), 4, "0"));
|
||||
// command.append(StringUtils.leftPad(Integer.toHexString(this.produceMode), 4, "0"));
|
||||
return List.of(ModbusCommandDto.builder().command(command.toString()).length(16).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.isu.gaswellwatch.vo.command.weps;
|
||||
|
||||
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/26 19:57
|
||||
*/
|
||||
public class MiWepsTurnOff extends Command {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6219690846185319542L;
|
||||
|
||||
public MiWepsTurnOff() {
|
||||
this.setCode("MI_WEPS.TURN_OFF_THE_WELL");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
return List.of(ModbusCommandDto.builder().command("010600400002").length(16).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.isu.gaswellwatch.vo.command.weps;
|
||||
|
||||
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/26 19:57
|
||||
*/
|
||||
public class MiWepsTurnOn extends Command {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -7123367842204864916L;
|
||||
|
||||
public MiWepsTurnOn() {
|
||||
this.setCode("MI_WEPS.TURN_ON_THE_WELL");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
return List.of(ModbusCommandDto.builder().command("010600400001").length(16).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -26,4 +26,5 @@ public class WepsTurnOff extends Command {
|
|||
protected Collection<ModbusCommandDto> builderModbusCommand() {
|
||||
return List.of(ModbusCommandDto.builder().command("010600400002").length(16).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,15 @@ VALUES (37, 'miWepsRunMode', 'ylhsms', '压力回升模式', '3', 4, now(), now(
|
|||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (38, 'miWepsRunMode', 'yldlms', '压力跌落模式', '4', 5, now(), now());
|
||||
|
||||
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
|
||||
`start_address`, `message_length`, `details`)
|
||||
VALUES (10301, 'DEVICE_PRODUCT_CODE', 29, '采集实时数据地址表', 'READ_REAL_TIME_DATA', 'COLLECTION', 30, '010300000016',
|
||||
0, 98, '(老板)维尔普斯控制器实时数据地址表');
|
||||
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
|
||||
`start_address`, `message_length`, `details`)
|
||||
VALUES (10302, 'DEVICE_PRODUCT_CODE', 29, '采集控制器参数地址表', 'READ_CONTROL_PARAM_DATA', 'COLLECTION', 30,
|
||||
'010303EC0047', 1004, 294, '(老板)维尔普斯控制器参数地址表数据采集');
|
||||
|
||||
|
||||
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
|
||||
`precision`, `format`, `decode_name`)
|
||||
|
@ -207,4 +216,62 @@ INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `s
|
|||
VALUES (13241, 10302, 'reserve2', '保留', NULL, 1073, 1, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
|
||||
`precision`, `format`, `decode_name`)
|
||||
VALUES (13242, 10302, 'protectionPressure', '保护压力', '单位:MPa', 1074, 2, NULL, NULL, '%s.%s', 'wepsDecimal');
|
||||
VALUES (13242, 10302, 'protectionPressure', '保护压力', '单位:MPa', 1074, 2, NULL, NULL, '%s.%s', 'wepsDecimal');
|
||||
|
||||
|
||||
|
||||
UPDATE `commands`
|
||||
SET `ref_type` = 'DEVICE_PRODUCT_CODE',
|
||||
`ref_id` = 29,
|
||||
`name` = '采集控制器参数地址表',
|
||||
`code` = 'READ_CONTROL_PARAM_DATA',
|
||||
`type` = 'COLLECTION',
|
||||
`collection_frequency` = 30,
|
||||
`command` = '010303EC0048',
|
||||
`start_address` = 1004,
|
||||
`message_length` = 202,
|
||||
`details` = '(老板)维尔普斯控制器参数地址表数据采集'
|
||||
WHERE `id` = 10302;
|
||||
|
||||
ALTER TABLE `command_points`
|
||||
ADD COLUMN `use_hex` bit NULL COMMENT '采用16进制值' AFTER `precision`;
|
||||
|
||||
UPDATE `command_points`
|
||||
SET `command_id` = 10301,
|
||||
`field` = 'currentTime',
|
||||
`name` = '当前时间',
|
||||
`details` = '控制器时间。\n示例:0x4830:0x0211:0x0924:0x2013。\n结果:2013-09-24 11:48:30',
|
||||
`start_address` = 3,
|
||||
`step_size` = 4,
|
||||
`factor` = NULL,
|
||||
`precision` = NULL,
|
||||
`use_hex` = b'1',
|
||||
`format` = '%s:%s:%s:%s',
|
||||
`decode_name` = 'wepsCurrentLocalDateTime'
|
||||
WHERE `id` = 13102;
|
||||
UPDATE `command_points`
|
||||
SET `command_id` = 10301,
|
||||
`field` = 'remainingTime',
|
||||
`name` = '剩余时间',
|
||||
`details` = '组合后时间格式:天.小时:分钟:秒\n示例:0x0930:0x0001\n结果:0.1:09:30',
|
||||
`start_address` = 7,
|
||||
`step_size` = 2,
|
||||
`factor` = NULL,
|
||||
`precision` = NULL,
|
||||
`use_hex` = b'1',
|
||||
`format` = '%s:%s',
|
||||
`decode_name` = 'wepsRemainingLocalTime'
|
||||
WHERE `id` = 13103;
|
||||
UPDATE `command_points`
|
||||
SET `command_id` = 10302,
|
||||
`field` = 'gasWellName',
|
||||
`name` = '气井名称',
|
||||
`details` = NULL,
|
||||
`start_address` = 1012,
|
||||
`step_size` = 16,
|
||||
`factor` = NULL,
|
||||
`precision` = NULL,
|
||||
`use_hex` = b'1',
|
||||
`format` = NULL,
|
||||
`decode_name` = 'byteToString'
|
||||
WHERE `id` = 13208;
|
||||
|
|
|
@ -101,10 +101,10 @@
|
|||
,t.solar_voltage,t.first_solenoid_status as wellStatus
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='weps_plug'">
|
||||
,'weps_plug' as type,case t.run_mode as runMode
|
||||
,'weps_plug' as type, t.run_mode as runMode
|
||||
,case t.solenoid_valve_status when 2 then t.open_well_remaining_time
|
||||
when 1 then t.close_well_remaining_time else null end as statusEndTime
|
||||
,case t.solenoid_valve_status when 2 then 0 when 1 then 1 else null end as wellStatus
|
||||
,case t.solenoid_valve_status when 2 then 1 when 1 then 0 else null end as wellStatus
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='mi_weps_plug'">
|
||||
,t.produce_mode as runMode,t.remaining_time as statusEndTime
|
||||
|
@ -199,10 +199,10 @@
|
|||
,t.solar_voltage,t.first_solenoid_status as wellStatus
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='weps_plug'">
|
||||
,'weps_plug' as type,case t.run_mode as runMode
|
||||
,'weps_plug' as type, t.run_mode as runMode
|
||||
,case t.solenoid_valve_status when 2 then t.open_well_remaining_time
|
||||
when 1 then t.close_well_remaining_time else null end as statusEndTime
|
||||
,case t.solenoid_valve_status when 2 then 0 when 1 then 1 else null end as wellStatus
|
||||
,case t.solenoid_valve_status when 2 then 1 when 1 then 0 else null end as wellStatus
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='mi_weps_plug'">
|
||||
,t.produce_mode as runMode,t.remaining_time as statusEndTime
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.isu.gaswellwatch;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.isu.gaswellwatch.modbus.data.listener.DynamicRabbitListener;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
|
||||
* 2025/2/20 21:13
|
||||
*/
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
public class MIWrpsDecodeTest {
|
||||
|
||||
private String message10301 = "564D2E53352E31352E34315831/50002/10301/1740200010000/1740200016203/01032C0003000000E0553106120222202500000000800358C0411E27B13F46AACB411ED507408C000042C80000000071B2";
|
||||
private String message10302 = "564D2E53352E31352E34315831/50002/10302/1740197640001/1740197646124/01038E00000CE9000100010A8C00FA028A0064D5CB2D353531342D583100310000000000000000000000000000000000000000000000000000000041C800010007001900020000070800000000D960FFFEFEFE2300FEFEFFFEEEFF00C41000000E08000007580000022000001C2000001C0000A000BAFEE770002002580000A000FEFE0000000000006B0000000000000046D5";
|
||||
|
||||
@Resource(name = "stringRedisTemplate")
|
||||
protected RedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private DynamicRabbitListener dynamicRabbitListener;
|
||||
|
||||
@Test
|
||||
public void testWrpsDecode() {
|
||||
Message testMessage10301 = Mockito.mock(Message.class);
|
||||
Message testMessage10302 = Mockito.mock(Message.class);
|
||||
MessageProperties testMessageProperties = Mockito.mock(MessageProperties.class);
|
||||
Mockito.doReturn(this.message10301.getBytes()).when(testMessage10301).getBody();
|
||||
Mockito.doReturn(this.message10302.getBytes()).when(testMessage10302).getBody();
|
||||
Mockito.doReturn(testMessageProperties).when(testMessage10301).getMessageProperties();
|
||||
Mockito.doReturn(testMessageProperties).when(testMessage10302).getMessageProperties();
|
||||
Mockito.doReturn("/modbus/collect/0").when(testMessageProperties).getConsumerQueue();
|
||||
|
||||
this.dynamicRabbitListener.getComposeListener().onMessage(testMessage10301);
|
||||
this.dynamicRabbitListener.getComposeListener().onMessage(testMessage10302);
|
||||
|
||||
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(2));
|
||||
|
||||
Map<String, Object> row = this.redisTemplate.opsForHash().entries("data:device:50002");
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(row));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue