Browse Source

fix:修改调试指令

master
王梦远 2 months ago
parent
commit
40896cae18
  1. 14
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugFanStopCommand.java
  2. 14
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStartCommand.java
  3. 14
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStopCommand.java
  4. 9
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
  5. 28
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/ValveState.java
  6. 7
      src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java
  7. 24
      src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java
  8. 12
      src/main/resources/sql/init.sql

14
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugFanStopCommand.java

@ -30,14 +30,12 @@ public class DebugFanStopCommand extends BaseCommandHandler {
String heatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
return runAsync(() -> {
DeviceCommandBundle deviceCommand;
switch (heatModuleCode) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Close();
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Close();
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Close();
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Close();
default -> throw new RuntimeException("heatModuleCode 未找到");
}
DeviceCommandBundle deviceCommand= switch (heatModuleCode) {
case heat_module_01 -> DeviceCommandGenerator.fan1Close();
case heat_module_02 -> DeviceCommandGenerator.fan2Close();
case heat_module_03 -> DeviceCommandGenerator.fan3Close();
case heat_module_04 -> DeviceCommandGenerator.fan4Close();
};
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

14
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStartCommand.java

@ -31,14 +31,12 @@ public class DebugHeaterStartCommand extends BaseCommandHandler {
Double temperature = cmdDTO.getDoubleParam("temperature");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
return runAsync(() -> {
DeviceCommandBundle deviceCommand;
switch (heatModuleCode) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Open(temperature);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heatRod2Open(temperature);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heatRod3Open(temperature);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heatRod4Open(temperature);
default -> throw new RuntimeException("heatModuleCode 未找到");
}
DeviceCommandBundle deviceCommand=switch (heatModuleCode) {
case heat_module_01 -> DeviceCommandGenerator.heatRod1Open(temperature);
case heat_module_02 -> DeviceCommandGenerator.heatRod2Open(temperature);
case heat_module_03 -> DeviceCommandGenerator.heatRod3Open(temperature);
case heat_module_04 -> DeviceCommandGenerator.heatRod4Open(temperature);
};
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

14
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStopCommand.java

@ -30,14 +30,12 @@ public class DebugHeaterStopCommand extends BaseCommandHandler {
String heatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
return runAsync(() -> {
DeviceCommandBundle deviceCommand;
switch (heatModuleCode) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Close();
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heatRod2Close();
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heatRod3Close();
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heatRod4Close();
default -> throw new RuntimeException("heatModuleCode 未找到");
}
DeviceCommandBundle deviceCommand= switch (heatModuleCode) {
case heat_module_01 -> DeviceCommandGenerator.heatRod1Close();
case heat_module_02 -> DeviceCommandGenerator.heatRod2Close();
case heat_module_03 -> DeviceCommandGenerator.heatRod3Close();
case heat_module_04 -> DeviceCommandGenerator.heatRod4Close();
};
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

9
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java

@ -2,11 +2,13 @@ package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.SystemConfigCode;
import com.iflytop.sgs.common.enums.cmd.CmdDirection;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
@ -24,12 +26,15 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("liquid_pump_add")
public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final SystemConfigService systemConfigService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume");
//todo 量转换成转数
Double position = Double.valueOf(1000);
//todo 监测阀门开启状态 将加液量转换成电机转数
Double scale = Double.valueOf(systemConfigService.getSystemConfig(SystemConfigCode.scale_thin));
Double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {

28
src/main/java/com/iflytop/sgs/app/model/bo/status/device/ValveState.java

@ -0,0 +1,28 @@
package com.iflytop.sgs.app.model.bo.status.device;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "电磁转换阀")
@Data
public class ValveState {
@Schema(description = "稀硝酸开关 true开")
private boolean thin = false;
@Schema(description = "浓硝酸开关 true开")
private boolean thick = false;
@Schema(description = "废水开关 true开")
private boolean waste = false;
@Schema(description = "蒸馏水开关 true开")
private boolean water = false;
}

7
src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java

@ -1,9 +1,12 @@
package com.iflytop.sgs.app.service.api;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytop.sgs.app.mapper.SystemConfigMapper;
import com.iflytop.sgs.app.model.entity.SystemConfig;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.common.enums.ScaleCode;
import com.iflytop.sgs.common.enums.SystemConfigCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -81,4 +84,8 @@ public class SystemConfigService extends ServiceImpl<SystemConfigMapper, SystemC
}
}
public String getSystemConfig(SystemConfigCode systemConfigCode) {
SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getKey, systemConfigCode.name()));
return systemConfig.getValue();
}
}

24
src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java

@ -0,0 +1,24 @@
package com.iflytop.sgs.common.enums;
import lombok.Getter;
/**
* 加热模块code枚举
* 格式为 "heat_module_01" ~ "heat_module_06"
*/
@Getter
public enum SystemConfigCode {
//加液时 液量的转换系数
scale_thin("稀硝酸转换系数"),
scale_thick("浓硝酸转换系数"),
scale_water("水转换系数"),
scale_waste("废水转换系数");
private String description;
SystemConfigCode(String description) {
this.description = description;
}
}

12
src/main/resources/sql/init.sql

@ -45,6 +45,12 @@ CREATE TABLE IF NOT EXISTS system_config
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
INSERT OR IGNORE INTO system_config (id, key, value)
VALUES ('1', 'scale_thin', '100'),
('2', 'scale_thick', '100'),
('3', 'scale_water', '100'),
('4', 'scale_waste', '100');
-- 系统日志 表
CREATE TABLE IF NOT EXISTS system_log
@ -60,9 +66,9 @@ CREATE TABLE IF NOT EXISTS system_log
CREATE TABLE IF NOT EXISTS device_param_config
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
mid text,
reg_index text,
reg_val INTEGER,
mid text,
reg_index text,
reg_val INTEGER,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP

Loading…
Cancel
Save