Browse Source

fix:增加业务指令执行过程中的模块状态

master
王梦远 2 months ago
parent
commit
c962e42515
  1. 13
      src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java
  2. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java
  3. 10
      src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java
  4. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/HeatStopCommand.java
  5. 19
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java
  6. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java
  7. 1
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java
  8. 2
      src/main/java/com/iflytop/sgs/app/controller/HeatController.java

13
src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java

@ -2,11 +2,13 @@ package com.iflytop.sgs.app.cmd.control;
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;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.HeatingType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -32,9 +34,14 @@ public class FanStartCommand extends BaseCommandHandler {
return runAsync(() -> {
for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) {
String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i);
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true);
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);//加热模块
HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);
if(!heatModuleState.getHeatingType().equals(HeatingType.stop)){//加热棒不是停止加热状态
heatModuleService.heatRodClose(cmdDTO.getCommandId(),cmdDTO.getCommand(),heatModuleCode);//关闭加热棒
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);//同步状态
}
heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//打开风扇
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true);//同步状态
}
});
}

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

@ -33,8 +33,8 @@ public class FanStopCommand extends BaseCommandHandler {
for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) {
String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i);
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true);
heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//关闭风扇
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(false);//同步转态
}
});
}

10
src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java

@ -1,5 +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;
@ -9,6 +10,8 @@ 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 com.iflytop.sgs.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -35,10 +38,11 @@ public class HeatStartCommand extends BaseCommandHandler {
for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) {
String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i);
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);//获取设定的加热温度
double targetTemperature = heatModuleState.getHeatTemperature();
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);//获取目标加热区
Assert.isTrue(heatModuleState.isTrayStatus(), ()->new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//目标加热区无托盘
double targetTemperature = heatModuleState.getHeatTemperature();//获取设定的加热温度
heatModuleState.setTargetTemperature(targetTemperature);//将加热温度设定为目标温度
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature);
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature);//打开加热棒
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.heating); //设置加热区状态 加热中
}
});

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

@ -34,8 +34,8 @@ public class HeatStopCommand extends BaseCommandHandler {
for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) {
String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i);
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr);
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//停止加热棒
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop);//同步转态
}
});
}

19
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java

@ -43,14 +43,20 @@ public class LiquidAddCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用
deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液
JSONArray jsonArray = cmdDTO.getJSONArrayParam("columns");//获取参数
Assert.notNull(jsonArray, () -> new AppException(ResultCode.INVALID_PARAMETER));//解析参数
TransferModuleState transferModuleState = deviceStateService.getDeviceState().getTransferModule();//获取机械臂状态
Assert.isTrue(transferModuleState.isTrayStatus(), () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘
Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位
Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon(); //加液模块电机下降进入试管加液位置
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //加液模块电机下降进入试管加液位置
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //托盘试管水平间距
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
Integer solutionId = jsonObject.getInt("solutionId");//溶液Id
@ -61,17 +67,20 @@ public class LiquidAddCommand extends BaseCommandHandler {
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比
double position = volume * scale * 8;//加液泵的转数
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//动至加液位置
double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂左移距离
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//机械臂左
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液
double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂左移距离
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//机械臂左移试管间距
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置
}
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置
deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用解除
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束
});
}
}

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

@ -49,6 +49,8 @@ public class LiquidReduceCommand extends BaseCommandHandler {
TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘
double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));
return runAsync(() -> {
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用
deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开
@ -62,6 +64,8 @@ public class LiquidReduceCommand extends BaseCommandHandler {
}
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高移出试管
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用解除
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束
});
}
}

1
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java

@ -36,6 +36,7 @@ public class DebugDoorCloseCommand extends BaseCommandHandler {
DeviceCommandBundle doorMoveDeviceCommand = DeviceCommandGenerator.doorMove(0.0);
CommandFuture doorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorMoveDeviceCommand);
CommandUtil.wait(doorMoveDeviceCommandFuture);
});
}
}

2
src/main/java/com/iflytop/sgs/app/controller/HeatController.java

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 加热模块控制 todo wmy 需要和前端同步参数 加热 烘干 退火
* 加热模块控制
*/
@Tag(name = "加热模块控制")
@RestController

Loading…
Cancel
Save