Browse Source

调整业务指令开始退火,停止退火

master
白凤吉 2 months ago
parent
commit
5573f6bb1c
  1. 29
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java
  2. 22
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java
  3. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java
  4. 32
      src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java

29
src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java

@ -1,7 +1,5 @@
package com.iflytop.sgs.app.cmd.control;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONArray;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
@ -10,7 +8,6 @@ import com.iflytop.sgs.app.service.device.module.HeatModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.HeatingType;
import com.iflytop.sgs.common.exception.AppException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -30,27 +27,13 @@ public class AnnealStartCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode");
HeatModuleCode heatModuleCode = HeatModuleCode.heat_module_04;
return runAsync(() -> {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
//获取当前加热区
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断是否可以进行退火
Assert.isTrue(heatModuleState.getTrayStatus() == 1, heatModuleId + "加热区无托盘");
//设置加热区目标温度
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTargetTemperature(heatModuleState.getAnnealTemperature());
//从系统状态中获取指定加热区设定的退火温度数值
double temperature = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).getAnnealTemperature();
//开启退火
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature);
//设置加热区状态 正在退火
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeatingType(HeatingType.annealing);
}
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);
double targetTemperature = heatModuleState.getAnnealTemperature();
heatModuleState.setTargetTemperature(targetTemperature);
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.annealing);
});
}
}

22
src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java

@ -1,9 +1,6 @@
package com.iflytop.sgs.app.cmd.control;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONArray;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -17,7 +14,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 结束退火
* 停止退火
*/
@Slf4j
@Component
@ -29,21 +26,10 @@ public class AnnealStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.heat_module_04;
return runAsync(() -> {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
//获取当前加热区
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断当前加热区是否处于退火状态
Assert.isTrue(heatModuleState.getHeatingType().equals(HeatingType.annealing), heatModuleId + "加热区目前不在退火状态");
//关闭加热
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId);
//设置加热区状态 退火结束
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeatingType(HeatingType.stop);
}
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);
});
}
}

4
src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java

@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 开始清洗 todo wmy 需要改
* 开始清洗
*/
@Slf4j
@Component
@ -39,6 +39,8 @@ public class CleanStartCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//清洗次数
JSONArray jsonArray=cmdDTO.getJSONArrayParam("index");
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);

32
src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java

@ -79,32 +79,50 @@ public class HeatModuleService {
return devicePosition.getPoint3D();
}
/**
* 指定加热模块开启散热风扇
*/
public void fanStart(HeatModuleCode heatModuleCode) throws Exception {
fanStart(null, null, heatModuleCode);
}
public void fanStart(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception {
/**
* 指定加热模块开启散热风扇
*/
public void fanStart(String cmdId, String cmdCode, HeatModuleCode heatModuleCode) throws Exception {
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
switch (heatModuleCode) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Open();
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Open();
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Open();
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Open();
default -> throw new RuntimeException("heatId 未找到");
default -> throw new RuntimeException("heatModuleCode 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
/**
* 指定加热模块关闭散热风扇
*/
public void fanClose(HeatModuleCode heatModuleCode) throws Exception {
fanClose(null, null, heatModuleCode);
}
public void fanClose(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception {
/**
* 指定加热模块关闭散热风扇
*/
public void fanClose(String cmdId, String cmdCode, HeatModuleCode heatModuleCode) throws Exception {
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
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("heatId 未找到");
default -> throw new RuntimeException("heatModuleCode 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
}
Loading…
Cancel
Save