From a48c60bcdb7caa21e46addedcaae6bca4124f09d Mon Sep 17 00:00:00 2001 From: wangshilong Date: Thu, 28 Nov 2024 00:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=9B=9B=E5=B7=9D?= =?UTF-8?q?=E5=8F=8C=E6=99=9F=E6=8E=A7=E5=88=B6=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isu/gaswellwatch/vo/command/Command.java | 23 ++- .../vo/command/etc/PlungerTimer.java | 6 +- .../vo/command/etc/SensorDelay.java | 6 +- .../vo/command/scss/ControlMode.java | 176 ++++++++++++++++++ .../vo/command/scss/PlungerLogicMode.java | 161 ++++++++++++++++ .../vo/command/scss/SimpleLogicMode.java | 119 ++++++++++++ .../vo/command/scss/SystemInfo.java | 77 ++++++++ 7 files changed, 564 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/isu/gaswellwatch/vo/command/scss/ControlMode.java create mode 100644 src/main/java/com/isu/gaswellwatch/vo/command/scss/PlungerLogicMode.java create mode 100644 src/main/java/com/isu/gaswellwatch/vo/command/scss/SimpleLogicMode.java create mode 100644 src/main/java/com/isu/gaswellwatch/vo/command/scss/SystemInfo.java diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/Command.java b/src/main/java/com/isu/gaswellwatch/vo/command/Command.java index b08dedf..9dce5c1 100644 --- a/src/main/java/com/isu/gaswellwatch/vo/command/Command.java +++ b/src/main/java/com/isu/gaswellwatch/vo/command/Command.java @@ -3,7 +3,13 @@ package com.isu.gaswellwatch.vo.command; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto; +import com.isu.gaswellwatch.vo.command.etc.PlungerTimer; +import com.isu.gaswellwatch.vo.command.etc.SensorDelay; 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; @@ -31,6 +37,12 @@ import java.util.Objects; @JsonSubTypes.Type(value = PlungerMode.class, name = Command.KNPCV1_RUN_PLUNGER), @JsonSubTypes.Type(value = PressureMode.class, name = Command.KNPCV1_RUN_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), @@ -62,10 +74,15 @@ public abstract class Command implements Serializable { /* 点表类型: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 */ @@ -73,7 +90,9 @@ public abstract class Command implements Serializable { /* 开关井 */ 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 */ diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/etc/PlungerTimer.java b/src/main/java/com/isu/gaswellwatch/vo/command/etc/PlungerTimer.java index 9a34080..b0d5cb3 100644 --- a/src/main/java/com/isu/gaswellwatch/vo/command/etc/PlungerTimer.java +++ b/src/main/java/com/isu/gaswellwatch/vo/command/etc/PlungerTimer.java @@ -14,7 +14,7 @@ import java.util.Collection; import java.util.List; /** - * @author 王仕龙 + * @author 王仕龙 * 2024/11/27 22:56 */ @Getter @@ -31,6 +31,10 @@ public class PlungerTimer extends Command implements Timing { @NotBlank(message = "柱塞上升时间不能为空") private String plungerRiseTime; + public PlungerTimer() { + this.setCode("ETC.PLUNGER_TIMER"); + } + @Override public boolean validate() { return super.validate() && StringUtils.isNotBlank(this.plungerRiseTime); diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/etc/SensorDelay.java b/src/main/java/com/isu/gaswellwatch/vo/command/etc/SensorDelay.java index fb58ad4..619d210 100644 --- a/src/main/java/com/isu/gaswellwatch/vo/command/etc/SensorDelay.java +++ b/src/main/java/com/isu/gaswellwatch/vo/command/etc/SensorDelay.java @@ -14,7 +14,7 @@ import java.util.Collection; import java.util.List; /** - * @author 王仕龙 + * @author 王仕龙 * 2024/11/27 23:04 */ @Getter @@ -40,6 +40,10 @@ public class SensorDelay extends Command implements Timing { @NotBlank(message = "续流时间不能为空") private String afterFlowTime; + public SensorDelay() { + this.setCode("ETC.SENSOR_DELAY"); + } + @Override public boolean validate() { return super.validate() diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/scss/ControlMode.java b/src/main/java/com/isu/gaswellwatch/vo/command/scss/ControlMode.java new file mode 100644 index 0000000..48858f1 --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/vo/command/scss/ControlMode.java @@ -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 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()); + } +} diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/scss/PlungerLogicMode.java b/src/main/java/com/isu/gaswellwatch/vo/command/scss/PlungerLogicMode.java new file mode 100644 index 0000000..b1d3e66 --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/vo/command/scss/PlungerLogicMode.java @@ -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 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()); + } +} diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/scss/SimpleLogicMode.java b/src/main/java/com/isu/gaswellwatch/vo/command/scss/SimpleLogicMode.java new file mode 100644 index 0000000..81b0ce3 --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/vo/command/scss/SimpleLogicMode.java @@ -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 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()); + } +} diff --git a/src/main/java/com/isu/gaswellwatch/vo/command/scss/SystemInfo.java b/src/main/java/com/isu/gaswellwatch/vo/command/scss/SystemInfo.java new file mode 100644 index 0000000..fc084ca --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/vo/command/scss/SystemInfo.java @@ -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 王仕龙 + * 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 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()); + } + +}