8 changed files with 200 additions and 0 deletions
-
62src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java
-
65src/main/java/com/iflytop/sgs/app/cmd/selftest/TrayOutCommand.java
-
9src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java
-
16src/main/java/com/iflytop/sgs/app/core/SelfMoveTestGenerator.java
-
23src/main/java/com/iflytop/sgs/app/model/vo/GetRequireOutTrayVO.java
-
18src/main/java/com/iflytop/sgs/app/service/device/SelfTestService.java
-
3src/main/java/com/iflytop/sgs/app/ws/server/WebSocketSender.java
-
4src/main/java/com/iflytop/sgs/common/constant/WebSocketMessageType.java
@ -0,0 +1,62 @@ |
|||
package com.iflytop.sgs.app.cmd.selftest; |
|||
|
|||
import com.iflytop.sgs.app.core.BaseCommandHandler; |
|||
import com.iflytop.sgs.app.core.SelfMoveTestGenerator; |
|||
import com.iflytop.sgs.app.model.bo.Point3D; |
|||
import com.iflytop.sgs.app.model.dto.CmdDTO; |
|||
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|||
import com.iflytop.sgs.app.service.device.DeviceStateService; |
|||
import com.iflytop.sgs.app.service.device.module.HeatModuleService; |
|||
import com.iflytop.sgs.app.service.device.module.SolutionModuleService; |
|||
import com.iflytop.sgs.app.service.device.module.TransferModuleService; |
|||
import com.iflytop.sgs.app.ws.server.WebSocketSender; |
|||
import com.iflytop.sgs.common.annotation.CommandMapping; |
|||
import com.iflytop.sgs.common.enums.HeatModuleCode; |
|||
import com.iflytop.sgs.common.enums.data.DevicePositionCode; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 自检移动测试 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("move_test")//业务指令注解 |
|||
public class MoveTestCommand extends BaseCommandHandler { |
|||
private final SolutionModuleService solutionModuleService; |
|||
private final TransferModuleService transferModuleService; |
|||
private final HeatModuleService heatModuleService; |
|||
private final DeviceStateService deviceStateService; |
|||
private final DevicePositionService devicePositionService; |
|||
|
|||
private final WebSocketSender webSocketService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
HeatModuleCode annealHeatModuleCode = HeatModuleCode.heat_module_04; |
|||
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 |
|||
Point3D annealHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(annealHeatModuleCode);//获取退火加热模块托盘夹取点 |
|||
Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 |
|||
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 |
|||
Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 |
|||
|
|||
return runAsync(() -> { |
|||
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "1、各项传感器正常", 25)); |
|||
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleTrayClawPoint3D.getX());//将X轴移动至托盘夹取点 |
|||
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 |
|||
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 |
|||
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "2、加液模块升降电机检测完毕", 50)); |
|||
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 |
|||
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 |
|||
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "3、x轴电机检测完毕", 75)); |
|||
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//Z轴下降至夹取点,使托盘落入上料区 |
|||
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 |
|||
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "4、z轴电机检测完毕", 100)); |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,65 @@ |
|||
package com.iflytop.sgs.app.cmd.selftest; |
|||
|
|||
import com.iflytop.sgs.app.core.BaseCommandHandler; |
|||
import com.iflytop.sgs.app.model.bo.Point3D; |
|||
import com.iflytop.sgs.app.model.dto.CmdDTO; |
|||
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|||
import com.iflytop.sgs.app.service.device.DeviceStateService; |
|||
import com.iflytop.sgs.app.service.device.module.DoorModuleService; |
|||
import com.iflytop.sgs.app.service.device.module.HeatModuleService; |
|||
import com.iflytop.sgs.app.service.device.module.TransferModuleService; |
|||
import com.iflytop.sgs.common.annotation.CommandMapping; |
|||
import com.iflytop.sgs.common.enums.HeatModuleCode; |
|||
import com.iflytop.sgs.common.enums.data.DevicePositionCode; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 移除一个托盘 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("tray_out")//业务指令注解 |
|||
public class TrayOutCommand extends BaseCommandHandler { |
|||
private final DoorModuleService doorModuleService; |
|||
private final TransferModuleService transferModuleService; |
|||
private final HeatModuleService heatModuleService; |
|||
private final DevicePositionService devicePositionService; |
|||
private final DeviceStateService deviceStateService; |
|||
|
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); |
|||
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); |
|||
Double doorOpenPosition = devicePositionService.getPosition(DevicePositionCode.doorOpenPosition).getDistance();//获取开门位置 |
|||
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 |
|||
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 |
|||
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 |
|||
Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 |
|||
return runAsync(() -> { |
|||
if (!deviceStateService.getDeviceState().getDoorModule().isOpen()) { |
|||
doorModuleService.doorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorOpenPosition); |
|||
deviceStateService.getDeviceState().getDoorModule().setOpen(true); |
|||
} |
|||
|
|||
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至目标加热模块托盘夹取点 + 进出卡槽移动距离 |
|||
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//Z轴下降至夹取点,使托盘落入石墨加热盘 |
|||
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽 |
|||
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态 |
|||
deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInHeatModule(false);//设定托盘不在加热模块中 |
|||
deviceStateService.getDeviceState().getTransferModule().setTrayStatus(true);//设定托盘在机械臂上 |
|||
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 |
|||
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX());//将X轴移动至上料区位置点 |
|||
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//Z轴下降至夹取点,使托盘落入上料区 |
|||
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽 |
|||
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高 |
|||
deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(true);//设定上料区托盘状态 |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,16 @@ |
|||
package com.iflytop.sgs.app.core; |
|||
|
|||
import cn.hutool.json.JSONObject; |
|||
|
|||
public class SelfMoveTestGenerator { |
|||
|
|||
public static JSONObject generateJson(String commandId, String command, String title, Object schedule) { |
|||
JSONObject jsonObject = new JSONObject(); |
|||
jsonObject.set("commandId", commandId); |
|||
jsonObject.set("command", command); |
|||
jsonObject.set("title", title); |
|||
jsonObject.set("schedule", schedule); |
|||
return jsonObject; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.iflytop.sgs.app.model.vo; |
|||
|
|||
import com.iflytop.sgs.common.enums.HeatModuleCode; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Schema(description = "是否存在需要移除的托盘") |
|||
@Data |
|||
public class GetRequireOutTrayVO { |
|||
|
|||
@Schema(description = "加热模块CODE") |
|||
private HeatModuleCode moduleCode; |
|||
|
|||
@Schema(description = "是否存在托盘") |
|||
private boolean trayExist; |
|||
|
|||
|
|||
public GetRequireOutTrayVO(HeatModuleCode moduleCode, boolean trayExist) { |
|||
this.moduleCode = moduleCode; |
|||
this.trayExist = trayExist; |
|||
} |
|||
|
|||
} |
@ -1,16 +1,34 @@ |
|||
package com.iflytop.sgs.app.service.device; |
|||
|
|||
import com.iflytop.sgs.app.model.bo.status.SelfTestState; |
|||
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; |
|||
import com.iflytop.sgs.app.model.vo.GetRequireOutTrayVO; |
|||
import lombok.Getter; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class SelfTestService { |
|||
private final DeviceStateService deviceStateService; |
|||
@Getter |
|||
private final SelfTestState selfTestState = new SelfTestState(); |
|||
|
|||
/** |
|||
* 是否存在需要移除的托盘 |
|||
*/ |
|||
public List<GetRequireOutTrayVO> getRequireOutTray() { |
|||
List<GetRequireOutTrayVO> getRequireOutTrayList = new ArrayList<>(); |
|||
List<HeatModuleState> heatModuleStateList = deviceStateService.getDeviceState().getHeatModule(); |
|||
for (HeatModuleState heatModuleState : heatModuleStateList) { |
|||
//TODO 只获取存在托盘的 |
|||
getRequireOutTrayList.add(new GetRequireOutTrayVO(heatModuleState.getModuleCode(),heatModuleState.isTrayStatus())); |
|||
} |
|||
return getRequireOutTrayList; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue